summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/lisp-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-09-29 15:08:55 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2015-09-29 15:08:55 -0400
commit1fea2f3b743da1db666be7ce34904b74319d3f83 (patch)
treec0ddc8bf5b4ef544c8d74f6dabcc3dd42422d2c3 /lisp/emacs-lisp/lisp-mode.el
parentb425b3ffb82fbcf07985a27ebe90715af3c1eac4 (diff)
downloademacs-1fea2f3b743da1db666be7ce34904b74319d3f83.tar.gz
* lisp/emacs-lisp/lisp-mode.el (let-when-compile): Work like let*
Diffstat (limited to 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index fec9467bbb7..9ce0dfd49e8 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"))