* lisp/emacs-lisp/lisp-mode.el (let-when-compile): Work like let*
This commit is contained in:
parent
b425b3ffb8
commit
1fea2f3b74
1 changed files with 12 additions and 8 deletions
|
@ -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"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue