# HG changeset patch # User vimboss # Date 1199536521 0 # Node ID 0f3f3090491faea043fa144780d1287e011390ac # Parent 62716fd61fe94fb9e7f39294dfa9dba4aa06fbf8 updated for version 7.1-205 diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.1. Last change: 2007 Sep 25 +*eval.txt* For Vim version 7.1. Last change: 2008 Jan 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1401,10 +1401,24 @@ v:mouse_col Column number for a mouse cl 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. This is a single + character except for commands starting with or , + in which case it is two characters. Best used alongside + |v:prevcount| and |v:register|. Useful if you want to cancel + Operator-pending mode and then use the operator, e.g.: > + :omap O :call MyMotion(v:operator) +< The value remains set until another operator is entered, thus + don't expect it to be empty. + v:operator is not set for |:delete|, |:yank| or other Ex + commands. + 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 - you want to cancel Visual mode and then use the count. > + you want to cancel Visual or Operator-pending mode and then + use the count, e.g.: > :vmap % :call MyFilter(v:prevcount) < Read-only. diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -345,6 +345,7 @@ static struct vimvar {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 */ diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -141,6 +141,9 @@ static void nv_redo __ARGS((cmdarg_T *ca static void nv_Undo __ARGS((cmdarg_T *cap)); static void nv_tilde __ARGS((cmdarg_T *cap)); static void nv_operator __ARGS((cmdarg_T *cap)); +#ifdef FEAT_EVAL +static void set_op_var __ARGS((int optype)); +#endif static void nv_lineop __ARGS((cmdarg_T *cap)); static void nv_home __ARGS((cmdarg_T *cap)); static void nv_pipe __ARGS((cmdarg_T *cap)); @@ -7180,6 +7183,9 @@ nv_optrans(cap) { cap->oap->start = curwin->w_cursor; cap->oap->op_type = OP_DELETE; +#ifdef FEAT_EVAL + set_op_var(OP_DELETE); +#endif cap->count1 = 1; nv_dollar(cap); finish_op = TRUE; @@ -8219,8 +8225,33 @@ nv_operator(cap) { cap->oap->start = curwin->w_cursor; cap->oap->op_type = op_type; - } -} +#ifdef FEAT_EVAL + set_op_var(op_type); +#endif + } +} + +#ifdef FEAT_EVAL +/* + * Set v:operator to the characters for "optype". + */ + static void +set_op_var(optype) + int optype; +{ + char_u opchars[3]; + + if (optype == OP_NOP) + set_vim_var_string(VV_OP, NULL, 0); + else + { + opchars[0] = get_op_char(optype); + opchars[1] = get_extra_op_char(optype); + opchars[2] = NUL; + set_vim_var_string(VV_OP, opchars, -1); + } +} +#endif /* * Handle linewise operator "dd", "yy", etc. diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -667,6 +667,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 205, +/**/ 204, /**/ 203, diff --git a/src/vim.h b/src/vim.h --- a/src/vim.h +++ b/src/vim.h @@ -1688,7 +1688,8 @@ int vim_memcmp __ARGS((void *, void *, s #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