[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : insert string at point with emacs-version
From: |
Drew Adams |
Subject: |
RE: [External] : insert string at point with emacs-version |
Date: |
Tue, 1 Feb 2022 19:44:27 +0000 |
> > `C-h f if'` C-h f cond'
> > `C-h i', choose Elisp manual,` g Conditionals'
>
> Would the use of cond in the case below make sense?
>
> (let* ( (colors annotation-chroma)
> (levels
> (cond (>= emacs-version 28.0)
> (alist-get (frame--current-backround-mode nil) colors)) ))
Pay attention to what `C-h f cond' tells you.
(cond ((>= emacs-version 28.0)
(alist-get (frame--current-backround-mode nil) colors))
Typically you use `cond' with more than one
condition branch, and often with more than two.
The above code is the same as this:
(when (>= emacs-version 28.0)
(alist-get (frame--current-backround-mode nil) colors))
or this:
(if (>= emacs-version 28.0)
(alist-get (frame--current-backround-mode nil) colors))
Again, the Elisp manual, node Conditionals, tells
you these things. Ask Emacs.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Conditionals.html
Many people use `if' only with two branches, or
when the result matters. Using `when' or `unless'
when the result isn't important makes that clear
to human readers.
When the result matters, you also have `and' and
`or', in addition to `if' and `cond'.
And know about `progn', to group multiple actions.
- Re: insert string at point with emacs-version, (continued)
- Re: insert string at point with emacs-version, Jean-Christophe Helary, 2022/02/01
- Re: insert string at point with emacs-version, Robert Pluim, 2022/02/01
- Re: insert string at point with emacs-version, H. Dieter Wilhelm, 2022/02/01
- Re: insert string at point with emacs-version, inasprecali, 2022/02/01
- Re: insert string at point with emacs-version, tomas, 2022/02/01
- insert string at point with emacs-version, goncholden, 2022/02/01
- insert string at point with emacs-version, goncholden, 2022/02/01
- RE: [External] : insert string at point with emacs-version,
Drew Adams <=