From: Tassilo Horn <tsdh@gnu.org>
Date: Sun, 5 Feb 2023 18:54:17 +0000 (+0100)
Subject: Add to bug-reference-auto-setup-functions after its declaring defvar
X-Git-Tag: emacs-29.0.90~491
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=60089dcfe06c64ff75d14f042fda1b052d0bad69;p=emacs.git

Add to bug-reference-auto-setup-functions after its declaring defvar

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.
---

diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index d7dd3ed1c9a..2c5378fcbb5 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -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)