mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
updated for version 7.1a-001
This commit is contained in:
parent
a022bb3567
commit
706cdebcf8
@ -1,6 +1,6 @@
|
|||||||
" Vim script to download a missing spell file
|
" Vim script to download a missing spell file
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last Change: 2006 Aug 29
|
" Last Change: 2007 May 06
|
||||||
|
|
||||||
if !exists('g:spellfile_URL')
|
if !exists('g:spellfile_URL')
|
||||||
let g:spellfile_URL = 'ftp://ftp.vim.org/pub/vim/runtime/spell'
|
let g:spellfile_URL = 'ftp://ftp.vim.org/pub/vim/runtime/spell'
|
||||||
@ -58,19 +58,40 @@ function! spellfile#LoadFile(lang)
|
|||||||
let fname = a:lang . '.' . enc . '.spl'
|
let fname = a:lang . '.' . enc . '.spl'
|
||||||
|
|
||||||
" Split the window, read the file into a new buffer.
|
" Split the window, read the file into a new buffer.
|
||||||
|
" Remember the buffer number, we check it below.
|
||||||
new
|
new
|
||||||
|
let newbufnr = winbufnr(0)
|
||||||
setlocal bin
|
setlocal bin
|
||||||
echo 'Downloading ' . fname . '...'
|
echo 'Downloading ' . fname . '...'
|
||||||
call spellfile#Nread(fname)
|
call spellfile#Nread(fname)
|
||||||
if getline(2) !~ 'VIMspell'
|
if getline(2) !~ 'VIMspell'
|
||||||
" Didn't work, perhaps there is an ASCII one.
|
" Didn't work, perhaps there is an ASCII one.
|
||||||
g/^/d
|
" Careful: Nread() may have opened a new window for the error message,
|
||||||
|
" we need to go back to our own buffer and window.
|
||||||
|
if newbufnr != winbufnr(0)
|
||||||
|
let winnr = bufwinnr(newbufnr)
|
||||||
|
if winnr == -1
|
||||||
|
" Our buffer has vanished!? Open a new window.
|
||||||
|
echomsg "download buffer disappeared, opening a new one"
|
||||||
|
new
|
||||||
|
setlocal bin
|
||||||
|
else
|
||||||
|
exe winnr . "wincmd w"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if newbufnr == winbufnr(0)
|
||||||
|
" We are back the old buffer, remove any (half-finished) download.
|
||||||
|
g/^/d
|
||||||
|
else
|
||||||
|
let newbufnr = winbufnr(0)
|
||||||
|
endif
|
||||||
|
|
||||||
let fname = a:lang . '.ascii.spl'
|
let fname = a:lang . '.ascii.spl'
|
||||||
echo 'Could not find it, trying ' . fname . '...'
|
echo 'Could not find it, trying ' . fname . '...'
|
||||||
call spellfile#Nread(fname)
|
call spellfile#Nread(fname)
|
||||||
if getline(2) !~ 'VIMspell'
|
if getline(2) !~ 'VIMspell'
|
||||||
echo 'Sorry, downloading failed'
|
echo 'Sorry, downloading failed'
|
||||||
bwipe!
|
exe newbufnr . "bwipe!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -96,17 +117,29 @@ function! spellfile#LoadFile(lang)
|
|||||||
let fname = substitute(fname, '\.spl$', '.sug', '')
|
let fname = substitute(fname, '\.spl$', '.sug', '')
|
||||||
echo 'Downloading ' . fname . '...'
|
echo 'Downloading ' . fname . '...'
|
||||||
call spellfile#Nread(fname)
|
call spellfile#Nread(fname)
|
||||||
if getline(2) !~ 'VIMsug'
|
if getline(2) =~ 'VIMsug'
|
||||||
echo 'Sorry, downloading failed'
|
|
||||||
else
|
|
||||||
1d
|
1d
|
||||||
exe "write " . escape(dirlist[dirchoice], ' ') . '/' . fname
|
exe "write " . escape(dirlist[dirchoice], ' ') . '/' . fname
|
||||||
|
set nomod
|
||||||
|
else
|
||||||
|
echo 'Sorry, downloading failed'
|
||||||
|
" Go back to our own buffer/window, Nread() may have taken us to
|
||||||
|
" another window.
|
||||||
|
if newbufnr != winbufnr(0)
|
||||||
|
let winnr = bufwinnr(newbufnr)
|
||||||
|
if winnr != -1
|
||||||
|
exe winnr . "wincmd w"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if newbufnr == winbufnr(0)
|
||||||
|
set nomod
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
set nomod
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
bwipe
|
" Wipe out the buffer we used.
|
||||||
|
exe newbufnr . "bwipe"
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
12
src/buffer.c
12
src/buffer.c
@ -1426,6 +1426,13 @@ enter_buffer(buf)
|
|||||||
if (curbuf->b_kmap_state & KEYMAP_INIT)
|
if (curbuf->b_kmap_state & KEYMAP_INIT)
|
||||||
keymap_init();
|
keymap_init();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef FEAT_SPELL
|
||||||
|
/* May need to set the spell language. Can only do this after the buffer
|
||||||
|
* has been properly setup. */
|
||||||
|
if (!curbuf->b_help && curwin->w_p_spell && *curbuf->b_p_spl != NUL)
|
||||||
|
did_set_spelllang(curbuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
redraw_later(NOT_VALID);
|
redraw_later(NOT_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2415,11 +2422,6 @@ get_winopts(buf)
|
|||||||
if (p_fdls >= 0)
|
if (p_fdls >= 0)
|
||||||
curwin->w_p_fdl = p_fdls;
|
curwin->w_p_fdl = p_fdls;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_SPELL
|
|
||||||
if (curwin->w_p_spell && *buf->b_p_spl != NUL)
|
|
||||||
did_set_spelllang(buf);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3088,6 +3088,9 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
|
|||||||
char_u *cp;
|
char_u *cp;
|
||||||
#endif
|
#endif
|
||||||
char_u *command = NULL;
|
char_u *command = NULL;
|
||||||
|
#ifdef FEAT_SPELL
|
||||||
|
int did_get_winopts = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (eap != NULL)
|
if (eap != NULL)
|
||||||
command = eap->do_ecmd_cmd;
|
command = eap->do_ecmd_cmd;
|
||||||
@ -3365,6 +3368,9 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
|
|||||||
* before, reset the local window options to the global
|
* before, reset the local window options to the global
|
||||||
* values. Also restores old folding stuff. */
|
* values. Also restores old folding stuff. */
|
||||||
get_winopts(buf);
|
get_winopts(buf);
|
||||||
|
#ifdef FEAT_SPELL
|
||||||
|
did_get_winopts = TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
}
|
}
|
||||||
@ -3640,6 +3646,13 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FEAT_SPELL
|
||||||
|
/* If the window options were changed may need to set the spell language.
|
||||||
|
* Can only do this after the buffer has been properly setup. */
|
||||||
|
if (did_get_winopts && curwin->w_p_spell && *buf->b_p_spl != NUL)
|
||||||
|
did_set_spelllang(buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (command == NULL)
|
if (command == NULL)
|
||||||
{
|
{
|
||||||
if (newcol >= 0) /* position set by autocommands */
|
if (newcol >= 0) /* position set by autocommands */
|
||||||
|
39
src/spell.c
39
src/spell.c
@ -4105,12 +4105,28 @@ did_set_spelllang(buf)
|
|||||||
int nobreak = FALSE;
|
int nobreak = FALSE;
|
||||||
int i, j;
|
int i, j;
|
||||||
langp_T *lp, *lp2;
|
langp_T *lp, *lp2;
|
||||||
|
static int recursive = FALSE;
|
||||||
|
char_u *ret_msg = NULL;
|
||||||
|
char_u *spl_copy;
|
||||||
|
|
||||||
|
/* We don't want to do this recursively. May happen when a language is
|
||||||
|
* not available and the SpellFileMissing autocommand opens a new buffer
|
||||||
|
* in which 'spell' is set. */
|
||||||
|
if (recursive)
|
||||||
|
return NULL;
|
||||||
|
recursive = TRUE;
|
||||||
|
|
||||||
ga_init2(&ga, sizeof(langp_T), 2);
|
ga_init2(&ga, sizeof(langp_T), 2);
|
||||||
clear_midword(buf);
|
clear_midword(buf);
|
||||||
|
|
||||||
|
/* Make a copy of 'spellang', the SpellFileMissing autocommands may change
|
||||||
|
* it under our fingers. */
|
||||||
|
spl_copy = vim_strsave(buf->b_p_spl);
|
||||||
|
if (spl_copy == NULL)
|
||||||
|
goto theend;
|
||||||
|
|
||||||
/* loop over comma separated language names. */
|
/* loop over comma separated language names. */
|
||||||
for (splp = buf->b_p_spl; *splp != NUL; )
|
for (splp = spl_copy; *splp != NUL; )
|
||||||
{
|
{
|
||||||
/* Get one language name. */
|
/* Get one language name. */
|
||||||
copy_option_part(&splp, lang, MAXWLEN, ",");
|
copy_option_part(&splp, lang, MAXWLEN, ",");
|
||||||
@ -4176,7 +4192,18 @@ did_set_spelllang(buf)
|
|||||||
if (filename)
|
if (filename)
|
||||||
(void)spell_load_file(lang, lang, NULL, FALSE);
|
(void)spell_load_file(lang, lang, NULL, FALSE);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
spell_load_lang(lang);
|
spell_load_lang(lang);
|
||||||
|
#ifdef FEAT_AUTOCMD
|
||||||
|
/* SpellFileMissing autocommands may do anything, including
|
||||||
|
* destroying the buffer we are using... */
|
||||||
|
if (!buf_valid(buf))
|
||||||
|
{
|
||||||
|
ret_msg = (char_u *)"E797: SpellFileMissing autocommand deleted buffer";
|
||||||
|
goto theend;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4215,7 +4242,8 @@ did_set_spelllang(buf)
|
|||||||
if (ga_grow(&ga, 1) == FAIL)
|
if (ga_grow(&ga, 1) == FAIL)
|
||||||
{
|
{
|
||||||
ga_clear(&ga);
|
ga_clear(&ga);
|
||||||
return e_outofmem;
|
ret_msg = e_outofmem;
|
||||||
|
goto theend;
|
||||||
}
|
}
|
||||||
LANGP_ENTRY(ga, ga.ga_len)->lp_slang = slang;
|
LANGP_ENTRY(ga, ga.ga_len)->lp_slang = slang;
|
||||||
LANGP_ENTRY(ga, ga.ga_len)->lp_region = region_mask;
|
LANGP_ENTRY(ga, ga.ga_len)->lp_region = region_mask;
|
||||||
@ -4231,7 +4259,7 @@ did_set_spelllang(buf)
|
|||||||
* round 1: load first name in 'spellfile'.
|
* round 1: load first name in 'spellfile'.
|
||||||
* round 2: load second name in 'spellfile.
|
* round 2: load second name in 'spellfile.
|
||||||
* etc. */
|
* etc. */
|
||||||
spf = curbuf->b_p_spf;
|
spf = buf->b_p_spf;
|
||||||
for (round = 0; round == 0 || *spf != NUL; ++round)
|
for (round = 0; round == 0 || *spf != NUL; ++round)
|
||||||
{
|
{
|
||||||
if (round == 0)
|
if (round == 0)
|
||||||
@ -4357,7 +4385,10 @@ did_set_spelllang(buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
theend:
|
||||||
|
vim_free(spl_copy);
|
||||||
|
recursive = FALSE;
|
||||||
|
return ret_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -666,6 +666,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1,
|
||||||
/**/
|
/**/
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user