]> granicus.if.org Git - vim/commitdiff
updated for version 7.0183
authorBram Moolenaar <Bram@vim.org>
Fri, 20 Jan 2006 23:02:51 +0000 (23:02 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 20 Jan 2006 23:02:51 +0000 (23:02 +0000)
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

index e850dac015f9c4485036a1889af594c327acbd59..25dc1a674e2e078188993dfd585cdf3c346384d1 100644 (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
@@ -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
 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 and you want to try again later with
                        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*
index 3ceeff88e29389b98494066f16d7936d344b2404..b0f6286164398f5ec6ffec21a184e461262e62c6 100644 (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
@@ -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*
index 677215d2d36882d0adcb75fb27b8a9b1bd09b199..83c96903f7281c4ada88c0e34242818893e6696c 100644 (file)
@@ -1806,9 +1806,9 @@ buflist_getfile(n, lnum, options, forceit)
     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, fillchar, maxwidth, hl)
            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;
index fe9cd6bc15bcb037a9c11d1b2085a51483372c45..4e430c7bc64b30c9d68a51edc0337ad23cbf7d95 100644 (file)
@@ -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())
+    if (text_locked())
     {
-       editing_cmdline_msg();
+       text_locked_msg();
        return;
     }
 
@@ -6103,9 +6103,9 @@ ex_quit_all(eap)
 # endif
 
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
+    if (text_locked())
     {
-       editing_cmdline_msg();
+       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())
+    if (text_locked())
     {
-       editing_cmdline_msg();
+       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
index 2236bbc1a2b7d79d0dd62ce7734af31ba6d0f7ab..ce3e2a043d85a470d11fbc6ada7e875fbc8024b5 100644 (file)
@@ -59,6 +59,7 @@ static char_u *check_for_cryptkey __ARGS((char_u *cryptkey, char_u *ptr, long *s
 #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_skip, lines_to_read, eap, flags)
            && 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, eap, append, forceit,
      * 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)
@@ -4600,6 +4586,50 @@ nofail:
     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.
  */
index 12ede7375a293c73faf6eeb8573421a8fb579557..e866250e92b200bfc77635ae3ea9bcfe3b1c4418 100644 (file)
@@ -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;
        }
 
index 3b11a38a7962fd0a5d96dfded522ae713278a24a..6b4fa4fdaaa0a1fed6bcf800aaaff3cc97d71b1b 100644 (file)
@@ -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));
index 49e1d9aead494513e1cb28ab2836da955ae08855..4a49d892167c5465b03520eb1c0a41065465f1b3 100644 (file)
@@ -17,6 +17,7 @@ void check_buf_options __ARGS((buf_T *buf));
 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));
index 882cc50eeff891ad1da87c61ba5c978e081ed7a1..ceb5b829e2e0a259477f4458fc12af42a238e594 100644 (file)
@@ -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, soundfold)
 
                    /* 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);
+                           }
+                       }
+                   }
                }
            }
 
index 680c3201715e890dbd1abda275e232db123fc06e..a021805941cc61251a971fec258566c6817ba67c 100644 (file)
@@ -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;
 }