aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2016-07-12 12:05:01 -0400
committerStefan Monnier2016-07-12 12:05:01 -0400
commit9c8c3a5478db6ff4b245e9128cbf24bd722ab1d6 (patch)
treeaabac02cd7933810188863afe4d189907235c444
parent3698c4e475fb59730626af5d001599785ef5ef9e (diff)
downloademacs-9c8c3a5478db6ff4b245e9128cbf24bd722ab1d6.tar.gz
emacs-9c8c3a5478db6ff4b245e9128cbf24bd722ab1d6.zip
* lisp/emacs-lisp/cl-macs.el (cl--prog): New function
(cl-prog, cl-prog*): New macros.
-rw-r--r--lisp/emacs-lisp/cl-macs.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index d2c90c2b809..56170e6a71b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1808,6 +1808,27 @@ Labels have lexical scope and dynamic extent."
1808 `(throw ',catch-tag ',label)))) 1808 `(throw ',catch-tag ',label))))
1809 ,@macroexpand-all-environment))))) 1809 ,@macroexpand-all-environment)))))
1810 1810
1811(defun cl--prog (binder bindings body)
1812 (let (decls)
1813 (while (eq 'declare (car-safe (car body)))
1814 (push (pop body) decls))
1815 `(cl-block nil
1816 (,binder ,bindings
1817 ,@(nreverse decls)
1818 (cl-tagbody . ,body)))))
1819
1820;;;###autoload
1821(defmacro cl-prog (bindings &rest body)
1822 "Run BODY like a `cl-tagbody' after setting up the BINDINGS.
1823Shorthand for (cl-block nil (let BINDINGS (cl-tagbody BODY)))"
1824 (cl--prog 'let bindings body))
1825
1826;;;###autoload
1827(defmacro cl-prog* (bindings &rest body)
1828 "Run BODY like a `cl-tagbody' after setting up the BINDINGS.
1829Shorthand for (cl-block nil (let* BINDINGS (cl-tagbody BODY)))"
1830 (cl--prog 'let* bindings body))
1831
1811;;;###autoload 1832;;;###autoload
1812(defmacro cl-do-symbols (spec &rest body) 1833(defmacro cl-do-symbols (spec &rest body)
1813 "Loop over all symbols. 1834 "Loop over all symbols.