0754c49
To: vim-dev@vim.org
0754c49
Subject: Patch 7.1.205
0754c49
Fcc: outbox
0754c49
From: Bram Moolenaar <Bram@moolenaar.net>
0754c49
Mime-Version: 1.0
0754c49
Content-Type: text/plain; charset=ISO-8859-1
0754c49
Content-Transfer-Encoding: 8bit
0754c49
------------
0754c49
0754c49
Patch 7.1.205
0754c49
Problem:    Can't get the operator in an ":omap".
0754c49
Solution:   Add the "v:operator" variable. (Ben Schmidt)
0754c49
Files:	    runtime/doc/eval.txt, src/eval.c, src/normal.c, src/vim.h
0754c49
0754c49
0754c49
*** ../vim-7.1.204/runtime/doc/eval.txt	Tue Sep 25 17:54:41 2007
0754c49
--- runtime/doc/eval.txt	Fri Jan  4 20:38:55 2008
0754c49
***************
0754c49
*** 1,4 ****
0754c49
! *eval.txt*      For Vim version 7.1.  Last change: 2007 Sep 25
0754c49
  
0754c49
  
0754c49
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
0754c49
--- 1,4 ----
0754c49
! *eval.txt*      For Vim version 7.1.  Last change: 2008 Jan 04
0754c49
  
0754c49
  
0754c49
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
0754c49
***************
0754c49
*** 1401,1410 ****
0754c49
  		This is the screen column number, like with |virtcol()|.  The
0754c49
  		value is zero when there was no mouse button click.
0754c49
  
0754c49
  					*v:prevcount* *prevcount-variable*
0754c49
  v:prevcount	The count given for the last but one Normal mode command.
0754c49
  		This is the v:count value of the previous command.  Useful if
0754c49
! 		you want to cancel Visual mode and then use the count. >
0754c49
  			:vmap % <Esc>:call MyFilter(v:prevcount)<CR>
0754c49
  <		Read-only.
0754c49
  
0754c49
--- 1401,1424 ----
0754c49
  		This is the screen column number, like with |virtcol()|.  The
0754c49
  		value is zero when there was no mouse button click.
0754c49
  
0754c49
+ 					*v:operator* *operator-variable*
0754c49
+ v:operator	The last operator given in Normal mode.  This is a single
0754c49
+ 		character except for commands starting with <g> or <z>,
0754c49
+ 		in which case it is two characters.  Best used alongside
0754c49
+ 		|v:prevcount| and |v:register|.  Useful if you want to cancel
0754c49
+ 		Operator-pending mode and then use the operator, e.g.: >
0754c49
+ 			:omap O <Esc>:call MyMotion(v:operator)<CR>
0754c49
+ <		The value remains set until another operator is entered, thus
0754c49
+ 		don't expect it to be empty.
0754c49
+ 		v:operator is not set for |:delete|, |:yank| or other Ex
0754c49
+ 		commands.
0754c49
+ 		Read-only.
0754c49
+ 
0754c49
  					*v:prevcount* *prevcount-variable*
0754c49
  v:prevcount	The count given for the last but one Normal mode command.
0754c49
  		This is the v:count value of the previous command.  Useful if
0754c49
! 		you want to cancel Visual or Operator-pending mode and then
0754c49
! 		use the count, e.g.: >
0754c49
  			:vmap % <Esc>:call MyFilter(v:prevcount)<CR>
0754c49
  <		Read-only.
0754c49
  
0754c49
*** ../vim-7.1.204/src/eval.c	Fri Dec  7 17:08:35 2007
0754c49
--- src/eval.c	Sat Jan  5 13:22:52 2008
0754c49
***************
0754c49
*** 345,350 ****
0754c49
--- 345,351 ----
0754c49
      {VV_NAME("mouse_win",	 VAR_NUMBER), 0},
0754c49
      {VV_NAME("mouse_lnum",	 VAR_NUMBER), 0},
0754c49
      {VV_NAME("mouse_col",	 VAR_NUMBER), 0},
0754c49
+     {VV_NAME("operator",	 VAR_STRING), VV_RO},
0754c49
  };
0754c49
  
0754c49
  /* shorthand */
0754c49
*** ../vim-7.1.204/src/normal.c	Thu Jan  3 13:19:50 2008
0754c49
--- src/normal.c	Fri Jan  4 20:53:43 2008
0754c49
***************
0754c49
*** 141,146 ****
0754c49
--- 141,149 ----
0754c49
  static void	nv_Undo __ARGS((cmdarg_T *cap));
0754c49
  static void	nv_tilde __ARGS((cmdarg_T *cap));
0754c49
  static void	nv_operator __ARGS((cmdarg_T *cap));
0754c49
+ #ifdef FEAT_EVAL
0754c49
+ static void	set_op_var __ARGS((int optype));
0754c49
+ #endif
0754c49
  static void	nv_lineop __ARGS((cmdarg_T *cap));
0754c49
  static void	nv_home __ARGS((cmdarg_T *cap));
0754c49
  static void	nv_pipe __ARGS((cmdarg_T *cap));
0754c49
***************
0754c49
*** 7180,7185 ****
0754c49
--- 7183,7191 ----
0754c49
  	{
0754c49
  	    cap->oap->start = curwin->w_cursor;
0754c49
  	    cap->oap->op_type = OP_DELETE;
0754c49
+ #ifdef FEAT_EVAL
0754c49
+ 	    set_op_var(OP_DELETE);
0754c49
+ #endif
0754c49
  	    cap->count1 = 1;
0754c49
  	    nv_dollar(cap);
0754c49
  	    finish_op = TRUE;
0754c49
***************
0754c49
*** 8219,8226 ****
0754c49
--- 8225,8257 ----
0754c49
      {
0754c49
  	cap->oap->start = curwin->w_cursor;
0754c49
  	cap->oap->op_type = op_type;
0754c49
+ #ifdef FEAT_EVAL
0754c49
+ 	set_op_var(op_type);
0754c49
+ #endif
0754c49
+     }
0754c49
+ }
0754c49
+ 
0754c49
+ #ifdef FEAT_EVAL
0754c49
+ /*
0754c49
+  * Set v:operator to the characters for "optype".
0754c49
+  */
0754c49
+     static void
0754c49
+ set_op_var(optype)
0754c49
+     int optype;
0754c49
+ {
0754c49
+     char_u	opchars[3];
0754c49
+ 
0754c49
+     if (optype == OP_NOP)
0754c49
+ 	set_vim_var_string(VV_OP, NULL, 0);
0754c49
+     else
0754c49
+     {
0754c49
+ 	opchars[0] = get_op_char(optype);
0754c49
+ 	opchars[1] = get_extra_op_char(optype);
0754c49
+ 	opchars[2] = NUL;
0754c49
+ 	set_vim_var_string(VV_OP, opchars, -1);
0754c49
      }
0754c49
  }
0754c49
+ #endif
0754c49
  
0754c49
  /*
0754c49
   * Handle linewise operator "dd", "yy", etc.
0754c49
*** ../vim-7.1.204/src/vim.h	Sat Aug 11 13:57:31 2007
0754c49
--- src/vim.h	Fri Jan  4 19:11:31 2008
0754c49
***************
0754c49
*** 1688,1694 ****
0754c49
  #define VV_MOUSE_WIN	49
0754c49
  #define VV_MOUSE_LNUM   50
0754c49
  #define VV_MOUSE_COL	51
0754c49
! #define VV_LEN		52	/* number of v: vars */
0754c49
  
0754c49
  #ifdef FEAT_CLIPBOARD
0754c49
  
0754c49
--- 1688,1695 ----
0754c49
  #define VV_MOUSE_WIN	49
0754c49
  #define VV_MOUSE_LNUM   50
0754c49
  #define VV_MOUSE_COL	51
0754c49
! #define VV_OP		52
0754c49
! #define VV_LEN		53	/* number of v: vars */
0754c49
  
0754c49
  #ifdef FEAT_CLIPBOARD
0754c49
  
0754c49
*** ../vim-7.1.204/src/version.c	Sat Jan  5 13:15:08 2008
0754c49
--- src/version.c	Sat Jan  5 13:31:49 2008
0754c49
***************
0754c49
*** 668,669 ****
0754c49
--- 668,671 ----
0754c49
  {   /* Add new patch number below this line */
0754c49
+ /**/
0754c49
+     205,
0754c49
  /**/
0754c49
0754c49
-- 
0754c49
ARTHUR:  Then who is your lord?
0754c49
WOMAN:   We don't have a lord.
0754c49
ARTHUR:  What?
0754c49
DENNIS:  I told you.  We're an anarcho-syndicalist commune.  We take it in
0754c49
         turns to act as a sort of executive officer for the week.
0754c49
                                  The Quest for the Holy Grail (Monty Python)
0754c49
0754c49
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
0754c49
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
0754c49
\\\        download, build and distribute -- http://www.A-A-P.org        ///
0754c49
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///