[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to run a elisp-function
From: |
Jean Louis |
Subject: |
Re: how to run a elisp-function |
Date: |
Tue, 11 May 2021 19:36:42 +0300 |
User-agent: |
Mutt/2.0.6 (2021-03-06) |
* Robert Weiner <rsw@gnu.org> [2021-05-08 20:33]:
> You can use something like:
>
> (push '("Name" . "https://url-with-%s-in-it") hyperbole-web-search-alist)
>
> or you could use a setq call and just replace the whole list with the items
> you want where you want them.
Robert this is not for you, it is just my mind exercise that can
help people understand it is better for alist to use alist
related functions. They are in the Manual at (info "(elisp)
Association Lists")
While `push' does work, single push would work, but is kind of
risky if person is trying to work with it.
(setq my-alist '()) ⇒ nil
(push '("Name" . "https://www.example.com") my-alist)
⇒ (("Name" . "https://www.example.com"))
But repeated push will create duplicate:
(push '("Name" . "https://www.example.com") my-alist)
⇒ (("Name" . "https://www.example.com") ("Name" . "https://www.example.com"))
(alist-get "Name" my-alist nil nil 'equal) ⇒ "https://www.example.com"
(setf (alist-get "Name" my-alist nil nil 'equal)
"https://www.other-example.com") ⇒ "https://www.other-example.com"
Now we have got duplicates because push was used to set the key
and not (setf (alist-get ...))
my-alist ⇒ (("Name" . "https://www.other-example.com") ("Name" .
"https://www.example.com"))
It will return the correct result though:
(alist-get "Name" my-alist nil nil 'equal) ⇒ "https://www.other-example.com"
What if user tries to make 3 times push with the sligthly
different key? Then it will end up with duplicates both in
variable description and in the init file.
I am not sure how the function in Hyperbole works, if it does not
call alist functions it could even start showing duplicates.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/
- Re: how to run a elisp-function, (continued)
- Re: how to run a elisp-function, Robert Weiner, 2021/05/08
- Re: how to run a elisp-function, Jean Louis, 2021/05/08
- Re: how to run a elisp-function, Robert Weiner, 2021/05/08
- Re: how to run a elisp-function, Robert Weiner, 2021/05/08
- Re: how to run a elisp-function, Jean Louis, 2021/05/09
- Re: how to run a elisp-function, Robert Weiner, 2021/05/09
- Re: how to run a elisp-function, Jean Louis, 2021/05/09
- Re: how to run a elisp-function, Robert Weiner, 2021/05/10
- Re: how to run a elisp-function, Jean Louis, 2021/05/11
- Re: how to run a elisp-function, Robert Weiner, 2021/05/11
Re: how to run a elisp-function,
Jean Louis <=
- Why no articles on Hyperbole?, Robert Weiner, 2021/05/11
- Re: Why no articles on Hyperbole?, Jean Louis, 2021/05/12
- Re: Why no articles on Hyperbole?, Jean Louis, 2021/05/12
- More ideas on using Hyperbole, Jean Louis, 2021/05/12
- Re: More ideas on using Hyperbole, Robert Weiner, 2021/05/12
- Re: More ideas on using Hyperbole, Jean Louis, 2021/05/19
Re: Why no articles on Hyperbole?, indieterminacy, 2021/05/13
Re: how to run a elisp-function, Jean Louis, 2021/05/11