|
|
22c937 |
To: vim_dev@googlegroups.com
|
|
|
22c937 |
Subject: Patch 7.4.310
|
|
|
22c937 |
Fcc: outbox
|
|
|
22c937 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
22c937 |
Mime-Version: 1.0
|
|
|
22c937 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c937 |
Content-Transfer-Encoding: 8bit
|
|
|
22c937 |
------------
|
|
|
22c937 |
|
|
|
22c937 |
Patch 7.4.310
|
|
|
22c937 |
Problem: getpos()/setpos() don't include curswant.
|
|
|
22c937 |
Solution: Add a fifth number when getting/setting the cursor.
|
|
|
22c937 |
Files: src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
|
|
|
22c937 |
runtime/doc/eval.txt
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.309/src/eval.c 2014-05-22 18:59:54.506169240 +0200
|
|
|
22c937 |
--- src/eval.c 2014-05-28 14:23:37.608099523 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 764,770 ****
|
|
|
22c937 |
static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
|
|
|
22c937 |
! static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
|
|
|
22c937 |
static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
|
|
|
22c937 |
static int get_env_len __ARGS((char_u **arg));
|
|
|
22c937 |
static int get_id_len __ARGS((char_u **arg));
|
|
|
22c937 |
--- 764,770 ----
|
|
|
22c937 |
static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
|
|
|
22c937 |
! static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp));
|
|
|
22c937 |
static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
|
|
|
22c937 |
static int get_env_len __ARGS((char_u **arg));
|
|
|
22c937 |
static int get_id_len __ARGS((char_u **arg));
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 9799,9812 ****
|
|
|
22c937 |
if (argvars[1].v_type == VAR_UNKNOWN)
|
|
|
22c937 |
{
|
|
|
22c937 |
pos_T pos;
|
|
|
22c937 |
|
|
|
22c937 |
! if (list2fpos(argvars, &pos, NULL) == FAIL)
|
|
|
22c937 |
return;
|
|
|
22c937 |
line = pos.lnum;
|
|
|
22c937 |
col = pos.col;
|
|
|
22c937 |
#ifdef FEAT_VIRTUALEDIT
|
|
|
22c937 |
coladd = pos.coladd;
|
|
|
22c937 |
#endif
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
{
|
|
|
22c937 |
--- 9799,9815 ----
|
|
|
22c937 |
if (argvars[1].v_type == VAR_UNKNOWN)
|
|
|
22c937 |
{
|
|
|
22c937 |
pos_T pos;
|
|
|
22c937 |
+ colnr_T curswant = -1;
|
|
|
22c937 |
|
|
|
22c937 |
! if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL)
|
|
|
22c937 |
return;
|
|
|
22c937 |
line = pos.lnum;
|
|
|
22c937 |
col = pos.col;
|
|
|
22c937 |
#ifdef FEAT_VIRTUALEDIT
|
|
|
22c937 |
coladd = pos.coladd;
|
|
|
22c937 |
#endif
|
|
|
22c937 |
+ if (curswant >= 0)
|
|
|
22c937 |
+ curwin->w_curswant = curswant - 1;
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
{
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 11770,11775 ****
|
|
|
22c937 |
--- 11773,11780 ----
|
|
|
22c937 |
(fp != NULL) ? (varnumber_T)fp->coladd :
|
|
|
22c937 |
#endif
|
|
|
22c937 |
(varnumber_T)0);
|
|
|
22c937 |
+ if (fp == &curwin->w_cursor)
|
|
|
22c937 |
+ list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
rettv->vval.v_number = FALSE;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 16751,16762 ****
|
|
|
22c937 |
pos_T pos;
|
|
|
22c937 |
int fnum;
|
|
|
22c937 |
char_u *name;
|
|
|
22c937 |
|
|
|
22c937 |
rettv->vval.v_number = -1;
|
|
|
22c937 |
name = get_tv_string_chk(argvars);
|
|
|
22c937 |
if (name != NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
! if (list2fpos(&argvars[1], &pos, &fnum) == OK)
|
|
|
22c937 |
{
|
|
|
22c937 |
if (--pos.col < 0)
|
|
|
22c937 |
pos.col = 0;
|
|
|
22c937 |
--- 16756,16768 ----
|
|
|
22c937 |
pos_T pos;
|
|
|
22c937 |
int fnum;
|
|
|
22c937 |
char_u *name;
|
|
|
22c937 |
+ colnr_T curswant = -1;
|
|
|
22c937 |
|
|
|
22c937 |
rettv->vval.v_number = -1;
|
|
|
22c937 |
name = get_tv_string_chk(argvars);
|
|
|
22c937 |
if (name != NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
! if (list2fpos(&argvars[1], &pos, &fnum, &curswant) == OK)
|
|
|
22c937 |
{
|
|
|
22c937 |
if (--pos.col < 0)
|
|
|
22c937 |
pos.col = 0;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 16766,16771 ****
|
|
|
22c937 |
--- 16772,16779 ----
|
|
|
22c937 |
if (fnum == curbuf->b_fnum)
|
|
|
22c937 |
{
|
|
|
22c937 |
curwin->w_cursor = pos;
|
|
|
22c937 |
+ if (curswant >= 0)
|
|
|
22c937 |
+ curwin->w_curswant = curswant - 1;
|
|
|
22c937 |
check_cursor();
|
|
|
22c937 |
rettv->vval.v_number = 0;
|
|
|
22c937 |
}
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 19532,19552 ****
|
|
|
22c937 |
* validity.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static int
|
|
|
22c937 |
! list2fpos(arg, posp, fnump)
|
|
|
22c937 |
typval_T *arg;
|
|
|
22c937 |
pos_T *posp;
|
|
|
22c937 |
int *fnump;
|
|
|
22c937 |
{
|
|
|
22c937 |
list_T *l = arg->vval.v_list;
|
|
|
22c937 |
long i = 0;
|
|
|
22c937 |
long n;
|
|
|
22c937 |
|
|
|
22c937 |
! /* List must be: [fnum, lnum, col, coladd], where "fnum" is only there
|
|
|
22c937 |
! * when "fnump" isn't NULL and "coladd" is optional. */
|
|
|
22c937 |
if (arg->v_type != VAR_LIST
|
|
|
22c937 |
|| l == NULL
|
|
|
22c937 |
|| l->lv_len < (fnump == NULL ? 2 : 3)
|
|
|
22c937 |
! || l->lv_len > (fnump == NULL ? 3 : 4))
|
|
|
22c937 |
return FAIL;
|
|
|
22c937 |
|
|
|
22c937 |
if (fnump != NULL)
|
|
|
22c937 |
--- 19540,19561 ----
|
|
|
22c937 |
* validity.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static int
|
|
|
22c937 |
! list2fpos(arg, posp, fnump, curswantp)
|
|
|
22c937 |
typval_T *arg;
|
|
|
22c937 |
pos_T *posp;
|
|
|
22c937 |
int *fnump;
|
|
|
22c937 |
+ colnr_T *curswantp;
|
|
|
22c937 |
{
|
|
|
22c937 |
list_T *l = arg->vval.v_list;
|
|
|
22c937 |
long i = 0;
|
|
|
22c937 |
long n;
|
|
|
22c937 |
|
|
|
22c937 |
! /* List must be: [fnum, lnum, col, coladd, curswant], where "fnum" is only
|
|
|
22c937 |
! * there when "fnump" isn't NULL; "coladd" and "curswant" are optional. */
|
|
|
22c937 |
if (arg->v_type != VAR_LIST
|
|
|
22c937 |
|| l == NULL
|
|
|
22c937 |
|| l->lv_len < (fnump == NULL ? 2 : 3)
|
|
|
22c937 |
! || l->lv_len > (fnump == NULL ? 4 : 5))
|
|
|
22c937 |
return FAIL;
|
|
|
22c937 |
|
|
|
22c937 |
if (fnump != NULL)
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 19570,19582 ****
|
|
|
22c937 |
posp->col = n;
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef FEAT_VIRTUALEDIT
|
|
|
22c937 |
! n = list_find_nr(l, i, NULL);
|
|
|
22c937 |
if (n < 0)
|
|
|
22c937 |
posp->coladd = 0;
|
|
|
22c937 |
else
|
|
|
22c937 |
posp->coladd = n;
|
|
|
22c937 |
#endif
|
|
|
22c937 |
|
|
|
22c937 |
return OK;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
--- 19579,19594 ----
|
|
|
22c937 |
posp->col = n;
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef FEAT_VIRTUALEDIT
|
|
|
22c937 |
! n = list_find_nr(l, i, NULL); /* off */
|
|
|
22c937 |
if (n < 0)
|
|
|
22c937 |
posp->coladd = 0;
|
|
|
22c937 |
else
|
|
|
22c937 |
posp->coladd = n;
|
|
|
22c937 |
#endif
|
|
|
22c937 |
|
|
|
22c937 |
+ if (curswantp != NULL)
|
|
|
22c937 |
+ *curswantp = list_find_nr(l, i + 1, NULL); /* curswant */
|
|
|
22c937 |
+
|
|
|
22c937 |
return OK;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.309/src/testdir/test_eval.in 2014-04-29 17:41:18.351689927 +0200
|
|
|
22c937 |
--- src/testdir/test_eval.in 2014-05-28 14:22:31.780098947 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 190,198 ****
|
|
|
22c937 |
--- 190,207 ----
|
|
|
22c937 |
:$put =v:exception
|
|
|
22c937 |
:endtry
|
|
|
22c937 |
:"
|
|
|
22c937 |
+ :$put ='{{{1 setpos/getpos'
|
|
|
22c937 |
+ /^012345678
|
|
|
22c937 |
+ 6l:let sp = getpos('.')
|
|
|
22c937 |
+ 0:call setpos('.', sp)
|
|
|
22c937 |
+ jyl:$put
|
|
|
22c937 |
+ :"
|
|
|
22c937 |
:/^start:/+1,$wq! test.out
|
|
|
22c937 |
:" vim: et ts=4 isk-=\: fmr=???,???
|
|
|
22c937 |
:call getchar()
|
|
|
22c937 |
ENDTEST
|
|
|
22c937 |
|
|
|
22c937 |
+ 012345678
|
|
|
22c937 |
+ 012345678
|
|
|
22c937 |
+
|
|
|
22c937 |
start:
|
|
|
22c937 |
*** ../vim-7.4.309/src/testdir/test_eval.ok 2014-04-29 17:41:18.351689927 +0200
|
|
|
22c937 |
--- src/testdir/test_eval.ok 2014-05-28 14:19:31.836097372 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 346,348 ****
|
|
|
22c937 |
--- 346,350 ----
|
|
|
22c937 |
Bar exists: 1
|
|
|
22c937 |
func Bar exists: 1
|
|
|
22c937 |
Vim(call):E116: Invalid arguments for function append
|
|
|
22c937 |
+ {{{1 setpos/getpos
|
|
|
22c937 |
+ 6
|
|
|
22c937 |
*** ../vim-7.4.309/runtime/doc/eval.txt 2014-05-07 18:35:25.661216052 +0200
|
|
|
22c937 |
--- runtime/doc/eval.txt 2014-05-28 14:04:40.928089573 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 2587,2595 ****
|
|
|
22c937 |
cursor({list})
|
|
|
22c937 |
Positions the cursor at the column (byte count) {col} in the
|
|
|
22c937 |
line {lnum}. The first column is one.
|
|
|
22c937 |
When there is one argument {list} this is used as a |List|
|
|
|
22c937 |
! with two or three items {lnum}, {col} and {off}. This is like
|
|
|
22c937 |
! the return value of |getpos()|, but without the first item.
|
|
|
22c937 |
Does not change the jumplist.
|
|
|
22c937 |
If {lnum} is greater than the number of lines in the buffer,
|
|
|
22c937 |
the cursor will be positioned at the last line in the buffer.
|
|
|
22c937 |
--- 2587,2600 ----
|
|
|
22c937 |
cursor({list})
|
|
|
22c937 |
Positions the cursor at the column (byte count) {col} in the
|
|
|
22c937 |
line {lnum}. The first column is one.
|
|
|
22c937 |
+
|
|
|
22c937 |
When there is one argument {list} this is used as a |List|
|
|
|
22c937 |
! with two, three or four item:
|
|
|
22c937 |
! [{lnum}, {col}, {off}]
|
|
|
22c937 |
! [{lnum}, {col}, {off}, {curswant}]
|
|
|
22c937 |
! This is like the return value of |getpos()|, but without the
|
|
|
22c937 |
! first item.
|
|
|
22c937 |
!
|
|
|
22c937 |
Does not change the jumplist.
|
|
|
22c937 |
If {lnum} is greater than the number of lines in the buffer,
|
|
|
22c937 |
the cursor will be positioned at the last line in the buffer.
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 4475,4482 ****
|
|
|
22c937 |
*getpos()*
|
|
|
22c937 |
getpos({expr}) Get the position for {expr}. For possible values of {expr}
|
|
|
22c937 |
see |line()|.
|
|
|
22c937 |
! The result is a |List| with four numbers:
|
|
|
22c937 |
[bufnum, lnum, col, off]
|
|
|
22c937 |
"bufnum" is zero, unless a mark like '0 or 'A is used, then it
|
|
|
22c937 |
is the buffer number of the mark.
|
|
|
22c937 |
"lnum" and "col" are the position in the buffer. The first
|
|
|
22c937 |
--- 4490,4498 ----
|
|
|
22c937 |
*getpos()*
|
|
|
22c937 |
getpos({expr}) Get the position for {expr}. For possible values of {expr}
|
|
|
22c937 |
see |line()|.
|
|
|
22c937 |
! The result is a |List| with four or five numbers:
|
|
|
22c937 |
[bufnum, lnum, col, off]
|
|
|
22c937 |
+ [bufnum, lnum, col, off, curswant]
|
|
|
22c937 |
"bufnum" is zero, unless a mark like '0 or 'A is used, then it
|
|
|
22c937 |
is the buffer number of the mark.
|
|
|
22c937 |
"lnum" and "col" are the position in the buffer. The first
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 4485,4490 ****
|
|
|
22c937 |
--- 4501,4511 ----
|
|
|
22c937 |
it is the offset in screen columns from the start of the
|
|
|
22c937 |
character. E.g., a position within a <Tab> or after the last
|
|
|
22c937 |
character.
|
|
|
22c937 |
+ The "curswant" number is only added for getpos('.'), it is the
|
|
|
22c937 |
+ preferred column when moving the cursor vertically.
|
|
|
22c937 |
+ Note that for '< and '> Visual mode matters: when it is "V"
|
|
|
22c937 |
+ (visual line mode) the column of '< is zero and the column of
|
|
|
22c937 |
+ '> is a large number.
|
|
|
22c937 |
This can be used to save and restore the cursor position: >
|
|
|
22c937 |
let save_cursor = getpos(".")
|
|
|
22c937 |
MoveTheCursorAround
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 5289,5296 ****
|
|
|
22c937 |
. the cursor
|
|
|
22c937 |
'x mark x
|
|
|
22c937 |
|
|
|
22c937 |
! {list} must be a |List| with four numbers:
|
|
|
22c937 |
[bufnum, lnum, col, off]
|
|
|
22c937 |
|
|
|
22c937 |
"bufnum" is the buffer number. Zero can be used for the
|
|
|
22c937 |
current buffer. Setting the cursor is only possible for
|
|
|
22c937 |
--- 5310,5318 ----
|
|
|
22c937 |
. the cursor
|
|
|
22c937 |
'x mark x
|
|
|
22c937 |
|
|
|
22c937 |
! {list} must be a |List| with four or five numbers:
|
|
|
22c937 |
[bufnum, lnum, col, off]
|
|
|
22c937 |
+ [bufnum, lnum, col, off, curswant]
|
|
|
22c937 |
|
|
|
22c937 |
"bufnum" is the buffer number. Zero can be used for the
|
|
|
22c937 |
current buffer. Setting the cursor is only possible for
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 5308,5320 ****
|
|
|
22c937 |
character. E.g., a position within a <Tab> or after the last
|
|
|
22c937 |
character.
|
|
|
22c937 |
|
|
|
22c937 |
Returns 0 when the position could be set, -1 otherwise.
|
|
|
22c937 |
An error message is given if {expr} is invalid.
|
|
|
22c937 |
|
|
|
22c937 |
Also see |getpos()|
|
|
|
22c937 |
|
|
|
22c937 |
This does not restore the preferred column for moving
|
|
|
22c937 |
! vertically. See |winrestview()| for that.
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
setqflist({list} [, {action}]) *setqflist()*
|
|
|
22c937 |
--- 5330,5355 ----
|
|
|
22c937 |
character. E.g., a position within a <Tab> or after the last
|
|
|
22c937 |
character.
|
|
|
22c937 |
|
|
|
22c937 |
+ The "curswant" number is only used when setting the cursor
|
|
|
22c937 |
+ position. It sets the preferred column for when moving the
|
|
|
22c937 |
+ cursor vertically. When the "curswant" number is missing the
|
|
|
22c937 |
+ preferred column is not set. When it is present and setting a
|
|
|
22c937 |
+ mark position it is not used.
|
|
|
22c937 |
+
|
|
|
22c937 |
+ Note that for '< and '> changing the line number may result in
|
|
|
22c937 |
+ the marks to be effectively be swapped, so that '< is always
|
|
|
22c937 |
+ before '>.
|
|
|
22c937 |
+
|
|
|
22c937 |
Returns 0 when the position could be set, -1 otherwise.
|
|
|
22c937 |
An error message is given if {expr} is invalid.
|
|
|
22c937 |
|
|
|
22c937 |
Also see |getpos()|
|
|
|
22c937 |
|
|
|
22c937 |
This does not restore the preferred column for moving
|
|
|
22c937 |
! vertically; if you set the cursor position with this, |j| and
|
|
|
22c937 |
! |k| motions will jump to previous columns! Use |cursor()| to
|
|
|
22c937 |
! also set the preferred column. Also see the "curswant" key in
|
|
|
22c937 |
! |winrestview()|.
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
setqflist({list} [, {action}]) *setqflist()*
|
|
|
22c937 |
*** ../vim-7.4.309/src/version.c 2014-05-28 13:42:59.884078184 +0200
|
|
|
22c937 |
--- src/version.c 2014-05-28 14:27:20.132101471 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 736,737 ****
|
|
|
22c937 |
--- 736,739 ----
|
|
|
22c937 |
{ /* Add new patch number below this line */
|
|
|
22c937 |
+ /**/
|
|
|
22c937 |
+ 310,
|
|
|
22c937 |
/**/
|
|
|
22c937 |
|
|
|
22c937 |
--
|
|
|
22c937 |
hundred-and-one symptoms of being an internet addict:
|
|
|
22c937 |
218. Your spouse hands you a gift wrapped magnet with your PC's name
|
|
|
22c937 |
on it and you accuse him or her of genocide.
|
|
|
22c937 |
|
|
|
22c937 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
22c937 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
22c937 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
22c937 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|