diff options
author | Oleh Krehel <ohwoeowho@gmail.com> | 2015-09-23 13:50:15 +0200 |
---|---|---|
committer | Oleh Krehel <ohwoeowho@gmail.com> | 2015-09-23 13:50:15 +0200 |
commit | 0a133c70f1d2c068e8ad3ed5527f13ea7246fc68 (patch) | |
tree | aed8cfbd0f6748da7830dd372f89227e3165ee3b /lisp/emacs-lisp | |
parent | 325200ac1dcf5bed6918ea827d8a48d89487e083 (diff) | |
download | emacs-0a133c70f1d2c068e8ad3ed5527f13ea7246fc68.tar.gz emacs-0a133c70f1d2c068e8ad3ed5527f13ea7246fc68.tar.bz2 emacs-0a133c70f1d2c068e8ad3ed5527f13ea7246fc68.zip |
Move let-when-compile to lisp-mode.el
This fixes the bootstrapping problem of `let-when-compile' using
`cl-progv' while being in subr.el (i.e. before cl stuff was loaded).
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 4576f5cd6ba..f8b935eb90b 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -235,6 +235,19 @@ (match-beginning 0))))) (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 +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))) + (let-when-compile ((lisp-fdefs '("defmacro" "defun")) (lisp-vdefs '("defvar")) |