3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.605
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.605
3ef2ca
Problem:    The # register is not writable, it cannot be restored after
3ef2ca
	    jumping around.
3ef2ca
Solution:   Make the # register writable. (Marcin Szamotulski)
3ef2ca
Files:	    runtime/doc/change.txt, src/ops.c, src/buffer.c, src/globals.h
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.604/runtime/doc/change.txt	2014-03-25 18:23:27.046087691 +0100
3ef2ca
--- runtime/doc/change.txt	2015-01-27 18:41:27.840005417 +0100
3ef2ca
***************
3ef2ca
*** 1100,1110 ****
3ef2ca
  2. 10 numbered registers "0 to "9
3ef2ca
  3. The small delete register "-
3ef2ca
  4. 26 named registers "a to "z or "A to "Z
3ef2ca
! 5. four read-only registers ":, "., "% and "#
3ef2ca
! 6. the expression register "=
3ef2ca
! 7. The selection and drop registers "*, "+ and "~ 
3ef2ca
! 8. The black hole register "_
3ef2ca
! 9. Last search pattern register "/
3ef2ca
  
3ef2ca
  1. Unnamed register ""				*quote_quote* *quotequote*
3ef2ca
  Vim fills this register with text deleted with the "d", "c", "s", "x" commands
3ef2ca
--- 1103,1114 ----
3ef2ca
  2. 10 numbered registers "0 to "9
3ef2ca
  3. The small delete register "-
3ef2ca
  4. 26 named registers "a to "z or "A to "Z
3ef2ca
! 5. three read-only registers ":, "., "%
3ef2ca
! 7. alternate buffer register "#
3ef2ca
! 7. the expression register "=
3ef2ca
! 8. The selection and drop registers "*, "+ and "~ 
3ef2ca
! 9. The black hole register "_
3ef2ca
! 10. Last search pattern register "/
3ef2ca
  
3ef2ca
  1. Unnamed register ""				*quote_quote* *quotequote*
3ef2ca
  Vim fills this register with text deleted with the "d", "c", "s", "x" commands
3ef2ca
***************
3ef2ca
*** 1131,1136 ****
3ef2ca
--- 1135,1142 ----
3ef2ca
  made for the delete operator with these movement commands: |%|, |(|, |)|, |`|,
3ef2ca
  |/|, |?|, |n|, |N|, |{| and |}|.  Register "1 is always used then (this is Vi
3ef2ca
  compatible).  The "- register is used as well if the delete is within a line.
3ef2ca
+ Note that these characters may be mapped.  E.g. |%| is mapped by the matchit
3ef2ca
+ plugin.
3ef2ca
     With each successive deletion or change, Vim shifts the previous contents
3ef2ca
  of register 1 into register 2, 2 into 3, and so forth, losing the previous
3ef2ca
  contents of register 9.
3ef2ca
***************
3ef2ca
*** 1148,1154 ****
3ef2ca
  to their previous contents.  When the '>' flag is present in 'cpoptions' then
3ef2ca
  a line break is inserted before the appended text.
3ef2ca
  
3ef2ca
! 5. Read-only registers ":, "., "% and "#
3ef2ca
  These are '%', '#', ':' and '.'.  You can use them only with the "p", "P",
3ef2ca
  and ":put" commands and with CTRL-R.  {not in Vi}
3ef2ca
  						*quote_.* *quote.* *E29*
3ef2ca
--- 1154,1160 ----
3ef2ca
  to their previous contents.  When the '>' flag is present in 'cpoptions' then
3ef2ca
  a line break is inserted before the appended text.
3ef2ca
  
3ef2ca
! 5. Read-only registers ":, ". and "%
3ef2ca
  These are '%', '#', ':' and '.'.  You can use them only with the "p", "P",
3ef2ca
  and ":put" commands and with CTRL-R.  {not in Vi}
3ef2ca
  						*quote_.* *quote.* *E29*
3ef2ca
***************
3ef2ca
*** 1159,1166 ****
3ef2ca
  		('textwidth' and other options affect what is inserted).
3ef2ca
  							*quote_%* *quote%*
3ef2ca
  	"%	Contains the name of the current file.
3ef2ca
- 							*quote_#* *quote#*
3ef2ca
- 	"#	Contains the name of the alternate file.
3ef2ca
  						*quote_:* *quote:* *E30*
3ef2ca
  	":	Contains the most recent executed command-line.  Example: Use
3ef2ca
  		"@:" to repeat the previous command-line command.
3ef2ca
--- 1165,1170 ----
3ef2ca
***************
3ef2ca
*** 1169,1176 ****
3ef2ca
  		the command was completely from a mapping.
3ef2ca
  		{not available when compiled without the |+cmdline_hist|
3ef2ca
  		feature}
3ef2ca
  
3ef2ca
! 6. Expression register "=			*quote_=* *quote=* *@=*
3ef2ca
  This is not really a register that stores text, but is a way to use an
3ef2ca
  expression in commands which use a register.  The expression register is
3ef2ca
  read-only; you cannot put text into it.  After the '=', the cursor moves to
3ef2ca
--- 1173,1195 ----
3ef2ca
  		the command was completely from a mapping.
3ef2ca
  		{not available when compiled without the |+cmdline_hist|
3ef2ca
  		feature}
3ef2ca
+ 							*quote_#* *quote#*
3ef2ca
+ 6. Alternate file register "#
3ef2ca
+ Contains the name of the alternate file for the current window.  It will
3ef2ca
+ change how the |CTRL-^| command works.
3ef2ca
+ This register is writable, mainly to allow for restoring it after a plugin has
3ef2ca
+ changed it.  It accepts buffer number: >
3ef2ca
+     let altbuf = bufnr(@#)
3ef2ca
+     ...
3ef2ca
+     let @# = altbuf
3ef2ca
+ It will give error |E86| if you pass buffer number and this buffer does not
3ef2ca
+ exist.
3ef2ca
+ It can also accept a match with an existing buffer name: >
3ef2ca
+     let @# = 'buffer_name'
3ef2ca
+ Error |E93| if there is more than one buffer matching the given name or |E94|
3ef2ca
+ if none of buffers matches the given name.
3ef2ca
  
3ef2ca
! 7. Expression register "=			*quote_=* *quote=* *@=*
3ef2ca
  This is not really a register that stores text, but is a way to use an
3ef2ca
  expression in commands which use a register.  The expression register is
3ef2ca
  read-only; you cannot put text into it.  After the '=', the cursor moves to
3ef2ca
***************
3ef2ca
*** 1191,1197 ****
3ef2ca
  characters.  If the String ends in a <NL>, it is regarded as a linewise
3ef2ca
  register.  {not in Vi}
3ef2ca
  
3ef2ca
! 7. Selection and drop registers "*, "+ and "~ 
3ef2ca
  Use these registers for storing and retrieving the selected text for the GUI.
3ef2ca
  See |quotestar| and |quoteplus|.  When the clipboard is not available or not
3ef2ca
  working, the unnamed register is used instead.  For Unix systems the clipboard
3ef2ca
--- 1210,1216 ----
3ef2ca
  characters.  If the String ends in a <NL>, it is regarded as a linewise
3ef2ca
  register.  {not in Vi}
3ef2ca
  
3ef2ca
! 8. Selection and drop registers "*, "+ and "~ 
3ef2ca
  Use these registers for storing and retrieving the selected text for the GUI.
3ef2ca
  See |quotestar| and |quoteplus|.  When the clipboard is not available or not
3ef2ca
  working, the unnamed register is used instead.  For Unix systems the clipboard
3ef2ca
***************
3ef2ca
*** 1213,1224 ****
3ef2ca
  Note: The "~ register is only used when dropping plain text onto Vim.
3ef2ca
  Drag'n'drop of URI lists is handled internally.
3ef2ca
  
3ef2ca
! 8. Black hole register "_				*quote_*
3ef2ca
  When writing to this register, nothing happens.  This can be used to delete
3ef2ca
  text without affecting the normal registers.  When reading from this register,
3ef2ca
  nothing is returned.  {not in Vi}
3ef2ca
  
3ef2ca
! 9. Last search pattern register	"/			*quote_/* *quote/*
3ef2ca
  Contains the most recent search-pattern.  This is used for "n" and 'hlsearch'.
3ef2ca
  It is writable with `:let`, you can change it to have 'hlsearch' highlight
3ef2ca
  other matches without actually searching.  You can't yank or delete into this
3ef2ca
--- 1232,1243 ----
3ef2ca
  Note: The "~ register is only used when dropping plain text onto Vim.
3ef2ca
  Drag'n'drop of URI lists is handled internally.
3ef2ca
  
3ef2ca
! 9. Black hole register "_				*quote_*
3ef2ca
  When writing to this register, nothing happens.  This can be used to delete
3ef2ca
  text without affecting the normal registers.  When reading from this register,
3ef2ca
  nothing is returned.  {not in Vi}
3ef2ca
  
3ef2ca
! 10. Last search pattern register	"/			*quote_/* *quote/*
3ef2ca
  Contains the most recent search-pattern.  This is used for "n" and 'hlsearch'.
3ef2ca
  It is writable with `:let`, you can change it to have 'hlsearch' highlight
3ef2ca
  other matches without actually searching.  You can't yank or delete into this
3ef2ca
*** ../vim-7.4.604/src/ops.c	2015-01-27 13:22:17.176885347 +0100
3ef2ca
--- src/ops.c	2015-01-27 18:33:06.813476985 +0100
3ef2ca
***************
3ef2ca
*** 856,866 ****
3ef2ca
      if (       (regname > 0 && ASCII_ISALNUM(regname))
3ef2ca
  	    || (!writing && vim_strchr((char_u *)
3ef2ca
  #ifdef FEAT_EVAL
3ef2ca
! 				    "/.%#:="
3ef2ca
  #else
3ef2ca
! 				    "/.%#:"
3ef2ca
  #endif
3ef2ca
  					, regname) != NULL)
3ef2ca
  	    || regname == '"'
3ef2ca
  	    || regname == '-'
3ef2ca
  	    || regname == '_'
3ef2ca
--- 856,867 ----
3ef2ca
      if (       (regname > 0 && ASCII_ISALNUM(regname))
3ef2ca
  	    || (!writing && vim_strchr((char_u *)
3ef2ca
  #ifdef FEAT_EVAL
3ef2ca
! 				    "/.%:="
3ef2ca
  #else
3ef2ca
! 				    "/.%:"
3ef2ca
  #endif
3ef2ca
  					, regname) != NULL)
3ef2ca
+ 	    || regname == '#'
3ef2ca
  	    || regname == '"'
3ef2ca
  	    || regname == '-'
3ef2ca
  	    || regname == '_'
3ef2ca
***************
3ef2ca
*** 6514,6519 ****
3ef2ca
--- 6515,6541 ----
3ef2ca
  	return;
3ef2ca
      }
3ef2ca
  
3ef2ca
+     if (name == '#')
3ef2ca
+     {
3ef2ca
+ 	buf_T	*buf;
3ef2ca
+ 
3ef2ca
+ 	if (VIM_ISDIGIT(*str))
3ef2ca
+ 	{
3ef2ca
+ 	    int	num = atoi((char *)str);
3ef2ca
+ 
3ef2ca
+ 	    buf = buflist_findnr(num);
3ef2ca
+ 	    if (buf == NULL)
3ef2ca
+ 		EMSGN(_(e_nobufnr), (long)num);
3ef2ca
+ 	}
3ef2ca
+ 	else
3ef2ca
+ 	    buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str),
3ef2ca
+ 							 TRUE, FALSE, FALSE));
3ef2ca
+ 	if (buf == NULL)
3ef2ca
+ 	    return;
3ef2ca
+ 	curwin->w_alt_fnum = buf->b_fnum;
3ef2ca
+ 	return;
3ef2ca
+     }
3ef2ca
+ 
3ef2ca
  #ifdef FEAT_EVAL
3ef2ca
      if (name == '=')
3ef2ca
      {
3ef2ca
*** ../vim-7.4.604/src/buffer.c	2015-01-07 13:31:48.886661739 +0100
3ef2ca
--- src/buffer.c	2015-01-27 18:19:29.334392632 +0100
3ef2ca
***************
3ef2ca
*** 1150,1156 ****
3ef2ca
  	{
3ef2ca
  	    /* don't warn when deleting */
3ef2ca
  	    if (!unload)
3ef2ca
! 		EMSGN(_("E86: Buffer %ld does not exist"), count);
3ef2ca
  	}
3ef2ca
  	else if (dir == FORWARD)
3ef2ca
  	    EMSG(_("E87: Cannot go beyond last buffer"));
3ef2ca
--- 1150,1156 ----
3ef2ca
  	{
3ef2ca
  	    /* don't warn when deleting */
3ef2ca
  	    if (!unload)
3ef2ca
! 		EMSGN(_(e_nobufnr), count);
3ef2ca
  	}
3ef2ca
  	else if (dir == FORWARD)
3ef2ca
  	    EMSG(_("E87: Cannot go beyond last buffer"));
3ef2ca
*** ../vim-7.4.604/src/globals.h	2015-01-14 12:44:38.407422077 +0100
3ef2ca
--- src/globals.h	2015-01-27 18:19:24.294447531 +0100
3ef2ca
***************
3ef2ca
*** 1571,1576 ****
3ef2ca
--- 1571,1577 ----
3ef2ca
  EXTERN char_u e_intern2[]	INIT(= N_("E685: Internal error: %s"));
3ef2ca
  EXTERN char_u e_maxmempat[]	INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
3ef2ca
  EXTERN char_u e_emptybuf[]	INIT(= N_("E749: empty buffer"));
3ef2ca
+ EXTERN char_u e_nobufnr[]	INIT(= N_("E86: Buffer %ld does not exist"));
3ef2ca
  
3ef2ca
  #ifdef FEAT_EX_EXTRA
3ef2ca
  EXTERN char_u e_invalpat[]	INIT(= N_("E682: Invalid search pattern or delimiter"));
3ef2ca
*** ../vim-7.4.604/src/version.c	2015-01-27 17:11:55.690558815 +0100
3ef2ca
--- src/version.c	2015-01-27 17:15:24.132287083 +0100
3ef2ca
***************
3ef2ca
*** 743,744 ****
3ef2ca
--- 743,746 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     605,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
All true wisdom is found on T-shirts.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///