emacs-diffs
[Top][All Lists]
Advanced

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

master b6d02dc: Add bug-reference-mode-force-auto-setup


From: Tassilo Horn
Subject: master b6d02dc: Add bug-reference-mode-force-auto-setup
Date: Sun, 16 May 2021 10:23:25 -0400 (EDT)

branch: master
commit b6d02dc3766f30078fdf7778951e2be78589f446
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Add bug-reference-mode-force-auto-setup
    
    * lisp/progmodes/bug-reference.el
    (bug-reference-try-setup-from-rmail): Match the Rmail mbox filename
    against GROUP-REGEXP in bug-reference-setup-from-mail-alist.
    (bug-reference-mode-force-auto-setup): New function which forces
    auto-setup even if bug-reference-bug-regexp and
    bug-reference-url-format are already set.
---
 lisp/progmodes/bug-reference.el | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index bdbe048..fc9627c 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -344,9 +344,11 @@ and set it if applicable."
 
 (defun bug-reference-try-setup-from-rmail ()
   "Try setting up `bug-reference-mode' from the current rmail mail.
-Looks at the headers List-Id, To, From, and Cc and tries to guess
-suitable values for `bug-reference-bug-regexp' and
-`bug-reference-url-format'."
+Guesses suitable `bug-reference-bug-regexp' and
+`bug-reference-url-format' values by matching the current Rmail
+file's name against GROUP-REGEXP and the values of List-Id, To,
+From, and Cc against HEADER-REGEXP in
+`bug-reference-setup-from-mail-alist'."
   (with-demoted-errors
       "Error in bug-reference-try-setup-from-rmail: %S"
     (when (and bug-reference-mode
@@ -358,7 +360,8 @@ suitable values for `bug-reference-bug-regexp' and
             (let ((val (mail-fetch-field field)))
               (when val
                 (push val header-values)))))
-        (bug-reference--maybe-setup-from-mail nil header-values)))))
+        (bug-reference--maybe-setup-from-mail
+         (buffer-file-name) header-values)))))
 
 (defvar bug-reference-setup-from-irc-alist
   `((,(concat "#" (regexp-opt '("emacs" "gnus" "org-mode" "rcirc"
@@ -482,6 +485,18 @@ guesswork is based on these variables:
       (widen)
       (bug-reference-unfontify (point-min) (point-max)))))
 
+(defun bug-reference-mode-force-auto-setup ()
+  "Enable `bug-reference-mode' and force auto-setup.
+Enabling `bug-reference-mode' runs its auto-setup only if
+`bug-reference-bug-regexp' and `bug-reference-url-format' are not
+set already.  This function sets the latter to `nil'
+buffer-locally, so that the auto-setup will always run.
+
+This is mostly intended for MUA modes like `rmail-mode' where the
+same buffer is re-used for different contexts."
+  (setq-local bug-reference-url-format nil)
+  (bug-reference-mode))
+
 ;;;###autoload
 (define-minor-mode bug-reference-prog-mode
   "Like `bug-reference-mode', but only buttonize in comments and strings."



reply via email to

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