GNU bug report logs - #72993
31.0.50; 4f521fa14c18f57e5207bffd68e9f79454dccc79 breaks binding mode hooks in use-package

Previous Next

Package: emacs;

Reported by: Steven Allen <steven <at> stebalien.com>

Date: Tue, 3 Sep 2024 02:03:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 72993 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: John Wiegley <johnw <at> gnu.org>
Cc: 72993 <at> debbugs.gnu.org, steven <at> stebalien.com
Subject: Re: bug#72993: 31.0.50; 4f521fa14c18f57e5207bffd68e9f79454dccc79
 breaks binding mode hooks in use-package
Date: Wed, 04 Sep 2024 14:31:27 +0300
> From: John Wiegley <johnw <at> gnu.org>
> Cc: steven <at> stebalien.com,  72993 <at> debbugs.gnu.org
> Date: Tue, 03 Sep 2024 15:35:48 -0700
> 
> >>>>> Eli Zaretskii <eliz <at> 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))))
 




This bug report was last modified 258 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.