Function: cond-let--while-let

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

Signature

(cond-let--while-let VARLIST BODY...)

Documentation

Bind variables according to VARLIST, conditionally evaluate BODY, and repeat.

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 BODY forms sequentially, with VARLIST's bindings in effect, and repeat the loop.

If any VALUEFORM yields nil, evaluate neither the remaining VALUEFORMs nor the BODY forms, and instead return, always yielding nil.

BODY can be one or more expressions.

Source Code

;; Defined in ~/.emacs.d/elpa/cond-let-20260201.1500/cond-let.el
(defmacro cond-let--while-let (varlist bodyform &rest body)
  "Bind variables according to VARLIST, conditionally evaluate BODY, and repeat.

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 BODY forms sequentially, with
VARLIST's bindings in effect, and repeat the loop.

If any VALUEFORM yields nil, evaluate neither the remaining VALUEFORMs
nor the BODY forms, and instead return, always yielding nil.

BODY can be one or more expressions.

\(fn VARLIST BODY...)"
  (declare (indent 1) (debug cond-let--if-let*))
  (pcase-let ((`(,anon ,set ,bind ,lastvar)
               (cond-let--prepare-varforms varlist))
              (tag (gensym ":while-let")))
    (cond (anon
           `(catch ',tag
              (while t
                (let ,anon
                  (if (and ,@set)
                      (let ,bind
                        ,bodyform ,@body)
                    (throw ',tag nil))))))
          (t
           `(catch ',tag
              (while t
                (let ,bind
                  (if ,lastvar
                      ,(macroexp-progn (cons bodyform body))
                    (throw ',tag nil)))))))))