Function: when-let

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

Signature

(when-let SPEC &rest BODY)

Documentation

Bind variables according to SPEC and conditionally evaluate BODY.

Evaluate each binding in turn, stopping if a binding value is nil. If all are non-nil, return the value of the last form in BODY.

The variable list SPEC is the same as in if-let.

View in manual

Probably introduced at or before Emacs version 25.1.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro when-let (spec &rest body)
  "Bind variables according to SPEC and conditionally evaluate BODY.
Evaluate each binding in turn, stopping if a binding value is nil.
If all are non-nil, return the value of the last form in BODY.

The variable list SPEC is the same as in `if-let'."
  (declare (indent 1) (debug if-let))
  (list 'if-let spec (macroexp-progn body)))