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