From 8e6519ef1a30f6b58597ed39b50594f17652c3e2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 Jun 2018 23:52:19 +0200 Subject: [PATCH] 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. --- core/core-lib.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index d4f802432..12fd42980 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -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)