Fix void-variable next error

And change TARGETS to PACKAGE, which is a more descriptive name.

Mentioned in #374
This commit is contained in:
Henrik Lissner 2019-07-22 18:57:17 +02:00
parent d8dbb90931
commit 457b542795
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -506,10 +506,10 @@ CATEGORY and MODULE can be omitted When this macro is used from inside a module
(memq category (doom-module-get (car module-pair) (cdr module-pair) :flags))))) (memq category (doom-module-get (car module-pair) (cdr module-pair) :flags)))))
t)) t))
(defmacro after! (targets &rest body) (defmacro after! (package &rest body)
"Evaluate BODY after TARGETS have loaded. "Evaluate BODY after PACKAGE have loaded.
TARGETS is a symbol or list of them. These are package names, not modes, PACKAGE is a symbol or list of them. These are package names, not modes,
functions or variables. It can be: functions or variables. It can be:
- An unquoted package symbol (the name of a package) - An unquoted package symbol (the name of a package)
@ -527,32 +527,32 @@ functions or variables. It can be:
This is a wrapper around `eval-after-load' that: This is a wrapper around `eval-after-load' that:
1. Suppresses warnings for disabled packages at compile-time 1. Suppresses warnings for disabled packages at compile-time
2. No-ops for TARGETS that are disabled by the user (via `package!') 2. No-ops for package that are disabled by the user (via `package!')
3. Supports compound TARGETS statements (see below) 3. Supports compound package statements (see below)
4. Prevents eager expansion pulling in autoloaded macros all at once" 4. Prevents eager expansion pulling in autoloaded macros all at once"
(declare (indent defun) (debug t)) (declare (indent defun) (debug t))
(if (symbolp targets) (if (symbolp package)
(unless (memq targets (bound-and-true-p doom-disabled-packages)) (unless (memq package (bound-and-true-p doom-disabled-packages))
(list (if (or (not (bound-and-true-p byte-compile-current-file)) (list (if (or (not (bound-and-true-p byte-compile-current-file))
(require next nil 'noerror)) (require package nil 'noerror))
#'progn #'progn
#'with-no-warnings) #'with-no-warnings)
(let ((body (macroexp-progn body))) (let ((body (macroexp-progn body)))
`(if (featurep ',targets) `(if (featurep ',package)
,body ,body
;; We intentionally avoid `with-eval-after-load' to prevent ;; We intentionally avoid `with-eval-after-load' to prevent
;; eager macro expansion from pulling (or failing to pull) in ;; eager macro expansion from pulling (or failing to pull) in
;; autoloaded macros/packages. ;; autoloaded macros/packages.
(eval-after-load ',targets ',body))))) (eval-after-load ',package ',body)))))
(let ((target (car-safe targets))) (let ((p (car package)))
(cond ((not (keywordp target)) (cond ((not (keywordp p))
`(after! (:and ,@targets) ,@body)) `(after! (:and ,@targets) ,@body))
((memq target '(:or :any)) ((memq p '(:or :any))
(macroexp-progn (macroexp-progn
(cl-loop for next in (cdr targets) (cl-loop for next in (cdr package)
collect `(after! ,next ,@body)))) collect `(after! ,next ,@body))))
((memq target '(:and :all)) ((memq p '(:and :all))
(dolist (next (cdr targets)) (dolist (next (cdr package))
(setq body `((after! ,next ,@body)))) (setq body `((after! ,next ,@body))))
(car body)))))) (car body))))))