summaryrefslogtreecommitdiff
path: root/lisp/progmodes/bug-reference.el
diff options
context:
space:
mode:
authorTassilo Horn <tsdh@gnu.org>2021-05-16 09:21:48 +0200
committerTassilo Horn <tsdh@gnu.org>2021-05-16 09:21:48 +0200
commit1b8f013d179e8866819fe53b4708b57e753a08fc (patch)
treeec19795d3fa042a0a139750ff05d56c82835ba63 /lisp/progmodes/bug-reference.el
parentb6e0b66e0edfcf339b37cd4ddc99a56dee1df213 (diff)
downloademacs-1b8f013d179e8866819fe53b4708b57e753a08fc.tar.gz
Bug reference auto-setup for Rmail
* lisp/progmodes/bug-reference.el (bug-reference-try-setup-from-rmail): New function setting up `bug-reference-mode' from the current Rmail message.
Diffstat (limited to 'lisp/progmodes/bug-reference.el')
-rw-r--r--lisp/progmodes/bug-reference.el23
1 files changed, 21 insertions, 2 deletions
diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index 81aeb60bdd5..bdbe048a933 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -238,8 +238,8 @@ and apply it if applicable."
"An alist for setting up `bug-reference-mode' in mail modes.
This takes action if `bug-reference-mode' is enabled in group and
-message buffers of Emacs mail clients. Currently, only Gnus is
-supported.
+message buffers of Emacs mail clients. Currently, Gnus and Rmail
+are supported.
Each element has the form
@@ -342,6 +342,24 @@ and set it if applicable."
(push val header-values))))))
(bug-reference--maybe-setup-from-mail nil header-values)))))))
+(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'."
+ (with-demoted-errors
+ "Error in bug-reference-try-setup-from-rmail: %S"
+ (when (and bug-reference-mode
+ (derived-mode-p 'rmail-mode))
+ (let (header-values)
+ (save-excursion
+ (goto-char (point-min))
+ (dolist (field '("list-id" "to" "from" "cc"))
+ (let ((val (mail-fetch-field field)))
+ (when val
+ (push val header-values)))))
+ (bug-reference--maybe-setup-from-mail nil header-values)))))
+
(defvar bug-reference-setup-from-irc-alist
`((,(concat "#" (regexp-opt '("emacs" "gnus" "org-mode" "rcirc"
"erc") 'words))
@@ -423,6 +441,7 @@ and set it if applicable."
(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)
"Functions trying to auto-setup `bug-reference-mode'.