Talespin_Kit
Talespin_Kit

Reputation: 21897

Improving Elisp Conditional expression

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.

Upvotes: 4

Views: 386

Answers (1)

Michael Markert
Michael Markert

Reputation: 4026

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))

Upvotes: 11

Related Questions