From: Christoffer Aasted Date: Thu, 18 Jun 2026 19:43:44 +0000 (+0000) Subject: patch 9.2.0677: Cannot clear the alternate file register # X-Git-Tag: v9.2.0677^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;ds=inline;p=thirdparty%2Fvim.git patch 9.2.0677: Cannot clear the alternate file register # Problem: Cannot clear the alternate file register # Solution: Allow to clear it (Christoffer Aasted) closes: #20537 Signed-off-by: Christoffer Aasted Signed-off-by: Christian Brabandt --- diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index b3448bf892..afcdca16b0 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1,4 +1,4 @@ -*change.txt* For Vim version 9.2. Last change: 2026 May 31 +*change.txt* For Vim version 9.2. Last change: 2026 Jun 18 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1334,19 +1334,19 @@ and ":put" commands and with CTRL-R. feature} *quote_#* *quote#* 6. Alternate file register "# -Contains the name of the alternate file for the current window. It will -change how the |CTRL-^| command works. -This register is writable, mainly to allow for restoring it after a plugin has -changed it. It accepts buffer number: > - let altbuf = bufnr(@#) - ... - let @# = altbuf -It will give error |E86| if you pass buffer number and this buffer does not -exist. -It can also accept a match with an existing buffer name: > +Contains the |alternate-file| name for current window +This register is writeable and changes which buffer CTRL-^ enters. +A String is matched against existing buffer names, like |:buffer|: > let @# = 'buffer_name' -Error |E93| if there is more than one buffer matching the given name or |E94| -if none of buffers matches the given name. +Also supports using buffer number and |file-pattern|. + +Throws + |E86| when the buffer number does not exist + |E93| when more than one buffer matches + |E94| when none match + +Clear the register with empty String: > + let @# = '' 7. Expression register "= *quote_=* *quote=* *@=* This is not really a register that stores text, but is a way to use an diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt index a7778b5fef..a515589de5 100644 --- a/runtime/doc/version9.txt +++ b/runtime/doc/version9.txt @@ -1,4 +1,4 @@ -*version9.txt* For Vim version 9.2. Last change: 2026 Jun 13 +*version9.txt* For Vim version 9.2. Last change: 2026 Jun 18 VIM REFERENCE MANUAL by Bram Moolenaar @@ -52687,6 +52687,7 @@ Changed ~ - Rewrite the clientserver socketserver backend to use channels and JSON. - During |complete()|-triggered completion, CTRL-N and CTRL-P are now subject to insert-mode mappings. +- It is possible to clear the alternate file register |quote#|. *added-9.3* diff --git a/src/register.c b/src/register.c index 358fe6454f..971cd70891 100644 --- a/src/register.c +++ b/src/register.c @@ -3152,6 +3152,12 @@ write_reg_contents_ex( if (name == '#') { + if (len == 0) + { + curwin->w_alt_fnum = 0; // clear altfile + return; + } + buf_T *buf; if (VIM_ISDIGIT(*str)) diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim index bb1dd31f3e..1bf3d6f607 100644 --- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -396,6 +396,11 @@ func Test_set_register() call assert_equal('Xfile_alt_1', getreg('#')) call setreg('#', b2) call assert_equal('Xfile_alt_2', getreg('#')) + call setreg('#', '') + call assert_equal('', getreg('#')) + call setreg('#', 'alt_1') + let @# = '' + call assert_equal('', getreg('#')) let ab = 'regwrite' call setreg('=', '') diff --git a/src/version.c b/src/version.c index 5aa9fde1c1..d2e01aecbc 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 677, /**/ 676, /**/