emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small bug-reference.el change; safe enough for emacs-29


From: Tassilo Horn
Subject: Small bug-reference.el change; safe enough for emacs-29
Date: Sun, 05 Feb 2023 19:26:27 +0100
User-agent: mu4e 1.9.19; emacs 30.0.50

Hi Eli & all,

I'd like to apply the below patch.  It just moves the
bug-reference-auto-setup-functions init value out of the defvar and sets
it afterwards.  That's because if a package like mu4e in the concrete
case (https://github.com/djcb/mu/pull/2428) uses

  (add-hook 'bug-reference-auto-setup-functions
            #'mu4e--view-try-setup-bug-reference-mode)

to add bug-reference auto-setup for its modes *before* bug-reference
itself is loaded, the stock auto-setup functions defined by
bug-reference would not be added when bug-reference gets loaded later
on.

--8<---------------cut here---------------start------------->8---
1 file changed, 13 insertions(+), 6 deletions(-)
lisp/progmodes/bug-reference.el | 19 +++++++++++++------

modified   lisp/progmodes/bug-reference.el
@@ -599,12 +599,7 @@ bug-reference-try-setup-from-erc
      (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,18 @@ bug-reference-auto-setup-functions
 - `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
+;; default 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-fn)
+;; 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)
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]