fix(use-package): use-package-ensure-function

Doom is configured to ignore :ensure in `use-package`, unless the user
has manually called `(package-initialize)` -- in which case, we assume
the user genuinely *wants* to use package.el, or some reason.
This commit is contained in:
Henrik Lissner 2026-03-03 06:57:35 -05:00
parent 7f17dcf09a
commit eccde78741
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -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