Fix handling of hook variables in 'use-package'
authorJohn Wiegley <johnw@gnu.org>
Mon, 26 Aug 2024 18:47:25 +0000 (11:47 -0700)
committerEli Zaretskii <eliz@gnu.org>
Sat, 31 Aug 2024 10:06:16 +0000 (13:06 +0300)
* lisp/use-package/use-package-core.el
(use-package-handler/:hook): Append "-hook" to the symbol's name
only if the named hook variable has no 'symbol-value'.
(Bug#72818)

lisp/use-package/use-package-core.el

index 7148c3341265b2d75c3450699e90c7844087ac88..2c5fc560749058bacecea6a5e486613ef03559ce 100644 (file)
@@ -1376,11 +1376,13 @@ enable gathering statistics."
           (when fun
             (mapcar
              #'(lambda (sym)
-                 `(add-hook
-                   (quote ,(intern
-                            (concat (symbol-name sym)
-                                    use-package-hook-name-suffix)))
-                   (function ,fun)))
+                 (if (boundp sym)
+                     `(add-hook (quote ,sym) (function ,fun))
+                   `(add-hook
+                     (quote ,(intern
+                              (concat (symbol-name sym)
+                                      use-package-hook-name-suffix)))
+                     (function ,fun))))
              (use-package-hook-handler-normalize-mode-symbols syms)))))
     (use-package-normalize-commands args))))