[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master c9a8a47ba4: Add new user option 'yank-transform-functions'
From: |
Stefan Monnier |
Subject: |
Re: master c9a8a47ba4: Add new user option 'yank-transform-functions' |
Date: |
Tue, 24 May 2022 12:15:13 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Lars Ingebrigtsen [2022-05-24 18:02:11] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> * lisp/simple.el (yank-transform-functions): New user option.
>>> (yank): Mention it.
>>
>> Hmm... why is this a user option?
>> [ Also, tho less importantly: Why is it a list of functions instead of
>> being symmetric with Emacs-28's `kill-transform-function`? ]
>>
>> Are users expected to be able to make use of this with Custom? How?
>
> It's a list of functions because it's a defcustom, really.
[ FWIW, `kill-transform-function` is also a defcustom, tho I'd argue it
would be better defined as a `defvar` for the same kinds of
reasons. ]
> I envisioned that people might be wanting to add other things to it to
> (say) record yanked text, for instance.
"Record yanked text" doesn't seem like a very compelling example.
I've never heard of anyone requesting such a feature or anything nearby.
And I'd expect such a feature to come in the form of a minor mode
instead (whose code then programmatically sets this var).
The problem with making it a defcustom is that packages can't
programmatically modify this var without risks of interfering
with Custom (e.g. the famous "CHANGED OUTSIDE CUSTOMIZE").
>>> +@lisp
>>> +(defun yank-with-clean-whitespace ()
>>> + (interactive)
>>> + (let ((yank-transform-functions
>>> + '(string-clean-whitespace)))
>>> + (call-interactively #'yank)))
>>> +@end lisp
>>> +@end defopt
>> This example doesn't call for a `defcustom` but for a `defvar`, no?
> It's in the lispref manual.
Right, but it's the only example I can find (and any uses of Custom on
this var during the above command may result in an incorrect value
being saved in the user's init file).
[ FWIW, this discussion is prompted by my trying to use this var in
`nhexl-mode` where it would be set rather than being let-bound. ]
Stefan