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.4 / 7.4.313 < prev    next >
Encoding:
Internet Message Format  |  2014-05-27  |  10.7 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.313
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.313 (after 7.4.310)
  11. Problem:    Changing the return value of getpos() causes an error. (Jie Zhu)
  12. Solution:   Revert getpos() and add getcurpos().
  13. Files:        src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
  14.         runtime/doc/eval.txt
  15.  
  16.  
  17. *** ../vim-7.4.312/src/eval.c    2014-05-28 18:22:37.876225054 +0200
  18. --- src/eval.c    2014-05-28 20:11:55.364282457 +0200
  19. ***************
  20. *** 560,565 ****
  21. --- 560,566 ----
  22.   static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
  23.   static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
  24.   static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv));
  25. + static void f_getcurpos __ARGS((typval_T *argvars, typval_T *rettv));
  26.   static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
  27.   static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
  28.   static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
  29. ***************
  30. *** 7967,7972 ****
  31. --- 7968,7974 ----
  32.       {"getcmdline",    0, 0, f_getcmdline},
  33.       {"getcmdpos",    0, 0, f_getcmdpos},
  34.       {"getcmdtype",    0, 0, f_getcmdtype},
  35. +     {"getcurpos",    0, 0, f_getcurpos},
  36.       {"getcwd",        0, 0, f_getcwd},
  37.       {"getfontname",    0, 1, f_getfontname},
  38.       {"getfperm",    1, 1, f_getfperm},
  39. ***************
  40. *** 11780,11785 ****
  41. --- 11782,11800 ----
  42.       rettv->vval.v_number = mch_get_pid();
  43.   }
  44.   
  45. + static void getpos_both __ARGS((typval_T *argvars, typval_T *rettv, int getcurpos));
  46. + /*
  47. +  * "getcurpos()" function
  48. +  */
  49. +     static void
  50. + f_getcurpos(argvars, rettv)
  51. +     typval_T    *argvars;
  52. +     typval_T    *rettv;
  53. + {
  54. +     getpos_both(argvars, rettv, TRUE);
  55. + }
  56.   /*
  57.    * "getpos(string)" function
  58.    */
  59. ***************
  60. *** 11788,11793 ****
  61. --- 11803,11817 ----
  62.       typval_T    *argvars;
  63.       typval_T    *rettv;
  64.   {
  65. +     getpos_both(argvars, rettv, FALSE);
  66. + }
  67. +     static void
  68. + getpos_both(argvars, rettv, getcurpos)
  69. +     typval_T    *argvars;
  70. +     typval_T    *rettv;
  71. +     int        getcurpos;
  72. + {
  73.       pos_T    *fp;
  74.       list_T    *l;
  75.       int        fnum = -1;
  76. ***************
  77. *** 11795,11801 ****
  78.       if (rettv_list_alloc(rettv) == OK)
  79.       {
  80.       l = rettv->vval.v_list;
  81. !     fp = var2fpos(&argvars[0], TRUE, &fnum);
  82.       if (fnum != -1)
  83.           list_append_number(l, (varnumber_T)fnum);
  84.       else
  85. --- 11819,11828 ----
  86.       if (rettv_list_alloc(rettv) == OK)
  87.       {
  88.       l = rettv->vval.v_list;
  89. !     if (getcurpos)
  90. !         fp = &curwin->w_cursor;
  91. !     else
  92. !         fp = var2fpos(&argvars[0], TRUE, &fnum);
  93.       if (fnum != -1)
  94.           list_append_number(l, (varnumber_T)fnum);
  95.       else
  96. ***************
  97. *** 11810,11816 ****
  98.                   (fp != NULL) ? (varnumber_T)fp->coladd :
  99.   #endif
  100.                                     (varnumber_T)0);
  101. !     if (fp == &curwin->w_cursor)
  102.           list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
  103.       }
  104.       else
  105. --- 11837,11843 ----
  106.                   (fp != NULL) ? (varnumber_T)fp->coladd :
  107.   #endif
  108.                                     (varnumber_T)0);
  109. !     if (getcurpos)
  110.           list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
  111.       }
  112.       else
  113. *** ../vim-7.4.312/src/testdir/test_eval.in    2014-05-28 14:32:47.160104334 +0200
  114. --- src/testdir/test_eval.in    2014-05-28 20:14:27.048283785 +0200
  115. ***************
  116. *** 190,198 ****
  117.   :$put =v:exception
  118.   :endtry
  119.   :"
  120. ! :$put ='{{{1 setpos/getpos'
  121.   /^012345678
  122. ! 6l:let sp = getpos('.')
  123.   0:call setpos('.', sp)
  124.   jyl:$put
  125.   :"
  126. --- 190,198 ----
  127.   :$put =v:exception
  128.   :endtry
  129.   :"
  130. ! :$put ='{{{1 getcurpos/setpos'
  131.   /^012345678
  132. ! 6l:let sp = getcurpos()
  133.   0:call setpos('.', sp)
  134.   jyl:$put
  135.   :"
  136. *** ../vim-7.4.312/src/testdir/test_eval.ok    2014-05-28 14:32:47.160104334 +0200
  137. --- src/testdir/test_eval.ok    2014-05-28 20:14:43.316283927 +0200
  138. ***************
  139. *** 346,350 ****
  140.   Bar exists: 1
  141.   func Bar exists: 1
  142.   Vim(call):E116: Invalid arguments for function append
  143. ! {{{1 setpos/getpos
  144.   6
  145. --- 346,350 ----
  146.   Bar exists: 1
  147.   func Bar exists: 1
  148.   Vim(call):E116: Invalid arguments for function append
  149. ! {{{1 getcurpos/setpos
  150.   6
  151. *** ../vim-7.4.312/runtime/doc/eval.txt    2014-05-28 18:22:37.872225054 +0200
  152. --- runtime/doc/eval.txt    2014-05-28 20:27:57.092290876 +0200
  153. ***************
  154. *** 1808,1817 ****
  155.   getcmdline()            String    return the current command-line
  156.   getcmdpos()            Number    return cursor position in command-line
  157.   getcmdtype()            String    return the current command-line type
  158.   getcwd()            String    the current working directory
  159.   getfperm( {fname})        String    file permissions of file {fname}
  160.   getfsize( {fname})        Number    size in bytes of file {fname}
  161. - getfontname( [{name}])        String    name of font being used
  162.   getftime( {fname})        Number    last modification time of file
  163.   getftype( {fname})        String    description of type of file {fname}
  164.   getline( {lnum})        String    line {lnum} of current buffer
  165. --- 1808,1818 ----
  166.   getcmdline()            String    return the current command-line
  167.   getcmdpos()            Number    return cursor position in command-line
  168.   getcmdtype()            String    return the current command-line type
  169. + getcurpos()            List    position of the cursor
  170.   getcwd()            String    the current working directory
  171. + getfontname( [{name}])        String    name of font being used
  172.   getfperm( {fname})        String    file permissions of file {fname}
  173.   getfsize( {fname})        Number    size in bytes of file {fname}
  174.   getftime( {fname})        Number    last modification time of file
  175.   getftype( {fname})        String    description of type of file {fname}
  176.   getline( {lnum})        String    line {lnum} of current buffer
  177. ***************
  178. *** 2606,2613 ****
  179.           with two, three or four item:
  180.               [{lnum}, {col}, {off}]
  181.               [{lnum}, {col}, {off}, {curswant}]
  182. !         This is like the return value of |getpos()|, but without the
  183. !         first item.
  184.   
  185.           Does not change the jumplist.
  186.           If {lnum} is greater than the number of lines in the buffer,
  187. --- 2607,2614 ----
  188.           with two, three or four item:
  189.               [{lnum}, {col}, {off}]
  190.               [{lnum}, {col}, {off}, {curswant}]
  191. !         This is like the return value of |getpos()| or |getcurpos|,
  192. !         but without the first item.
  193.   
  194.           Does not change the jumplist.
  195.           If {lnum} is greater than the number of lines in the buffer,
  196. ***************
  197. *** 2617,2622 ****
  198. --- 2618,2625 ----
  199.           the cursor will be positioned at the last character in the
  200.           line.
  201.           If {col} is zero, the cursor will stay in the current column.
  202. +         If {curswant} is given it is used to set the preferred column
  203. +         for vertical movment.  Otherwise {col} is used.
  204.           When 'virtualedit' is used {off} specifies the offset in
  205.           screen columns from the start of the character.  E.g., a
  206.           position within a <Tab> or after the last character.
  207. ***************
  208. *** 3339,3344 ****
  209. --- 3347,3363 ----
  210.           Returns an empty string otherwise.
  211.           Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  212.   
  213. +                             *getcurpos()*
  214. + getcurpos()    Get the position of the cursor.  This is like getpos('.'), but
  215. +         includes an extra item in the list:
  216. +             [bufnum, lnum, col, off, curswant]
  217. +         The "curswant" number is the preferred column when moving the
  218. +         cursor vertically.
  219. +         This can be used to save and restore the cursor position: >
  220. +             let save_cursor = getcurpos()
  221. +             MoveTheCursorAround
  222. +             call setpos('.', save_cursor)
  223.                               *getcwd()*
  224.   getcwd()    The result is a String, which is the name of the current
  225.           working directory.
  226. ***************
  227. *** 4493,4502 ****
  228.   
  229.                               *getpos()*
  230.   getpos({expr})    Get the position for {expr}.  For possible values of {expr}
  231. !         see |line()|.
  232. !         The result is a |List| with four or five numbers:
  233.               [bufnum, lnum, col, off]
  234. -             [bufnum, lnum, col, off, curswant]
  235.           "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  236.           is the buffer number of the mark.
  237.           "lnum" and "col" are the position in the buffer.  The first
  238. --- 4517,4526 ----
  239.   
  240.                               *getpos()*
  241.   getpos({expr})    Get the position for {expr}.  For possible values of {expr}
  242. !         see |line()|.  For getting the cursor position see
  243. !         |getcurpos()|.
  244. !         The result is a |List| with four numbers:
  245.               [bufnum, lnum, col, off]
  246.           "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  247.           is the buffer number of the mark.
  248.           "lnum" and "col" are the position in the buffer.  The first
  249. ***************
  250. *** 4505,4520 ****
  251.           it is the offset in screen columns from the start of the
  252.           character.  E.g., a position within a <Tab> or after the last
  253.           character.
  254. -         The "curswant" number is only added for getpos('.'), it is the
  255. -         preferred column when moving the cursor vertically.
  256.           Note that for '< and '> Visual mode matters: when it is "V"
  257.           (visual line mode) the column of '< is zero and the column of
  258.           '> is a large number.
  259. !         This can be used to save and restore the cursor position: >
  260. !             let save_cursor = getpos(".")
  261. !             MoveTheCursorAround
  262. !             call setpos('.', save_cursor)
  263. ! <        Also see |setpos()|.
  264.   
  265.   or({expr}, {expr})                    *or()*
  266.           Bitwise OR on the two arguments.  The arguments are converted
  267. --- 4529,4542 ----
  268.           it is the offset in screen columns from the start of the
  269.           character.  E.g., a position within a <Tab> or after the last
  270.           character.
  271.           Note that for '< and '> Visual mode matters: when it is "V"
  272.           (visual line mode) the column of '< is zero and the column of
  273.           '> is a large number.
  274. !         This can be used to save and restore the position of a mark: >
  275. !             let save_a_mark = getpos("'a")
  276. !             ...
  277. !             call setpos(''a', save_a_mark
  278. ! <        Also see |getcurpos()| and |setpos()|.
  279.   
  280.   or({expr}, {expr})                    *or()*
  281.           Bitwise OR on the two arguments.  The arguments are converted
  282. ***************
  283. *** 5347,5353 ****
  284.           Returns 0 when the position could be set, -1 otherwise.
  285.           An error message is given if {expr} is invalid.
  286.   
  287. !         Also see |getpos()|
  288.   
  289.           This does not restore the preferred column for moving
  290.           vertically; if you set the cursor position with this, |j| and
  291. --- 5369,5375 ----
  292.           Returns 0 when the position could be set, -1 otherwise.
  293.           An error message is given if {expr} is invalid.
  294.   
  295. !         Also see |getpos()| and |getcurpos()|.
  296.   
  297.           This does not restore the preferred column for moving
  298.           vertically; if you set the cursor position with this, |j| and
  299. *** ../vim-7.4.312/src/version.c    2014-05-28 18:22:37.880225054 +0200
  300. --- src/version.c    2014-05-28 20:15:52.164284530 +0200
  301. ***************
  302. *** 736,737 ****
  303. --- 736,739 ----
  304.   {   /* Add new patch number below this line */
  305. + /**/
  306. +     313,
  307.   /**/
  308.  
  309. -- 
  310. hundred-and-one symptoms of being an internet addict:
  311. 225. You sign up for free subscriptions for all the computer magazines
  312.  
  313.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  314. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  315. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  316.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  317.