Function: cond-let
cond-let is a macro defined in cond-let.el.
Signature
(cond-let &rest CLAUSES)
Documentation
Try each clause until one succeeds.
Each clause has one of these forms:
- a plain clause (CONDITION BODY...)
- a binding clause ([SYMBOL VALUEFORM]... BODY...)
- a binding vector [[SYMBOL VALUEFORM]...]
A (CONDITION BODY...) clause works as for cond. Evaluate CONDITION,
and if it yields non-nil, the clause succeeds. Then evaluate BODY forms
sequentially and return the value of the last; or if there are no BODY
forms, return the value of CONDITION. If CONDITION yields nil, do not
evaluate the BODY forms and instead proceed to the next clause.
A ([SYMBOL VALUEFORM]... BODY...) clause begins with one or more binding
vectors, followed by one or more BODY forms. Bind SYMBOL to the value
of VALUEFORM. Evaluate all VALUEFORMs before binding their respective
SYMBOLs (as for let).
If all VALUEFORMs yield non-nil, evaluate BODY forms sequentially, with VARLIST's bindings in effect, and return the value of the last form.
If any VALUEFORM yields nil, evaluate neither the remaining VALUEFORMs nor the BODY forms, and proceed to the next clause.
A [[SYMBOL VALUEFORM]...] form creates bindings, which extend to all remaining clauses and binding vectors. Evaluate all VALUEFORMs before binding their respective SYMBOLs. Unlike for the previous form, bind all SYMBOLs, even if a VALUEFORM yields nil. Always proceed to the next clause.
Source Code
;; Defined in ~/.emacs.d/elpa/cond-let-20260201.1500/cond-let.el
(defmacro cond-let (&rest clauses)
"Try each clause until one succeeds.
Each clause has one of these forms:
- a plain clause (CONDITION BODY...)
- a binding clause ([SYMBOL VALUEFORM]... BODY...)
- a binding vector [[SYMBOL VALUEFORM]...]
A (CONDITION BODY...) clause works as for `cond'. Evaluate CONDITION,
and if it yields non-nil, the clause succeeds. Then evaluate BODY forms
sequentially and return the value of the last; or if there are no BODY
forms, return the value of CONDITION. If CONDITION yields nil, do not
evaluate the BODY forms and instead proceed to the next clause.
A ([SYMBOL VALUEFORM]... BODY...) clause begins with one or more binding
vectors, followed by one or more BODY forms. Bind SYMBOL to the value
of VALUEFORM. Evaluate all VALUEFORMs before binding their respective
SYMBOLs (as for `let').
If all VALUEFORMs yield non-nil, evaluate BODY forms sequentially, with
VARLIST's bindings in effect, and return the value of the last form.
If any VALUEFORM yields nil, evaluate neither the remaining VALUEFORMs
nor the BODY forms, and proceed to the next clause.
A [[SYMBOL VALUEFORM]...] form creates bindings, which extend to all
remaining clauses and binding vectors. Evaluate all VALUEFORMs before
binding their respective SYMBOLs. Unlike for the previous form, bind
all SYMBOLs, even if a VALUEFORM yields nil. Always proceed to the
next clause."
(declare (indent 0) (debug cond-let*))
(let ((tag (gensym ":cond-let")))
`(catch ',tag
,@(cond-let--prepare-clauses tag nil clauses))))