From: John Wiegley Date: Wed, 29 Nov 2017 05:12:25 +0000 (-0800) Subject: When use-package-inject-hooks is non-nil, always fire init/config hooks X-Git-Tag: emacs-29.0.90~1306^2~15^2~238 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b7041c0f29;p=emacs.git When use-package-inject-hooks is non-nil, always fire init/config hooks This used to not happen if `:init` or `:config` was missing, or set to nil as with `:init nil`. Fixes https://github.com/jwiegley/use-package/issues/250 --- diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index 7185999d14d..a1beca1fc05 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -371,19 +371,18 @@ ARGS is a list of forms, so `((foo))' if only `foo' is being called." (if (not use-package-inject-hooks) (use-package-expand name-string (format "%s" keyword) body) (let ((keyword-name (substring (format "%s" keyword) 1))) - (when body - `((when ,(macroexp-progn - (use-package-expand name-string (format "pre-%s hook" keyword) - `((run-hook-with-args-until-failure - ',(intern (concat "use-package--" name-string - "--pre-" keyword-name "-hook")))))) - ,(macroexp-progn - (use-package-expand name-string (format "%s" keyword) body)) - ,(macroexp-progn - (use-package-expand name-string (format "post-%s hook" keyword) - `((run-hooks - ',(intern (concat "use-package--" name-string - "--post-" keyword-name "-hook")))))))))))) + `((when ,(macroexp-progn + (use-package-expand name-string (format "pre-%s hook" keyword) + `((run-hook-with-args-until-failure + ',(intern (concat "use-package--" name-string + "--pre-" keyword-name "-hook")))))) + ,(macroexp-progn + (use-package-expand name-string (format "%s" keyword) body)) + ,(macroexp-progn + (use-package-expand name-string (format "post-%s hook" keyword) + `((run-hooks + ',(intern (concat "use-package--" name-string + "--post-" keyword-name "-hook"))))))))))) (defun use-package--with-elapsed-timer (text body) "BODY is a list of forms, so `((foo))' if only `foo' is being called." @@ -1703,10 +1702,15 @@ this file. Usage: (let ((body (macroexp-progn (use-package-process-keywords name - (if (and use-package-always-demand - (not (memq :defer args))) - (append args '(:demand t)) - args) + (let ((args* (if (and use-package-always-demand + (not (memq :defer args))) + (append args '(:demand t)) + args))) + (unless (plist-member args* :init) + (plist-put args* :init nil)) + (unless (plist-member args* :config) + (plist-put args* :config nil)) + args*) (and use-package-always-defer (list :deferred t)))))) (when use-package-debug