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
This commit is contained in:
John Wiegley 2017-11-28 21:12:25 -08:00
parent 2825987619
commit b7041c0f29

View file

@ -371,19 +371,18 @@ ARGS is a list of forms, so `((foo))' if only `foo' is being called."
(if (not use-package-inject-hooks) (if (not use-package-inject-hooks)
(use-package-expand name-string (format "%s" keyword) body) (use-package-expand name-string (format "%s" keyword) body)
(let ((keyword-name (substring (format "%s" keyword) 1))) (let ((keyword-name (substring (format "%s" keyword) 1)))
(when body `((when ,(macroexp-progn
`((when ,(macroexp-progn (use-package-expand name-string (format "pre-%s hook" keyword)
(use-package-expand name-string (format "pre-%s hook" keyword) `((run-hook-with-args-until-failure
`((run-hook-with-args-until-failure ',(intern (concat "use-package--" name-string
',(intern (concat "use-package--" name-string "--pre-" keyword-name "-hook"))))))
"--pre-" keyword-name "-hook")))))) ,(macroexp-progn
,(macroexp-progn (use-package-expand name-string (format "%s" keyword) body))
(use-package-expand name-string (format "%s" keyword) body)) ,(macroexp-progn
,(macroexp-progn (use-package-expand name-string (format "post-%s hook" keyword)
(use-package-expand name-string (format "post-%s hook" keyword) `((run-hooks
`((run-hooks ',(intern (concat "use-package--" name-string
',(intern (concat "use-package--" name-string "--post-" keyword-name "-hook")))))))))))
"--post-" keyword-name "-hook"))))))))))))
(defun use-package--with-elapsed-timer (text body) (defun use-package--with-elapsed-timer (text body)
"BODY is a list of forms, so `((foo))' if only `foo' is being called." "BODY is a list of forms, so `((foo))' if only `foo' is being called."
@ -1703,10 +1702,15 @@ this file. Usage:
(let ((body (let ((body
(macroexp-progn (macroexp-progn
(use-package-process-keywords name (use-package-process-keywords name
(if (and use-package-always-demand (let ((args* (if (and use-package-always-demand
(not (memq :defer args))) (not (memq :defer args)))
(append args '(:demand t)) (append args '(:demand t))
args) 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 (and use-package-always-defer
(list :deferred t)))))) (list :deferred t))))))
(when use-package-debug (when use-package-debug