]> code.delx.au - gnu-emacs/commitdiff
* lisp/emacs-lisp/lisp-mode.el (let-when-compile): Work like let*
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 29 Sep 2015 19:08:55 +0000 (15:08 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 29 Sep 2015 19:08:55 +0000 (15:08 -0400)
lisp/emacs-lisp/lisp-mode.el

index fec9467bbb7600ec5ea27c1e0a665febc88911b9..9ce0dfd49e84b1f0665867dc98846fec8c839898 100644 (file)
          (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"))