Function: when

when is a macro defined in subr.el.gz.

Signature

(when COND &rest BODY)

Documentation

If COND yields non-nil, do BODY, else return nil.

When COND yields non-nil, eval BODY forms sequentially and return value of last one, or nil if there are none.

View in manual

Probably introduced at or before Emacs version 19.1.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro when (cond &rest body)
  "If COND yields non-nil, do BODY, else return nil.
When COND yields non-nil, eval BODY forms sequentially and return
value of last one, or nil if there are none."
  (declare (indent 1) (debug t))
  (if body
      (list 'if cond (cons 'progn body))
    (macroexp-warn-and-return (format-message "`when' with empty body")
                              (list 'progn cond nil) '(empty-body when) t)))