Blame SOURCES/7.4.605

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