[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: let-alist can't deal with the keys which includes spaces.
From: |
tomas |
Subject: |
Re: let-alist can't deal with the keys which includes spaces. |
Date: |
Tue, 20 Jul 2021 16:56:59 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, Jul 20, 2021 at 09:21:32PM +0800, Hongyi Zhao wrote:
> On Tue, Jul 20, 2021 at 8:49 PM <tomas@tuxteam.de> wrote:
> >
> > On Tue, Jul 20, 2021 at 07:12:14PM +0800, Hongyi Zhao wrote:
> > > I adapted the examples given on
> > > <https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html>
> > > to the following:
> > >
> > > ;;;
> > > (setq colors '(("rose merry" . red) (lily (belladonna . yellow))))
> > >
> > > (let-alist colors
> > > (if (eq ."rose merry" 'red)
> > > .lily.belladonna))
> > > ;;;
> > >
> > > When I try to evaluate the above code snippet, the following error is
> > > triggered:
> >
> > It's not the space. It's the dot ".". This is wrong Lisp syntax:
> >
> > (eq ."rose merry" 'red)
> >
> > Also the dots in .lily.belladonna look strange. This will be the next
> > syntax error.
> >
> > BTW., if you take the dot out, like so
> >
> > (eq "rose merry" 'red)
>
> The dot syntax is described on
> <https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html>,
> as follows:
>
> Macro: let-alist alist body
>
> Creates a binding for each symbol used as keys the association list
> alist
[...]
Oh -- thanks. Didn't know about `let-alist'. But if I read it correctly,
the macro wants to have symbols as keys, not other types (like strings).
Note the snippet of the doc quote above.
This works for me:
(setq colors '((rose . "red") (lily . "white") (sunflower . "yellow")))
(let-alist colors
(format "a lily is %S\n" .lily))
=> a lily is "white"
It seems `let-alist' gets horribly confused if it tries to build a
variable binding from a string.
Cheers
- t
signature.asc
Description: Digital signature
- let-alist can't deal with the keys which includes spaces., Hongyi Zhao, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., Omar Polo, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/20
- Re: let-alist can't deal with the keys which includes spaces., tomas, 2021/07/21
- Re: let-alist can't deal with the keys which includes spaces., Emanuel Berg, 2021/07/21