Skip to content

Commit 34807a0

Browse files
brammooldouglaskayama
authored andcommitted
updated for version 7.4.605
Problem: The # register is not writable, it cannot be restored after jumping around. Solution: Make the # register writable. (Marcin Szamotulski)
1 parent 63597f3 commit 34807a0

5 files changed

Lines changed: 56 additions & 17 deletions

File tree

runtime/doc/change.txt

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*change.txt* For Vim version 7.4. Last change: 2014 Jun 26
1+
*change.txt* For Vim version 7.4. Last change: 2015 Jan 27
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1103,11 +1103,12 @@ There are nine types of registers: *registers* *E354*
11031103
2. 10 numbered registers "0 to "9
11041104
3. The small delete register "-
11051105
4. 26 named registers "a to "z or "A to "Z
1106-
5. four read-only registers ":, "., "% and "#
1107-
6. the expression register "=
1108-
7. The selection and drop registers "*, "+ and "~
1109-
8. The black hole register "_
1110-
9. Last search pattern register "/
1106+
5. three read-only registers ":, "., "%
1107+
7. alternate buffer register "#
1108+
7. the expression register "=
1109+
8. The selection and drop registers "*, "+ and "~
1110+
9. The black hole register "_
1111+
10. Last search pattern register "/
11111112

11121113
1. Unnamed register "" *quote_quote* *quotequote*
11131114
Vim fills this register with text deleted with the "d", "c", "s", "x" commands
@@ -1153,7 +1154,7 @@ letters to replace their previous contents or as uppercase letters to append
11531154
to their previous contents. When the '>' flag is present in 'cpoptions' then
11541155
a line break is inserted before the appended text.
11551156

1156-
5. Read-only registers ":, "., "% and "#
1157+
5. Read-only registers ":, ". and "%
11571158
These are '%', '#', ':' and '.'. You can use them only with the "p", "P",
11581159
and ":put" commands and with CTRL-R. {not in Vi}
11591160
*quote_.* *quote.* *E29*
@@ -1164,8 +1165,6 @@ and ":put" commands and with CTRL-R. {not in Vi}
11641165
('textwidth' and other options affect what is inserted).
11651166
*quote_%* *quote%*
11661167
"% Contains the name of the current file.
1167-
*quote_#* *quote#*
1168-
"# Contains the name of the alternate file.
11691168
*quote_:* *quote:* *E30*
11701169
": Contains the most recent executed command-line. Example: Use
11711170
"@:" to repeat the previous command-line command.
@@ -1174,8 +1173,23 @@ and ":put" commands and with CTRL-R. {not in Vi}
11741173
the command was completely from a mapping.
11751174
{not available when compiled without the |+cmdline_hist|
11761175
feature}
1177-
1178-
6. Expression register "= *quote_=* *quote=* *@=*
1176+
*quote_#* *quote#*
1177+
6. Alternate file register "#
1178+
Contains the name of the alternate file for the current window. It will
1179+
change how the |CTRL-^| command works.
1180+
This register is writable, mainly to allow for restoring it after a plugin has
1181+
changed it. It accepts buffer number: >
1182+
let altbuf = bufnr(@#)
1183+
...
1184+
let @# = altbuf
1185+
It will give error |E86| if you pass buffer number and this buffer does not
1186+
exist.
1187+
It can also accept a match with an existing buffer name: >
1188+
let @# = 'buffer_name'
1189+
Error |E93| if there is more than one buffer matching the given name or |E94|
1190+
if none of buffers matches the given name.
1191+
1192+
7. Expression register "= *quote_=* *quote=* *@=*
11791193
This is not really a register that stores text, but is a way to use an
11801194
expression in commands which use a register. The expression register is
11811195
read-only; you cannot put text into it. After the '=', the cursor moves to
@@ -1196,7 +1210,7 @@ If the "= register is used for the "p" command, the String is split up at <NL>
11961210
characters. If the String ends in a <NL>, it is regarded as a linewise
11971211
register. {not in Vi}
11981212

1199-
7. Selection and drop registers "*, "+ and "~
1213+
8. Selection and drop registers "*, "+ and "~
12001214
Use these registers for storing and retrieving the selected text for the GUI.
12011215
See |quotestar| and |quoteplus|. When the clipboard is not available or not
12021216
working, the unnamed register is used instead. For Unix systems the clipboard
@@ -1218,12 +1232,12 @@ GTK GUI}
12181232
Note: The "~ register is only used when dropping plain text onto Vim.
12191233
Drag'n'drop of URI lists is handled internally.
12201234

1221-
8. Black hole register "_ *quote_*
1235+
9. Black hole register "_ *quote_*
12221236
When writing to this register, nothing happens. This can be used to delete
12231237
text without affecting the normal registers. When reading from this register,
12241238
nothing is returned. {not in Vi}
12251239

1226-
9. Last search pattern register "/ *quote_/* *quote/*
1240+
10. Last search pattern register "/ *quote_/* *quote/*
12271241
Contains the most recent search-pattern. This is used for "n" and 'hlsearch'.
12281242
It is writable with `:let`, you can change it to have 'hlsearch' highlight
12291243
other matches without actually searching. You can't yank or delete into this

src/buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ do_buffer(action, start, dir, count, forceit)
11501150
{
11511151
/* don't warn when deleting */
11521152
if (!unload)
1153-
EMSGN(_("E86: Buffer %ld does not exist"), count);
1153+
EMSGN(_(e_nobufnr), count);
11541154
}
11551155
else if (dir == FORWARD)
11561156
EMSG(_("E87: Cannot go beyond last buffer"));

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,7 @@ EXTERN char_u e_nbreadonly[] INIT(= N_("E744: NetBeans does not allow changes in
15711571
EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
15721572
EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
15731573
EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer"));
1574+
EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %ld does not exist"));
15741575

15751576
#ifdef FEAT_EX_EXTRA
15761577
EXTERN char_u e_invalpat[] INIT(= N_("E682: Invalid search pattern or delimiter"));

src/ops.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,12 @@ valid_yank_reg(regname, writing)
856856
if ( (regname > 0 && ASCII_ISALNUM(regname))
857857
|| (!writing && vim_strchr((char_u *)
858858
#ifdef FEAT_EVAL
859-
"/.%#:="
859+
"/.%:="
860860
#else
861-
"/.%#:"
861+
"/.%:"
862862
#endif
863863
, regname) != NULL)
864+
|| regname == '#'
864865
|| regname == '"'
865866
|| regname == '-'
866867
|| regname == '_'
@@ -6514,6 +6515,27 @@ write_reg_contents_ex(name, str, maxlen, must_append, yank_type, block_len)
65146515
return;
65156516
}
65166517

6518+
if (name == '#')
6519+
{
6520+
buf_T *buf;
6521+
6522+
if (VIM_ISDIGIT(*str))
6523+
{
6524+
int num = atoi((char *)str);
6525+
6526+
buf = buflist_findnr(num);
6527+
if (buf == NULL)
6528+
EMSGN(_(e_nobufnr), (long)num);
6529+
}
6530+
else
6531+
buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str),
6532+
TRUE, FALSE, FALSE));
6533+
if (buf == NULL)
6534+
return;
6535+
curwin->w_alt_fnum = buf->b_fnum;
6536+
return;
6537+
}
6538+
65176539
#ifdef FEAT_EVAL
65186540
if (name == '=')
65196541
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
605,
744746
/**/
745747
604,
746748
/**/

0 commit comments

Comments
 (0)