* insert string at point with emacs-version
@ 2022-02-01 18:23 goncholden
2022-02-01 18:26 ` [External] : " Drew Adams
0 siblings, 1 reply; 3+ messages in thread
From: goncholden @ 2022-02-01 18:23 UTC (permalink / raw)
To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, February 1st, 2022 at 5:54 PM, Drew Adams <drew.adams@oracle.com> wrote:
> How can I have a condition that checks whether the version
>
> is 28.0 or later
(> emacs-major-version 27)
My difficulty is about calling
(alist-get (frame--current-backround-mode nil) colors)
when (> emacs-version 28.0)
and do some other thing otherwise.
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [External] : insert string at point with emacs-version
2022-02-01 18:23 goncholden
@ 2022-02-01 18:26 ` Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2022-02-01 18:26 UTC (permalink / raw)
To: goncholden; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'
Ask Emacs:
`C-h f if'
`C-h f cond'
`C-h i', choose Elisp manual, `g Conditionals'
> My difficulty is about calling
> (alist-get (frame--current-backround-mode nil) colors)
> when (> emacs-version 28.0)
> and do some other thing otherwise.
^ permalink raw reply [flat|nested] 3+ messages in thread
* insert string at point with emacs-version
@ 2022-02-01 18:57 goncholden
2022-02-01 19:44 ` [External] : " Drew Adams
0 siblings, 1 reply; 3+ messages in thread
From: goncholden @ 2022-02-01 18:57 UTC (permalink / raw)
To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, February 1st, 2022 at 6:26 PM, Drew Adams <drew.adams@oracle.com> wrote:
> Ask Emacs:
>
> `C-h f if'` C-h f cond'
>
> `C-h i', choose Elisp manual,` g Conditionals'
>
> > My difficulty is about calling
> >
> > (alist-get (frame--current-backround-mode nil) colors)
> >
> > when (> emacs-version 28.0)
> >
> > and do some other thing otherwise.
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)) ))
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [External] : insert string at point with emacs-version
2022-02-01 18:57 goncholden
@ 2022-02-01 19:44 ` Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2022-02-01 19:44 UTC (permalink / raw)
To: goncholden; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'
> > `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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-01 19:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4h3iso1W7puJXGdUPTCvSojWJ5reWSAjBducYzNRkaLAOZLcHlY4I81FGlAWDTGdAjetS-uCUk3eJ8b5zdU2DnDJGki4PdrjgAKRIEFDlJE=@protonmail.com>
2022-02-01 17:54 ` [External] : insert string at point with emacs-version Drew Adams
2022-02-01 18:23 goncholden
2022-02-01 18:26 ` [External] : " Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2022-02-01 18:57 goncholden
2022-02-01 19:44 ` [External] : " Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).