1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-11 14:01:43 -08:00

Add new customization variables `use-package-hook-name-suffix'

Fixes https://github.com/jwiegley/use-package/issues/530
This commit is contained in:
John Wiegley 2017-12-04 12:04:20 -08:00
parent d771e8d719
commit 057814ae24
3 changed files with 46 additions and 2 deletions

View file

@ -66,6 +66,8 @@
- New customization variable `use-package-enable-imenu-support`.
- New customization variable `use-package-hook-name-suffix`.
- Allow `:diminish` to take no arguments.
- Support multiple symbols passed to `:after`, and a mini-DSL using `:all` and

View file

@ -180,6 +180,13 @@ be attempted."
(choice :tag "Enable if non-nil" sexp function)))
:group 'use-package)
(defcustom use-package-hook-name-suffix "-hook"
"Text append to the name of hooks mentioned by :hook.
Set to `nil' if you don't want this to happen; it's only a
convenience."
:type '(choice string (const :tag "No suffix" nil))
:group 'use-package)
(defcustom use-package-minimum-reported-time 0.1
"Minimal load time that will be reported.
Note that `use-package-verbose' has to be set to a non-nil value
@ -1136,8 +1143,11 @@ deferred until the prefix key sequence is pressed."
(when fun
(mapcar
#'(lambda (sym)
`(add-hook (quote ,(intern (format "%s-hook" sym)))
(function ,fun)))
`(add-hook
(quote ,(intern
(concat (symbol-name sym)
use-package-hook-name-suffix)))
(function ,fun)))
(if (use-package-non-nil-symbolp syms) (list syms) syms)))))
nargs))))))

View file

@ -891,6 +891,38 @@
(ignore
(bind-keys :package foo ("C-a" . key))))))))
(ert-deftest use-package-test/:hook-2 ()
(match-expansion
(use-package foo
:hook (hook . fun))
`(progn
(unless (fboundp 'fun)
(autoload #'fun "foo" nil t))
(ignore
(add-hook 'hook-hook #'fun)))))
(ert-deftest use-package-test/:hook-3 ()
(let ((use-package-hook-name-suffix nil))
(match-expansion
(use-package foo
:hook (hook . fun))
`(progn
(unless (fboundp 'fun)
(autoload #'fun "foo" nil t))
(ignore
(add-hook 'hook #'fun))))))
(ert-deftest use-package-test/:hook-4 ()
(let ((use-package-hook-name-suffix "-special"))
(match-expansion
(use-package foo
:hook (hook . fun))
`(progn
(unless (fboundp 'fun)
(autoload #'fun "foo" nil t))
(ignore
(add-hook 'hook-special #'fun))))))
(ert-deftest use-package-test-normalize/:custom ()
(flet ((norm (&rest args)
(apply #'use-package-normalize/:custom