[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 e4dc6711b02: Fix :hook in 'use-package'
From: |
Eli Zaretskii |
Subject: |
emacs-30 e4dc6711b02: Fix :hook in 'use-package' |
Date: |
Wed, 4 Sep 2024 13:44:11 -0400 (EDT) |
branch: emacs-30
commit e4dc6711b02bf459c1e64794107c5046f9e3c054
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix :hook in 'use-package'
* lisp/use-package/use-package-core.el
(use-package-handler/:hook): Support mode variables in :hook
declarations. (Bug#72993)
---
lisp/use-package/use-package-core.el | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lisp/use-package/use-package-core.el
b/lisp/use-package/use-package-core.el
index 2c5fc560749..6c3d350c610 100644
--- a/lisp/use-package/use-package-core.el
+++ b/lisp/use-package/use-package-core.el
@@ -1376,13 +1376,16 @@ enable gathering statistics."
(when fun
(mapcar
#'(lambda (sym)
- (if (boundp sym)
- `(add-hook (quote ,sym) (function ,fun))
- `(add-hook
- (quote ,(intern
- (concat (symbol-name sym)
- use-package-hook-name-suffix)))
- (function ,fun))))
+ (let ((symname (symbol-name sym)))
+ (if (and (boundp sym)
+ ;; Mode variables are usually bound, but
+ ;; their hooks are named FOO-mode-hook.
+ (not (string-suffix-p "-mode" symname)))
+ `(add-hook (quote ,sym) (function ,fun))
+ `(add-hook
+ (quote ,(intern
+ (concat symname use-package-hook-name-suffix)))
+ (function ,fun)))))
(use-package-hook-handler-normalize-mode-symbols syms)))))
(use-package-normalize-commands args))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-30 e4dc6711b02: Fix :hook in 'use-package',
Eli Zaretskii <=