-*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
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
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
-useful when entering text in an empty buffer and then writing it to a file.
-If 'cpoptions' contains the 'f' flag (by default it is NOT included) the file
-name is set for the ":read file" command. This is useful when starting Vim
-without an argument and then doing ":read file" to start editing a file.
+the 'F' flag is included in 'cpoptions' (by default it is included) |cpo-F|.
+This is useful when entering text in an empty buffer and then writing it to a
+file. If 'cpoptions' contains the 'f' flag (by default it is NOT included)
+|cpo-f| the file name is set for the ":read file" command. This is useful
+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*
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
the filename of the current buffer to {file}. The
previous name is used for the alternate file name.
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}
*:up* *:update*
-*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.eval(str) *python-eval*
Evaluates the expression str using the vim internal expression
- evaluator (see |expression|). Returns the expression result as a
- string.
+ evaluator (see |expression|). Returns the expression result as:
+ - 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: >
:py text_width = vim.eval("&tw")
:py str = vim.eval("12+12") # NB result is a string! Use
# string.atoi() to convert to
# 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
vim.error *python-error*
if (buf == curbuf)
return OK;
- if (editing_cmdline())
+ if (text_locked())
{
- editing_cmdline_msg();
+ text_locked_msg();
return FAIL;
}
curwin = wp;
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;
curbuf = o_curbuf;
goto doend;
}
- if (editing_cmdline() && !(ea.argt & CMDWIN)
+ if (text_locked() && !(ea.argt & CMDWIN)
# ifdef FEAT_USR_CMDS
&& !USER_CMDIDX(ea.cmdidx)
# endif
}
#endif
/* Don't quit while editing the command line. */
- if (editing_cmdline())
+ if (text_locked())
{
- editing_cmdline_msg();
+ text_locked_msg();
return;
}
# endif
/* Don't quit while editing the command line. */
- if (editing_cmdline())
+ if (text_locked())
{
- editing_cmdline_msg();
+ text_locked_msg();
return;
}
cmdwin_result = K_IGNORE;
else
# endif
- if (!editing_cmdline())
+ if (!text_locked())
ex_win_close(eap, curwin);
}
}
#endif
/* Don't quit while editing the command line. */
- if (editing_cmdline())
+ if (text_locked())
{
- editing_cmdline_msg();
+ text_locked_msg();
return;
}
int save_msg_scroll = msg_scroll;
/* Postpone this while editing the command line. */
- if (editing_cmdline())
+ if (text_locked())
return;
/* Check whether the current buffer is changed. If so, we will need
#ifdef UNIX
static void set_file_time __ARGS((char_u *fname, time_t atime, time_t mtime));
#endif
+static int set_rw_fname __ARGS((char_u *fname, char_u *sfname));
static int msg_add_fileformat __ARGS((int eol_type));
static void msg_add_eol __ARGS((void));
static int check_mtime __ARGS((buf_T *buf, struct stat *s));
&& vim_strchr(p_cpo, CPO_FNAMER) != NULL
&& !(flags & READ_DUMMY))
{
- if (setfname(curbuf, fname, sfname, FALSE) == OK)
- curbuf->b_flags |= BF_NOTEDITED;
+ if (set_rw_fname(fname, sfname) == FAIL)
+ return FAIL;
}
/* After reading a file the cursor line changes but we don't want to
* Don't do this when appending.
* Only do this when 'cpoptions' contains the 'F' flag.
*/
- if (reset_changed
+ if (buf->b_ffname == NULL
+ && reset_changed
&& whole
&& buf == curbuf
#ifdef FEAT_QUICKFIX
&& !bt_nofile(buf)
#endif
- && buf->b_ffname == NULL
&& !filtering
&& (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
&& vim_strchr(p_cpo, CPO_FNAMEW) != NULL)
{
-#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 */
+ if (set_rw_fname(fname, sfname) == FAIL)
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);
-#endif
+ buf = curbuf; /* just in case autocmds made "buf" invalid */
}
if (sfname == NULL)
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.
*/
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. */
clearopbeep(oap);
- editing_cmdline_msg();
+ text_locked_msg();
goto normal_end;
}
{
char_u *ptr;
- if (editing_cmdline())
+ if (text_locked())
{
clearopbeep(cap->oap);
- editing_cmdline_msg();
+ text_locked_msg();
return;
}
/* "gQ": improved Ex mode */
case 'Q':
- if (editing_cmdline())
+ if (text_locked())
{
clearopbeep(cap->oap);
- editing_cmdline_msg();
+ text_locked_msg();
break;
}
/* ex_getln.c */
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));
-int editing_cmdline __ARGS((void));
-void editing_cmdline_msg __ARGS((void));
+int text_locked __ARGS((void));
+void text_locked_msg __ARGS((void));
char_u *getexline __ARGS((int c, void *dummy, int indent));
char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent));
int cmdline_overstrike __ARGS((void));
void free_string_option __ARGS((char_u *p));
void clear_string_option __ARGS((char_u **pp));
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));
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));
# define SPELL_PRINTTREE
#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
# define DEBUG_TRIEWALK
#endif
#define WF_HAS_AFF 0x0100 /* word includes affix */
#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)
/* flags for <pflags> */
flags |= WF_ALLCAP;
else if (first)
flags |= WF_ONECAP;
+
+ if (u >= 2 && l >= 2) /* maCARONI maCAroni */
+ flags |= WF_MIXCAP;
}
return flags;
}
/* Add the suggestion if the score isn't too bad. */
if (score <= su->su_maxscore)
+ {
add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra,
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);
+ }
+ }
+ }
}
}
win_goto(wp)
win_T *wp;
{
- if (editing_cmdline())
+ if (text_locked())
{
beep_flush();
- editing_cmdline_msg();
+ text_locked_msg();
return;
}
char_u *res;
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);
return res;
}