[vim/vim] Add new "custom" register (PR #18642)

35 views
Skip to first unread message

Foxe Chen

unread,
Oct 26, 2025, 9:11:03 PM (4 days ago) Oct 26
to vim/vim, Subscribed

This is based off of the now defunct clipboard provider feature. I've decided on "&" being the custom register, which can be controlled via the 'regputfunc' and 'regyankfunc' options. This is based in register.c, instead of clipboard.c, so it shouldn't break any clipboard code.

I didn't use the existing "+" or "*" registers since I think this and those registers should handle different things, instead of trying to fit them together. Also makes things a bit simpler


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18642

Commit Summary

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642@github.com>

Foxe Chen

unread,
Oct 26, 2025, 10:08:30 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/9f6338d2cc86c27034d53740d72de9b4e8f80a3c/after/d12cdea1ea8c6c535ca7202105f46b9860ad21fd@github.com>

Foxe Chen

unread,
Oct 26, 2025, 10:23:18 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 0825a1c rename to 'regreqfunc' and 'regsetfunc'

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/d12cdea1ea8c6c535ca7202105f46b9860ad21fd/after/0825a1cf37c3134b0d4dae214f67a3f09684c0cc@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:17:05 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/0825a1cf37c3134b0d4dae214f67a3f09684c0cc/after/13d64d58bb7b60919656ebe31897a715c194155b@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:20:26 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/13d64d58bb7b60919656ebe31897a715c194155b/after/3a4a86dfbfebf2a012df0b7ed3b81486780bb532@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:22:48 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/3a4a86dfbfebf2a012df0b7ed3b81486780bb532/after/a612b4c5b71389209e62fb78c50495614f72d2df@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:32:24 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/a612b4c5b71389209e62fb78c50495614f72d2df/after/afe7e8b579a126843bf2c14724a709b35f4d6190@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:47:09 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/afe7e8b579a126843bf2c14724a709b35f4d6190/after/5df943b2794c73627ade7dd5a66d3e30bfa27a67@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:52:27 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/5df943b2794c73627ade7dd5a66d3e30bfa27a67/after/37c4f0377eeb232d3935a41610e4d1ecf9e836a3@github.com>

Foxe Chen

unread,
Oct 26, 2025, 11:56:00 PM (4 days ago) Oct 26
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 68c6791 don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/37c4f0377eeb232d3935a41610e4d1ecf9e836a3/after/68c679147aed0b3e2d84bc73102e567d040e67fd@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:02:57 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • facbbd4 don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/68c679147aed0b3e2d84bc73102e567d040e67fd/after/facbbd453feda6e0fdb6c12fb3bd54b93d819b7e@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:03:38 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 2b05722 don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/facbbd453feda6e0fdb6c12fb3bd54b93d819b7e/after/2b05722e5543297d3275d4c27e263c23522b034c@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:04:54 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • a655ef2 don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/2b05722e5543297d3275d4c27e263c23522b034c/after/a655ef2c181029f639a7ae44db4fe237e4263351@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:05:34 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 8f5730f don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/a655ef2c181029f639a7ae44db4fe237e4263351/after/8f5730f87e28d75c3c22404de3025a43d2f4d4ff@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:22:01 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • a85528a don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/8f5730f87e28d75c3c22404de3025a43d2f4d4ff/after/a85528a5a1afa011b63b3139d9b7234515d4905c@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:29:38 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • f462aa6 don't save custom register in viminfo

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/a85528a5a1afa011b63b3139d9b7234515d4905c/after/f462aa6574b4bf88988fcc0ade6c72e7f75a3990@github.com>

Foxe Chen

unread,
Oct 27, 2025, 1:05:02 AM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/f462aa6574b4bf88988fcc0ade6c72e7f75a3990/after/dad8fca79c08518056f0429ef68429c6bebed908@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:39:27 PM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/dad8fca79c08518056f0429ef68429c6bebed908/after/2f4f987d9ce98f1ae65c96c18a1c08d37b14a342@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:45:46 PM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • d6e9ab6 document how register type is automatically chosen

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/2f4f987d9ce98f1ae65c96c18a1c08d37b14a342/after/d6e9ab6eaaca5ab5105a156678701322b8111a6f@github.com>

Foxe Chen

unread,
Oct 27, 2025, 12:51:53 PM (4 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/d6e9ab6eaaca5ab5105a156678701322b8111a6f/after/1f1eda088b04ba40b2884587539d53ca7866ca4e@github.com>

Foxe Chen

unread,
Oct 27, 2025, 8:13:59 PM (3 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

  • 863533a document that +eval feature is required

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/1f1eda088b04ba40b2884587539d53ca7866ca4e/after/863533a9948334a0c17aaafa0dc2c1a7d5897641@github.com>

Foxe Chen

unread,
Oct 27, 2025, 8:23:38 PM (3 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/863533a9948334a0c17aaafa0dc2c1a7d5897641/after/3e2b9d0cd6d0d63eb4630456098b8648d546b1f1@github.com>

Foxe Chen

unread,
Oct 27, 2025, 8:30:55 PM (3 days ago) Oct 27
to vim/vim, Push

@64-bitman pushed 12 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/3e2b9d0cd6d0d63eb4630456098b8648d546b1f1/after/91f23e8bb711f04f3f9c8bf706992cea6315cd47@github.com>

Foxe Chen

unread,
Oct 27, 2025, 9:24:20 PM (3 days ago) Oct 27
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18642)

I think this is ready


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/c3454031304@github.com>

dkearns

unread,
Oct 28, 2025, 8:38:12 AM (3 days ago) Oct 28
to vim/vim, Subscribed

@dkearns commented on this pull request.

Thanks. I just left a few comments after a quick read through the help.


In runtime/doc/change.txt:

> @@ -1401,6 +1402,15 @@ register.  The search direction is available in |v:searchforward|.
 Note that the value is restored when returning from a function
 |function-search-undo|.
 
+11. Custom register			"&		*quote_&* *quote&*
+Acts like a numbered or named register, but when the register is yanked to,
⬇️ Suggested change
-Acts like a numbered or named register, but when the register is yanked to,
+Acts like a named register, but when writing to the register
  • Numbered registers are different and I don't think mentioning them here adds anything.
  • I'm not too keen on the existing language but "fill" seems to be the term used for setting a register value, though "write" is also used.

In runtime/doc/change.txt:

> @@ -1401,6 +1402,15 @@ register.  The search direction is available in |v:searchforward|.
 Note that the value is restored when returning from a function
 |function-search-undo|.
 
+11. Custom register			"&		*quote_&* *quote&*
+Acts like a numbered or named register, but when the register is yanked to,
+the callback specified in 'regsetfunc' is called, and when it is put, the
⬇️ Suggested change
-the callback specified in 'regsetfunc' is called, and when it is put, the
+the callback specified in 'regsetfunc' is called, and when it is read, the

In runtime/doc/change.txt:

> +specified (empty), then the register simply acts like another numbered or
+named register.  This register is not saved in the |viminfo| file and the
⬇️ Suggested change
-specified (empty), then the register simply acts like another numbered or
-named register.  This register is not saved in the |viminfo| file and the
+specified (empty), then the register simply acts like another 
+named register.  This register is not saved in the |viminfo| file and the

In runtime/doc/options.txt:

> @@ -7033,6 +7033,64 @@ A jump table for the options with a short description can be found at |Q_op|.
 	many states.  This should prevent Vim from hanging on a combination of
 	a complex pattern with long text.
 
+						*'regreqfunc* *'rrf'*
+'regreqfunc' 'rrf'	string	(default "")

Shouldn't this be named 'reggetfunc'?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3388555435@github.com>

dkearns

unread,
Oct 28, 2025, 8:39:04 AM (3 days ago) Oct 28
to vim/vim, Subscribed

@dkearns commented on this pull request.

In runtime/doc/options.txt:

> @@ -7033,6 +7033,64 @@ A jump table for the options with a short description can be found at |Q_op|.
 	many states.  This should prevent Vim from hanging on a combination of
 	a complex pattern with long text.
 
+						*'regreqfunc* *'rrf'*
⬇️ Suggested change
-						*'regreqfunc* *'rrf'*
+						*'regreqfunc'* *'rrf'*


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3388565723@github.com>

Foxe Chen

unread,
Oct 28, 2025, 8:42:35 AM (3 days ago) Oct 28
to vim/vim, Subscribed

@64-bitman commented on this pull request.


In runtime/doc/options.txt:

> @@ -7033,6 +7033,64 @@ A jump table for the options with a short description can be found at |Q_op|.
 	many states.  This should prevent Vim from hanging on a combination of
 	a complex pattern with long text.
 
+						*'regreqfunc* *'rrf'*
+'regreqfunc' 'rrf'	string	(default "")

In the clipboard source code Vim uses "request" as the keyword for accessing the clipboard, so I did the same for here


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3388578437@github.com>

dkearns

unread,
Oct 28, 2025, 10:42:04 AM (3 days ago) Oct 28
to vim/vim, Subscribed

@dkearns commented on this pull request.


In runtime/doc/options.txt:

> @@ -7033,6 +7033,64 @@ A jump table for the options with a short description can be found at |Q_op|.
 	many states.  This should prevent Vim from hanging on a combination of
 	a complex pattern with long text.
 
+						*'regreqfunc* *'rrf'*
+'regreqfunc' 'rrf'	string	(default "")

The feature isn't related to the clipboard anymore is it? Irrespective, I think it's more important to be consistent with setreg()/getreg() naming.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3389091004@github.com>

Foxe Chen

unread,
Oct 28, 2025, 12:36:18 PM (3 days ago) Oct 28
to vim/vim, Subscribed

@64-bitman commented on this pull request.


In runtime/doc/options.txt:

> @@ -7033,6 +7033,64 @@ A jump table for the options with a short description can be found at |Q_op|.
 	many states.  This should prevent Vim from hanging on a combination of
 	a complex pattern with long text.
 
+						*'regreqfunc* *'rrf'*
+'regreqfunc' 'rrf'	string	(default "")

I suppose so, I'll change it. thanks


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3389745661@github.com>

Foxe Chen

unread,
Oct 28, 2025, 4:20:34 PM (3 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/91f23e8bb711f04f3f9c8bf706992cea6315cd47/after/0cba9584596f5da0eab5f9b4b323345f2a73d581@github.com>

Foxe Chen

unread,
Oct 28, 2025, 4:23:59 PM (3 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/0cba9584596f5da0eab5f9b4b323345f2a73d581/after/ae792b8f357b2e6831b9fd01bba13e6eba97a58b@github.com>

Foxe Chen

unread,
Oct 28, 2025, 4:24:01 PM (3 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/ae792b8f357b2e6831b9fd01bba13e6eba97a58b/after/909b92b76b313970d62cfb556adc4bb0ab2f54b1@github.com>

Foxe Chen

unread,
Oct 28, 2025, 4:24:50 PM (3 days ago) Oct 28
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18642)

I think this is ready


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/c3458339033@github.com>

zeertzjq

unread,
Oct 28, 2025, 8:02:44 PM (2 days ago) Oct 28
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In runtime/doc/options.txt:

> +		set reggetfunc=GetFunc
+<
+	The value can be the name of a function, a |lambda| or a |Funcref|.  See
+	|option-value-function| for more information.
+	This option cannot be set from a |modeline| or in the |sandbox|, for
+	security reasons.
+	Additionally it is not allowed to change the buffer
+	text in the function, see |textlock|.
+
+						*'regsetfunc* *'rsf'*
+'regsetfunc' 'rsf'	string	(default "")
+			global
+			{not available when compiled without the |+eval|
+			feature}
+	This option specifies a function to be used whenever the custom
+	register |quote_&| is written inclusing |setreg()|. The function

What is "inclusing"?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3391272743@github.com>

zeertzjq

unread,
Oct 28, 2025, 8:03:59 PM (2 days ago) Oct 28
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/register.c:

> +}
+
+/*
+ * Call the function specified in 'reggetfunc'. Should be called to update the
+ * custom register before being accessed.
+ */
+    static void
+call_reggetfunc(void)
+{
+    typval_T	rettv;
+    typval_T	argvars[1];
+    int		ret;
+    char_u	*reg_type;
+    list_T	*lines;
+
+    // If 'reqreqfunc' option is empty, then do nothing and treat the register
⬇️ Suggested change
-    // If 'reqreqfunc' option is empty, then do nothing and treat the register
+    // If 'reqgetfunc' option is empty, then do nothing and treat the register


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3391275634@github.com>

Foxe Chen

unread,
Oct 28, 2025, 8:18:33 PM (2 days ago) Oct 28
to vim/vim, Subscribed

@64-bitman commented on this pull request.


In runtime/doc/options.txt:

> +		set reggetfunc=GetFunc
+<
+	The value can be the name of a function, a |lambda| or a |Funcref|.  See
+	|option-value-function| for more information.
+	This option cannot be set from a |modeline| or in the |sandbox|, for
+	security reasons.
+	Additionally it is not allowed to change the buffer
+	text in the function, see |textlock|.
+
+						*'regsetfunc* *'rsf'*
+'regsetfunc' 'rsf'	string	(default "")
+			global
+			{not available when compiled without the |+eval|
+			feature}
+	This option specifies a function to be used whenever the custom
+	register |quote_&| is written inclusing |setreg()|. The function

typo


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3391299617@github.com>

Foxe Chen

unread,
Oct 28, 2025, 8:19:01 PM (2 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/909b92b76b313970d62cfb556adc4bb0ab2f54b1/after/33d3a62512dedd2b20eddfd8aac3079c6f7289ca@github.com>

zeertzjq

unread,
Oct 28, 2025, 8:22:06 PM (2 days ago) Oct 28
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In runtime/doc/options.txt:

> +		set reggetfunc=GetFunc
+<
+	The value can be the name of a function, a |lambda| or a |Funcref|.  See
+	|option-value-function| for more information.
+	This option cannot be set from a |modeline| or in the |sandbox|, for
+	security reasons.
+	Additionally it is not allowed to change the buffer
+	text in the function, see |textlock|.
+
+						*'regsetfunc* *'rsf'*
+'regsetfunc' 'rsf'	string	(default "")
+			global
+			{not available when compiled without the |+eval|
+			feature}
+	This option specifies a function to be used whenever the custom
+	register |quote_&| is written including |setreg()|. The function
⬇️ Suggested change
-	register |quote_&| is written including |setreg()|. The function
+	register |quote_&| is written including |setreg()|.  The function


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3391306205@github.com>

Foxe Chen

unread,
Oct 28, 2025, 8:24:02 PM (2 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/33d3a62512dedd2b20eddfd8aac3079c6f7289ca/after/897c79a691073b089cab8eecb2fc13568ab2d6a4@github.com>

zeertzjq

unread,
Oct 28, 2025, 8:24:09 PM (2 days ago) Oct 28
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In runtime/doc/options.txt:

> +	Additionally it is not allowed to change the buffer
+	text in the function, see |textlock|.
⬇️ Suggested change
-	Additionally it is not allowed to change the buffer
-	text in the function, see |textlock|.
+	Additionally it is not allowed to change the buffer text in the
+	function, see |textlock|.

In runtime/doc/options.txt:

> +	Additionally it is not allowed to change the buffer
+	text in the function, see |textlock|.
⬇️ Suggested change
-	Additionally it is not allowed to change the buffer
-	text in the function, see |textlock|.
+	Additionally it is not allowed to change the buffer text in the
+	function, see |textlock|.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3391308113@github.com>

Foxe Chen

unread,
Oct 28, 2025, 8:24:57 PM (2 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/897c79a691073b089cab8eecb2fc13568ab2d6a4/after/0b94d1e905828667ae1ec68d36dbd033da9cdd2e@github.com>

Foxe Chen

unread,
Oct 28, 2025, 11:43:10 PM (2 days ago) Oct 28
to vim/vim, Push

@64-bitman pushed 15 commits.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/0b94d1e905828667ae1ec68d36dbd033da9cdd2e/after/8dabf65b9961b84fe88f0c178c4ce018720f0434@github.com>

Foxe Chen

unread,
Oct 28, 2025, 11:44:30 PM (2 days ago) Oct 28
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18642)

Made it so that there are two custom registers ("^" and "&"). Did this since OSC 52 supports multiple selections on X11/Wayland on some terminals.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/c3459499282@github.com>

D. Ben Knoble

unread,
Oct 30, 2025, 5:51:41 PM (11 hours ago) Oct 30
to vim/vim, Subscribed

@benknoble commented on this pull request.


In runtime/doc/options.txt:

> +	This options specifies a function to be used whenever the custom
+	registers |quote_&|, |quote_^| are read.  The function takes no
+	arguments, and should return a |tuple| or |list| containing the
+	following elements in order:
+		1. The register name.
+		2. The register type, conforming to |setreg()|, that the
+		   register will be set to.
+		3. A |list| containing a list of strings to set the register
+		   to.
+	Note that this function is not called on |:registers| or |:display|.
+
+	The following is a possible example use of this option:
+>vim
+		function GetFunc(reg)
+		    echom "Updating register " .. a:reg
+		    return ('l', readfile('stuff.txt'))
+		endfunction
+
+		set reggetfunc=GetFunc

I'm lost: how does reggetfunc know which register it's reading if it takes no argument? And yet the examples does… And why does the example only return 3 elements instead of 2? TIL that tuples are available in Vimscript, though.

It might help to see an actual use case for this.

In particular, why is that reading "& will mutate a different register? That seems… icky. I would prefer that reading it simply executes the callback and gives that value to whatever needs the register (a put or expression, presumably).

The docs seem to indicate that reading one of these will mutate another register, but that's not what happens at all. The docs really need to accurately describe the behavior, and a motivating use makes a much better example.


In runtime/doc/options.txt:

> +	nothing and takes two arguments:
+		1. The register name.
+		2. The register type being used, conforming to |getregtype()|.
+		3. A list of strings being written.

Similar counting comments, of course.


In src/register.c:

> +    if ((long *)args->os_varp == (long *)&p_rgf)
+	ret = option_set_callback_func(p_rgf, &rgf_cb);
+    else
+	ret = option_set_callback_func(p_rsf, &rsf_cb);

nit: indentation looks inconsistent in changes here.


In src/structs.h:

> +
 #ifdef FEAT_DND
-# define TILDE_REGISTER		(PLUS_REGISTER + 1)
+# define TILDE_REGISTER	(PLUS_REGISTER + 1)

nit: unnecessary whitespace changes?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3401770943@github.com>

Foxe Chen

unread,
Oct 30, 2025, 8:53:23 PM (8 hours ago) Oct 30
to vim/vim, Subscribed

@64-bitman commented on this pull request.


In runtime/doc/options.txt:

> +	This options specifies a function to be used whenever the custom
+	registers |quote_&|, |quote_^| are read.  The function takes no
+	arguments, and should return a |tuple| or |list| containing the
+	following elements in order:
+		1. The register name.
+		2. The register type, conforming to |setreg()|, that the
+		   register will be set to.
+		3. A |list| containing a list of strings to set the register
+		   to.
+	Note that this function is not called on |:registers| or |:display|.
+
+	The following is a possible example use of this option:
+>vim
+		function GetFunc(reg)
+		    echom "Updating register " .. a:reg
+		    return ('l', readfile('stuff.txt'))
+		endfunction
+
+		set reggetfunc=GetFunc

I'm lost: how does reggetfunc know which register it's reading if it takes no argument? And yet the examples does… And why does the example only return 3 elements instead of 2? TIL that tuples are available in Vimscript, though.

I just messed up the documentation, I'll fix this later. Thanks for catching

The docs seem to indicate that reading one of these will mutate another register, but that's not what happens at all. The docs really need to accurately describe the behavior, and a motivating use makes a much better example.

I'm not sure what you mean by "mutate another register". If the "&yy is pressed, then it'll yank to the & register, same for the ^ register. I created this PR for the OSC52 feature, but from what ChatGPT said, there seems to be a bunch of other uses as well. I don't think we need to documentate it though, the user will find their way to this feature likely


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3402199066@github.com>

Foxe Chen

unread,
Oct 30, 2025, 9:01:29 PM (8 hours ago) Oct 30
to vim/vim, Subscribed

@64-bitman commented on this pull request.


In src/register.c:

> +    if ((long *)args->os_varp == (long *)&p_rgf)
+	ret = option_set_callback_func(p_rgf, &rgf_cb);
+    else
+	ret = option_set_callback_func(p_rsf, &rsf_cb);

I believe thats just Github doing weird things


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/review/3402207851@github.com>

Foxe Chen

unread,
Oct 30, 2025, 9:43:35 PM (7 hours ago) Oct 30
to vim/vim, Push

@64-bitman pushed 15 commits.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/8dabf65b9961b84fe88f0c178c4ce018720f0434/after/31409a834a63cd67bcc5b49d975bdb97169438a0@github.com>

Foxe Chen

unread,
Oct 30, 2025, 9:44:03 PM (7 hours ago) Oct 30
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/31409a834a63cd67bcc5b49d975bdb97169438a0/after/1a434aa4cedabecd26bbbd2782410ff2c7d04548@github.com>

Foxe Chen

unread,
Oct 30, 2025, 9:45:40 PM (7 hours ago) Oct 30
to vim/vim, Push

@64-bitman pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/before/1a434aa4cedabecd26bbbd2782410ff2c7d04548/after/7ccc3299be62aaecf583b5a3ee61304ec7ecf709@github.com>

dkearns

unread,
3:23 AM (2 hours ago) 3:23 AM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#18642)

I have not yet found the time to have a good look at this PR but I think that some considerable thought should be given to the names used for these registers before they're cast in stone.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18642/c3471612703@github.com>

Reply all
Reply to author
Forward
0 new messages