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.

This macro will be marked obsolete in Emacs 31.1; prefer when-let* and and-let* in new code.

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'.

This macro will be marked obsolete in Emacs 31.1; prefer `when-let*' and
`and-let*' in new code."
  (declare (indent 1) (debug if-let))
  (list 'if-let spec (macroexp-progn body)))