Make after! noop if package is disabled

After disabling a package, def-package! blocks for that package are
ignored. Now, after! blocks for those packages will be ignored too.
This commit is contained in:
Henrik Lissner 2018-05-20 15:51:47 +02:00
parent f2c02e32c8
commit 16a9126b3e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -108,27 +108,29 @@
"A smart wrapper around `with-eval-after-load'. Supresses warnings during "A smart wrapper around `with-eval-after-load'. Supresses warnings during
compilation." compilation."
(declare (indent defun) (debug t)) (declare (indent defun) (debug t))
(list (if (or (not (bound-and-true-p byte-compile-current-file)) (unless (and (symbolp targets)
(dolist (next (doom-enlist targets)) (memq targets doom-disabled-packages))
(if (symbolp next) (list (if (or (not (bound-and-true-p byte-compile-current-file))
(require next nil :no-error) (dolist (next (doom-enlist targets))
(load next :no-message :no-error)))) (if (symbolp next)
#'progn (require next nil :no-error)
#'with-no-warnings) (load next :no-message :no-error))))
(cond ((symbolp targets) #'progn
`(eval-after-load ',targets '(progn ,@body))) #'with-no-warnings)
((and (consp targets) (cond ((symbolp targets)
(memq (car targets) '(:or :any))) `(eval-after-load ',targets '(progn ,@body)))
`(progn ((and (consp targets)
,@(cl-loop for next in (cdr targets) (memq (car targets) '(:or :any)))
collect `(after! ,next ,@body)))) `(progn
((and (consp targets) ,@(cl-loop for next in (cdr targets)
(memq (car targets) '(:and :all))) collect `(after! ,next ,@body))))
(dolist (next (cdr targets)) ((and (consp targets)
(setq body `(after! ,next ,@body))) (memq (car targets) '(:and :all)))
body) (dolist (next (cdr targets))
((listp targets) (setq body `(after! ,next ,@body)))
`(after! (:all ,@targets) ,@body))))) body)
((listp targets)
`(after! (:all ,@targets) ,@body))))))
(defmacro quiet! (&rest forms) (defmacro quiet! (&rest forms)
"Run FORMS without making any output." "Run FORMS without making any output."