From ebd53e5664215472a64b3b284006b79d7877f30f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 7 Jul 2019 13:29:22 +0200 Subject: [PATCH] Allow expansion of stage-restricted forms The package! family of macros will throw an error if used in the wrong files. This same check would prevent macroexpand from expanding them, or prevent them from being evaluated inline. --- core/core-lib.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/core-lib.el b/core/core-lib.el index 4baa0bca6..60c9c2c9f 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -77,7 +77,11 @@ list is returned as-is." else collect (intern (format "%s-hook" (symbol-name hook))))))) (defun doom--assert-stage-p (stage macro) - (unless (bound-and-true-p byte-compile-current-file) + (unless (or (bound-and-true-p byte-compile-current-file) + ;; Don't complain if we're being evaluated on-the-fly. Since forms + ;; are often evaluated (by `eval-region') or expanded (by + ;; macroexpand) in a temp buffer in `emacs-lisp-mode'... + (eq major-mode 'emacs-lisp-mode)) (cl-assert (eq stage doom--stage) nil "Found %s call in non-%s.el file (%s)"