• R/O
  • SSH

vim: 提交

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

修訂184d2020d8f12823a2f2cb96335a68ac1bda3270 (tree)
時間2007-05-07 06:55:31
作者vimboss
Commitervimboss

Log Message

updated for version 7.1a-001

Change Summary

差異

diff -r d38420e2fafe -r 184d2020d8f1 runtime/autoload/spellfile.vim
--- a/runtime/autoload/spellfile.vim Sun May 06 17:22:46 2007 +0000
+++ b/runtime/autoload/spellfile.vim Sun May 06 21:55:31 2007 +0000
@@ -1,6 +1,6 @@
11 " Vim script to download a missing spell file
22 " Maintainer: Bram Moolenaar <Bram@vim.org>
3-" Last Change: 2006 Aug 29
3+" Last Change: 2007 May 06
44
55 if !exists('g:spellfile_URL')
66 let g:spellfile_URL = 'ftp://ftp.vim.org/pub/vim/runtime/spell'
@@ -58,19 +58,40 @@
5858 let fname = a:lang . '.' . enc . '.spl'
5959
6060 " Split the window, read the file into a new buffer.
61+ " Remember the buffer number, we check it below.
6162 new
63+ let newbufnr = winbufnr(0)
6264 setlocal bin
6365 echo 'Downloading ' . fname . '...'
6466 call spellfile#Nread(fname)
6567 if getline(2) !~ 'VIMspell'
6668 " Didn't work, perhaps there is an ASCII one.
67- g/^/d
69+ " Careful: Nread() may have opened a new window for the error message,
70+ " we need to go back to our own buffer and window.
71+ if newbufnr != winbufnr(0)
72+ let winnr = bufwinnr(newbufnr)
73+ if winnr == -1
74+ " Our buffer has vanished!? Open a new window.
75+ echomsg "download buffer disappeared, opening a new one"
76+ new
77+ setlocal bin
78+ else
79+ exe winnr . "wincmd w"
80+ endif
81+ endif
82+ if newbufnr == winbufnr(0)
83+ " We are back the old buffer, remove any (half-finished) download.
84+ g/^/d
85+ else
86+ let newbufnr = winbufnr(0)
87+ endif
88+
6889 let fname = a:lang . '.ascii.spl'
6990 echo 'Could not find it, trying ' . fname . '...'
7091 call spellfile#Nread(fname)
7192 if getline(2) !~ 'VIMspell'
7293 echo 'Sorry, downloading failed'
73- bwipe!
94+ exe newbufnr . "bwipe!"
7495 return
7596 endif
7697 endif
@@ -96,17 +117,29 @@
96117 let fname = substitute(fname, '\.spl$', '.sug', '')
97118 echo 'Downloading ' . fname . '...'
98119 call spellfile#Nread(fname)
99- if getline(2) !~ 'VIMsug'
100- echo 'Sorry, downloading failed'
101- else
120+ if getline(2) =~ 'VIMsug'
102121 1d
103122 exe "write " . escape(dirlist[dirchoice], ' ') . '/' . fname
123+ set nomod
124+ else
125+ echo 'Sorry, downloading failed'
126+ " Go back to our own buffer/window, Nread() may have taken us to
127+ " another window.
128+ if newbufnr != winbufnr(0)
129+ let winnr = bufwinnr(newbufnr)
130+ if winnr != -1
131+ exe winnr . "wincmd w"
132+ endif
133+ endif
134+ if newbufnr == winbufnr(0)
135+ set nomod
136+ endif
104137 endif
105- set nomod
106138 endif
107139 endif
108140
109- bwipe
141+ " Wipe out the buffer we used.
142+ exe newbufnr . "bwipe"
110143 endif
111144 endfunc
112145
diff -r d38420e2fafe -r 184d2020d8f1 src/buffer.c
--- a/src/buffer.c Sun May 06 17:22:46 2007 +0000
+++ b/src/buffer.c Sun May 06 21:55:31 2007 +0000
@@ -1426,6 +1426,13 @@
14261426 if (curbuf->b_kmap_state & KEYMAP_INIT)
14271427 keymap_init();
14281428 #endif
1429+#ifdef FEAT_SPELL
1430+ /* May need to set the spell language. Can only do this after the buffer
1431+ * has been properly setup. */
1432+ if (!curbuf->b_help && curwin->w_p_spell && *curbuf->b_p_spl != NUL)
1433+ did_set_spelllang(curbuf);
1434+#endif
1435+
14291436 redraw_later(NOT_VALID);
14301437 }
14311438
@@ -2415,11 +2422,6 @@
24152422 if (p_fdls >= 0)
24162423 curwin->w_p_fdl = p_fdls;
24172424 #endif
2418-
2419-#ifdef FEAT_SPELL
2420- if (curwin->w_p_spell && *buf->b_p_spl != NUL)
2421- did_set_spelllang(buf);
2422-#endif
24232425 }
24242426
24252427 /*
diff -r d38420e2fafe -r 184d2020d8f1 src/ex_cmds.c
--- a/src/ex_cmds.c Sun May 06 17:22:46 2007 +0000
+++ b/src/ex_cmds.c Sun May 06 21:55:31 2007 +0000
@@ -3088,6 +3088,9 @@
30883088 char_u *cp;
30893089 #endif
30903090 char_u *command = NULL;
3091+#ifdef FEAT_SPELL
3092+ int did_get_winopts = FALSE;
3093+#endif
30913094
30923095 if (eap != NULL)
30933096 command = eap->do_ecmd_cmd;
@@ -3365,6 +3368,9 @@
33653368 * before, reset the local window options to the global
33663369 * values. Also restores old folding stuff. */
33673370 get_winopts(buf);
3371+#ifdef FEAT_SPELL
3372+ did_get_winopts = TRUE;
3373+#endif
33683374
33693375 #ifdef FEAT_AUTOCMD
33703376 }
@@ -3640,6 +3646,13 @@
36403646 }
36413647 #endif
36423648
3649+#ifdef FEAT_SPELL
3650+ /* If the window options were changed may need to set the spell language.
3651+ * Can only do this after the buffer has been properly setup. */
3652+ if (did_get_winopts && curwin->w_p_spell && *buf->b_p_spl != NUL)
3653+ did_set_spelllang(buf);
3654+#endif
3655+
36433656 if (command == NULL)
36443657 {
36453658 if (newcol >= 0) /* position set by autocommands */
diff -r d38420e2fafe -r 184d2020d8f1 src/spell.c
--- a/src/spell.c Sun May 06 17:22:46 2007 +0000
+++ b/src/spell.c Sun May 06 21:55:31 2007 +0000
@@ -4105,12 +4105,28 @@
41054105 int nobreak = FALSE;
41064106 int i, j;
41074107 langp_T *lp, *lp2;
4108+ static int recursive = FALSE;
4109+ char_u *ret_msg = NULL;
4110+ char_u *spl_copy;
4111+
4112+ /* We don't want to do this recursively. May happen when a language is
4113+ * not available and the SpellFileMissing autocommand opens a new buffer
4114+ * in which 'spell' is set. */
4115+ if (recursive)
4116+ return NULL;
4117+ recursive = TRUE;
41084118
41094119 ga_init2(&ga, sizeof(langp_T), 2);
41104120 clear_midword(buf);
41114121
4122+ /* Make a copy of 'spellang', the SpellFileMissing autocommands may change
4123+ * it under our fingers. */
4124+ spl_copy = vim_strsave(buf->b_p_spl);
4125+ if (spl_copy == NULL)
4126+ goto theend;
4127+
41124128 /* loop over comma separated language names. */
4113- for (splp = buf->b_p_spl; *splp != NUL; )
4129+ for (splp = spl_copy; *splp != NUL; )
41144130 {
41154131 /* Get one language name. */
41164132 copy_option_part(&splp, lang, MAXWLEN, ",");
@@ -4176,7 +4192,18 @@
41764192 if (filename)
41774193 (void)spell_load_file(lang, lang, NULL, FALSE);
41784194 else
4195+ {
41794196 spell_load_lang(lang);
4197+#ifdef FEAT_AUTOCMD
4198+ /* SpellFileMissing autocommands may do anything, including
4199+ * destroying the buffer we are using... */
4200+ if (!buf_valid(buf))
4201+ {
4202+ ret_msg = (char_u *)"E797: SpellFileMissing autocommand deleted buffer";
4203+ goto theend;
4204+ }
4205+#endif
4206+ }
41804207 }
41814208
41824209 /*
@@ -4215,7 +4242,8 @@
42154242 if (ga_grow(&ga, 1) == FAIL)
42164243 {
42174244 ga_clear(&ga);
4218- return e_outofmem;
4245+ ret_msg = e_outofmem;
4246+ goto theend;
42194247 }
42204248 LANGP_ENTRY(ga, ga.ga_len)->lp_slang = slang;
42214249 LANGP_ENTRY(ga, ga.ga_len)->lp_region = region_mask;
@@ -4231,7 +4259,7 @@
42314259 * round 1: load first name in 'spellfile'.
42324260 * round 2: load second name in 'spellfile.
42334261 * etc. */
4234- spf = curbuf->b_p_spf;
4262+ spf = buf->b_p_spf;
42354263 for (round = 0; round == 0 || *spf != NUL; ++round)
42364264 {
42374265 if (round == 0)
@@ -4357,7 +4385,10 @@
43574385 }
43584386 }
43594387
4360- return NULL;
4388+theend:
4389+ vim_free(spl_copy);
4390+ recursive = FALSE;
4391+ return ret_msg;
43614392 }
43624393
43634394 /*
diff -r d38420e2fafe -r 184d2020d8f1 src/version.c
--- a/src/version.c Sun May 06 17:22:46 2007 +0000
+++ b/src/version.c Sun May 06 21:55:31 2007 +0000
@@ -667,6 +667,8 @@
667667 static int included_patches[] =
668668 { /* Add new patch number below this line */
669669 /**/
670+ 1,
671+/**/
670672 0
671673 };
672674
Show on old repository browser