Function: static-if

static-if is a macro defined in subr.el.gz.

Signature

(static-if CONDITION THEN-FORM &rest ELSE-FORMS)

Documentation

A conditional compilation macro.

Evaluate CONDITION at macro-expansion time. If it is non-nil, expand the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS enclosed in a progn form. ELSE-FORMS may be empty.

View in manual

Probably introduced at or before Emacs version 30.1.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
;; Note: `static-if' can be copied into a package to enable it to be
;; used in Emacsen older than Emacs 30.1.  If the package is used in
;; very old Emacsen or XEmacs (in which `eval' takes exactly one
;; argument) the copy will need amending.
(defmacro static-if (condition then-form &rest else-forms)
  "A conditional compilation macro.
Evaluate CONDITION at macro-expansion time.  If it is non-nil,
expand the macro to THEN-FORM.  Otherwise expand it to ELSE-FORMS
enclosed in a `progn' form.  ELSE-FORMS may be empty."
  (declare (indent 2)
           (debug (sexp sexp &rest sexp)))
  (if (eval condition lexical-binding)
      then-form
    (cons 'progn else-forms)))