changeset 633:7437be625546

updated for version 7.0183
author vimboss
date Fri, 20 Jan 2006 23:02:51 +0000
parents b6632d553df3
children 1c586ee8dd45
files runtime/doc/editing.txt runtime/doc/if_pyth.txt src/buffer.c src/ex_docmd.c src/fileio.c src/normal.c src/proto/ex_getln.pro src/proto/option.pro src/spell.c src/window.c
diffstat 10 files changed, 132 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -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
@@ -155,11 +155,14 @@ Technical: On the Amiga you can use 30 c
 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
@@ -874,6 +877,8 @@ used, for example, when the write fails 
 			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*
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -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
@@ -131,14 +131,24 @@ vim.command(str)					*python-command*
 
 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*
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1806,9 +1806,9 @@ buflist_getfile(n, lnum, options, forcei
     if (buf == curbuf)
 	return OK;
 
-    if (editing_cmdline())
+    if (text_locked())
     {
-	editing_cmdline_msg();
+	text_locked_msg();
 	return FAIL;
     }
 
@@ -3506,7 +3506,8 @@ build_stl_str_hl(wp, out, outlen, fmt, f
 	    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;
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2137,7 +2137,7 @@ do_one_cmd(cmdlinep, sourcing,
 	    goto doend;
 	}
 
-	if (editing_cmdline() && !(ea.argt & CMDWIN)
+	if (text_locked() && !(ea.argt & CMDWIN)
 # ifdef FEAT_USR_CMDS
 		&& !USER_CMDIDX(ea.cmdidx)
 # endif
@@ -6034,9 +6034,9 @@ ex_quit(eap)
     }
 #endif
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
-    {
-	editing_cmdline_msg();
+    if (text_locked())
+    {
+	text_locked_msg();
 	return;
     }
 
@@ -6103,9 +6103,9 @@ ex_quit_all(eap)
 # endif
 
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
-    {
-	editing_cmdline_msg();
+    if (text_locked())
+    {
+	text_locked_msg();
 	return;
     }
 
@@ -6128,7 +6128,7 @@ ex_close(eap)
 	cmdwin_result = K_IGNORE;
     else
 # endif
-	if (!editing_cmdline())
+	if (!text_locked())
 	    ex_win_close(eap, curwin);
 }
 
@@ -6289,9 +6289,9 @@ ex_exit(eap)
     }
 #endif
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
-    {
-	editing_cmdline_msg();
+    if (text_locked())
+    {
+	text_locked_msg();
 	return;
     }
 
@@ -6407,7 +6407,7 @@ handle_drop(filec, filev, split)
     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
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -59,6 +59,7 @@ static char_u *check_for_cryptkey __ARGS
 #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));
@@ -301,8 +302,8 @@ readfile(fname, sfname, from, lines_to_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
@@ -2801,35 +2802,20 @@ buf_write(buf, fname, sfname, start, end
      * 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)
@@ -4601,6 +4587,50 @@ nofail:
 }
 
 /*
+ * 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.
  */
     void
--- a/src/normal.c
+++ b/src/normal.c
@@ -789,11 +789,11 @@ getcount:
 	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;
     }
 
@@ -5741,10 +5741,10 @@ nv_gotofile(cap)
 {
     char_u	*ptr;
 
-    if (editing_cmdline())
+    if (text_locked())
     {
 	clearopbeep(cap->oap);
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -7801,10 +7801,10 @@ nv_g_cmd(cap)
 
     /* "gQ": improved Ex mode */
     case 'Q':
-	if (editing_cmdline())
+	if (text_locked())
 	{
 	    clearopbeep(cap->oap);
-	    editing_cmdline_msg();
+	    text_locked_msg();
 	    break;
 	}
 
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -1,8 +1,8 @@
 /* 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));
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -17,6 +17,7 @@ void check_buf_options __ARGS((buf_T *bu
 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));
--- a/src/spell.c
+++ b/src/spell.c
@@ -59,7 +59,8 @@
 # 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
@@ -328,6 +329,9 @@ typedef long idx_T;
 #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> */
@@ -4328,6 +4332,9 @@ badword_captype(word, end)
 	    flags |= WF_ALLCAP;
 	else if (first)
 	    flags |= WF_ONECAP;
+
+	if (u >= 2 && l >= 2)	/* maCARONI maCAroni */
+	    flags |= WF_MIXCAP;
     }
     return flags;
 }
@@ -10895,9 +10902,29 @@ suggest_trie_walk(su, lp, fword, soundfo
 
 		    /* 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);
+			    }
+			}
+		    }
 		}
 	    }
 
--- a/src/window.c
+++ b/src/window.c
@@ -2717,10 +2717,10 @@ win_alloc_first()
 win_goto(wp)
     win_T	*wp;
 {
-    if (editing_cmdline())
+    if (text_locked())
     {
 	beep_flush();
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -4638,7 +4638,8 @@ eval_includeexpr(ptr, len)
     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;
 }