0
0
mirror of https://github.com/vim/vim.git synced 2025-08-27 20:13:38 -04:00

updated for version 7.0183

This commit is contained in:
Bram Moolenaar 2006-01-20 23:02:51 +00:00
parent 8ada17c4d9
commit 2d3f489e09
10 changed files with 129 additions and 54 deletions

View File

@ -1,4 +1,4 @@
*editing.txt* For Vim version 7.0aa. Last change: 2005 Dec 13 *editing.txt* For Vim version 7.0aa. Last change: 2006 Jan 20
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -155,11 +155,14 @@ Technical: On the Amiga you can use 30 characters for a file name. But on an
When you started editing without giving a file name, "No File" is displayed in When you started editing without giving a file name, "No File" is displayed in
messages. If the ":write" command is used with a file name argument, the file messages. If the ":write" command is used with a file name argument, the file
name for the current file is set to that file name. This only happens when name for the current file is set to that file name. This only happens when
the 'F' flag is included in 'cpoptions' (by default it is included). This is the 'F' flag is included in 'cpoptions' (by default it is included) |cpo-F|.
useful when entering text in an empty buffer and then writing it to a file. This is useful when entering text in an empty buffer and then writing it to a
If 'cpoptions' contains the 'f' flag (by default it is NOT included) the file file. If 'cpoptions' contains the 'f' flag (by default it is NOT included)
name is set for the ":read file" command. This is useful when starting Vim |cpo-f| the file name is set for the ":read file" command. This is useful
without an argument and then doing ":read file" to start editing a file. when starting Vim without an argument and then doing ":read file" to start
editing a file.
When the file name was set and 'filetype' is empty the filetype detection
autocommands will be triggered.
*not-edited* *not-edited*
Because the file name was set without really starting to edit that file, you Because the file name was set without really starting to edit that file, you
are protected from overwriting that file. This is done by setting the are protected from overwriting that file. This is done by setting the
@ -874,6 +877,8 @@ used, for example, when the write fails and you want to try again later with
the filename of the current buffer to {file}. The the filename of the current buffer to {file}. The
previous name is used for the alternate file name. previous name is used for the alternate file name.
The [!] is needed to overwrite an existing file. The [!] is needed to overwrite an existing file.
When 'filetype' is empty filetype detection is done
with the new name, before the file is written.
{not in Vi} {not in Vi}
*:up* *:update* *:up* *:update*

View File

@ -1,4 +1,4 @@
*if_pyth.txt* For Vim version 7.0aa. Last change: 2005 Oct 14 *if_pyth.txt* For Vim version 7.0aa. Last change: 2006 Jan 20
VIM REFERENCE MANUAL by Paul Moore VIM REFERENCE MANUAL by Paul Moore
@ -131,14 +131,24 @@ vim.command(str) *python-command*
vim.eval(str) *python-eval* vim.eval(str) *python-eval*
Evaluates the expression str using the vim internal expression Evaluates the expression str using the vim internal expression
evaluator (see |expression|). Returns the expression result as a evaluator (see |expression|). Returns the expression result as:
string. - a string if the Vim expression evaluates to a string or number
- a list if the Vim expression evaluates to a Vim list
- a dictionary if the Vim expression evaluates to a Vim dictionary
Dictionaries and lists are recursively expanded.
Examples: > Examples: >
:py text_width = vim.eval("&tw") :py text_width = vim.eval("&tw")
:py str = vim.eval("12+12") # NB result is a string! Use :py str = vim.eval("12+12") # NB result is a string! Use
# string.atoi() to convert to # string.atoi() to convert to
# a number. # a number.
:py tagList = vim.eval('taglist("eval_expr")')
< The latter will return a python list of python dicts, for instance:
[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name':
'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}]
Error object of the "vim" module Error object of the "vim" module
vim.error *python-error* vim.error *python-error*

View File

@ -1806,9 +1806,9 @@ buflist_getfile(n, lnum, options, forceit)
if (buf == curbuf) if (buf == curbuf)
return OK; return OK;
if (editing_cmdline()) if (text_locked())
{ {
editing_cmdline_msg(); text_locked_msg();
return FAIL; return FAIL;
} }
@ -3506,7 +3506,8 @@ build_stl_str_hl(wp, out, outlen, fmt, fillchar, maxwidth, hl)
curwin = wp; curwin = wp;
curbuf = wp->w_buffer; curbuf = wp->w_buffer;
str = eval_to_string_safe(p, &t); str = eval_to_string_safe(p, &t,
was_set_insecurely((char_u *)"statusline"));
curwin = o_curwin; curwin = o_curwin;
curbuf = o_curbuf; curbuf = o_curbuf;

View File

@ -2137,7 +2137,7 @@ do_one_cmd(cmdlinep, sourcing,
goto doend; goto doend;
} }
if (editing_cmdline() && !(ea.argt & CMDWIN) if (text_locked() && !(ea.argt & CMDWIN)
# ifdef FEAT_USR_CMDS # ifdef FEAT_USR_CMDS
&& !USER_CMDIDX(ea.cmdidx) && !USER_CMDIDX(ea.cmdidx)
# endif # endif
@ -6034,9 +6034,9 @@ ex_quit(eap)
} }
#endif #endif
/* Don't quit while editing the command line. */ /* Don't quit while editing the command line. */
if (editing_cmdline()) if (text_locked())
{ {
editing_cmdline_msg(); text_locked_msg();
return; return;
} }
@ -6103,9 +6103,9 @@ ex_quit_all(eap)
# endif # endif
/* Don't quit while editing the command line. */ /* Don't quit while editing the command line. */
if (editing_cmdline()) if (text_locked())
{ {
editing_cmdline_msg(); text_locked_msg();
return; return;
} }
@ -6128,7 +6128,7 @@ ex_close(eap)
cmdwin_result = K_IGNORE; cmdwin_result = K_IGNORE;
else else
# endif # endif
if (!editing_cmdline()) if (!text_locked())
ex_win_close(eap, curwin); ex_win_close(eap, curwin);
} }
@ -6289,9 +6289,9 @@ ex_exit(eap)
} }
#endif #endif
/* Don't quit while editing the command line. */ /* Don't quit while editing the command line. */
if (editing_cmdline()) if (text_locked())
{ {
editing_cmdline_msg(); text_locked_msg();
return; return;
} }
@ -6407,7 +6407,7 @@ handle_drop(filec, filev, split)
int save_msg_scroll = msg_scroll; int save_msg_scroll = msg_scroll;
/* Postpone this while editing the command line. */ /* Postpone this while editing the command line. */
if (editing_cmdline()) if (text_locked())
return; return;
/* Check whether the current buffer is changed. If so, we will need /* Check whether the current buffer is changed. If so, we will need

View File

@ -59,6 +59,7 @@ static char_u *check_for_cryptkey __ARGS((char_u *cryptkey, char_u *ptr, long *s
#ifdef UNIX #ifdef UNIX
static void set_file_time __ARGS((char_u *fname, time_t atime, time_t mtime)); static void set_file_time __ARGS((char_u *fname, time_t atime, time_t mtime));
#endif #endif
static int set_rw_fname __ARGS((char_u *fname, char_u *sfname));
static int msg_add_fileformat __ARGS((int eol_type)); static int msg_add_fileformat __ARGS((int eol_type));
static void msg_add_eol __ARGS((void)); static void msg_add_eol __ARGS((void));
static int check_mtime __ARGS((buf_T *buf, struct stat *s)); static int check_mtime __ARGS((buf_T *buf, struct stat *s));
@ -301,8 +302,8 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
&& vim_strchr(p_cpo, CPO_FNAMER) != NULL && vim_strchr(p_cpo, CPO_FNAMER) != NULL
&& !(flags & READ_DUMMY)) && !(flags & READ_DUMMY))
{ {
if (setfname(curbuf, fname, sfname, FALSE) == OK) if (set_rw_fname(fname, sfname) == FAIL)
curbuf->b_flags |= BF_NOTEDITED; return FAIL;
} }
/* After reading a file the cursor line changes but we don't want to /* After reading a file the cursor line changes but we don't want to
@ -2801,35 +2802,20 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
* Don't do this when appending. * Don't do this when appending.
* Only do this when 'cpoptions' contains the 'F' flag. * Only do this when 'cpoptions' contains the 'F' flag.
*/ */
if (reset_changed if (buf->b_ffname == NULL
&& reset_changed
&& whole && whole
&& buf == curbuf && buf == curbuf
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
&& !bt_nofile(buf) && !bt_nofile(buf)
#endif #endif
&& buf->b_ffname == NULL
&& !filtering && !filtering
&& (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL) && (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
&& vim_strchr(p_cpo, CPO_FNAMEW) != NULL) && vim_strchr(p_cpo, CPO_FNAMEW) != NULL)
{ {
#ifdef FEAT_AUTOCMD if (set_rw_fname(fname, sfname) == FAIL)
/* It's like the unnamed buffer is deleted.... */
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
if (aborting()) /* autocmds may abort script processing */
return FAIL; return FAIL;
#endif buf = curbuf; /* just in case autocmds made "buf" invalid */
#endif
if (setfname(curbuf, fname, sfname, FALSE) == OK)
curbuf->b_flags |= BF_NOTEDITED;
#ifdef FEAT_AUTOCMD
/* ....and a new named one is created */
apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf);
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
#endif
} }
if (sfname == NULL) if (sfname == NULL)
@ -4600,6 +4586,50 @@ nofail:
return retval; return retval;
} }
/*
* Set the name of the current buffer. Use when the buffer doesn't have a
* name and a ":r" or ":w" command with a file name is used.
*/
static int
set_rw_fname(fname, sfname)
char_u *fname;
char_u *sfname;
{
#ifdef FEAT_AUTOCMD
/* It's like the unnamed buffer is deleted.... */
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
# ifdef FEAT_EVAL
if (aborting()) /* autocmds may abort script processing */
return FAIL;
# endif
#endif
if (setfname(curbuf, fname, sfname, FALSE) == OK)
curbuf->b_flags |= BF_NOTEDITED;
#ifdef FEAT_AUTOCMD
/* ....and a new named one is created */
apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf);
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
# ifdef FEAT_EVAL
if (aborting()) /* autocmds may abort script processing */
return FAIL;
# endif
/* Do filetype detection now if 'filetype' is empty. */
if (*curbuf->b_p_ft == NUL)
{
(void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
do_modelines(FALSE);
}
#endif
return OK;
}
/* /*
* Put file name into IObuff with quotes. * Put file name into IObuff with quotes.
*/ */

View File

@ -789,11 +789,11 @@ getcount:
goto normal_end; goto normal_end;
} }
if (editing_cmdline() && (nv_cmds[idx].cmd_flags & NV_NCW)) if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW))
{ {
/* This command is not allowed wile editing a ccmdline: beep. */ /* This command is not allowed wile editing a ccmdline: beep. */
clearopbeep(oap); clearopbeep(oap);
editing_cmdline_msg(); text_locked_msg();
goto normal_end; goto normal_end;
} }
@ -5741,10 +5741,10 @@ nv_gotofile(cap)
{ {
char_u *ptr; char_u *ptr;
if (editing_cmdline()) if (text_locked())
{ {
clearopbeep(cap->oap); clearopbeep(cap->oap);
editing_cmdline_msg(); text_locked_msg();
return; return;
} }
@ -7801,10 +7801,10 @@ nv_g_cmd(cap)
/* "gQ": improved Ex mode */ /* "gQ": improved Ex mode */
case 'Q': case 'Q':
if (editing_cmdline()) if (text_locked())
{ {
clearopbeep(cap->oap); clearopbeep(cap->oap);
editing_cmdline_msg(); text_locked_msg();
break; break;
} }

View File

@ -1,8 +1,8 @@
/* ex_getln.c */ /* ex_getln.c */
char_u *getcmdline __ARGS((int firstc, long count, int indent)); char_u *getcmdline __ARGS((int firstc, long count, int indent));
char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg)); char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg));
int editing_cmdline __ARGS((void)); int text_locked __ARGS((void));
void editing_cmdline_msg __ARGS((void)); void text_locked_msg __ARGS((void));
char_u *getexline __ARGS((int c, void *dummy, int indent)); char_u *getexline __ARGS((int c, void *dummy, int indent));
char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent)); char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent));
int cmdline_overstrike __ARGS((void)); int cmdline_overstrike __ARGS((void));

View File

@ -17,6 +17,7 @@ void check_buf_options __ARGS((buf_T *buf));
void free_string_option __ARGS((char_u *p)); void free_string_option __ARGS((char_u *p));
void clear_string_option __ARGS((char_u **pp)); void clear_string_option __ARGS((char_u **pp));
void set_term_option_alloced __ARGS((char_u **p)); void set_term_option_alloced __ARGS((char_u **p));
int was_set_insecurely __ARGS((char_u *opt));
void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags)); void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags));
char_u *check_stl_option __ARGS((char_u *s)); char_u *check_stl_option __ARGS((char_u *s));
int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags)); int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags));

View File

@ -59,7 +59,8 @@
# define SPELL_PRINTTREE # define SPELL_PRINTTREE
#endif #endif
/* Use DEBUG_TRIEWALK to print the changes made in suggest_trie_walk(). */ /* Use DEBUG_TRIEWALK to print the changes made in suggest_trie_walk() for a
* specific word. */
#if 0 #if 0
# define DEBUG_TRIEWALK # define DEBUG_TRIEWALK
#endif #endif
@ -328,6 +329,9 @@ typedef long idx_T;
#define WF_HAS_AFF 0x0100 /* word includes affix */ #define WF_HAS_AFF 0x0100 /* word includes affix */
#define WF_NEEDCOMP 0x0200 /* word only valid in compound */ #define WF_NEEDCOMP 0x0200 /* word only valid in compound */
/* only used for su_badflags */
#define WF_MIXCAP 0x20 /* mix of upper and lower case: macaRONI */
#define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP) #define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP)
/* flags for <pflags> */ /* flags for <pflags> */
@ -4328,6 +4332,9 @@ badword_captype(word, end)
flags |= WF_ALLCAP; flags |= WF_ALLCAP;
else if (first) else if (first)
flags |= WF_ONECAP; flags |= WF_ONECAP;
if (u >= 2 && l >= 2) /* maCARONI maCAroni */
flags |= WF_MIXCAP;
} }
return flags; return flags;
} }
@ -10895,9 +10902,29 @@ suggest_trie_walk(su, lp, fword, soundfold)
/* Add the suggestion if the score isn't too bad. */ /* Add the suggestion if the score isn't too bad. */
if (score <= su->su_maxscore) if (score <= su->su_maxscore)
{
add_suggestion(su, &su->su_ga, preword, add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra, sp->ts_fidx - repextra,
score, 0, FALSE, lp->lp_sallang, FALSE); score, 0, FALSE, lp->lp_sallang, FALSE);
if (su->su_badflags & WF_MIXCAP)
{
/* We really don't know if the word should be
* upper or lower case, add both. */
c = captype(preword, NULL);
if (c == 0 || c == WF_ALLCAP)
{
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen,
c == 0 ? WF_ALLCAP : 0);
add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra,
score + SCORE_ICASE, 0, FALSE,
lp->lp_sallang, FALSE);
}
}
}
} }
} }

View File

@ -2717,10 +2717,10 @@ win_alloc_first()
win_goto(wp) win_goto(wp)
win_T *wp; win_T *wp;
{ {
if (editing_cmdline()) if (text_locked())
{ {
beep_flush(); beep_flush();
editing_cmdline_msg(); text_locked_msg();
return; return;
} }
@ -4638,7 +4638,8 @@ eval_includeexpr(ptr, len)
char_u *res; char_u *res;
set_vim_var_string(VV_FNAME, ptr, len); set_vim_var_string(VV_FNAME, ptr, len);
res = eval_to_string_safe(curbuf->b_p_inex, NULL); res = eval_to_string_safe(curbuf->b_p_inex, NULL,
was_set_insecurely((char_u *)"includeexpr"));
set_vim_var_string(VV_FNAME, NULL, 0); set_vim_var_string(VV_FNAME, NULL, 0);
return res; return res;
} }