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.396 < prev    next >
Encoding:
Internet Message Format  |  2014-08-05  |  8.7 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.396
  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.396
  11. Problem:    When 'clipboard' is "unnamed", :g/pat/d is very slow. (Praful)
  12. Solution:   Only set the clipboard after the last delete. (Christian Brabandt)
  13. Files:        src/ex_cmds.c, src/ex_cmds2.c, src/ex_docmd.c, src/globals.h,
  14.         src/ops.c, src/proto/ui.pro, src/ui.c
  15.  
  16.  
  17. *** ../vim-7.4.395/src/ex_cmds.c    2014-07-09 21:17:59.755550204 +0200
  18. --- src/ex_cmds.c    2014-08-06 18:06:37.931152276 +0200
  19. ***************
  20. *** 5514,5520 ****
  21. --- 5514,5528 ----
  22.           smsg((char_u *)_("Pattern not found: %s"), pat);
  23.       }
  24.       else
  25. +     {
  26. + #ifdef FEAT_CLIPBOARD
  27. +     start_global_changes();
  28. + #endif
  29.       global_exe(cmd);
  30. + #ifdef FEAT_CLIPBOARD
  31. +     end_global_changes();
  32. + #endif
  33. +     }
  34.   
  35.       ml_clearmarked();       /* clear rest of the marks */
  36.       vim_regfree(regmatch.regprog);
  37. *** ../vim-7.4.395/src/ex_cmds2.c    2014-04-05 19:44:36.903160723 +0200
  38. --- src/ex_cmds2.c    2014-08-06 18:05:07.563152926 +0200
  39. ***************
  40. *** 2464,2469 ****
  41. --- 2464,2472 ----
  42.        * great speed improvement. */
  43.       save_ei = au_event_disable(",Syntax");
  44.   #endif
  45. + #ifdef FEAT_CLIPBOARD
  46. +     start_global_changes();
  47. + #endif
  48.   
  49.       if (eap->cmdidx == CMD_windo
  50.           || eap->cmdidx == CMD_tabdo
  51. ***************
  52. *** 2591,2596 ****
  53. --- 2594,2602 ----
  54.                              curbuf->b_fname, TRUE, curbuf);
  55.       }
  56.   #endif
  57. + #ifdef FEAT_CLIPBOARD
  58. +     end_global_changes();
  59. + #endif
  60.   }
  61.   
  62.   /*
  63. ***************
  64. *** 2750,2757 ****
  65.    * used.
  66.    * Returns OK when at least one match found, FAIL otherwise.
  67.    *
  68. !  * If "name" is NULL calls callback for each entry in runtimepath. Cookie is 
  69. !  * passed by reference in this case, setting it to NULL indicates that callback 
  70.    * has done its job.
  71.    */
  72.       int
  73. --- 2756,2763 ----
  74.    * used.
  75.    * Returns OK when at least one match found, FAIL otherwise.
  76.    *
  77. !  * If "name" is NULL calls callback for each entry in runtimepath. Cookie is
  78. !  * passed by reference in this case, setting it to NULL indicates that callback
  79.    * has done its job.
  80.    */
  81.       int
  82. *** ../vim-7.4.395/src/ex_docmd.c    2014-06-17 17:48:21.780628008 +0200
  83. --- src/ex_docmd.c    2014-08-06 18:05:07.563152926 +0200
  84. ***************
  85. *** 11534,11539 ****
  86. --- 11534,11543 ----
  87.   {
  88.       linenr_T    lnum;
  89.   
  90. + #ifdef FEAT_CLIPBOARD
  91. +     start_global_changes();
  92. + #endif
  93.       /* First set the marks for all lines closed/open. */
  94.       for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
  95.       if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed))
  96. ***************
  97. *** 11542,11546 ****
  98. --- 11546,11553 ----
  99.       /* Execute the command on the marked lines. */
  100.       global_exe(eap->arg);
  101.       ml_clearmarked();       /* clear rest of the marks */
  102. + #ifdef FEAT_CLIPBOARD
  103. +     end_global_changes();
  104. + #endif
  105.   }
  106.   #endif
  107. *** ../vim-7.4.395/src/globals.h    2014-07-30 17:21:53.815518506 +0200
  108. --- src/globals.h    2014-08-06 18:05:07.563152926 +0200
  109. ***************
  110. *** 533,538 ****
  111. --- 533,540 ----
  112.   EXTERN int    clip_autoselectml INIT(= FALSE);
  113.   EXTERN int    clip_html INIT(= FALSE);
  114.   EXTERN regprog_T *clip_exclude_prog INIT(= NULL);
  115. + EXTERN int    clip_did_set_selection INIT(= TRUE);
  116. + EXTERN int    clip_unnamed_saved INIT(= 0);
  117.   #endif
  118.   
  119.   /*
  120. *** ../vim-7.4.395/src/ops.c    2014-06-25 14:39:35.106348584 +0200
  121. --- src/ops.c    2014-08-06 18:05:07.563152926 +0200
  122. ***************
  123. *** 1597,1605 ****
  124.   {
  125.       /* If no reg. specified, and "unnamed" or "unnamedplus" is in 'clipboard',
  126.        * use '*' or '+' reg, respectively. "unnamedplus" prevails. */
  127. !     if (*rp == 0 && clip_unnamed != 0)
  128. !     *rp = ((clip_unnamed & CLIP_UNNAMED_PLUS) && clip_plus.available)
  129.                                     ? '+' : '*';
  130.       if (!clip_star.available && *rp == '*')
  131.       *rp = 0;
  132.       if (!clip_plus.available && *rp == '+')
  133. --- 1597,1611 ----
  134.   {
  135.       /* If no reg. specified, and "unnamed" or "unnamedplus" is in 'clipboard',
  136.        * use '*' or '+' reg, respectively. "unnamedplus" prevails. */
  137. !     if (*rp == 0 && (clip_unnamed != 0 || clip_unnamed_saved != 0))
  138. !     {
  139. !     if (clip_unnamed != 0)
  140. !         *rp = ((clip_unnamed & CLIP_UNNAMED_PLUS) && clip_plus.available)
  141. !                                   ? '+' : '*';
  142. !     else
  143. !         *rp = ((clip_unnamed_saved & CLIP_UNNAMED_PLUS) && clip_plus.available)
  144.                                     ? '+' : '*';
  145. +     }
  146.       if (!clip_star.available && *rp == '*')
  147.       *rp = 0;
  148.       if (!clip_plus.available && *rp == '+')
  149. ***************
  150. *** 3203,3209 ****
  151.       if (clip_star.available
  152.           && (curr == &(y_regs[STAR_REGISTER])
  153.           || (!deleting && oap->regname == 0
  154. !                        && (clip_unnamed & CLIP_UNNAMED))))
  155.       {
  156.       if (curr != &(y_regs[STAR_REGISTER]))
  157.           /* Copy the text from register 0 to the clipboard register. */
  158. --- 3209,3215 ----
  159.       if (clip_star.available
  160.           && (curr == &(y_regs[STAR_REGISTER])
  161.           || (!deleting && oap->regname == 0
  162. !            && ((clip_unnamed | clip_unnamed_saved) & CLIP_UNNAMED))))
  163.       {
  164.       if (curr != &(y_regs[STAR_REGISTER]))
  165.           /* Copy the text from register 0 to the clipboard register. */
  166. ***************
  167. *** 3224,3230 ****
  168.       if (clip_plus.available
  169.           && (curr == &(y_regs[PLUS_REGISTER])
  170.           || (!deleting && oap->regname == 0
  171. !                       && (clip_unnamed & CLIP_UNNAMED_PLUS))))
  172.       {
  173.       if (curr != &(y_regs[PLUS_REGISTER]))
  174.           /* Copy the text from register 0 to the clipboard register. */
  175. --- 3230,3237 ----
  176.       if (clip_plus.available
  177.           && (curr == &(y_regs[PLUS_REGISTER])
  178.           || (!deleting && oap->regname == 0
  179. !           && ((clip_unnamed | clip_unnamed_saved) &
  180. !               CLIP_UNNAMED_PLUS))))
  181.       {
  182.       if (curr != &(y_regs[PLUS_REGISTER]))
  183.           /* Copy the text from register 0 to the clipboard register. */
  184. *** ../vim-7.4.395/src/proto/ui.pro    2013-08-10 13:37:29.000000000 +0200
  185. --- src/proto/ui.pro    2014-08-06 18:05:07.563152926 +0200
  186. ***************
  187. *** 14,19 ****
  188. --- 14,21 ----
  189.   void clip_update_selection __ARGS((VimClipboard *clip));
  190.   void clip_own_selection __ARGS((VimClipboard *cbd));
  191.   void clip_lose_selection __ARGS((VimClipboard *cbd));
  192. + void start_global_changes __ARGS((void));
  193. + void end_global_changes __ARGS((void));
  194.   void clip_auto_select __ARGS((void));
  195.   int clip_isautosel_star __ARGS((void));
  196.   int clip_isautosel_plus __ARGS((void));
  197. *** ../vim-7.4.395/src/ui.c    2014-06-25 14:39:35.114348584 +0200
  198. --- src/ui.c    2014-08-06 18:13:13.475149434 +0200
  199. ***************
  200. *** 558,563 ****
  201. --- 558,608 ----
  202.   }
  203.   
  204.   /*
  205. +  * Save and restore clip_unnamed before doing possibly many changes. This
  206. +  * prevents accessing the clipboard very often which might slow down Vim
  207. +  * considerably.
  208. +  */
  209. + /*
  210. +  * Save clip_unnamed and reset it.
  211. +  */
  212. +     void
  213. + start_global_changes()
  214. + {
  215. +     clip_unnamed_saved = clip_unnamed;
  216. +     if (clip_did_set_selection)
  217. +     {
  218. +     clip_unnamed = FALSE;
  219. +     clip_did_set_selection = FALSE;
  220. +     }
  221. + }
  222. + /*
  223. +  * Restore clip_unnamed and set the selection when needed.
  224. +  */
  225. +     void
  226. + end_global_changes()
  227. + {
  228. +     if (!clip_did_set_selection)
  229. +     {
  230. +     clip_did_set_selection = TRUE;
  231. +     clip_unnamed = clip_unnamed_saved;
  232. +     if (clip_unnamed & CLIP_UNNAMED)
  233. +     {
  234. +         clip_own_selection(&clip_star);
  235. +         clip_gen_set_selection(&clip_star);
  236. +     }
  237. +     if (clip_unnamed & CLIP_UNNAMED_PLUS)
  238. +     {
  239. +         clip_own_selection(&clip_plus);
  240. +         clip_gen_set_selection(&clip_plus);
  241. +     }
  242. +     }
  243. +     clip_unnamed_saved = FALSE;
  244. + }
  245. + /*
  246.    * Called when Visual mode is ended: update the selection.
  247.    */
  248.       void
  249. ***************
  250. *** 1428,1433 ****
  251. --- 1473,1487 ----
  252.   clip_gen_set_selection(cbd)
  253.       VimClipboard    *cbd;
  254.   {
  255. +     if (!clip_did_set_selection)
  256. +     {
  257. +     /* Updating postponed, so that accessing the system clipboard won't
  258. +      * hang Vim when accessing it many times (e.g. on a :g comand). */
  259. +     if (cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
  260. +         return;
  261. +     else if (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED))
  262. +         return;
  263. +     }
  264.   #ifdef FEAT_XCLIPBOARD
  265.   # ifdef FEAT_GUI
  266.       if (gui.in_use)
  267. *** ../vim-7.4.395/src/version.c    2014-08-06 17:44:09.867161966 +0200
  268. --- src/version.c    2014-08-06 18:04:47.359153071 +0200
  269. ***************
  270. *** 743,744 ****
  271. --- 743,746 ----
  272.   {   /* Add new patch number below this line */
  273. + /**/
  274. +     396,
  275.   /**/
  276.  
  277. -- 
  278. You have heard the saying that if you put a thousand monkeys in a room with a
  279. thousand typewriters and waited long enough, eventually you would have a room
  280. full of dead monkeys.
  281.                 (Scott Adams - The Dilbert principle)
  282.  
  283.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  284. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  285. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  286.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  287.