summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.313
blob: 39468e0ad112892863188ec6de0a144c8835bc37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
To: vim_dev@googlegroups.com
Subject: Patch 7.4.313
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.313 (after 7.4.310)
Problem:    Changing the return value of getpos() causes an error. (Jie Zhu)
Solution:   Revert getpos() and add getcurpos().
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
	    runtime/doc/eval.txt


*** ../vim-7.4.312/src/eval.c	2014-05-28 18:22:37.876225054 +0200
--- src/eval.c	2014-05-28 20:11:55.364282457 +0200
***************
*** 560,565 ****
--- 560,566 ----
  static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv));
+ static void f_getcurpos __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
***************
*** 7967,7972 ****
--- 7968,7974 ----
      {"getcmdline",	0, 0, f_getcmdline},
      {"getcmdpos",	0, 0, f_getcmdpos},
      {"getcmdtype",	0, 0, f_getcmdtype},
+     {"getcurpos",	0, 0, f_getcurpos},
      {"getcwd",		0, 0, f_getcwd},
      {"getfontname",	0, 1, f_getfontname},
      {"getfperm",	1, 1, f_getfperm},
***************
*** 11780,11785 ****
--- 11782,11800 ----
      rettv->vval.v_number = mch_get_pid();
  }
  
+ static void getpos_both __ARGS((typval_T *argvars, typval_T *rettv, int getcurpos));
+ 
+ /*
+  * "getcurpos()" function
+  */
+     static void
+ f_getcurpos(argvars, rettv)
+     typval_T	*argvars;
+     typval_T	*rettv;
+ {
+     getpos_both(argvars, rettv, TRUE);
+ }
+ 
  /*
   * "getpos(string)" function
   */
***************
*** 11788,11793 ****
--- 11803,11817 ----
      typval_T	*argvars;
      typval_T	*rettv;
  {
+     getpos_both(argvars, rettv, FALSE);
+ }
+ 
+     static void
+ getpos_both(argvars, rettv, getcurpos)
+     typval_T	*argvars;
+     typval_T	*rettv;
+     int		getcurpos;
+ {
      pos_T	*fp;
      list_T	*l;
      int		fnum = -1;
***************
*** 11795,11801 ****
      if (rettv_list_alloc(rettv) == OK)
      {
  	l = rettv->vval.v_list;
! 	fp = var2fpos(&argvars[0], TRUE, &fnum);
  	if (fnum != -1)
  	    list_append_number(l, (varnumber_T)fnum);
  	else
--- 11819,11828 ----
      if (rettv_list_alloc(rettv) == OK)
      {
  	l = rettv->vval.v_list;
! 	if (getcurpos)
! 	    fp = &curwin->w_cursor;
! 	else
! 	    fp = var2fpos(&argvars[0], TRUE, &fnum);
  	if (fnum != -1)
  	    list_append_number(l, (varnumber_T)fnum);
  	else
***************
*** 11810,11816 ****
  				(fp != NULL) ? (varnumber_T)fp->coladd :
  #endif
  							      (varnumber_T)0);
! 	if (fp == &curwin->w_cursor)
  	    list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
      }
      else
--- 11837,11843 ----
  				(fp != NULL) ? (varnumber_T)fp->coladd :
  #endif
  							      (varnumber_T)0);
! 	if (getcurpos)
  	    list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
      }
      else
*** ../vim-7.4.312/src/testdir/test_eval.in	2014-05-28 14:32:47.160104334 +0200
--- src/testdir/test_eval.in	2014-05-28 20:14:27.048283785 +0200
***************
*** 190,198 ****
  :$put =v:exception
  :endtry
  :"
! :$put ='{{{1 setpos/getpos'
  /^012345678
! 6l:let sp = getpos('.')
  0:call setpos('.', sp)
  jyl:$put
  :"
--- 190,198 ----
  :$put =v:exception
  :endtry
  :"
! :$put ='{{{1 getcurpos/setpos'
  /^012345678
! 6l:let sp = getcurpos()
  0:call setpos('.', sp)
  jyl:$put
  :"
*** ../vim-7.4.312/src/testdir/test_eval.ok	2014-05-28 14:32:47.160104334 +0200
--- src/testdir/test_eval.ok	2014-05-28 20:14:43.316283927 +0200
***************
*** 346,350 ****
  Bar exists: 1
  func Bar exists: 1
  Vim(call):E116: Invalid arguments for function append
! {{{1 setpos/getpos
  6
--- 346,350 ----
  Bar exists: 1
  func Bar exists: 1
  Vim(call):E116: Invalid arguments for function append
! {{{1 getcurpos/setpos
  6
*** ../vim-7.4.312/runtime/doc/eval.txt	2014-05-28 18:22:37.872225054 +0200
--- runtime/doc/eval.txt	2014-05-28 20:27:57.092290876 +0200
***************
*** 1808,1817 ****
  getcmdline()			String	return the current command-line
  getcmdpos()			Number	return cursor position in command-line
  getcmdtype()			String	return the current command-line type
  getcwd()			String	the current working directory
  getfperm( {fname})		String	file permissions of file {fname}
  getfsize( {fname})		Number	size in bytes of file {fname}
- getfontname( [{name}])		String	name of font being used
  getftime( {fname})		Number	last modification time of file
  getftype( {fname})		String	description of type of file {fname}
  getline( {lnum})		String	line {lnum} of current buffer
--- 1808,1818 ----
  getcmdline()			String	return the current command-line
  getcmdpos()			Number	return cursor position in command-line
  getcmdtype()			String	return the current command-line type
+ getcurpos()			List	position of the cursor
  getcwd()			String	the current working directory
+ getfontname( [{name}])		String	name of font being used
  getfperm( {fname})		String	file permissions of file {fname}
  getfsize( {fname})		Number	size in bytes of file {fname}
  getftime( {fname})		Number	last modification time of file
  getftype( {fname})		String	description of type of file {fname}
  getline( {lnum})		String	line {lnum} of current buffer
***************
*** 2606,2613 ****
  		with two, three or four item:
  			[{lnum}, {col}, {off}]
  			[{lnum}, {col}, {off}, {curswant}]
! 		This is like the return value of |getpos()|, but without the
! 		first item.
  
  		Does not change the jumplist.
  		If {lnum} is greater than the number of lines in the buffer,
--- 2607,2614 ----
  		with two, three or four item:
  			[{lnum}, {col}, {off}]
  			[{lnum}, {col}, {off}, {curswant}]
! 		This is like the return value of |getpos()| or |getcurpos|,
! 		but without the first item.
  
  		Does not change the jumplist.
  		If {lnum} is greater than the number of lines in the buffer,
***************
*** 2617,2622 ****
--- 2618,2625 ----
  		the cursor will be positioned at the last character in the
  		line.
  		If {col} is zero, the cursor will stay in the current column.
+ 		If {curswant} is given it is used to set the preferred column
+ 		for vertical movment.  Otherwise {col} is used.
  		When 'virtualedit' is used {off} specifies the offset in
  		screen columns from the start of the character.  E.g., a
  		position within a <Tab> or after the last character.
***************
*** 3339,3344 ****
--- 3347,3363 ----
  		Returns an empty string otherwise.
  		Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  
+ 							*getcurpos()*
+ getcurpos()	Get the position of the cursor.  This is like getpos('.'), but
+ 		includes an extra item in the list:
+ 		    [bufnum, lnum, col, off, curswant]
+ 		The "curswant" number is the preferred column when moving the
+ 		cursor vertically.
+ 		This can be used to save and restore the cursor position: >
+ 			let save_cursor = getcurpos()
+ 			MoveTheCursorAround
+ 			call setpos('.', save_cursor)
+ 
  							*getcwd()*
  getcwd()	The result is a String, which is the name of the current
  		working directory.
***************
*** 4493,4502 ****
  
  							*getpos()*
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
! 		see |line()|.
! 		The result is a |List| with four or five numbers:
  		    [bufnum, lnum, col, off]
- 		    [bufnum, lnum, col, off, curswant]
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
  		is the buffer number of the mark.
  		"lnum" and "col" are the position in the buffer.  The first
--- 4517,4526 ----
  
  							*getpos()*
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
! 		see |line()|.  For getting the cursor position see
! 		|getcurpos()|.
! 		The result is a |List| with four numbers:
  		    [bufnum, lnum, col, off]
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
  		is the buffer number of the mark.
  		"lnum" and "col" are the position in the buffer.  The first
***************
*** 4505,4520 ****
  		it is the offset in screen columns from the start of the
  		character.  E.g., a position within a <Tab> or after the last
  		character.
- 		The "curswant" number is only added for getpos('.'), it is the
- 		preferred column when moving the cursor vertically.
  		Note that for '< and '> Visual mode matters: when it is "V"
  		(visual line mode) the column of '< is zero and the column of
  		'> is a large number.
! 		This can be used to save and restore the cursor position: >
! 			let save_cursor = getpos(".")
! 			MoveTheCursorAround
! 			call setpos('.', save_cursor)
! <		Also see |setpos()|.
  
  or({expr}, {expr})					*or()*
  		Bitwise OR on the two arguments.  The arguments are converted
--- 4529,4542 ----
  		it is the offset in screen columns from the start of the
  		character.  E.g., a position within a <Tab> or after the last
  		character.
  		Note that for '< and '> Visual mode matters: when it is "V"
  		(visual line mode) the column of '< is zero and the column of
  		'> is a large number.
! 		This can be used to save and restore the position of a mark: >
! 			let save_a_mark = getpos("'a")
! 			...
! 			call setpos(''a', save_a_mark
! <		Also see |getcurpos()| and |setpos()|.
  
  or({expr}, {expr})					*or()*
  		Bitwise OR on the two arguments.  The arguments are converted
***************
*** 5347,5353 ****
  		Returns 0 when the position could be set, -1 otherwise.
  		An error message is given if {expr} is invalid.
  
! 		Also see |getpos()|
  
  		This does not restore the preferred column for moving
  		vertically; if you set the cursor position with this, |j| and
--- 5369,5375 ----
  		Returns 0 when the position could be set, -1 otherwise.
  		An error message is given if {expr} is invalid.
  
! 		Also see |getpos()| and |getcurpos()|.
  
  		This does not restore the preferred column for moving
  		vertically; if you set the cursor position with this, |j| and
*** ../vim-7.4.312/src/version.c	2014-05-28 18:22:37.880225054 +0200
--- src/version.c	2014-05-28 20:15:52.164284530 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     313,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
225. You sign up for free subscriptions for all the computer magazines

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///