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)
|
||||
(memq targets (bound-and-true-p doom-disabled-packages)))
|
||||
(list (if (or (not (bound-and-true-p byte-compile-current-file))
|
||||
(eq (car-safe targets) :when)
|
||||
(dolist (next (doom-enlist targets))
|
||||
(if (symbolp next)
|
||||
(require next nil :no-error)
|
||||
(load next :no-message :no-error))))
|
||||
(unless (keywordp next)
|
||||
(if (symbolp next)
|
||||
(require next nil :no-error)
|
||||
(load next :no-message :no-error)))))
|
||||
#'progn
|
||||
#'with-no-warnings)
|
||||
(cond ((eq (car-safe targets) :when)
|
||||
`(if ,(cadr targets)
|
||||
(progn ,@body)
|
||||
,(let* ((hook 'after-load-functions)
|
||||
(fun (intern (format "doom|delay-form-in-%s" hook))))
|
||||
,(let ((fun (gensym "doom|delay-form-")))
|
||||
`(progn
|
||||
(fset ',fun (lambda (&rest args)
|
||||
(when ,(or (car (cdr-safe targets)) t)
|
||||
(remove-hook ',hook #',fun)
|
||||
(remove-hook 'after-load-functions #',fun)
|
||||
(unintern ',fun nil)
|
||||
(ignore args)
|
||||
,@body)))
|
||||
(put ',fun 'permanent-local-hook t)
|
||||
(add-hook ',hook #',fun)))))
|
||||
(add-hook 'after-load-functions #',fun)))))
|
||||
((symbolp targets)
|
||||
`(eval-after-load ',targets '(progn ,@body)))
|
||||
((and (consp targets)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue