> From: John Wiegley <jo...@gnu.org>
> Cc: ste...@stebalien.com,  72...@debbugs.gnu.org
> Date: Tue, 03 Sep 2024 15:35:48 -0700
> 
> >>>>> Eli Zaretskii <e...@gnu.org> 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))))
 



  • bug#72993:... Bug reports for GNU Emacs, the Swiss army knife of text editors
    • bug#7... Eli Zaretskii
      • b... John Wiegley
        • ... Eli Zaretskii
          • ... John Wiegley
            • ... Eli Zaretskii
              • ... John Wiegley
                • ... Eli Zaretskii

Reply via email to