073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.396
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.396
073263
Problem:    When 'clipboard' is "unnamed", :g/pat/d is very slow. (Praful)
073263
Solution:   Only set the clipboard after the last delete. (Christian Brabandt)
073263
Files:	    src/ex_cmds.c, src/ex_cmds2.c, src/ex_docmd.c, src/globals.h,
073263
	    src/ops.c, src/proto/ui.pro, src/ui.c
073263
073263
073263
*** ../vim-7.4.395/src/ex_cmds.c	2014-07-09 21:17:59.755550204 +0200
073263
--- src/ex_cmds.c	2014-08-06 18:06:37.931152276 +0200
073263
***************
073263
*** 5514,5520 ****
073263
--- 5514,5528 ----
073263
  	    smsg((char_u *)_("Pattern not found: %s"), pat);
073263
      }
073263
      else
073263
+     {
073263
+ #ifdef FEAT_CLIPBOARD
073263
+ 	start_global_changes();
073263
+ #endif
073263
  	global_exe(cmd);
073263
+ #ifdef FEAT_CLIPBOARD
073263
+ 	end_global_changes();
073263
+ #endif
073263
+     }
073263
  
073263
      ml_clearmarked();	   /* clear rest of the marks */
073263
      vim_regfree(regmatch.regprog);
073263
*** ../vim-7.4.395/src/ex_cmds2.c	2014-04-05 19:44:36.903160723 +0200
073263
--- src/ex_cmds2.c	2014-08-06 18:05:07.563152926 +0200
073263
***************
073263
*** 2464,2469 ****
073263
--- 2464,2472 ----
073263
  	 * great speed improvement. */
073263
  	save_ei = au_event_disable(",Syntax");
073263
  #endif
073263
+ #ifdef FEAT_CLIPBOARD
073263
+     start_global_changes();
073263
+ #endif
073263
  
073263
      if (eap->cmdidx == CMD_windo
073263
  	    || eap->cmdidx == CMD_tabdo
073263
***************
073263
*** 2591,2596 ****
073263
--- 2594,2602 ----
073263
  					       curbuf->b_fname, TRUE, curbuf);
073263
      }
073263
  #endif
073263
+ #ifdef FEAT_CLIPBOARD
073263
+     end_global_changes();
073263
+ #endif
073263
  }
073263
  
073263
  /*
073263
***************
073263
*** 2750,2757 ****
073263
   * used.
073263
   * Returns OK when at least one match found, FAIL otherwise.
073263
   *
073263
!  * If "name" is NULL calls callback for each entry in runtimepath. Cookie is 
073263
!  * passed by reference in this case, setting it to NULL indicates that callback 
073263
   * has done its job.
073263
   */
073263
      int
073263
--- 2756,2763 ----
073263
   * used.
073263
   * Returns OK when at least one match found, FAIL otherwise.
073263
   *
073263
!  * If "name" is NULL calls callback for each entry in runtimepath. Cookie is
073263
!  * passed by reference in this case, setting it to NULL indicates that callback
073263
   * has done its job.
073263
   */
073263
      int
073263
*** ../vim-7.4.395/src/ex_docmd.c	2014-06-17 17:48:21.780628008 +0200
073263
--- src/ex_docmd.c	2014-08-06 18:05:07.563152926 +0200
073263
***************
073263
*** 11534,11539 ****
073263
--- 11534,11543 ----
073263
  {
073263
      linenr_T	lnum;
073263
  
073263
+ #ifdef FEAT_CLIPBOARD
073263
+     start_global_changes();
073263
+ #endif
073263
+ 
073263
      /* First set the marks for all lines closed/open. */
073263
      for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
073263
  	if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed))
073263
***************
073263
*** 11542,11546 ****
073263
--- 11546,11553 ----
073263
      /* Execute the command on the marked lines. */
073263
      global_exe(eap->arg);
073263
      ml_clearmarked();	   /* clear rest of the marks */
073263
+ #ifdef FEAT_CLIPBOARD
073263
+     end_global_changes();
073263
+ #endif
073263
  }
073263
  #endif
073263
*** ../vim-7.4.395/src/globals.h	2014-07-30 17:21:53.815518506 +0200
073263
--- src/globals.h	2014-08-06 18:05:07.563152926 +0200
073263
***************
073263
*** 533,538 ****
073263
--- 533,540 ----
073263
  EXTERN int	clip_autoselectml INIT(= FALSE);
073263
  EXTERN int	clip_html INIT(= FALSE);
073263
  EXTERN regprog_T *clip_exclude_prog INIT(= NULL);
073263
+ EXTERN int	clip_did_set_selection INIT(= TRUE);
073263
+ EXTERN int	clip_unnamed_saved INIT(= 0);
073263
  #endif
073263
  
073263
  /*
073263
*** ../vim-7.4.395/src/ops.c	2014-06-25 14:39:35.106348584 +0200
073263
--- src/ops.c	2014-08-06 18:05:07.563152926 +0200
073263
***************
073263
*** 1597,1605 ****
073263
  {
073263
      /* If no reg. specified, and "unnamed" or "unnamedplus" is in 'clipboard',
073263
       * use '*' or '+' reg, respectively. "unnamedplus" prevails. */
073263
!     if (*rp == 0 && clip_unnamed != 0)
073263
! 	*rp = ((clip_unnamed & CLIP_UNNAMED_PLUS) && clip_plus.available)
073263
  								  ? '+' : '*';
073263
      if (!clip_star.available && *rp == '*')
073263
  	*rp = 0;
073263
      if (!clip_plus.available && *rp == '+')
073263
--- 1597,1611 ----
073263
  {
073263
      /* If no reg. specified, and "unnamed" or "unnamedplus" is in 'clipboard',
073263
       * use '*' or '+' reg, respectively. "unnamedplus" prevails. */
073263
!     if (*rp == 0 && (clip_unnamed != 0 || clip_unnamed_saved != 0))
073263
!     {
073263
! 	if (clip_unnamed != 0)
073263
! 	    *rp = ((clip_unnamed & CLIP_UNNAMED_PLUS) && clip_plus.available)
073263
! 								  ? '+' : '*';
073263
! 	else
073263
! 	    *rp = ((clip_unnamed_saved & CLIP_UNNAMED_PLUS) && clip_plus.available)
073263
  								  ? '+' : '*';
073263
+     }
073263
      if (!clip_star.available && *rp == '*')
073263
  	*rp = 0;
073263
      if (!clip_plus.available && *rp == '+')
073263
***************
073263
*** 3203,3209 ****
073263
      if (clip_star.available
073263
  	    && (curr == &(y_regs[STAR_REGISTER])
073263
  		|| (!deleting && oap->regname == 0
073263
! 					   && (clip_unnamed & CLIP_UNNAMED))))
073263
      {
073263
  	if (curr != &(y_regs[STAR_REGISTER]))
073263
  	    /* Copy the text from register 0 to the clipboard register. */
073263
--- 3209,3215 ----
073263
      if (clip_star.available
073263
  	    && (curr == &(y_regs[STAR_REGISTER])
073263
  		|| (!deleting && oap->regname == 0
073263
! 		   && ((clip_unnamed | clip_unnamed_saved) & CLIP_UNNAMED))))
073263
      {
073263
  	if (curr != &(y_regs[STAR_REGISTER]))
073263
  	    /* Copy the text from register 0 to the clipboard register. */
073263
***************
073263
*** 3224,3230 ****
073263
      if (clip_plus.available
073263
  	    && (curr == &(y_regs[PLUS_REGISTER])
073263
  		|| (!deleting && oap->regname == 0
073263
! 				      && (clip_unnamed & CLIP_UNNAMED_PLUS))))
073263
      {
073263
  	if (curr != &(y_regs[PLUS_REGISTER]))
073263
  	    /* Copy the text from register 0 to the clipboard register. */
073263
--- 3230,3237 ----
073263
      if (clip_plus.available
073263
  	    && (curr == &(y_regs[PLUS_REGISTER])
073263
  		|| (!deleting && oap->regname == 0
073263
! 		  && ((clip_unnamed | clip_unnamed_saved) &
073263
! 		      CLIP_UNNAMED_PLUS))))
073263
      {
073263
  	if (curr != &(y_regs[PLUS_REGISTER]))
073263
  	    /* Copy the text from register 0 to the clipboard register. */
073263
*** ../vim-7.4.395/src/proto/ui.pro	2013-08-10 13:37:29.000000000 +0200
073263
--- src/proto/ui.pro	2014-08-06 18:05:07.563152926 +0200
073263
***************
073263
*** 14,19 ****
073263
--- 14,21 ----
073263
  void clip_update_selection __ARGS((VimClipboard *clip));
073263
  void clip_own_selection __ARGS((VimClipboard *cbd));
073263
  void clip_lose_selection __ARGS((VimClipboard *cbd));
073263
+ void start_global_changes __ARGS((void));
073263
+ void end_global_changes __ARGS((void));
073263
  void clip_auto_select __ARGS((void));
073263
  int clip_isautosel_star __ARGS((void));
073263
  int clip_isautosel_plus __ARGS((void));
073263
*** ../vim-7.4.395/src/ui.c	2014-06-25 14:39:35.114348584 +0200
073263
--- src/ui.c	2014-08-06 18:13:13.475149434 +0200
073263
***************
073263
*** 558,563 ****
073263
--- 558,608 ----
073263
  }
073263
  
073263
  /*
073263
+  * Save and restore clip_unnamed before doing possibly many changes. This
073263
+  * prevents accessing the clipboard very often which might slow down Vim
073263
+  * considerably.
073263
+  */
073263
+ 
073263
+ /*
073263
+  * Save clip_unnamed and reset it.
073263
+  */
073263
+     void
073263
+ start_global_changes()
073263
+ {
073263
+     clip_unnamed_saved = clip_unnamed;
073263
+ 
073263
+     if (clip_did_set_selection)
073263
+     {
073263
+ 	clip_unnamed = FALSE;
073263
+ 	clip_did_set_selection = FALSE;
073263
+     }
073263
+ }
073263
+ 
073263
+ /*
073263
+  * Restore clip_unnamed and set the selection when needed.
073263
+  */
073263
+     void
073263
+ end_global_changes()
073263
+ {
073263
+     if (!clip_did_set_selection)
073263
+     {
073263
+ 	clip_did_set_selection = TRUE;
073263
+ 	clip_unnamed = clip_unnamed_saved;
073263
+ 	if (clip_unnamed & CLIP_UNNAMED)
073263
+ 	{
073263
+ 	    clip_own_selection(&clip_star);
073263
+ 	    clip_gen_set_selection(&clip_star);
073263
+ 	}
073263
+ 	if (clip_unnamed & CLIP_UNNAMED_PLUS)
073263
+ 	{
073263
+ 	    clip_own_selection(&clip_plus);
073263
+ 	    clip_gen_set_selection(&clip_plus);
073263
+ 	}
073263
+     }
073263
+     clip_unnamed_saved = FALSE;
073263
+ }
073263
+ 
073263
+ /*
073263
   * Called when Visual mode is ended: update the selection.
073263
   */
073263
      void
073263
***************
073263
*** 1428,1433 ****
073263
--- 1473,1487 ----
073263
  clip_gen_set_selection(cbd)
073263
      VimClipboard	*cbd;
073263
  {
073263
+     if (!clip_did_set_selection)
073263
+     {
073263
+ 	/* Updating postponed, so that accessing the system clipboard won't
073263
+ 	 * hang Vim when accessing it many times (e.g. on a :g comand). */
073263
+ 	if (cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
073263
+ 	    return;
073263
+ 	else if (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED))
073263
+ 	    return;
073263
+     }
073263
  #ifdef FEAT_XCLIPBOARD
073263
  # ifdef FEAT_GUI
073263
      if (gui.in_use)
073263
*** ../vim-7.4.395/src/version.c	2014-08-06 17:44:09.867161966 +0200
073263
--- src/version.c	2014-08-06 18:04:47.359153071 +0200
073263
***************
073263
*** 743,744 ****
073263
--- 743,746 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     396,
073263
  /**/
073263
073263
-- 
073263
You have heard the saying that if you put a thousand monkeys in a room with a
073263
thousand typewriters and waited long enough, eventually you would have a room
073263
full of dead monkeys.
073263
				(Scott Adams - The Dilbert principle)
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///