Commit 5d752c8a authored by Oleh Krehel's avatar Oleh Krehel
Browse files

Add let-when-compile macro instead of using pcase-let

* lisp/subr.el (let-when-compile): New let-like macro that makes its
bindings known to macros like `eval-when-compile' in the body.

* lisp/emacs-lisp/lisp-mode.el: Change the top-level `pcase-let' to a
  `let-when-compile'. Also comment out the unused lexical var

The change greatly improves readability, while providing almost the
same (even shorter) byte code: instead of pre-evaluating 10 variables,
tossing them into a list, and destructuring that list a full screen
page later, the variables are simply bound as they are evaluated,
wrapped individually in `eval-when-compile'.
parent 1972e49f
This diff is collapsed.
......@@ -1502,6 +1502,19 @@ All symbols are bound before the VALUEFORMs are evalled."
,@(mapcar (lambda (binder) `(setq ,@binder)) binders)
(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)
(defmacro with-wrapper-hook (hook args &rest body)
"Run BODY, using wrapper functions from HOOK with additional ARGS.
HOOK is an abnormal hook. Each hook function in HOOK \"wraps\"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment