diff --git a/etc/USE-PACKAGE-NEWS b/etc/USE-PACKAGE-NEWS index 805272f43e1..4e1a6e949e6 100644 --- a/etc/USE-PACKAGE-NEWS +++ b/etc/USE-PACKAGE-NEWS @@ -35,6 +35,10 @@ declaration, and the macro-expanded version (without verbosity-related code). Note that this still does not help if there are parsing errors, which will still cause Emacs to encounter a Lisp error at startup time. + +- New customization variable `use-package-deferring-keywords`, mainly intended + for use by extension packages, indicates keywords that, if used without + `:demand`, cause deferred loading (as if `:defer t` had been specified). - New `:hook` keyword. diff --git a/up-core.el b/up-core.el index a00f2bf6ab2..6e9daadb211 100644 --- a/up-core.el +++ b/up-core.el @@ -97,6 +97,21 @@ declaration is incorrect." :type '(repeat symbol) :group 'use-package) +(defcustom use-package-deferring-keywords + '(:bind + :bind* + :bind-keymap + :bind-keymap* + :interpreter + :mode + :magic + :magic-fallback + :commands + :hook) + "Unless `:demand' is used, keywords in this list imply deferred loading." + :type '(repeat symbol) + :group 'use-package) + (defcustom use-package-verbose nil "Whether to report about loading and configuration details. If you customize this, then you should require the `use-package' @@ -499,16 +514,9 @@ This is in contrast to merely setting it to 0." ;; Certain keywords imply :defer, if :demand was not specified. (when (and (not (plist-member args :demand)) (not (plist-member args :defer)) - (or (plist-member args :bind) - (plist-member args :bind*) - (plist-member args :bind-keymap) - (plist-member args :bind-keymap*) - (plist-member args :interpreter) - (plist-member args :mode) - (plist-member args :magic) - (plist-member args :magic-fallback) - (plist-member args :commands) - (plist-member args :hook))) + (cl-some #'identity + (mapcar (apply-partially #'plist-member args) + use-package-deferring-keywords))) (setq args (append args '(:defer t)))) (when (and (plist-member args :load)