Function: cond-let--and-let

cond-let--and-let is a macro defined in cond-let.el.

Signature

(cond-let--and-let VARLIST &optional BODYFORM)

Documentation

Bind according to VARLIST until one yields nil, else evaluate BODYFORM.

Each element of VARLIST is a list (SYMBOL VALUEFORM), which binds SYMBOL to the value of VALUEFORM. Evaluate all VALUEFORMs before binding their respective SYMBOLs (as for let).

Evaluate VALUEFORMs until on of them yields nil. If that happens return nil, and evaluate neither the remaining VALUEFORMs nor BODYFORM. If all VALUEFORMs yield non-nil, evaluate BODYFORM with the bindings in effect, and return its value; or if there is no BODYFORM, the value of the last VALUEFORM.

Source Code

;; Defined in ~/.emacs.d/elpa/cond-let-20260201.1500/cond-let.el
(defmacro cond-let--and-let (varlist &optional bodyform)
  "Bind according to VARLIST until one yields nil, else evaluate BODYFORM.

Each element of VARLIST is a list (SYMBOL VALUEFORM), which binds SYMBOL
to the value of VALUEFORM.  Evaluate all VALUEFORMs before binding their
respective SYMBOLs (as for `let').

Evaluate VALUEFORMs until on of them yields nil.  If that happens return
nil, and evaluate neither the remaining VALUEFORMs nor BODYFORM.  If all
VALUEFORMs yield non-nil, evaluate BODYFORM with the bindings in effect,
and return its value; or if there is no BODYFORM, the value of the last
VALUEFORM."
  (declare (indent 1) (debug cond-let--and-let*))
  (pcase-let ((`(,anon ,set ,bind ,lastvar)
               (cond-let--prepare-varforms varlist)))
    (cond (anon
           `(let ,anon
              (and ,@set
                   (let ,bind
                     ,(or bodyform lastvar)))))
          (t
           `(let ,bind
              ,(if bodyform
                   `(and ,lastvar ,bodyform)
                 lastvar))))))