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 / 6.2.190 < prev    next >
Encoding:
Internet Message Format  |  2004-01-17  |  14.2 KB

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