> From: John Wiegley <[email protected]>
> Cc: [email protected], [email protected]
> Date: Tue, 03 Sep 2024 15:35:48 -0700
>
> >>>>> Eli Zaretskii <[email protected]> writes:
>
> >> Perhaps we should avoid auto -hook’ifying the variable name only if the
> >> name
> >> does not already end in ‘-functions’?
>
> > Either that, or maybe exempt FOO-mode from the boundp test.
>
> This sounds likely to be even better.
Like the below?
diff --git a/lisp/use-package/use-package-core.el
b/lisp/use-package/use-package-core.el
index 2c5fc56..6c3d350 100644
--- a/lisp/use-package/use-package-core.el
+++ b/lisp/use-package/use-package-core.el
@@ -1376,13 +1376,16 @@ use-package-handler/:hook
(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))))