[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Re: Locating file via load-path
From: |
Drew Adams |
Subject: |
RE: [External] : Re: Locating file via load-path |
Date: |
Fri, 9 Aug 2024 16:19:01 +0000 |
> > > Why cl-pushnew ?
> >
> > Either is OK. The doc of `add-to-list' says:
> >
> > you are usually better off using `push' or `cl-pushnew'.
>
> Talk about citation out of context. The full quotation is
>
> This is handy to add some elements to configuration variables,
> but please do not abuse it in Elisp code, where you are usually
> better off using ‘push’ or ‘cl-pushnew’.
>
> IOW, don't (ab)use add-to-list if all you need is to add a new element
> to some list of elements. add-to-list is for adding path elements to
> variables like load-path.
That text says use it mainly for user ("configuration")
variables, not generally for Lisp code. And it neither
says nor suggests anything about lists of path elements.
> > It doesn't say why, and neither does the Elisp manual.
>
> Oh, yes, it does, see above.
No, there's nothing about "why" above.
May I humbly encourage you to review the following
mails in this very list from Stefan Monnier on the
subject, back in 2013, during his tenure as the
Emacs maintainer (thread "Is add-to-list supposed
to work when lexical-binding is t?"):
Not in chronological order, but perhaps in order of
relevance and understanding for us, here:
https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00096.html
https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00064.html
https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00124.html
https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00188.html
In particular, this bit summarizes _WHY_ he added that
"usually better off using ‘push’ or ‘cl-pushnew’" [in
Lisp code] text to the doc string (in Emacs 24):
"The warning was added because add-to-list is a
frequent use-case where Elisp code presumes
dynamic binding."
And:
> Unless you're knee-deep in the internals of the language,
> the difference between `cl-pushnew' and `add-to-list' is
> so obscure as to be incomprehensible.
"Agreed. I never liked add-to-list, and now I really
know why ... other than by ad-hoc handling the case
where the first arg is passed via quoting, the
byte-compiler" [is pretty hopeless for add-to-list]
- Re: Locating file via load-path, (continued)
- Re: Locating file via load-path, Heime, 2024/08/08
- Re: Locating file via load-path, Heime, 2024/08/08
- Re: Locating file via load-path, Heime, 2024/08/08
- RE: [External] : Re: Locating file via load-path, Drew Adams, 2024/08/08
- RE: [External] : Re: Locating file via load-path, Heime, 2024/08/08
- RE: [External] : Re: Locating file via load-path, Drew Adams, 2024/08/08
- RE: [External] : Re: Locating file via load-path, Heime, 2024/08/08
- RE: [External] : Re: Locating file via load-path, Drew Adams, 2024/08/08
- RE: [External] : Re: Locating file via load-path, Heime, 2024/08/08
- Re: [External] : Re: Locating file via load-path, Eli Zaretskii, 2024/08/09
- RE: [External] : Re: Locating file via load-path,
Drew Adams <=
- Locating file via load-path, Christopher Dimech, 2024/08/09
- Re: [External] : Re: Locating file via load-path, Eli Zaretskii, 2024/08/09
- Re: Locating file via load-path, Arash Esbati, 2024/08/09
- Re: Locating file via load-path, Eli Zaretskii, 2024/08/10
- Re: Locating file via load-path, Arash Esbati, 2024/08/11
- Re: Locating file via load-path, Eli Zaretskii, 2024/08/11
- Re: Locating file via load-path, Arash Esbati, 2024/08/11
- RE: [External] : Re: Locating file via load-path, Drew Adams, 2024/08/11
- Locating file via load-path, Christopher Dimech, 2024/08/11
- Re: [External] : Re: Locating file via load-path, Eli Zaretskii, 2024/08/09