]> granicus.if.org Git - vim/commitdiff
updated for version 7.2-266 v7.2.266
authorBram Moolenaar <Bram@vim.org>
Wed, 30 Sep 2009 13:17:02 +0000 (13:17 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 30 Sep 2009 13:17:02 +0000 (13:17 +0000)
runtime/doc/map.txt
src/eval.c
src/getchar.c
src/ops.c
src/proto/eval.pro
src/version.c

index 607295779efa787a8da744bb8df86a69b649f6fd..e7b93787c972bb8171290305c2745760eaf65b7b 100644 (file)
@@ -224,6 +224,10 @@ expression is evaluated to obtain the {rhs} that is used.  Example: >
 The result of the InsertDot() function will be inserted.  It could check the
 text before the cursor and start omni completion when some condition is met.
 
+For abbreviations |v:char| is set to the character that was typed to trigger
+the abbreviation.  You can use this to decide how to expand the {lhs}.  You
+can't change v:char and you should not insert it.
+
 Be very careful about side effects!  The expression is evaluated while
 obtaining characters, you may very well make the command dysfunctional.
 For this reason the following is blocked:
index f94178d6643c9d8762a90f786694da3b577cfa14..a48e1529372c4b309bd5f02e718d52e9d7807846 100644 (file)
@@ -18100,6 +18100,31 @@ get_vim_var_list(idx)
     return vimvars[idx].vv_list;
 }
 
+/*
+ * Set v:char to character "c".
+ */
+    void
+set_vim_var_char(c)
+    int c;
+{
+#ifdef FEAT_MBYTE
+    char_u     buf[MB_MAXBYTES];
+#else
+    char_u     buf[2];
+#endif
+
+#ifdef FEAT_MBYTE
+    if (has_mbyte)
+       buf[(*mb_char2bytes)(c, buf)] = NUL;
+    else
+#endif
+    {
+       buf[0] = c;
+       buf[1] = NUL;
+    }
+    set_vim_var_string(VV_CHAR, buf, -1);
+}
+
 /*
  * Set v:count to "count" and v:count1 to "count1".
  * When "set_prevcount" is TRUE first set v:prevcount from v:count.
index e81f7cb5633b4bfc10713968d4cfaa6e98f64aeb..b39ff74a36839d0527b94ef03b3b26b11241e8ca 100644 (file)
@@ -129,7 +129,7 @@ static void map_free __ARGS((mapblock_T **));
 static void    validate_maphash __ARGS((void));
 static void    showmap __ARGS((mapblock_T *mp, int local));
 #ifdef FEAT_EVAL
-static char_u  *eval_map_expr __ARGS((char_u *str));
+static char_u  *eval_map_expr __ARGS((char_u *str, int c));
 #endif
 
 /*
@@ -2446,7 +2446,7 @@ vgetorpeek(advance)
                            if (tabuf.typebuf_valid)
                            {
                                vgetc_busy = 0;
-                               s = eval_map_expr(mp->m_str);
+                               s = eval_map_expr(mp->m_str, NUL);
                                vgetc_busy = save_vgetc_busy;
                            }
                            else
@@ -4367,9 +4367,9 @@ check_abbr(c, ptr, col, mincol)
             * abbreviation, but is not inserted into the input stream.
             */
            j = 0;
-                                       /* special key code, split up */
            if (c != Ctrl_RSB)
            {
+                                       /* special key code, split up */
                if (IS_SPECIAL(c) || c == K_SPECIAL)
                {
                    tb[j++] = K_SPECIAL;
@@ -4398,7 +4398,7 @@ check_abbr(c, ptr, col, mincol)
            }
 #ifdef FEAT_EVAL
            if (mp->m_expr)
-               s = eval_map_expr(mp->m_str);
+               s = eval_map_expr(mp->m_str, c);
            else
 #endif
                s = mp->m_str;
@@ -4434,8 +4434,9 @@ check_abbr(c, ptr, col, mincol)
  * special characters.
  */
     static char_u *
-eval_map_expr(str)
+eval_map_expr(str, c)
     char_u     *str;
+    int                c;          /* NUL or typed character for abbreviation */
 {
     char_u     *res;
     char_u     *p;
@@ -4452,6 +4453,7 @@ eval_map_expr(str)
 #ifdef FEAT_EX_EXTRA
     ++ex_normal_lock;
 #endif
+    set_vim_var_char(c);  /* set v:char to the typed character */
     save_cursor = curwin->w_cursor;
     p = eval_to_string(str, NULL, FALSE);
     --textlock;
index f75613def2ecdfa6b235f99f0623eb0be528f3b0..b21f4c2509fe10d0d6a637f95a266fc8cfbb8013 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -4473,11 +4473,6 @@ fex_format(lnum, count, c)
     int                use_sandbox = was_set_insecurely((char_u *)"formatexpr",
                                                                   OPT_LOCAL);
     int                r;
-#ifdef FEAT_MBYTE
-    char_u     buf[MB_MAXBYTES];
-#else
-    char_u     buf[2];
-#endif
 
     /*
      * Set v:lnum to the first line number and v:count to the number of lines.
@@ -4485,17 +4480,7 @@ fex_format(lnum, count, c)
      */
     set_vim_var_nr(VV_LNUM, lnum);
     set_vim_var_nr(VV_COUNT, count);
-
-#ifdef FEAT_MBYTE
-    if (has_mbyte)
-       buf[(*mb_char2bytes)(c, buf)] = NUL;
-    else
-#endif
-    {
-       buf[0] = c;
-       buf[1] = NUL;
-    }
-    set_vim_var_string(VV_CHAR, buf, -1);
+    set_vim_var_char(c);
 
     /*
      * Evaluate the function.
index 362b9d90fe335127fb7d5194cb2b0bff397d4a60..d520046769329f6e2bded3dc37fffd4fccc1a90d 100644 (file)
@@ -61,6 +61,7 @@ void set_vim_var_nr __ARGS((int idx, long val));
 long get_vim_var_nr __ARGS((int idx));
 char_u *get_vim_var_str __ARGS((int idx));
 list_T *get_vim_var_list __ARGS((int idx));
+void set_vim_var_char __ARGS((int c));
 void set_vcount __ARGS((long count, long count1, int set_prevcount));
 void set_vim_var_string __ARGS((int idx, char_u *val, int len));
 void set_vim_var_list __ARGS((int idx, list_T *val));
index 3102a6fec1be039c17a059cf4aea00d6dd203a73..1a7e765271bf835512ffa43c694bb86aa015793b 100644 (file)
@@ -676,6 +676,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    266,
 /**/
     265,
 /**/