[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 1fea2f3 1/2: * lisp/emacs-lisp/lisp-mode.el (let-wh
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 1fea2f3 1/2: * lisp/emacs-lisp/lisp-mode.el (let-when-compile): Work like let* |
Date: |
Tue, 29 Sep 2015 19:13:49 +0000 |
branch: master
commit 1fea2f3b743da1db666be7ce34904b74319d3f83
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/emacs-lisp/lisp-mode.el (let-when-compile): Work like let*
---
lisp/emacs-lisp/lisp-mode.el | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index fec9467..9ce0dfd 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -238,17 +238,21 @@
(throw 'found t))))))
(defmacro let-when-compile (bindings &rest body)
- "Like `let', but allow for compile time optimization.
-Use BINDINGS as in regular `let', but in BODY each usage should
+ "Like `let*', but allow for compile time optimization.
+Use BINDINGS as in regular `let*', but in BODY each usage should
be wrapped in `eval-when-compile'.
This will generate compile-time constants from BINDINGS."
(declare (indent 1) (debug let))
- (cl-progv (mapcar #'car bindings)
- (mapcar (lambda (x) (eval (cadr x))) bindings)
- (macroexpand-all
- (macroexp-progn
- body)
- macroexpand-all-environment)))
+ (letrec ((loop
+ (lambda (bindings)
+ (if (null bindings)
+ (macroexpand-all (macroexp-progn body)
+ macroexpand-all-environment)
+ (let ((binding (pop bindings)))
+ (cl-progv (list (car binding))
+ (list (eval (nth 1 binding) t))
+ (funcall loop bindings)))))))
+ (funcall loop bindings)))
(let-when-compile
((lisp-fdefs '("defmacro" "defun"))