Function: cond-let--if-let

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

Signature

(cond-let--if-let VARLIST THEN [ELSE...])

Documentation

Bind variables according to VARLIST and evaluate THEN or ELSE.

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

If all VALUEFORMs yield non-nil, evaluate THEN with VARLIST's bindings in effect, and return its value. THEN must be one expression.

If any VALUEFORM yields nil, evaluate ELSE sequentially and return the value of the last form; or if there are no ELSE forms return nil. The bindings from VARLIST do _not_ extend to the ELSE forms.

Source Code

;; Defined in ~/.emacs.d/elpa/cond-let-20260201.1500/cond-let.el
(defmacro cond-let--if-let (varlist then &rest else)
  "Bind variables according to VARLIST and evaluate THEN or ELSE.

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

If all VALUEFORMs yield non-nil, evaluate THEN with VARLIST's bindings
in effect, and return its value.  THEN must be one expression.

If any VALUEFORM yields nil, evaluate ELSE sequentially and return the
value of the last form; or if there are no ELSE forms return nil.  The
bindings from VARLIST do _not_ extend to the ELSE forms.

\(fn VARLIST THEN [ELSE...])"
  (declare (indent 2) (debug cond-let--if-let*))
  (pcase-let* ((`(,anon ,set ,bind ,_)
                (cond-let--prepare-varforms varlist t))
               (set (if (length= set 1) (car set) (cons 'and set))))
    `(let ,anon
       (if ,set
           (let ,bind
             ,then)
         ,@else))))