help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting numecir values according to symbol


From: Emanuel Berg
Subject: Re: Setting numecir values according to symbol
Date: Mon, 31 Oct 2022 12:25:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Heime wrote:

> I did simplify this with the following "cl-case".
> Am interested in seeing how a can implement the equivalent
> using "pcase".
>
> (setq mbcomplt
>   (cl-case armg
>     ('auto 0)
>     ('icomplt-horz 1)
>     ('icomplt-vert 2)
>     ('ivy 3)
>     ('vertico 4)
>     ('helm 5)))

Again, that's not a good idea to do, to just set one variable
to something depending on some other, it's error-prone and it
doesn't bring anything, really, the information is already
there and does not increase from that (what you just did).

Also, what you have done looks like an enumeration from C,
actually I don't know if that is any better since its
a variation of what I just said one shouldn't do, but if it's
just a matter of doing that you can do

(setq mbcomplt-armg
  (list 'auto 'icomplt-horz 'icomplt-vert 'ivy 'vertico 'helm) )

(cl-position 'auto         mbcomplt-armg) ; 0
(cl-position 'icomplt-horz mbcomplt-armg) ; 1
                                          ; etc

Well, it's a little bit better since the information is
"built-in", but the so-called position should still not be
used unless the list has some order one has decided to uphold
(and has some meaning).

> Would this be all, as below?
>
> (setq mbcomplt
>   (pcase armg
>     ('auto 0)
>     ('icomplt-horz 1)
>     ('icomplt-vert 2)
>     ('ivy 3)
>     ('vertico 4)
>     ('helm 5)))

Yes, but I don't see any reason to use `pcase' here, even less
than `cl-case' ...

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]