diff --git a/modules/config/use-package/init.el b/modules/config/use-package/init.el index 78c01a773..d3cecdd42 100644 --- a/modules/config/use-package/init.el +++ b/modules/config/use-package/init.el @@ -24,14 +24,14 @@ ;; packages with package.el, by copying over old `use-package' declarations with ;; an :ensure t property. Doom doesn't use package.el, so this will throw an ;; error that will confuse beginners, so we disable `:ensure'. -(setq use-package-ensure-function - (lambda (name &rest _) - (message "Ignoring ':ensure t' in '%s' config" name))) -;; ...On the other hand, if the user has loaded `package', then we should assume -;; they know what they're doing and restore the old behavior: -(add-transient-hook! 'package-initialize - (when (eq use-package-ensure-function #'ignore) - (setq use-package-ensure-function #'use-package-ensure-elpa))) +(defun +use-package--ignore-ensure-maybe-fn (name &rest args) + ;; ...On the other hand, if the user has loaded `package', then we should + ;; assume they know what they're doing and restore the old behavior: + (if (bound-and-true-p package--initialized) + (apply #'use-package-ensure-elpa name args) + (doom-log "Ignoring ':ensure t' in '%s' config" name) + (not (memq name doom-disabled-packages)))) +(setq use-package-ensure-function #'+use-package--ignore-ensure-maybe-fn) (with-eval-after-load 'use-package-core ;; `use-package' adds syntax highlighting for the `use-package' macro, but