> 3.  Don't know about v:operator (works for me), the showcmd option
> means it could also be v:command or v:operatorcommand (since there is
> a v:swapcommand).

Try the attached patch which is against recent-ish svn. I think it will apply 
cleanly enough to any similar vintage code. I used v:operator. There's only one 
place it needs to be changed if a different name is preferred.

Ben.




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Index: runtime/doc/eval.txt
===================================================================
--- runtime/doc/eval.txt        (revision 621)
+++ runtime/doc/eval.txt        (working copy)
@@ -1401,6 +1401,12 @@
                This is the screen column number, like with |virtcol()|.  The
                value is zero when there was no mouse button click.
 
+                                       *v:operator* *operator-variable*
+v:operator     The last operator given in Normal mode. Useful in an
+               operator-pending mapping if you want to cancel the command
+               at first but later restart it.
+               Read-only.
+
                                        *v:prevcount* *prevcount-variable*
 v:prevcount    The count given for the last but one Normal mode command.
                This is the v:count value of the previous command.  Useful if
Index: src/vim.h
===================================================================
--- src/vim.h   (revision 607)
+++ src/vim.h   (working copy)
@@ -1688,7 +1688,8 @@
 #define VV_MOUSE_WIN   49
 #define VV_MOUSE_LNUM   50
 #define VV_MOUSE_COL   51
-#define VV_LEN         52      /* number of v: vars */
+#define VV_OP          52
+#define VV_LEN         53      /* number of v: vars */
 
 #ifdef FEAT_CLIPBOARD
 
Index: src/eval.c
===================================================================
--- src/eval.c  (revision 607)
+++ src/eval.c  (working copy)
@@ -345,6 +345,7 @@
     {VV_NAME("mouse_win",       VAR_NUMBER), 0},
     {VV_NAME("mouse_lnum",      VAR_NUMBER), 0},
     {VV_NAME("mouse_col",       VAR_NUMBER), 0},
+    {VV_NAME("operator",        VAR_STRING), VV_RO},
 };
 
 /* shorthand */
@@ -17260,6 +17261,35 @@
 }
 
 /*
+ * Set v:operator if needed.
+ */
+    void
+set_op_var(optype)
+    int                optype;
+{
+    /* This will either be two operator characters, or one and a NUL. */
+    char_u     opchars[2];
+
+    if (optype == OP_NOP)
+    {
+       set_vim_var_string(VV_OP, NULL, 0);
+       return;
+    }
+
+    opchars[0] = get_op_char(optype);
+    if (opchars[0] == 'g' || opchars[0] == 'z')
+       opchars[1] = get_extra_op_char(optype);
+    else
+       opchars[1] = 0;
+    
+    /* Avoid free/alloc when the value is already right. */
+    if (vimvars[VV_OP].vv_str == NULL ||
+           vimvars[VV_OP].vv_str[0] != opchars[0] ||
+           vimvars[VV_OP].vv_str[1] != opchars[1])
+       set_vim_var_string(VV_OP, opchars, opchars[1]==0?1:2);
+}
+
+/*
  * Get or set v:exception.  If "oldval" == NULL, return the current value.
  * Otherwise, restore the value to "oldval" and return NULL.
  * Must always be called in pairs to save and restore v:exception!  Does not
Index: src/normal.c
===================================================================
--- src/normal.c        (revision 607)
+++ src/normal.c        (working copy)
@@ -7173,6 +7173,7 @@
        {
            cap->oap->start = curwin->w_cursor;
            cap->oap->op_type = OP_DELETE;
+           set_op_var(OP_DELETE);
            cap->count1 = 1;
            nv_dollar(cap);
            finish_op = TRUE;
@@ -8212,6 +8213,7 @@
     {
        cap->oap->start = curwin->w_cursor;
        cap->oap->op_type = op_type;
+       set_op_var(op_type);
     }
 }
 

Raspunde prin e-mail lui