Karsten Hopp 81c285
To: vim-dev@vim.org
Karsten Hopp 81c285
Subject: Patch 7.2.190
Karsten Hopp 81c285
Fcc: outbox
Karsten Hopp 81c285
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 81c285
Mime-Version: 1.0
Karsten Hopp 81c285
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 81c285
Content-Transfer-Encoding: 8bit
Karsten Hopp 81c285
------------
Karsten Hopp 81c285
Karsten Hopp 81c285
Patch 7.2.190
Karsten Hopp 81c285
Problem:    The register executed by @@ isn't restored.
Karsten Hopp 81c285
Solution:   Mark the executable register in the viminfo file.
Karsten Hopp 81c285
Files:	    src/ops.c
Karsten Hopp 81c285
Karsten Hopp 81c285
Karsten Hopp 81c285
*** ../vim-7.2.189/src/ops.c	2009-05-13 12:46:36.000000000 +0200
Karsten Hopp 81c285
--- src/ops.c	2009-05-26 18:05:23.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1143,1148 ****
Karsten Hopp 81c285
--- 1143,1150 ----
Karsten Hopp 81c285
      return OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ static int execreg_lastc = NUL;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * execute a yank register: copy it into the stuff buffer
Karsten Hopp 81c285
   *
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1155,1161 ****
Karsten Hopp 81c285
      int	    addcr;		/* always add '\n' to end of line */
Karsten Hopp 81c285
      int	    silent;		/* set "silent" flag in typeahead buffer */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
-     static int	lastc = NUL;
Karsten Hopp 81c285
      long	i;
Karsten Hopp 81c285
      char_u	*p;
Karsten Hopp 81c285
      int		retval = OK;
Karsten Hopp 81c285
--- 1157,1162 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1163,1174 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (regname == '@')			/* repeat previous one */
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	if (lastc == NUL)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    EMSG(_("E748: No previously used register"));
Karsten Hopp 81c285
  	    return FAIL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
! 	regname = lastc;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  					/* check for valid regname */
Karsten Hopp 81c285
      if (regname == '%' || regname == '#' || !valid_yank_reg(regname, FALSE))
Karsten Hopp 81c285
--- 1164,1175 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (regname == '@')			/* repeat previous one */
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	if (execreg_lastc == NUL)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    EMSG(_("E748: No previously used register"));
Karsten Hopp 81c285
  	    return FAIL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
! 	regname = execreg_lastc;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  					/* check for valid regname */
Karsten Hopp 81c285
      if (regname == '%' || regname == '#' || !valid_yank_reg(regname, FALSE))
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1176,1182 ****
Karsten Hopp 81c285
  	emsg_invreg(regname);
Karsten Hopp 81c285
  	return FAIL;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
!     lastc = regname;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_CLIPBOARD
Karsten Hopp 81c285
      regname = may_get_selection(regname);
Karsten Hopp 81c285
--- 1177,1183 ----
Karsten Hopp 81c285
  	emsg_invreg(regname);
Karsten Hopp 81c285
  	return FAIL;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
!     execreg_lastc = regname;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_CLIPBOARD
Karsten Hopp 81c285
      regname = may_get_selection(regname);
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 5337,5347 ****
Karsten Hopp 81c285
--- 5338,5351 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* We only get here (hopefully) if line[0] == '"' */
Karsten Hopp 81c285
      str = virp->vir_line + 1;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     /* If the line starts with "" this is the y_previous register. */
Karsten Hopp 81c285
      if (*str == '"')
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	set_prev = TRUE;
Karsten Hopp 81c285
  	str++;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      if (!ASCII_ISALNUM(*str) && *str != '-')
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (viminfo_error("E577: ", _("Illegal register name"), virp->vir_line))
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 5351,5356 ****
Karsten Hopp 81c285
--- 5355,5368 ----
Karsten Hopp 81c285
      get_yank_register(*str++, FALSE);
Karsten Hopp 81c285
      if (!force && y_current->y_array != NULL)
Karsten Hopp 81c285
  	do_it = FALSE;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     if (*str == '@')
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	/* "x@: register x used for @@ */
Karsten Hopp 81c285
+ 	if (force || execreg_lastc == NUL)
Karsten Hopp 81c285
+ 	    execreg_lastc = str[-1];
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      size = 0;
Karsten Hopp 81c285
      limit = 100;	/* Optimized for registers containing <= 100 lines */
Karsten Hopp 81c285
      if (do_it)
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 5360,5366 ****
Karsten Hopp 81c285
  	vim_free(y_current->y_array);
Karsten Hopp 81c285
  	array = y_current->y_array =
Karsten Hopp 81c285
  		       (char_u **)alloc((unsigned)(limit * sizeof(char_u *)));
Karsten Hopp 81c285
! 	str = skipwhite(str);
Karsten Hopp 81c285
  	if (STRNCMP(str, "CHAR", 4) == 0)
Karsten Hopp 81c285
  	    y_current->y_type = MCHAR;
Karsten Hopp 81c285
  #ifdef FEAT_VISUAL
Karsten Hopp 81c285
--- 5372,5378 ----
Karsten Hopp 81c285
  	vim_free(y_current->y_array);
Karsten Hopp 81c285
  	array = y_current->y_array =
Karsten Hopp 81c285
  		       (char_u **)alloc((unsigned)(limit * sizeof(char_u *)));
Karsten Hopp 81c285
! 	str = skipwhite(skiptowhite(str));
Karsten Hopp 81c285
  	if (STRNCMP(str, "CHAR", 4) == 0)
Karsten Hopp 81c285
  	    y_current->y_type = MCHAR;
Karsten Hopp 81c285
  #ifdef FEAT_VISUAL
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 5443,5448 ****
Karsten Hopp 81c285
--- 5455,5461 ----
Karsten Hopp 81c285
      max_kbyte = get_viminfo_parameter('s');
Karsten Hopp 81c285
      if (max_kbyte == 0)
Karsten Hopp 81c285
  	return;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      for (i = 0; i < NUM_REGISTERS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (y_regs[i].y_array == NULL)
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 5497,5503 ****
Karsten Hopp 81c285
  	if (y_previous == &y_regs[i])
Karsten Hopp 81c285
  	    fprintf(fp, "\"");
Karsten Hopp 81c285
  	c = get_register_name(i);
Karsten Hopp 81c285
! 	fprintf(fp, "\"%c\t%s\t%d\n", c, type,
Karsten Hopp 81c285
  #ifdef FEAT_VISUAL
Karsten Hopp 81c285
  		    (int)y_regs[i].y_width
Karsten Hopp 81c285
  #else
Karsten Hopp 81c285
--- 5510,5519 ----
Karsten Hopp 81c285
  	if (y_previous == &y_regs[i])
Karsten Hopp 81c285
  	    fprintf(fp, "\"");
Karsten Hopp 81c285
  	c = get_register_name(i);
Karsten Hopp 81c285
! 	fprintf(fp, "\"%c", c);
Karsten Hopp 81c285
! 	if (c == execreg_lastc)
Karsten Hopp 81c285
! 	    fprintf(fp, "@");
Karsten Hopp 81c285
! 	fprintf(fp, "\t%s\t%d\n", type,
Karsten Hopp 81c285
  #ifdef FEAT_VISUAL
Karsten Hopp 81c285
  		    (int)y_regs[i].y_width
Karsten Hopp 81c285
  #else
Karsten Hopp 81c285
*** ../vim-7.2.189/src/version.c	2009-05-26 11:01:43.000000000 +0200
Karsten Hopp 81c285
--- src/version.c	2009-05-26 18:10:13.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 678,679 ****
Karsten Hopp 81c285
--- 678,681 ----
Karsten Hopp 81c285
  {   /* Add new patch number below this line */
Karsten Hopp 81c285
+ /**/
Karsten Hopp 81c285
+     190,
Karsten Hopp 81c285
  /**/
Karsten Hopp 81c285
Karsten Hopp 81c285
-- 
Karsten Hopp 81c285
If you had to identify, in one word, the reason why the
Karsten Hopp 81c285
human race has not achieved, and never will achieve, its
Karsten Hopp 81c285
full potential, that word would be "meetings."
Karsten Hopp 81c285
Karsten Hopp 81c285
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 81c285
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 81c285
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 81c285
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///