home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.1 / 7.1.031 < prev    next >
Encoding:
Internet Message Format  |  2007-11-19  |  6.4 KB

  1. To: vim-dev@vim.org
  2. Subject: patch 7.1.031
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.1.031
  11. Problem:    virtcol([123, '$']) doesn't work. (Michael Schaap)
  12. Solution:   When '$' is used for the column number get the last column.
  13. Files:        runtime/doc/eval.txt, src/eval.c
  14.  
  15.  
  16. *** ../vim-7.1.030/runtime/doc/eval.txt    Tue Jun 19 17:23:46 2007
  17. --- runtime/doc/eval.txt    Wed Jul 11 21:21:28 2007
  18. ***************
  19. *** 1,4 ****
  20. ! *eval.txt*      For Vim version 7.1.  Last change: 2007 Jun 09
  21.   
  22.   
  23.             VIM REFERENCE MANUAL    by Bram Moolenaar
  24. --- 1,4 ----
  25. ! *eval.txt*      For Vim version 7.1.  Last change: 2007 Jul 11
  26.   
  27.   
  28.             VIM REFERENCE MANUAL    by Bram Moolenaar
  29. ***************
  30. *** 2020,2025 ****
  31. --- 2020,2029 ----
  32.                   number of characters in the cursor line plus one)
  33.               'x        position of mark x (if the mark is not set, 0 is
  34.                   returned)
  35. +         Additionally {expr} can be [lnum, col]: a |List| with the line
  36. +         and column number. Most useful when the column is "$", to get
  37. +         the las column of a specific line.  When "lnum" or "col" is
  38. +         out of range then col() returns zero.
  39.           To get the line number use |line()|.  To get both use
  40.           |getpos()|.
  41.           For the screen column position use |virtcol()|.
  42. ***************
  43. *** 5024,5037 ****
  44.           position, the returned Number will be the column at the end of
  45.           the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
  46.           set to 8, it returns 8.
  47. !         For the use of {expr} see |col()|.  Additionally you can use
  48. !         [lnum, col]: a |List| with the line and column number.  When
  49. !         "lnum" or "col" is out of range then virtcol() returns zero.
  50. !         When 'virtualedit' is used it can be [lnum, col, off], where
  51.           "off" is the offset in screen columns from the start of the
  52.           character.  E.g., a position within a <Tab> or after the last
  53.           character.
  54. -         For the byte position use |col()|.
  55.           When Virtual editing is active in the current mode, a position
  56.           beyond the end of the line can be returned. |'virtualedit'|
  57.           The accepted positions are:
  58. --- 5029,5040 ----
  59.           position, the returned Number will be the column at the end of
  60.           the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
  61.           set to 8, it returns 8.
  62. !         For the byte position use |col()|.
  63. !         For the use of {expr} see |col()|.
  64. !         When 'virtualedit' is used {expr} can be [lnum, col, off], where
  65.           "off" is the offset in screen columns from the start of the
  66.           character.  E.g., a position within a <Tab> or after the last
  67.           character.
  68.           When Virtual editing is active in the current mode, a position
  69.           beyond the end of the line can be returned. |'virtualedit'|
  70.           The accepted positions are:
  71. *** ../vim-7.1.030/src/eval.c    Tue Jul 10 13:27:46 2007
  72. --- src/eval.c    Wed Jul 11 19:50:27 2007
  73. ***************
  74. *** 672,678 ****
  75.   static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
  76.   
  77.   static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
  78. ! static pos_T *var2fpos __ARGS((typval_T *varp, int lnum, int *fnum));
  79.   static int get_env_len __ARGS((char_u **arg));
  80.   static int get_id_len __ARGS((char_u **arg));
  81.   static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
  82. --- 672,678 ----
  83.   static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
  84.   
  85.   static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
  86. ! static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
  87.   static int get_env_len __ARGS((char_u **arg));
  88.   static int get_id_len __ARGS((char_u **arg));
  89.   static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
  90. ***************
  91. *** 16505,16513 ****
  92.    * Returns NULL when there is an error.
  93.    */
  94.       static pos_T *
  95. ! var2fpos(varp, lnum, fnum)
  96.       typval_T    *varp;
  97. !     int        lnum;        /* TRUE when $ is last line */
  98.       int        *fnum;        /* set to fnum for '0, 'A, etc. */
  99.   {
  100.       char_u        *name;
  101. --- 16508,16516 ----
  102.    * Returns NULL when there is an error.
  103.    */
  104.       static pos_T *
  105. ! var2fpos(varp, dollar_lnum, fnum)
  106.       typval_T    *varp;
  107. !     int        dollar_lnum;    /* TRUE when $ is last line */
  108.       int        *fnum;        /* set to fnum for '0, 'A, etc. */
  109.   {
  110.       char_u        *name;
  111. ***************
  112. *** 16520,16525 ****
  113. --- 16523,16529 ----
  114.       list_T        *l;
  115.       int        len;
  116.       int        error = FALSE;
  117. +     listitem_T    *li;
  118.   
  119.       l = varp->vval.v_list;
  120.       if (l == NULL)
  121. ***************
  122. *** 16535,16540 ****
  123. --- 16539,16552 ----
  124.       if (error)
  125.           return NULL;
  126.       len = (long)STRLEN(ml_get(pos.lnum));
  127. +     /* We accept "$" for the column number: last column. */
  128. +     li = list_find(l, 1L);
  129. +     if (li != NULL && li->li_tv.v_type == VAR_STRING
  130. +         && li->li_tv.vval.v_string != NULL
  131. +         && STRCMP(li->li_tv.vval.v_string, "$") == 0)
  132. +         pos.col = len + 1;
  133.       /* Accept a position up to the NUL after the line. */
  134.       if (pos.col == 0 || (int)pos.col > len + 1)
  135.           return NULL;    /* invalid column number */
  136. ***************
  137. *** 16567,16573 ****
  138.       pos.coladd = 0;
  139.   #endif
  140.   
  141. !     if (name[0] == 'w' && lnum)
  142.       {
  143.       pos.col = 0;
  144.       if (name[1] == '0')        /* "w0": first visible line */
  145. --- 16579,16585 ----
  146.       pos.coladd = 0;
  147.   #endif
  148.   
  149. !     if (name[0] == 'w' && dollar_lnum)
  150.       {
  151.       pos.col = 0;
  152.       if (name[1] == '0')        /* "w0": first visible line */
  153. ***************
  154. *** 16585,16591 ****
  155.       }
  156.       else if (name[0] == '$')        /* last column or line */
  157.       {
  158. !     if (lnum)
  159.       {
  160.           pos.lnum = curbuf->b_ml.ml_line_count;
  161.           pos.col = 0;
  162. --- 16597,16603 ----
  163.       }
  164.       else if (name[0] == '$')        /* last column or line */
  165.       {
  166. !     if (dollar_lnum)
  167.       {
  168.           pos.lnum = curbuf->b_ml.ml_line_count;
  169.           pos.col = 0;
  170. *** ../vim-7.1.030/src/version.c    Tue Jul 17 14:32:07 2007
  171. --- src/version.c    Tue Jul 17 16:24:54 2007
  172. ***************
  173. *** 668,669 ****
  174. --- 668,671 ----
  175.   {   /* Add new patch number below this line */
  176. + /**/
  177. +     31,
  178.   /**/
  179.  
  180. -- 
  181. CRONE:  Who sent you?
  182. ARTHUR: The Knights Who Say GNU!
  183. CRONE:  Aaaagh!  (she looks around in rear) No!  We have no licenses here.
  184.            "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
  185.  
  186.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  187. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  188. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  189.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  190.