Fix & refactor after!'s :when keyword support
It no longer tries to load keywords (like :when and :any) as packages, and won't treat :when's arguments as a require target.
This commit is contained in:
parent
c0e271ef5a
commit
8e6519ef1a
1 changed files with 9 additions and 7 deletions
|
@ -210,25 +210,27 @@ compilation. This will no-op on features that have been disabled by the user."
|
||||||
(unless (and (symbolp targets)
|
(unless (and (symbolp targets)
|
||||||
(memq targets (bound-and-true-p doom-disabled-packages)))
|
(memq targets (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))
|
||||||
|
(eq (car-safe targets) :when)
|
||||||
(dolist (next (doom-enlist targets))
|
(dolist (next (doom-enlist targets))
|
||||||
(if (symbolp next)
|
(unless (keywordp next)
|
||||||
(require next nil :no-error)
|
(if (symbolp next)
|
||||||
(load next :no-message :no-error))))
|
(require next nil :no-error)
|
||||||
|
(load next :no-message :no-error)))))
|
||||||
#'progn
|
#'progn
|
||||||
#'with-no-warnings)
|
#'with-no-warnings)
|
||||||
(cond ((eq (car-safe targets) :when)
|
(cond ((eq (car-safe targets) :when)
|
||||||
`(if ,(cadr targets)
|
`(if ,(cadr targets)
|
||||||
(progn ,@body)
|
(progn ,@body)
|
||||||
,(let* ((hook 'after-load-functions)
|
,(let ((fun (gensym "doom|delay-form-")))
|
||||||
(fun (intern (format "doom|delay-form-in-%s" hook))))
|
|
||||||
`(progn
|
`(progn
|
||||||
(fset ',fun (lambda (&rest args)
|
(fset ',fun (lambda (&rest args)
|
||||||
(when ,(or (car (cdr-safe targets)) t)
|
(when ,(or (car (cdr-safe targets)) t)
|
||||||
(remove-hook ',hook #',fun)
|
(remove-hook 'after-load-functions #',fun)
|
||||||
|
(unintern ',fun nil)
|
||||||
(ignore args)
|
(ignore args)
|
||||||
,@body)))
|
,@body)))
|
||||||
(put ',fun 'permanent-local-hook t)
|
(put ',fun 'permanent-local-hook t)
|
||||||
(add-hook ',hook #',fun)))))
|
(add-hook 'after-load-functions #',fun)))))
|
||||||
((symbolp targets)
|
((symbolp targets)
|
||||||
`(eval-after-load ',targets '(progn ,@body)))
|
`(eval-after-load ',targets '(progn ,@body)))
|
||||||
((and (consp targets)
|
((and (consp targets)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue