]> git.eshelyaron.com Git - emacs.git/commitdiff
Add to bug-reference-auto-setup-functions after its declaring defvar
authorTassilo Horn <tsdh@gnu.org>
Sun, 5 Feb 2023 18:54:17 +0000 (19:54 +0100)
committerTassilo Horn <tsdh@gnu.org>
Sun, 5 Feb 2023 18:54:17 +0000 (19:54 +0100)
If it's the init-value of the defvar, add-hook from a third-party
package will suppress the default functions if it takes place before
bug-reference is loaded.

* lisp/progmodes/bug-reference.el (bug-reference-auto-setup-functions):
Add to bug-reference-auto-setup-functions after its declaring defvar.

lisp/progmodes/bug-reference.el

index d7dd3ed1c9ae1c9a61d3083b0762c46d722f5bb4..2c5378fcbb5b01f77d1c81c2fdfa9a4d2d45496b 100644 (file)
@@ -599,12 +599,7 @@ and set it if applicable."
      (erc-format-target)
      (erc-network-name))))
 
-(defvar bug-reference-auto-setup-functions
-  (list #'bug-reference-try-setup-from-vc
-        #'bug-reference-try-setup-from-gnus
-        #'bug-reference-try-setup-from-rmail
-        #'bug-reference-try-setup-from-rcirc
-        #'bug-reference-try-setup-from-erc)
+(defvar bug-reference-auto-setup-functions nil
   "Functions trying to auto-setup `bug-reference-mode'.
 These functions are run after `bug-reference-mode' has been
 activated in a buffer and try to guess suitable values for
@@ -618,6 +613,21 @@ guesswork is based on these variables:
 - `bug-reference-setup-from-irc-alist' for guessing based on IRC
   channel or network names.")
 
+;; Add the default auto-setup functions.  We don't have them as
+;; init value of bug-reference-auto-setup-functions because then
+;; they wouldn't be added if some package uses
+;;
+;;   (add-hook 'bug-reference-auto-setup-functions
+;;             #'my-pkg--bug-reference-try-setup-from-my-pkg)
+;;
+;; before bug-reference.el is loaded.
+(dolist (fn (list #'bug-reference-try-setup-from-vc
+                  #'bug-reference-try-setup-from-gnus
+                  #'bug-reference-try-setup-from-rmail
+                  #'bug-reference-try-setup-from-rcirc
+                  #'bug-reference-try-setup-from-erc))
+  (add-hook 'bug-reference-auto-setup-functions fn))
+
 (defun bug-reference--run-auto-setup ()
   (when (or bug-reference-mode
             bug-reference-prog-mode)