Function: when-let
when-let is a macro defined in subr.el.gz.
This macro is obsolete since 31.1; use when-let* or and-let*
instead.
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, evaluate the forms in BODY and return the value of the last form.
The variable list SPEC is the same as in if-let.
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, evaluate the forms in BODY
and return the value of the last form.
The variable list SPEC is the same as in `if-let'."
(declare (indent 1) (debug if-let)
(obsolete "use `when-let*' or `and-let*' instead." "31.1"))
;; Previously we expanded to `if-let', and then required a
;; `with-suppressed-warnings' to avoid doubling up the obsoletion
;; warnings. But that triggers a bytecompiler bug; see bug#74530.
;; So for now we reimplement `if-let' here.
(when (and (<= (length spec) 2)
(not (listp (car spec))))
(setq spec (list spec)))
(list 'if-let* spec (macroexp-progn body)))