[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9c8c3a5: * lisp/emacs-lisp/cl-macs.el (cl--prog): N
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 9c8c3a5: * lisp/emacs-lisp/cl-macs.el (cl--prog): New function |
Date: |
Tue, 12 Jul 2016 16:05:05 +0000 (UTC) |
branch: master
commit 9c8c3a5478db6ff4b245e9128cbf24bd722ab1d6
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/emacs-lisp/cl-macs.el (cl--prog): New function
(cl-prog, cl-prog*): New macros.
---
lisp/emacs-lisp/cl-macs.el | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index d2c90c2..56170e6 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."
`(throw ',catch-tag ',label))))
,@macroexpand-all-environment)))))
+(defun cl--prog (binder bindings body)
+ (let (decls)
+ (while (eq 'declare (car-safe (car body)))
+ (push (pop body) decls))
+ `(cl-block nil
+ (,binder ,bindings
+ ,@(nreverse decls)
+ (cl-tagbody . ,body)))))
+
+;;;###autoload
+(defmacro cl-prog (bindings &rest body)
+ "Run BODY like a `cl-tagbody' after setting up the BINDINGS.
+Shorthand for (cl-block nil (let BINDINGS (cl-tagbody BODY)))"
+ (cl--prog 'let bindings body))
+
+;;;###autoload
+(defmacro cl-prog* (bindings &rest body)
+ "Run BODY like a `cl-tagbody' after setting up the BINDINGS.
+Shorthand for (cl-block nil (let* BINDINGS (cl-tagbody BODY)))"
+ (cl--prog 'let* bindings body))
+
;;;###autoload
(defmacro cl-do-symbols (spec &rest body)
"Loop over all symbols.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9c8c3a5: * lisp/emacs-lisp/cl-macs.el (cl--prog): New function,
Stefan Monnier <=