all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Setting numecir values according to symbol
Date: Mon, 31 Oct 2022 12:25:02 +0100	[thread overview]
Message-ID: <87cza8dylt.fsf@dataswamp.org> (raw)
In-Reply-To: KGSKcNKEV8-pRM30aVt6chtIIJHvbjYfc61cCHNi2ydhgTOO2cut2jfae-gYD1oxVNlQVyuS-xHdtdAA3r44fOR1J8sUnSiraOJoicJzG-g=@protonmail.com

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	other threads:[~2022-10-31 11:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30  4:31 Setting numecir values according to symbol Heime
2022-10-30 12:54 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-10-30 13:01   ` Emanuel Berg
2022-10-30 22:12     ` Heime
2022-10-31 11:25       ` Emanuel Berg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cza8dylt.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.