all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RE: [External] : insert string at point with emacs-version
       [not found] <4h3iso1W7puJXGdUPTCvSojWJ5reWSAjBducYzNRkaLAOZLcHlY4I81FGlAWDTGdAjetS-uCUk3eJ8b5zdU2DnDJGki4PdrjgAKRIEFDlJE=@protonmail.com>
@ 2022-02-01 17:54 ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2022-02-01 17:54 UTC (permalink / raw)
  To: goncholden; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 114 bytes --]

> How can I have a condition that checks whether the version
> is 28.0 or later

(> emacs-major-version 27)


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13071 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 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; 4+ 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] 4+ messages in thread

* RE: [External] : insert string at point with emacs-version
  2022-02-01 18:23 insert string at point with emacs-version goncholden
@ 2022-02-01 18:26 ` Drew Adams
  0 siblings, 0 replies; 4+ 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] 4+ 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; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2022-02-01 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-01 18:23 insert string at point with emacs-version 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
     [not found] <4h3iso1W7puJXGdUPTCvSojWJ5reWSAjBducYzNRkaLAOZLcHlY4I81FGlAWDTGdAjetS-uCUk3eJ8b5zdU2DnDJGki4PdrjgAKRIEFDlJE=@protonmail.com>
2022-02-01 17:54 ` Drew Adams

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.