]>
Commit | Line | Data |
---|---|---|
d02ad552 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.190 | |
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 6.2.190 | |
11 | Problem: When editing a compressed files, marks are lost. | |
12 | Solution: Add the ":lockmarks" modifier and use it in the gzip plugin. | |
13 | Make exists() also check for command modifiers, so that the | |
14 | existence of ":lockmarks" can be checked for. | |
15 | Also add ":keepmarks" to avoid that marks are deleted when | |
16 | filtering text. | |
17 | When deleting lines put marks 'A - 'Z and '0 - '9 at the first | |
18 | deleted line instead of clearing the mark. They were kept in the | |
19 | viminfo file anyway. | |
20 | Avoid that the gzip plugin puts deleted text in registers. | |
21 | Files: runtime/doc/motion.txt, runtime/plugin/gzip.vim, src/ex_cmds.c, | |
22 | src/ex_docmd.c, src/mark.c, src/structs.h | |
23 | ||
24 | ||
25 | *** ../vim-6.2.189/runtime/doc/motion.txt Sun Jun 1 12:20:33 2003 | |
26 | --- runtime/doc/motion.txt Sat Jan 17 16:37:22 2004 | |
27 | *************** | |
28 | *** 1,4 **** | |
29 | ! *motion.txt* For Vim version 6.2. Last change: 2003 May 27 | |
30 | ||
31 | ||
32 | VIM REFERENCE MANUAL by Bram Moolenaar | |
33 | --- 1,4 ---- | |
34 | ! *motion.txt* For Vim version 6.2. Last change: 2004 Jan 17 | |
35 | ||
36 | ||
37 | VIM REFERENCE MANUAL by Bram Moolenaar | |
38 | *************** | |
39 | *** 700,705 **** | |
40 | --- 706,716 ---- | |
41 | Lowercase marks 'a to 'z are remembered as long as the file remains in the | |
42 | buffer list. If you remove the file from the buffer list, all its marks are | |
43 | lost. If you delete a line that contains a mark, that mark is erased. | |
44 | + | |
45 | + To delete a mark: Create a new line, position the mark there, delete the line. | |
46 | + E.g.: "o<Esc>mxdd". This does change the file though. Using "u" won't work, | |
47 | + it also restores marks. | |
48 | + | |
49 | Lowercase marks can be used in combination with operators. For example: "d't" | |
50 | deletes the lines from the cursor position to mark 't'. Hint: Use mark 't' for | |
51 | Top, 'b' for Bottom, etc.. Lowercase marks are restored when using undo and | |
52 | *************** | |
53 | *** 811,816 **** | |
54 | --- 822,868 ---- | |
55 | [` [count] times to lowercase mark before the cursor. | |
56 | {not in Vi} | |
57 | ||
58 | + | |
59 | + :loc[kmarks] {command} *:loc* *:lockmarks* | |
60 | + Execute {command} without adjusting marks. This is | |
61 | + useful when changing text in a way that the line count | |
62 | + will be the same when the change has completed. | |
63 | + WARNING: When the line count does change, marks below | |
64 | + the change will keep their line number, thus move to | |
65 | + another text line. | |
66 | + These items will not be adjusted for deleted/inserted | |
67 | + lines: | |
68 | + - lower case letter marks 'a - 'z | |
69 | + - upper case letter marks 'A - 'Z | |
70 | + - numbered marks '0 - '9 | |
71 | + - last insert position '^ | |
72 | + - last change position '. | |
73 | + - the Visual area '< and '> | |
74 | + - line numbers in placed signs | |
75 | + - line numbers in quickfix positions | |
76 | + - positions in the |jumplist| | |
77 | + - positions in the |tagstack| | |
78 | + These items will still be adjusted: | |
79 | + - previous context mark '' | |
80 | + - the cursor position | |
81 | + - the view of a window on a buffer | |
82 | + - folds | |
83 | + - diffs | |
84 | + | |
85 | + :kee[pmarks] {command} *:kee* *:keepmarks* | |
86 | + Currently only has effect for the filter command | |
87 | + |:range!|: | |
88 | + - When the number of lines after filtering is equal to | |
89 | + or larger than before, all marks are kept at the | |
90 | + same line number. | |
91 | + - When the number of lines decreases, the marks in the | |
92 | + ilnes that disappeared are deleted. | |
93 | + In any case the marks below the filtered text have | |
94 | + their line numbers adjusted, thus stick to the text, | |
95 | + as usual. | |
96 | + When the 'R' flag is missing from 'cpoptions' this has | |
97 | + the same effect as using ":keepmarks". | |
98 | + | |
99 | ============================================================================== | |
100 | 8. Jumps *jump-motions* | |
101 | ||
102 | *** ../vim-6.2.189/runtime/plugin/gzip.vim Mon Dec 29 21:04:38 2003 | |
103 | --- runtime/plugin/gzip.vim Mon Jan 12 17:39:39 2004 | |
104 | *************** | |
105 | *** 1,6 **** | |
106 | " Vim plugin for editing compressed files. | |
107 | " Maintainer: Bram Moolenaar <Bram@vim.org> | |
108 | ! " Last Change: 2003 Dec 22 | |
109 | ||
110 | " Exit quickly when: | |
111 | " - this plugin was already loaded | |
112 | --- 1,6 ---- | |
113 | " Vim plugin for editing compressed files. | |
114 | " Maintainer: Bram Moolenaar <Bram@vim.org> | |
115 | ! " Last Change: 2004 Jan 12 | |
116 | ||
117 | " Exit quickly when: | |
118 | " - this plugin was already loaded | |
119 | *************** | |
120 | *** 73,85 **** | |
121 | call system(a:cmd . " " . tmpe) | |
122 | " delete the compressed lines; remember the line number | |
123 | let l = line("'[") - 1 | |
124 | ! '[,']d | |
125 | " read in the uncompressed lines "'[-1r tmp" | |
126 | setlocal nobin | |
127 | ! execute "silent " . l . "r " . tmp | |
128 | " if buffer became empty, delete trailing blank line | |
129 | if empty | |
130 | ! silent $delete | |
131 | 1 | |
132 | endif | |
133 | " delete the temp file and the used buffers | |
134 | --- 73,94 ---- | |
135 | call system(a:cmd . " " . tmpe) | |
136 | " delete the compressed lines; remember the line number | |
137 | let l = line("'[") - 1 | |
138 | ! if exists(":lockmarks") | |
139 | ! lockmarks '[,']d _ | |
140 | ! else | |
141 | ! '[,']d _ | |
142 | ! endif | |
143 | " read in the uncompressed lines "'[-1r tmp" | |
144 | setlocal nobin | |
145 | ! if exists(":lockmarks") | |
146 | ! execute "silent lockmarks " . l . "r " . tmp | |
147 | ! else | |
148 | ! execute "silent " . l . "r " . tmp | |
149 | ! endif | |
150 | ! | |
151 | " if buffer became empty, delete trailing blank line | |
152 | if empty | |
153 | ! silent $delete _ | |
154 | 1 | |
155 | endif | |
156 | " delete the temp file and the used buffers | |
157 | *** ../vim-6.2.189/src/ex_cmds.c Fri Jan 9 15:02:40 2004 | |
158 | --- src/ex_cmds.c Sun Jan 18 16:18:17 2004 | |
159 | *************** | |
160 | *** 746,751 **** | |
161 | --- 746,752 ---- | |
162 | char_u *itmp = NULL; | |
163 | char_u *otmp = NULL; | |
164 | linenr_T linecount; | |
165 | + linenr_T read_linecount; | |
166 | pos_T cursor_save; | |
167 | char_u *cmd_buf; | |
168 | #ifdef FEAT_AUTOCMD | |
169 | *************** | |
170 | *** 858,863 **** | |
171 | --- 859,865 ---- | |
172 | if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL) | |
173 | goto error; | |
174 | redraw_curbuf_later(VALID); | |
175 | + read_linecount = curbuf->b_ml.ml_line_count; | |
176 | if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, | |
177 | READ_FILTER) == FAIL) | |
178 | { | |
179 | *************** | |
180 | *** 877,882 **** | |
181 | --- 879,900 ---- | |
182 | ||
183 | if (do_in) | |
184 | { | |
185 | + if (cmdmod.keepmarks || vim_strchr(p_cpo, CPO_REMMARK) == NULL) | |
186 | + { | |
187 | + read_linecount = curbuf->b_ml.ml_line_count - read_linecount; | |
188 | + if (read_linecount >= linecount) | |
189 | + /* move all marks from old lines to new lines */ | |
190 | + mark_adjust(line1, line2, linecount, 0L); | |
191 | + else | |
192 | + { | |
193 | + /* move marks from old lines to new lines, delete marks | |
194 | + * that are in deleted lines */ | |
195 | + mark_adjust(line1, line1 + read_linecount - 1, | |
196 | + linecount, 0L); | |
197 | + mark_adjust(line1 + read_linecount, line2, MAXLNUM, 0L); | |
198 | + } | |
199 | + } | |
200 | + | |
201 | /* | |
202 | * Put cursor on first filtered line for ":range!cmd". | |
203 | * Adjust '[ and '] (set by buf_write()). | |
204 | *** ../vim-6.2.189/src/ex_docmd.c Sun Jan 18 20:46:13 2004 | |
205 | --- src/ex_docmd.c Fri Jan 16 17:20:17 2004 | |
206 | *************** | |
207 | *** 1432,1437 **** | |
208 | --- 1432,1438 ---- | |
209 | p = skipwhite(skipdigits(ea.cmd)); | |
210 | switch (*p) | |
211 | { | |
212 | + /* When adding an entry, also modify cmd_exists(). */ | |
213 | case 'a': if (!checkforcmd(&ea.cmd, "aboveleft", 3)) | |
214 | break; | |
215 | #ifdef FEAT_WINDOWS | |
216 | *************** | |
217 | *** 1467,1472 **** | |
218 | --- 1468,1478 ---- | |
219 | #endif | |
220 | continue; | |
221 | ||
222 | + case 'k': if (!checkforcmd(&ea.cmd, "keepmarks", 3)) | |
223 | + break; | |
224 | + cmdmod.keepmarks = TRUE; | |
225 | + continue; | |
226 | + | |
227 | /* ":hide" and ":hide | cmd" are not modifiers */ | |
228 | case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3) | |
229 | || *p == NUL || ends_excmd(*p)) | |
230 | *************** | |
231 | *** 1475,1481 **** | |
232 | cmdmod.hide = TRUE; | |
233 | continue; | |
234 | ||
235 | ! case 'l': if (!checkforcmd(&ea.cmd, "leftabove", 5)) | |
236 | break; | |
237 | #ifdef FEAT_WINDOWS | |
238 | cmdmod.split |= WSP_ABOVE; | |
239 | --- 1481,1493 ---- | |
240 | cmdmod.hide = TRUE; | |
241 | continue; | |
242 | ||
243 | ! case 'l': if (checkforcmd(&ea.cmd, "lockmarks", 3)) | |
244 | ! { | |
245 | ! cmdmod.lockmarks = TRUE; | |
246 | ! continue; | |
247 | ! } | |
248 | ! | |
249 | ! if (!checkforcmd(&ea.cmd, "leftabove", 5)) | |
250 | break; | |
251 | #ifdef FEAT_WINDOWS | |
252 | cmdmod.split |= WSP_ABOVE; | |
253 | *************** | |
254 | *** 2530,2536 **** | |
255 | --- 2542,2581 ---- | |
256 | { | |
257 | exarg_T ea; | |
258 | int full = FALSE; | |
259 | + int i; | |
260 | + int j; | |
261 | + static struct cmdmod | |
262 | + { | |
263 | + char *name; | |
264 | + int minlen; | |
265 | + } cmdmods[] = { | |
266 | + {"aboveleft", 3}, | |
267 | + {"belowright", 3}, | |
268 | + {"botright", 2}, | |
269 | + {"browse", 3}, | |
270 | + {"confirm", 4}, | |
271 | + {"hide", 3}, | |
272 | + {"keepmarks", 3}, | |
273 | + {"leftabove", 5}, | |
274 | + {"lockmarks", 3}, | |
275 | + {"rightbelow", 6}, | |
276 | + {"silent", 3}, | |
277 | + {"topleft", 2}, | |
278 | + {"verbose", 4}, | |
279 | + {"vertical", 4}, | |
280 | + }; | |
281 | + | |
282 | + /* Check command modifiers. */ | |
283 | + for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i) | |
284 | + { | |
285 | + for (j = 0; name[j] != NUL; ++j) | |
286 | + if (name[j] != cmdmods[i].name[j]) | |
287 | + break; | |
288 | + if (name[j] == NUL && j >= cmdmods[i].minlen) | |
289 | + return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
290 | + } | |
291 | ||
292 | + /* Check built-in commands and user defined commands. */ | |
293 | ea.cmd = name; | |
294 | ea.cmdidx = (cmdidx_T)0; | |
295 | if (find_command(&ea, &full) == NULL) | |
296 | *** ../vim-6.2.189/src/mark.c Sun Jan 18 20:58:01 2004 | |
297 | --- src/mark.c Fri Jan 16 11:56:14 2004 | |
298 | *************** | |
299 | *** 800,859 **** | |
300 | return; | |
301 | ||
302 | /* named marks, lower case and upper case */ | |
303 | ! for (i = 0; i < NMARKS; i++) | |
304 | { | |
305 | ! one_adjust(&(curbuf->b_namedm[i].lnum)); | |
306 | ! if (namedfm[i].fmark.fnum == fnum) | |
307 | ! one_adjust(&(namedfm[i].fmark.mark.lnum)); | |
308 | ! } | |
309 | ! for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
310 | ! { | |
311 | ! if (namedfm[i].fmark.fnum == fnum) | |
312 | ! one_adjust(&(namedfm[i].fmark.mark.lnum)); | |
313 | ! } | |
314 | ! | |
315 | ! /* previous context mark */ | |
316 | ! one_adjust(&(curwin->w_pcmark.lnum)); | |
317 | ! | |
318 | ! /* previous pcmark */ | |
319 | ! one_adjust(&(curwin->w_prev_pcmark.lnum)); | |
320 | ||
321 | ! /* last Insert position */ | |
322 | ! one_adjust(&(curbuf->b_last_insert.lnum)); | |
323 | ||
324 | ! /* last change position */ | |
325 | ! one_adjust(&(curbuf->b_last_change.lnum)); | |
326 | ||
327 | #ifdef FEAT_VISUAL | |
328 | ! /* Visual area */ | |
329 | ! one_adjust_nodel(&(curbuf->b_visual_start.lnum)); | |
330 | ! one_adjust_nodel(&(curbuf->b_visual_end.lnum)); | |
331 | #endif | |
332 | ||
333 | #ifdef FEAT_QUICKFIX | |
334 | ! /* quickfix marks */ | |
335 | ! qf_mark_adjust(line1, line2, amount, amount_after); | |
336 | #endif | |
337 | ||
338 | /* | |
339 | * Adjust items in all windows related to the current buffer. | |
340 | */ | |
341 | FOR_ALL_WINDOWS(win) | |
342 | { | |
343 | #ifdef FEAT_JUMPLIST | |
344 | ! /* Marks in the jumplist. When deleting lines, this may create | |
345 | ! * duplicate marks in the jumplist, they will be removed later. */ | |
346 | ! for (i = 0; i < win->w_jumplistlen; ++i) | |
347 | ! if (win->w_jumplist[i].fmark.fnum == fnum) | |
348 | ! one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum)); | |
349 | #endif | |
350 | ||
351 | if (win->w_buffer == curbuf) | |
352 | { | |
353 | ! /* marks in the tag stack */ | |
354 | ! for (i = 0; i < win->w_tagstacklen; i++) | |
355 | ! if (win->w_tagstack[i].fmark.fnum == fnum) | |
356 | ! one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum)); | |
357 | ||
358 | #ifdef FEAT_VISUAL | |
359 | /* the displayed Visual area */ | |
360 | --- 800,868 ---- | |
361 | return; | |
362 | ||
363 | /* named marks, lower case and upper case */ | |
364 | ! if (!cmdmod.lockmarks) | |
365 | { | |
366 | ! for (i = 0; i < NMARKS; i++) | |
367 | ! { | |
368 | ! one_adjust(&(curbuf->b_namedm[i].lnum)); | |
369 | ! if (namedfm[i].fmark.fnum == fnum) | |
370 | ! one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
371 | ! } | |
372 | ! for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++) | |
373 | ! { | |
374 | ! if (namedfm[i].fmark.fnum == fnum) | |
375 | ! one_adjust_nodel(&(namedfm[i].fmark.mark.lnum)); | |
376 | ! } | |
377 | ||
378 | ! /* last Insert position */ | |
379 | ! one_adjust(&(curbuf->b_last_insert.lnum)); | |
380 | ||
381 | ! /* last change position */ | |
382 | ! one_adjust(&(curbuf->b_last_change.lnum)); | |
383 | ||
384 | #ifdef FEAT_VISUAL | |
385 | ! /* Visual area */ | |
386 | ! one_adjust_nodel(&(curbuf->b_visual_start.lnum)); | |
387 | ! one_adjust_nodel(&(curbuf->b_visual_end.lnum)); | |
388 | #endif | |
389 | ||
390 | #ifdef FEAT_QUICKFIX | |
391 | ! /* quickfix marks */ | |
392 | ! qf_mark_adjust(line1, line2, amount, amount_after); | |
393 | #endif | |
394 | ||
395 | + #ifdef FEAT_SIGNS | |
396 | + sign_mark_adjust(line1, line2, amount, amount_after); | |
397 | + #endif | |
398 | + } | |
399 | + | |
400 | + /* previous context mark */ | |
401 | + one_adjust(&(curwin->w_pcmark.lnum)); | |
402 | + | |
403 | + /* previous pcmark */ | |
404 | + one_adjust(&(curwin->w_prev_pcmark.lnum)); | |
405 | + | |
406 | /* | |
407 | * Adjust items in all windows related to the current buffer. | |
408 | */ | |
409 | FOR_ALL_WINDOWS(win) | |
410 | { | |
411 | #ifdef FEAT_JUMPLIST | |
412 | ! if (!cmdmod.lockmarks) | |
413 | ! /* Marks in the jumplist. When deleting lines, this may create | |
414 | ! * duplicate marks in the jumplist, they will be removed later. */ | |
415 | ! for (i = 0; i < win->w_jumplistlen; ++i) | |
416 | ! if (win->w_jumplist[i].fmark.fnum == fnum) | |
417 | ! one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum)); | |
418 | #endif | |
419 | ||
420 | if (win->w_buffer == curbuf) | |
421 | { | |
422 | ! if (!cmdmod.lockmarks) | |
423 | ! /* marks in the tag stack */ | |
424 | ! for (i = 0; i < win->w_tagstacklen; i++) | |
425 | ! if (win->w_tagstack[i].fmark.fnum == fnum) | |
426 | ! one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum)); | |
427 | ||
428 | #ifdef FEAT_VISUAL | |
429 | /* the displayed Visual area */ | |
430 | *************** | |
431 | *** 917,926 **** | |
432 | #ifdef FEAT_DIFF | |
433 | /* adjust diffs */ | |
434 | diff_mark_adjust(line1, line2, amount, amount_after); | |
435 | - #endif | |
436 | - | |
437 | - #ifdef FEAT_SIGNS | |
438 | - sign_mark_adjust(line1, line2, amount, amount_after); | |
439 | #endif | |
440 | } | |
441 | ||
442 | --- 926,931 ---- | |
443 | *** ../vim-6.2.189/src/structs.h Sun Nov 2 15:27:38 2003 | |
444 | --- src/structs.h Tue Jan 13 12:57:23 2004 | |
445 | *************** | |
446 | *** 403,408 **** | |
447 | --- 403,410 ---- | |
448 | # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
449 | int confirm; /* TRUE to invoke yes/no dialog */ | |
450 | # endif | |
451 | + int keepmarks; /* TRUE when ":keepmarks" was used */ | |
452 | + int lockmarks; /* TRUE when ":lockmarks" was used */ | |
453 | } cmdmod_T; | |
454 | ||
455 | /* | |
456 | *** ../vim-6.2.189/src/version.c Sun Jan 18 21:04:53 2004 | |
457 | --- src/version.c Sun Jan 18 21:07:07 2004 | |
458 | *************** | |
459 | *** 639,640 **** | |
460 | --- 639,642 ---- | |
461 | { /* Add new patch number below this line */ | |
462 | + /**/ | |
463 | + 190, | |
464 | /**/ | |
465 | ||
466 | -- | |
467 | ARTHUR: Well, I AM king... | |
468 | DENNIS: Oh king, eh, very nice. An' how'd you get that, eh? By exploitin' | |
469 | the workers -- by 'angin' on to outdated imperialist dogma which | |
470 | perpetuates the economic an' social differences in our society! If | |
471 | there's ever going to be any progress-- | |
472 | The Quest for the Holy Grail (Monty Python) | |
473 | ||
474 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
475 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
476 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
477 | \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |