Karsten Hopp 83eea1
To: vim-dev@vim.org
Karsten Hopp 83eea1
Subject: patch 7.1.031
Karsten Hopp 83eea1
Fcc: outbox
Karsten Hopp 83eea1
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 83eea1
Mime-Version: 1.0
Karsten Hopp 83eea1
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 83eea1
Content-Transfer-Encoding: 8bit
Karsten Hopp 83eea1
------------
Karsten Hopp 83eea1
Karsten Hopp 83eea1
Patch 7.1.031
Karsten Hopp 83eea1
Problem:    virtcol([123, '$']) doesn't work. (Michael Schaap)
Karsten Hopp 83eea1
Solution:   When '$' is used for the column number get the last column.
Karsten Hopp 83eea1
Files:	    runtime/doc/eval.txt, src/eval.c
Karsten Hopp 83eea1
Karsten Hopp 83eea1
Karsten Hopp 83eea1
*** ../vim-7.1.030/runtime/doc/eval.txt	Tue Jun 19 17:23:46 2007
Karsten Hopp 83eea1
--- runtime/doc/eval.txt	Wed Jul 11 21:21:28 2007
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 1,4 ****
Karsten Hopp 83eea1
! *eval.txt*      For Vim version 7.1.  Last change: 2007 Jun 09
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
Karsten Hopp 83eea1
--- 1,4 ----
Karsten Hopp 83eea1
! *eval.txt*      For Vim version 7.1.  Last change: 2007 Jul 11
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 2020,2025 ****
Karsten Hopp 83eea1
--- 2020,2029 ----
Karsten Hopp 83eea1
  			    number of characters in the cursor line plus one)
Karsten Hopp 83eea1
  		    'x	    position of mark x (if the mark is not set, 0 is
Karsten Hopp 83eea1
  			    returned)
Karsten Hopp 83eea1
+ 		Additionally {expr} can be [lnum, col]: a |List| with the line
Karsten Hopp 83eea1
+ 		and column number. Most useful when the column is "$", to get
Karsten Hopp 83eea1
+ 		the las column of a specific line.  When "lnum" or "col" is
Karsten Hopp 83eea1
+ 		out of range then col() returns zero.
Karsten Hopp 83eea1
  		To get the line number use |line()|.  To get both use
Karsten Hopp 83eea1
  		|getpos()|.
Karsten Hopp 83eea1
  		For the screen column position use |virtcol()|.
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 5024,5037 ****
Karsten Hopp 83eea1
  		position, the returned Number will be the column at the end of
Karsten Hopp 83eea1
  		the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
Karsten Hopp 83eea1
  		set to 8, it returns 8.
Karsten Hopp 83eea1
! 		For the use of {expr} see |col()|.  Additionally you can use
Karsten Hopp 83eea1
! 		[lnum, col]: a |List| with the line and column number.  When
Karsten Hopp 83eea1
! 		"lnum" or "col" is out of range then virtcol() returns zero.
Karsten Hopp 83eea1
! 		When 'virtualedit' is used it can be [lnum, col, off], where
Karsten Hopp 83eea1
  		"off" is the offset in screen columns from the start of the
Karsten Hopp 83eea1
  		character.  E.g., a position within a <Tab> or after the last
Karsten Hopp 83eea1
  		character.
Karsten Hopp 83eea1
- 		For the byte position use |col()|.
Karsten Hopp 83eea1
  		When Virtual editing is active in the current mode, a position
Karsten Hopp 83eea1
  		beyond the end of the line can be returned. |'virtualedit'|
Karsten Hopp 83eea1
  		The accepted positions are:
Karsten Hopp 83eea1
--- 5029,5040 ----
Karsten Hopp 83eea1
  		position, the returned Number will be the column at the end of
Karsten Hopp 83eea1
  		the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
Karsten Hopp 83eea1
  		set to 8, it returns 8.
Karsten Hopp 83eea1
! 		For the byte position use |col()|.
Karsten Hopp 83eea1
! 		For the use of {expr} see |col()|.
Karsten Hopp 83eea1
! 		When 'virtualedit' is used {expr} can be [lnum, col, off], where
Karsten Hopp 83eea1
  		"off" is the offset in screen columns from the start of the
Karsten Hopp 83eea1
  		character.  E.g., a position within a <Tab> or after the last
Karsten Hopp 83eea1
  		character.
Karsten Hopp 83eea1
  		When Virtual editing is active in the current mode, a position
Karsten Hopp 83eea1
  		beyond the end of the line can be returned. |'virtualedit'|
Karsten Hopp 83eea1
  		The accepted positions are:
Karsten Hopp 83eea1
*** ../vim-7.1.030/src/eval.c	Tue Jul 10 13:27:46 2007
Karsten Hopp 83eea1
--- src/eval.c	Wed Jul 11 19:50:27 2007
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 672,678 ****
Karsten Hopp 83eea1
  static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
Karsten Hopp 83eea1
! static pos_T *var2fpos __ARGS((typval_T *varp, int lnum, int *fnum));
Karsten Hopp 83eea1
  static int get_env_len __ARGS((char_u **arg));
Karsten Hopp 83eea1
  static int get_id_len __ARGS((char_u **arg));
Karsten Hopp 83eea1
  static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
Karsten Hopp 83eea1
--- 672,678 ----
Karsten Hopp 83eea1
  static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
Karsten Hopp 83eea1
! static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
Karsten Hopp 83eea1
  static int get_env_len __ARGS((char_u **arg));
Karsten Hopp 83eea1
  static int get_id_len __ARGS((char_u **arg));
Karsten Hopp 83eea1
  static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 16505,16513 ****
Karsten Hopp 83eea1
   * Returns NULL when there is an error.
Karsten Hopp 83eea1
   */
Karsten Hopp 83eea1
      static pos_T *
Karsten Hopp 83eea1
! var2fpos(varp, lnum, fnum)
Karsten Hopp 83eea1
      typval_T	*varp;
Karsten Hopp 83eea1
!     int		lnum;		/* TRUE when $ is last line */
Karsten Hopp 83eea1
      int		*fnum;		/* set to fnum for '0, 'A, etc. */
Karsten Hopp 83eea1
  {
Karsten Hopp 83eea1
      char_u		*name;
Karsten Hopp 83eea1
--- 16508,16516 ----
Karsten Hopp 83eea1
   * Returns NULL when there is an error.
Karsten Hopp 83eea1
   */
Karsten Hopp 83eea1
      static pos_T *
Karsten Hopp 83eea1
! var2fpos(varp, dollar_lnum, fnum)
Karsten Hopp 83eea1
      typval_T	*varp;
Karsten Hopp 83eea1
!     int		dollar_lnum;	/* TRUE when $ is last line */
Karsten Hopp 83eea1
      int		*fnum;		/* set to fnum for '0, 'A, etc. */
Karsten Hopp 83eea1
  {
Karsten Hopp 83eea1
      char_u		*name;
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 16520,16525 ****
Karsten Hopp 83eea1
--- 16523,16529 ----
Karsten Hopp 83eea1
  	list_T		*l;
Karsten Hopp 83eea1
  	int		len;
Karsten Hopp 83eea1
  	int		error = FALSE;
Karsten Hopp 83eea1
+ 	listitem_T	*li;
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
  	l = varp->vval.v_list;
Karsten Hopp 83eea1
  	if (l == NULL)
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 16535,16540 ****
Karsten Hopp 83eea1
--- 16539,16552 ----
Karsten Hopp 83eea1
  	if (error)
Karsten Hopp 83eea1
  	    return NULL;
Karsten Hopp 83eea1
  	len = (long)STRLEN(ml_get(pos.lnum));
Karsten Hopp 83eea1
+ 
Karsten Hopp 83eea1
+ 	/* We accept "$" for the column number: last column. */
Karsten Hopp 83eea1
+ 	li = list_find(l, 1L);
Karsten Hopp 83eea1
+ 	if (li != NULL && li->li_tv.v_type == VAR_STRING
Karsten Hopp 83eea1
+ 		&& li->li_tv.vval.v_string != NULL
Karsten Hopp 83eea1
+ 		&& STRCMP(li->li_tv.vval.v_string, "$") == 0)
Karsten Hopp 83eea1
+ 	    pos.col = len + 1;
Karsten Hopp 83eea1
+ 
Karsten Hopp 83eea1
  	/* Accept a position up to the NUL after the line. */
Karsten Hopp 83eea1
  	if (pos.col == 0 || (int)pos.col > len + 1)
Karsten Hopp 83eea1
  	    return NULL;	/* invalid column number */
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 16567,16573 ****
Karsten Hopp 83eea1
      pos.coladd = 0;
Karsten Hopp 83eea1
  #endif
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
!     if (name[0] == 'w' && lnum)
Karsten Hopp 83eea1
      {
Karsten Hopp 83eea1
  	pos.col = 0;
Karsten Hopp 83eea1
  	if (name[1] == '0')		/* "w0": first visible line */
Karsten Hopp 83eea1
--- 16579,16585 ----
Karsten Hopp 83eea1
      pos.coladd = 0;
Karsten Hopp 83eea1
  #endif
Karsten Hopp 83eea1
  
Karsten Hopp 83eea1
!     if (name[0] == 'w' && dollar_lnum)
Karsten Hopp 83eea1
      {
Karsten Hopp 83eea1
  	pos.col = 0;
Karsten Hopp 83eea1
  	if (name[1] == '0')		/* "w0": first visible line */
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 16585,16591 ****
Karsten Hopp 83eea1
      }
Karsten Hopp 83eea1
      else if (name[0] == '$')		/* last column or line */
Karsten Hopp 83eea1
      {
Karsten Hopp 83eea1
! 	if (lnum)
Karsten Hopp 83eea1
  	{
Karsten Hopp 83eea1
  	    pos.lnum = curbuf->b_ml.ml_line_count;
Karsten Hopp 83eea1
  	    pos.col = 0;
Karsten Hopp 83eea1
--- 16597,16603 ----
Karsten Hopp 83eea1
      }
Karsten Hopp 83eea1
      else if (name[0] == '$')		/* last column or line */
Karsten Hopp 83eea1
      {
Karsten Hopp 83eea1
! 	if (dollar_lnum)
Karsten Hopp 83eea1
  	{
Karsten Hopp 83eea1
  	    pos.lnum = curbuf->b_ml.ml_line_count;
Karsten Hopp 83eea1
  	    pos.col = 0;
Karsten Hopp 83eea1
*** ../vim-7.1.030/src/version.c	Tue Jul 17 14:32:07 2007
Karsten Hopp 83eea1
--- src/version.c	Tue Jul 17 16:24:54 2007
Karsten Hopp 83eea1
***************
Karsten Hopp 83eea1
*** 668,669 ****
Karsten Hopp 83eea1
--- 668,671 ----
Karsten Hopp 83eea1
  {   /* Add new patch number below this line */
Karsten Hopp 83eea1
+ /**/
Karsten Hopp 83eea1
+     31,
Karsten Hopp 83eea1
  /**/
Karsten Hopp 83eea1
Karsten Hopp 83eea1
-- 
Karsten Hopp 83eea1
CRONE:  Who sent you?
Karsten Hopp 83eea1
ARTHUR: The Knights Who Say GNU!
Karsten Hopp 83eea1
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no licenses here.
Karsten Hopp 83eea1
           "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
Karsten Hopp 83eea1
Karsten Hopp 83eea1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 83eea1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 83eea1
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 83eea1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///