Re: master e4df903f6b5 2/2: ; Fix last change
Richard Stallman <[email protected]> Wed, 29 Jul 2026 02:54:37 -0400
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> I don't think that would be very helpful: most uses of `cl-letf` are
> definitely no accidents: yes, most (all?) of them are hacks, but they're
> hacks where the alternatives are arguably worse.
You may be right, but let's take a look at some of them and see if we
can find better ways to write them -- avoiding, I hope, the binding
of a function cell.
One clearer way to write them is to have a variable and funcall its
value. For a value that varies, the use of a variable (rather than a
function cell) will help guide people to understand.
Perhaps all instances of binding a function cell can be improved
in this way.
> OTOH, we could add an `advice-let` to replace those `cl-letf` uses with
> something slightly better behaved. I've considered it several times in
> the past, but I'm still not sure it's worth the trouble.
That would not be better -- it would cause the same sort of problem
that binding a function cell causes. Indeed, the Emacs Lisp Ref
Manual says not to do it:
If you are writing code for release, for others to use, try to avoid
including advice in it. If the function you want to advise has no hook
to do the job, please talk with the Emacs developers about adding a
suitable hook. Especially, Emacs’s own source files should not put
advice on functions in Emacs. (There are currently a few exceptions to
this convention, but we aim to correct them.) It is generally cleaner
to create a new hook in ‘foo’, and make ‘bar’ use the hook, than to have
‘bar’ put advice in ‘foo’.
Let's add whatever hooks are needed so that these jobs can be done
cleanly, by binding variables.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)