Function: cl-do
cl-do is an autoloaded macro defined in cl-macs.el.gz.
Signature
(cl-do ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)
Documentation
Bind variables and run BODY forms until END-TEST returns non-nil.
First, each VAR is bound to the associated INIT value as if by a let form.
Then, in each iteration of the loop, the END-TEST is evaluated; if true,
the loop is finished. Otherwise, the BODY forms are evaluated, then each
VAR is set to the associated STEP expression (as if by a cl-psetq form)
and the next iteration begins.
Once the END-TEST becomes true, the RESULT forms are evaluated (with
the VARs still bound to their values) to produce the result
returned by cl-do.
Note that the entire loop is enclosed in an implicit nil block, so
that you can use cl-return to exit at any time.
Also note that END-TEST is checked before evaluating BODY. If END-TEST
is initially non-nil, cl-do will exit without running BODY.
For more details, see cl-do description in Info node (cl) Iteration.
Aliases
do (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;;; Other iteration control structures.
;;;###autoload
(defmacro cl-do (steps endtest &rest body)
"Bind variables and run BODY forms until END-TEST returns non-nil.
First, each VAR is bound to the associated INIT value as if by a `let' form.
Then, in each iteration of the loop, the END-TEST is evaluated; if true,
the loop is finished. Otherwise, the BODY forms are evaluated, then each
VAR is set to the associated STEP expression (as if by a `cl-psetq' form)
and the next iteration begins.
Once the END-TEST becomes true, the RESULT forms are evaluated (with
the VARs still bound to their values) to produce the result
returned by `cl-do'.
Note that the entire loop is enclosed in an implicit nil block, so
that you can use `cl-return' to exit at any time.
Also note that END-TEST is checked before evaluating BODY. If END-TEST
is initially non-nil, `cl-do' will exit without running BODY.
For more details, see `cl-do' description in Info node `(cl) Iteration'.
\(fn ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)"
(declare (indent 2)
(debug
((&rest &or symbolp (symbolp &optional form form))
(form body)
cl-declarations body)))
(cl--expand-do-loop steps endtest body nil))