diff options
author | Glenn Morris <rgm@gnu.org> | 2018-10-03 09:23:16 -0700 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2018-10-03 09:23:16 -0700 |
commit | 48adb87bcb0f27e2d18fc6523c472af4916d5884 (patch) | |
tree | 0299f7ce336e0d21fe902af6809798e3bb2045a7 /lisp/emacs-lisp | |
parent | 51f0cccdde9bd1679e20f35d30e39e872ce6513a (diff) | |
parent | 7296b6fbf27aeae76ea63ab2d9d9f2e46491b971 (diff) | |
download | emacs-48adb87bcb0f27e2d18fc6523c472af4916d5884.tar.gz emacs-48adb87bcb0f27e2d18fc6523c472af4916d5884.tar.bz2 emacs-48adb87bcb0f27e2d18fc6523c472af4916d5884.zip |
Merge from origin/emacs-26
7296b6f Improve cl-do, cl-do* docstrings
d416109 Avoid returning early in 'while-no-input' due to subprocesses
e8a4d94 Cleanup when opening a new terminal fails. (Bug#32794)
# Conflicts:
# etc/NEWS
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index d0d1c3b156a..29ddd491af0 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1779,7 +1779,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) @@ -1791,7 +1808,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)) |