From: Tassilo Horn Date: Sat, 15 May 2021 19:19:55 +0000 (+0200) Subject: Refactor bug-reference setup functions into a defvar X-Git-Tag: emacs-28.0.90~2460 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=de61b0b25f0ff47e6da1c86da04b37bc61f963df;p=emacs.git Refactor bug-reference setup functions into a defvar * lisp/progmodes/bug-reference.el (bug-reference-auto-setup-functions): New defvar so that other packages can add their own auto-setup functions to it. * lisp/progmodes/bug-reference.el (bug-reference--run-auto-setup): Use the new variable instead of hard-coding the 4 functions we've had already. --- diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 0c5837cae7e..81aeb60bdd5 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -420,6 +420,24 @@ 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-rcirc + #'bug-reference-try-setup-from-erc) + "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 +`bug-reference-bug-regexp' and `bug-reference-url-format'. Their +guesswork is based on these variables: + +- `bug-reference-setup-from-vc-alist' for guessing based on + version control, e.g., URL of repository. +- `bug-reference-setup-from-mail-alist' for guessing based on + mail group names or mail header values. +- `bug-reference-setup-from-irc-alist' for guessing based on IRC + channel or network names.") + (defun bug-reference--run-auto-setup () (when (or bug-reference-mode bug-reference-prog-mode) @@ -430,10 +448,7 @@ and set it if applicable." (with-demoted-errors "Error during bug-reference auto-setup: %S" (catch 'setup - (dolist (f (list #'bug-reference-try-setup-from-vc - #'bug-reference-try-setup-from-gnus - #'bug-reference-try-setup-from-rcirc - #'bug-reference-try-setup-from-erc)) + (dolist (f bug-reference-auto-setup-functions) (when (funcall f) (throw 'setup t))))))))