* Locating file via load-path @ 2024-08-08 16:59 Heime 2024-08-08 18:33 ` Eli Zaretskii 2024-08-08 18:38 ` Bruno Barbier 0 siblings, 2 replies; 26+ messages in thread From: Heime @ 2024-08-08 16:59 UTC (permalink / raw) To: Heime via Users list for the GNU Emacs text editor Is this the way to see if a file is accessible via load-path ? Or do I need 'load-path or similar ? (if (locate-file "tema.el" load-path) Sent with Proton Mail secure email. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-08 16:59 Locating file via load-path Heime @ 2024-08-08 18:33 ` Eli Zaretskii [not found] ` <DDYXKsMNq=5FPzC2iDOfz6ETUaC7H-vuOcAXfNk2GimDjscOHbeHzG6k=5FZi7IY3HMwckcFmb=5FFSBn9rYaDxKDD5OSzLlcq7SJksWLI=5FczwUvc=3D@protonmail.com> 2024-08-08 19:09 ` Heime 2024-08-08 18:38 ` Bruno Barbier 1 sibling, 2 replies; 26+ messages in thread From: Eli Zaretskii @ 2024-08-08 18:33 UTC (permalink / raw) To: help-gnu-emacs > Date: Thu, 08 Aug 2024 16:59:04 +0000 > From: Heime <heimeborgia@protonmail.com> > > > Is this the way to see if a file is accessible via load-path ? > Or do I need 'load-path or similar ? > > (if (locate-file "tema.el" load-path) For ELisp files on load-path, it is better to use locate-library. ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <DDYXKsMNq=5FPzC2iDOfz6ETUaC7H-vuOcAXfNk2GimDjscOHbeHzG6k=5FZi7IY3HMwckcFmb=5FFSBn9rYaDxKDD5OSzLlcq7SJksWLI=5FczwUvc=3D@protonmail.com>]
* Re: Locating file via load-path 2024-08-08 18:33 ` Eli Zaretskii [not found] ` <DDYXKsMNq=5FPzC2iDOfz6ETUaC7H-vuOcAXfNk2GimDjscOHbeHzG6k=5FZi7IY3HMwckcFmb=5FFSBn9rYaDxKDD5OSzLlcq7SJksWLI=5FczwUvc=3D@protonmail.com> @ 2024-08-08 19:09 ` Heime 2024-08-08 19:15 ` Heime 2024-08-09 5:20 ` Eli Zaretskii 1 sibling, 2 replies; 26+ messages in thread From: Heime @ 2024-08-08 19:09 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Sent with Proton Mail secure email. On Friday, August 9th, 2024 at 6:33 AM, Eli Zaretskii <eliz@gnu.org> wrote: > > Date: Thu, 08 Aug 2024 16:59:04 +0000 > > From: Heime heimeborgia@protonmail.com > > > > Is this the way to see if a file is accessible via load-path ? > > Or do I need 'load-path or similar ? > > > > (if (locate-file "tema.el" load-path) > > > For ELisp files on load-path, it is better to use locate-library. Would the check for a general file prevodilac.el be this ? (locate-library "prevodilac") ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-08 19:09 ` Heime @ 2024-08-08 19:15 ` Heime 2024-08-08 19:42 ` Heime 2024-08-09 5:21 ` Eli Zaretskii 2024-08-09 5:20 ` Eli Zaretskii 1 sibling, 2 replies; 26+ messages in thread From: Heime @ 2024-08-08 19:15 UTC (permalink / raw) To: Heime; +Cc: Eli Zaretskii, help-gnu-emacs On Friday, August 9th, 2024 at 7:09 AM, Heime <heimeborgia@protonmail.com> wrote: > Sent with Proton Mail secure email. > > On Friday, August 9th, 2024 at 6:33 AM, Eli Zaretskii eliz@gnu.org wrote: > > > > Date: Thu, 08 Aug 2024 16:59:04 +0000 > > > From: Heime heimeborgia@protonmail.com > > > > > > Is this the way to see if a file is accessible via load-path ? > > > Or do I need 'load-path or similar ? > > > > > > (if (locate-file "tema.el" load-path) > > > > For ELisp files on load-path, it is better to use locate-library. > > > Would the check for a general file prevodilac.el be this ? > > (locate-library "prevodilac") How can different files under different paths but having the same name be handled ? ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-08 19:15 ` Heime @ 2024-08-08 19:42 ` Heime 2024-08-08 19:51 ` [External] : " Drew Adams 2024-08-09 5:21 ` Eli Zaretskii 1 sibling, 1 reply; 26+ messages in thread From: Heime @ 2024-08-08 19:42 UTC (permalink / raw) To: Heime; +Cc: Eli Zaretskii, help-gnu-emacs Sent with Proton Mail secure email. On Friday, August 9th, 2024 at 7:15 AM, Heime <heimeborgia@protonmail.com> wrote: > On Friday, August 9th, 2024 at 7:09 AM, Heime heimeborgia@protonmail.com wrote: > > > Sent with Proton Mail secure email. > > > > On Friday, August 9th, 2024 at 6:33 AM, Eli Zaretskii eliz@gnu.org wrote: > > > > > > Date: Thu, 08 Aug 2024 16:59:04 +0000 > > > > From: Heime heimeborgia@protonmail.com > > > > > > > > Is this the way to see if a file is accessible via load-path ? > > > > Or do I need 'load-path or similar ? > > > > > > > > (if (locate-file "tema.el" load-path) > > > > > > For ELisp files on load-path, it is better to use locate-library. > > > > Would the check for a general file prevodilac.el be this ? > > > > (locate-library "prevodilac") > > > How can different files under different paths but having the same name be handled ? What I want to do is this. Should package-path not has been added to load-path using (add-to-list 'load-path package-path) then a test is made, so it is added if required (if (locate-file "tema.el" load-path) (require 'tema) (progn (add-to-list 'load-path tema-path) (require 'tema))) ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-08 19:42 ` Heime @ 2024-08-08 19:51 ` Drew Adams [not found] ` <dfOBGQnGfe22rKYsEePcBLU2WWYEt5JBoyDuis=5FJnnmM90x5w2lHn6cWlp61yG63OxKWTfWP0=5FBk9F6-836xfAfBbbx6gOHzOTAvMzxhnL8=3D@protonmail.com> ` (2 more replies) 0 siblings, 3 replies; 26+ messages in thread From: Drew Adams @ 2024-08-08 19:51 UTC (permalink / raw) To: Heime; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org > a test is made, so it is added if required > > (if (locate-file "tema.el" load-path) > (require 'tema) (require 'tema nil t) loads it if available, and returns nil otherwise. > (progn > (add-to-list 'load-path tema-path) > (require 'tema))) You might as well just add it to `load-path' unconditionally, unless it's already there: (cl-pushnew tema load-path) ^ permalink raw reply [flat|nested] 26+ messages in thread
[parent not found: <dfOBGQnGfe22rKYsEePcBLU2WWYEt5JBoyDuis=5FJnnmM90x5w2lHn6cWlp61yG63OxKWTfWP0=5FBk9F6-836xfAfBbbx6gOHzOTAvMzxhnL8=3D@protonmail.com>]
* RE: [External] : Re: Locating file via load-path 2024-08-08 19:51 ` [External] : " Drew Adams [not found] ` <dfOBGQnGfe22rKYsEePcBLU2WWYEt5JBoyDuis=5FJnnmM90x5w2lHn6cWlp61yG63OxKWTfWP0=5FBk9F6-836xfAfBbbx6gOHzOTAvMzxhnL8=3D@protonmail.com> @ 2024-08-08 20:07 ` Heime 2024-08-08 21:25 ` Drew Adams 2024-08-09 5:28 ` [External] : " Eli Zaretskii 2 siblings, 1 reply; 26+ messages in thread From: Heime @ 2024-08-08 20:07 UTC (permalink / raw) To: Drew Adams; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org Sent with Proton Mail secure email. On Friday, August 9th, 2024 at 7:51 AM, Drew Adams <drew.adams@oracle.com> wrote: > > a test is made, so it is added if required > > > > (if (locate-file "tema.el" load-path) > > (require 'tema) > > > (require 'tema nil t) > loads it if available, and returns nil otherwise. > > > (progn > > (add-to-list 'load-path tema-path) > > (require 'tema))) > > > You might as well just add it to `load-path' > unconditionally, unless it's already there: > > (cl-pushnew tema load-path) That would be a good thing. (add-to-list 'load-path tema-path) should add tema-path only if it isn't there yet. Why cl-pushnew ? ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-08 20:07 ` Heime @ 2024-08-08 21:25 ` Drew Adams 2024-08-08 21:59 ` Heime 2024-08-09 5:31 ` Eli Zaretskii 0 siblings, 2 replies; 26+ messages in thread From: Drew Adams @ 2024-08-08 21:25 UTC (permalink / raw) To: Heime; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org > On Friday, August 9th, 2024 at 7:51 AM, Drew Adams wrote: > > > > a test is made, so it is added if required > > > > > > (if (locate-file "tema.el" load-path) > > > (require 'tema) > > > > > > (require 'tema nil t) > > loads it if available, and returns nil otherwise. > > > > > (progn > > > (add-to-list 'load-path tema-path) > > > (require 'tema))) > > > > You might as well just add it to `load-path' > > unconditionally, unless it's already there: > > > > (cl-pushnew tema load-path) (I meant tema-path, not tema.) > That would be a good thing. > > (add-to-list 'load-path tema-path) should add tema-path only if it isn't > there yet. Why cl-pushnew ? Either is OK. The doc of `add-to-list' says: you are usually better off using `push' or `cl-pushnew'. It doesn't say why, and neither does the Elisp manual. Some people get confused over the args to `add-to-list', in particular, that it's a function, so it evaluates its args, so if you want to provide a variable literally then you need to quote it. ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-08 21:25 ` Drew Adams @ 2024-08-08 21:59 ` Heime 2024-08-08 22:30 ` Drew Adams 2024-08-09 5:31 ` Eli Zaretskii 1 sibling, 1 reply; 26+ messages in thread From: Heime @ 2024-08-08 21:59 UTC (permalink / raw) To: Drew Adams; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org On Friday, August 9th, 2024 at 9:25 AM, Drew Adams <drew.adams@oracle.com> wrote: > > On Friday, August 9th, 2024 at 7:51 AM, Drew Adams wrote: > > > > > > a test is made, so it is added if required > > > > > > > > (if (locate-file "tema.el" load-path) > > > > (require 'tema) > > > > > > (require 'tema nil t) > > > loads it if available, and returns nil otherwise. > > > > > > > (progn > > > > (add-to-list 'load-path tema-path) > > > > (require 'tema))) > > > > > > You might as well just add it to `load-path' > > > unconditionally, unless it's already there: > > > > > > (cl-pushnew tema load-path) > > > (I meant tema-path, not tema.) > > > That would be a good thing. > > > > (add-to-list 'load-path tema-path) should add tema-path only if it isn't > > there yet. Why cl-pushnew ? > > > Either is OK. The doc of `add-to-list' says: you are usually better off using` push' or `cl-pushnew'. It doesn't say why, and neither does the Elisp manual. Some people get confused over the args to` add-to-list', > in particular, that it's a function, so it evaluates its > args, so if you want to provide a variable literally > then you need to quote it. Are you referring to quoting LIST-VAR ? add-to-list expects the first argument to be the symbol of a list variable, not the list itself. ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-08 21:59 ` Heime @ 2024-08-08 22:30 ` Drew Adams 2024-08-08 22:35 ` Heime 0 siblings, 1 reply; 26+ messages in thread From: Drew Adams @ 2024-08-08 22:30 UTC (permalink / raw) To: Heime; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org > > Some people get confused over the args to` add-to-list', > > in particular, that it's a function, so it evaluates its > > args, so if you want to provide a variable literally > > then you need to quote it. > > Are you referring to quoting LIST-VAR ? Yes. > add-to-list expects the first argument to be the > symbol of a list variable, not the list itself. Yes. Which is why, if you want to pass a variable's symbol literally, you need to quote it: 'SYMBOL evals to SYMBOL. Arg LIST-VAR in code can be any sexp. It need not be something as obvious as 'var. ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-08 22:30 ` Drew Adams @ 2024-08-08 22:35 ` Heime 0 siblings, 0 replies; 26+ messages in thread From: Heime @ 2024-08-08 22:35 UTC (permalink / raw) To: Drew Adams; +Cc: Eli Zaretskii, help-gnu-emacs@gnu.org Sent with Proton Mail secure email. On Friday, August 9th, 2024 at 10:30 AM, Drew Adams <drew.adams@oracle.com> wrote: > > > Some people get confused over the args to` add-to-list', > > > in particular, that it's a function, so it evaluates its > > > args, so if you want to provide a variable literally > > > then you need to quote it. > > > > Are you referring to quoting LIST-VAR ? > > > Yes. > > > add-to-list expects the first argument to be the > > symbol of a list variable, not the list itself. > > > Yes. > > Which is why, if you want to pass a variable's > symbol literally, you need to quote it: 'SYMBOL > evals to SYMBOL. > > Arg LIST-VAR in code can be any sexp. It need not > be something as obvious as 'var. There should not be the problem you mention for the case of load-path because all instances show that it is customarily quoted. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [External] : Re: Locating file via load-path 2024-08-08 21:25 ` Drew Adams 2024-08-08 21:59 ` Heime @ 2024-08-09 5:31 ` Eli Zaretskii 2024-08-09 16:19 ` Drew Adams 2024-08-09 19:52 ` Arash Esbati 1 sibling, 2 replies; 26+ messages in thread From: Eli Zaretskii @ 2024-08-09 5:31 UTC (permalink / raw) To: help-gnu-emacs > From: Drew Adams <drew.adams@oracle.com> > CC: Eli Zaretskii <eliz@gnu.org>, > "help-gnu-emacs@gnu.org" > <help-gnu-emacs@gnu.org> > Date: Thu, 8 Aug 2024 21:25:46 +0000 > > > (add-to-list 'load-path tema-path) should add tema-path only if it isn't > > there yet. 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. > It doesn't say why, and neither does the Elisp manual. Oh, yes, it does, see above. ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-09 5:31 ` Eli Zaretskii @ 2024-08-09 16:19 ` Drew Adams 2024-08-09 16:51 ` Christopher Dimech 2024-08-09 17:39 ` [External] : " Eli Zaretskii 2024-08-09 19:52 ` Arash Esbati 1 sibling, 2 replies; 26+ messages in thread From: Drew Adams @ 2024-08-09 16:19 UTC (permalink / raw) To: Eli Zaretskii, help-gnu-emacs@gnu.org > > > 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] ^ permalink raw reply [flat|nested] 26+ messages in thread
* Locating file via load-path 2024-08-09 16:19 ` Drew Adams @ 2024-08-09 16:51 ` Christopher Dimech 2024-08-09 17:39 ` [External] : " Eli Zaretskii 1 sibling, 0 replies; 26+ messages in thread From: Christopher Dimech @ 2024-08-09 16:51 UTC (permalink / raw) To: Eli Zaretskii, Drew Adams; +Cc: help-gnu-emacs@gnu.org > Sent: Saturday, August 10, 2024 at 4:19 AM > From: "Drew Adams" <drew.adams@oracle.com> > To: "Eli Zaretskii" <eliz@gnu.org>, "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> > Subject: RE: [External] : Re: Locating file via load-path > > > > > 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?"): In such case add-to-list has to the potential for misleading code. There’s an argument to be made that functions like add-to-list should be robust enough to handle a variety of scenarios, not just for modifying configuration variables like load-path. There should be some robustness expectations rather than expecting users not to abuse it. The function should be versatile and resistant to misuse. If developers could use more appropriate list operations when dealing with general-purpose list manipulation (including for load-path), the better life would be for everybody. > 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] > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [External] : Re: Locating file via load-path 2024-08-09 16:19 ` Drew Adams 2024-08-09 16:51 ` Christopher Dimech @ 2024-08-09 17:39 ` Eli Zaretskii 1 sibling, 0 replies; 26+ messages in thread From: Eli Zaretskii @ 2024-08-09 17:39 UTC (permalink / raw) To: help-gnu-emacs > From: Drew Adams <drew.adams@oracle.com> > 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 did, albeit not explicitly enough. Now it does that more clearly. > > > It doesn't say why, and neither does the Elisp manual. > > > > Oh, yes, it does, see above. > > No, there's nothing about "why" above. Only if you refuse to think about what it says. > 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: Not relevant to this discussion. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-09 5:31 ` Eli Zaretskii 2024-08-09 16:19 ` Drew Adams @ 2024-08-09 19:52 ` Arash Esbati 2024-08-10 5:39 ` Eli Zaretskii 1 sibling, 1 reply; 26+ messages in thread From: Arash Esbati @ 2024-08-09 19:52 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Eli Zaretskii <eliz@gnu.org> writes: > 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. Maybe off-topic, but I always missed the APPEND arg provided by `add-to-list' in `cl-pushnew'. Best, Arash ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-09 19:52 ` Arash Esbati @ 2024-08-10 5:39 ` Eli Zaretskii 2024-08-11 13:35 ` Arash Esbati 0 siblings, 1 reply; 26+ messages in thread From: Eli Zaretskii @ 2024-08-10 5:39 UTC (permalink / raw) To: help-gnu-emacs > From: Arash Esbati <arash@gnu.org> > Cc: help-gnu-emacs@gnu.org > Date: Fri, 09 Aug 2024 21:52:24 +0200 > > Eli Zaretskii <eliz@gnu.org> writes: > > > 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. > > Maybe off-topic, but I always missed the APPEND arg provided by > `add-to-list' in `cl-pushnew'. If the order matters, then perhaps cl-pushnew is not what you want. Or maybe you need to sort the list in some way. The order rarely matters if all you need is to construct a list of arbitrary elements. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-10 5:39 ` Eli Zaretskii @ 2024-08-11 13:35 ` Arash Esbati 2024-08-11 14:11 ` Eli Zaretskii 0 siblings, 1 reply; 26+ messages in thread From: Arash Esbati @ 2024-08-11 13:35 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Eli Zaretskii <eliz@gnu.org> writes: > If the order matters, then perhaps cl-pushnew is not what you want. And then I usually end up using `add-to-list'. Admittedly, it is not often, but sometimes I need to append an entry to a list from lisp, and this missing bit keeps me from using `cl-pushnew' exclusively. Best, Arash ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-11 13:35 ` Arash Esbati @ 2024-08-11 14:11 ` Eli Zaretskii 2024-08-11 19:49 ` Arash Esbati 0 siblings, 1 reply; 26+ messages in thread From: Eli Zaretskii @ 2024-08-11 14:11 UTC (permalink / raw) To: help-gnu-emacs > From: Arash Esbati <arash@gnu.org> > Cc: help-gnu-emacs@gnu.org > Date: Sun, 11 Aug 2024 15:35:05 +0200 > > Eli Zaretskii <eliz@gnu.org> writes: > > > If the order matters, then perhaps cl-pushnew is not what you want. > > And then I usually end up using `add-to-list'. Why not nconc? ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-11 14:11 ` Eli Zaretskii @ 2024-08-11 19:49 ` Arash Esbati 2024-08-11 21:07 ` [External] : " Drew Adams 0 siblings, 1 reply; 26+ messages in thread From: Arash Esbati @ 2024-08-11 19:49 UTC (permalink / raw) To: Eli Zaretskii; +Cc: help-gnu-emacs Eli Zaretskii <eliz@gnu.org> writes: > Why not nconc? The use case I have to deal with runs inside hooks which run more than once, and I don't want to pollute the target variable with same entry over and over again. Of course I can check if the entry is already there, but I think it would be convenient if `cl-pushnew' could be a full replacement for `add-to-list' and one would use only the former in Lisp and be done with it. Best, Arash ^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [External] : Re: Locating file via load-path 2024-08-11 19:49 ` Arash Esbati @ 2024-08-11 21:07 ` Drew Adams 2024-08-11 21:24 ` Christopher Dimech 0 siblings, 1 reply; 26+ messages in thread From: Drew Adams @ 2024-08-11 21:07 UTC (permalink / raw) To: Arash Esbati, Eli Zaretskii; +Cc: help-gnu-emacs@gnu.org > > Why not nconc? > > The use case I have to deal with runs inside hooks which run more than > once, and I don't want to pollute the target variable with same entry > over and over again. > > Of course I can check if the entry is already there, but I think it > would be convenient if `cl-pushnew' could be a full replacement for > `add-to-list' and one would use only the former in Lisp and be done with > it. It would be OK for Emacs to have such a function, but it shouldn't be called `cl-pushnew'. That name should be reserved for our emulation of the Common Lisp function `pushnew'. `cl-pushnew' shouldn't do anything different from what CL's `pushnew' does. Just one opinion. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Locating file via load-path 2024-08-11 21:07 ` [External] : " Drew Adams @ 2024-08-11 21:24 ` Christopher Dimech 0 siblings, 0 replies; 26+ messages in thread From: Christopher Dimech @ 2024-08-11 21:24 UTC (permalink / raw) To: Drew Adams; +Cc: Arash Esbati, Eli Zaretskii, help-gnu-emacs@gnu.org > Sent: Monday, August 12, 2024 at 9:07 AM > From: "Drew Adams" <drew.adams@oracle.com> > To: "Arash Esbati" <arash@gnu.org>, "Eli Zaretskii" <eliz@gnu.org> > Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org> > Subject: RE: [External] : Re: Locating file via load-path > > > > Why not nconc? > > > > The use case I have to deal with runs inside hooks which run more than > > once, and I don't want to pollute the target variable with same entry > > over and over again. > > > > Of course I can check if the entry is already there, but I think it > > would be convenient if `cl-pushnew' could be a full replacement for > > `add-to-list' and one would use only the former in Lisp and be done with > > it. > > It would be OK for Emacs to have such a function, > but it shouldn't be called `cl-pushnew'. > > That name should be reserved for our emulation of > the Common Lisp function `pushnew'. `cl-pushnew' > shouldn't do anything different from what CL's > `pushnew' does. > > Just one opinion. A agree with it. A good set that are always recommended would be a great improvement and no guesswork would be required on which ones are to be used. There could also be some special ones if properly named. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [External] : Re: Locating file via load-path 2024-08-08 19:51 ` [External] : " Drew Adams [not found] ` <dfOBGQnGfe22rKYsEePcBLU2WWYEt5JBoyDuis=5FJnnmM90x5w2lHn6cWlp61yG63OxKWTfWP0=5FBk9F6-836xfAfBbbx6gOHzOTAvMzxhnL8=3D@protonmail.com> 2024-08-08 20:07 ` Heime @ 2024-08-09 5:28 ` Eli Zaretskii 2 siblings, 0 replies; 26+ messages in thread From: Eli Zaretskii @ 2024-08-09 5:28 UTC (permalink / raw) To: help-gnu-emacs > From: Drew Adams <drew.adams@oracle.com> > CC: Eli Zaretskii <eliz@gnu.org>, > "help-gnu-emacs@gnu.org" > <help-gnu-emacs@gnu.org> > Date: Thu, 8 Aug 2024 19:51:41 +0000 > > You might as well just add it to `load-path' > unconditionally, unless it's already there: > > (cl-pushnew tema load-path) add-to-list does the same job and doesn't require cl-lib. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-08 19:15 ` Heime 2024-08-08 19:42 ` Heime @ 2024-08-09 5:21 ` Eli Zaretskii 1 sibling, 0 replies; 26+ messages in thread From: Eli Zaretskii @ 2024-08-09 5:21 UTC (permalink / raw) To: help-gnu-emacs > Date: Thu, 08 Aug 2024 19:15:29 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: Eli Zaretskii <eliz@gnu.org>, help-gnu-emacs@gnu.org > > > Would the check for a general file prevodilac.el be this ? > > > > (locate-library "prevodilac") > > How can different files under different paths but having the same name be handled ? Why is it important? And what do you mean by "handled"? ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-08 19:09 ` Heime 2024-08-08 19:15 ` Heime @ 2024-08-09 5:20 ` Eli Zaretskii 1 sibling, 0 replies; 26+ messages in thread From: Eli Zaretskii @ 2024-08-09 5:20 UTC (permalink / raw) To: help-gnu-emacs > Date: Thu, 08 Aug 2024 19:09:58 +0000 > From: Heime <heimeborgia@protonmail.com> > Cc: help-gnu-emacs@gnu.org > > > For ELisp files on load-path, it is better to use locate-library. > > Would the check for a general file prevodilac.el be this ? > > (locate-library "prevodilac") The answer is in the doc string of locate-library, I suggest to read it. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: Locating file via load-path 2024-08-08 16:59 Locating file via load-path Heime 2024-08-08 18:33 ` Eli Zaretskii @ 2024-08-08 18:38 ` Bruno Barbier 1 sibling, 0 replies; 26+ messages in thread From: Bruno Barbier @ 2024-08-08 18:38 UTC (permalink / raw) To: Heime, Heime via Users list for the GNU Emacs text editor Heime <heimeborgia@protonmail.com> writes: > Is this the way to see if a file is accessible via load-path ? > Or do I need 'load-path or similar ? > > (if (locate-file "tema.el" load-path) Maybe. But 'load-path' is for libraries. Its documentation refers to the info node (info "(elisp)Library Search") and that info node documents 'locate-library'. So, maybe, depending on your goal, 'locate-library' is more appropriate. Note that, from the description of 'locate-library', you can jump to its source code, and, thus see how it's implemented relying on 'locate-file'. HTH, Bruno ^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2024-08-11 21:24 UTC | newest] Thread overview: 26+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-08-08 16:59 Locating file via load-path Heime 2024-08-08 18:33 ` Eli Zaretskii [not found] ` <DDYXKsMNq=5FPzC2iDOfz6ETUaC7H-vuOcAXfNk2GimDjscOHbeHzG6k=5FZi7IY3HMwckcFmb=5FFSBn9rYaDxKDD5OSzLlcq7SJksWLI=5FczwUvc=3D@protonmail.com> [not found] ` <Q1xAU81Xn9UZt8V95EDVRqwUvUNfmlk3rU-arBrbQ8CMmh7IpXd3xgEt4qZwH3zJ7l989GxHrEb=5F3R9eJ-sd1SoofwcnBVpnYWjxU5ni1TE=3D@protonmail.com> 2024-08-08 19:09 ` Heime 2024-08-08 19:15 ` Heime 2024-08-08 19:42 ` Heime 2024-08-08 19:51 ` [External] : " Drew Adams [not found] ` <dfOBGQnGfe22rKYsEePcBLU2WWYEt5JBoyDuis=5FJnnmM90x5w2lHn6cWlp61yG63OxKWTfWP0=5FBk9F6-836xfAfBbbx6gOHzOTAvMzxhnL8=3D@protonmail.com> [not found] ` <DS7PR10MB5 23233B5F43170D4D4328BCBF3B92@DS7PR10MB5232.namprd10.prod.outlook.com> [not found] ` <UrKx-9HV=5FVLIwsNkymmTbUk5GX6jduusTCwQVBacu2z8PK2QT1SLrG30lyq7J5PaKayGO7XcU5bq1R-pGMPgQtZWYI0dxXnrxj6vfgrXXt8=3D@protonmail.com> 2024-08-08 20:07 ` Heime 2024-08-08 21:25 ` Drew Adams 2024-08-08 21:59 ` Heime 2024-08-08 22:30 ` Drew Adams 2024-08-08 22:35 ` Heime 2024-08-09 5:31 ` Eli Zaretskii 2024-08-09 16:19 ` Drew Adams 2024-08-09 16:51 ` Christopher Dimech 2024-08-09 17:39 ` [External] : " Eli Zaretskii 2024-08-09 19:52 ` Arash Esbati 2024-08-10 5:39 ` Eli Zaretskii 2024-08-11 13:35 ` Arash Esbati 2024-08-11 14:11 ` Eli Zaretskii 2024-08-11 19:49 ` Arash Esbati 2024-08-11 21:07 ` [External] : " Drew Adams 2024-08-11 21:24 ` Christopher Dimech 2024-08-09 5:28 ` [External] : " Eli Zaretskii 2024-08-09 5:21 ` Eli Zaretskii 2024-08-09 5:20 ` Eli Zaretskii 2024-08-08 18:38 ` Bruno Barbier
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).