Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving Elisp Conditional expression

Tags:

elisp

The elisp code for the below pseudo code

if "the emacs version is less than 23.1.x"
do
  something
else
  something-else

is written as

(if (or (< emacs-major-version 23)
        (and (= emacs-major-version 23)
             (<= emacs-minor-version 1)))
    (setq color-theme-is-global t)
  (color-theme-initialize))

How to optimize the above code, so that the "emacs-major-version" is not referenced twice.

like image 790
Talespin_Kit Avatar asked Dec 21 '22 10:12

Talespin_Kit


1 Answers

No need for that, there's version<= and emacs-version

(if (version<= emacs-version "23.1")
    (setq color-theme-is-global t)
  (color-theme-initialize))
like image 163
Michael Markert Avatar answered Jun 11 '23 15:06

Michael Markert