summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorTino Calancha <tino.calancha@gmail.com>2018-09-29 18:06:03 +0900
committerTino Calancha <tino.calancha@gmail.com>2018-09-29 18:06:15 +0900
commit7296b6fbf27aeae76ea63ab2d9d9f2e46491b971 (patch)
treecb488a359572bce734d0ff3fbc9a803dea10bb44 /lisp/emacs-lisp
parentd416109f06ab3910e3f49176185154a5179b6354 (diff)
downloademacs-7296b6fbf27aeae76ea63ab2d9d9f2e46491b971.tar.gz
emacs-7296b6fbf27aeae76ea63ab2d9d9f2e46491b971.tar.bz2
emacs-7296b6fbf27aeae76ea63ab2d9d9f2e46491b971.zip
Improve cl-do, cl-do* docstrings
* lisp/emacs-lisp/cl-macs.el(cl-do, cl-do*): Improve docstring (Bug#32803).
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl-macs.el39
1 files changed, 37 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 0854e665b9b..ffe88a21a85 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1745,7 +1745,24 @@ such that COMBO is equivalent to (and . CLAUSES)."
;;;###autoload
(defmacro cl-do (steps endtest &rest body)
- "The Common Lisp `do' loop.
+ "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)
@@ -1757,7 +1774,25 @@ such that COMBO is equivalent to (and . CLAUSES)."
;;;###autoload
(defmacro cl-do* (steps endtest &rest body)
- "The Common Lisp `do*' loop.
+ "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 `setq'
+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.
+
+This is to `cl-do' what `let*' is to `let'.
+For more details, see `cl-do*' description in Info node `(cl) Iteration'.
\(fn ((VAR INIT [STEP])...) (END-TEST [RESULT...]) BODY...)"
(declare (indent 2) (debug cl-do))