[PATCH 2/2] emacs: Tag forwarded messages with +forwarded (customizable)
Örjan Ekeberg
ekeberg at kth.se
Sat Mar 30 14:48:21 PDT 2019
Use the buffer-local variable notmuch-message-queued-tag-changes
to change tags when the forwarding message is sent.
---
emacs/notmuch-message.el | 13 +++++++++++++
emacs/notmuch-mua.el | 21 ++++++++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index 513bbe66..f6466de8 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -38,6 +38,19 @@ the \"inbox\" and \"todo\" tags, you would set:
:type '(repeat string)
:group 'notmuch-send)
+(defcustom notmuch-message-forwarded-tags '("+forwarded")
+ "List of tag changes to apply to a message when it has been forwarded.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message being forwarded.
+
+For example, if you wanted to add a \"forwarded\" tag and remove
+the \"inbox\" tag, you would set:
+ (\"+forwarded\" \"-inbox\")"
+ :type '(repeat string)
+ :group 'notmuch-send)
+
;; This function is not used by default, but kept for backward compatibility
(defun notmuch-message-mark-replied ()
;; get the in-reply-to header and parse it for the message id.
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index b23a8c2d..4030399e 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -477,7 +477,8 @@ the From: address."
(list (cons 'From (notmuch-mua-prompt-for-sender)))))
forward-subject ;; Comes from the first message and is
;; applied later.
- forward-references) ;; Accumulated message-ids of forwarded messages
+ forward-references ;; List of accumulated message-references of forwarded messages
+ forward-queries) ;; List of corresponding message-query
;; Generate the template for the outgoing message.
(notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function))
@@ -496,11 +497,8 @@ the From: address."
;; always generate a forwarded subject, then use the
;; last (i.e. first) one.
(setq forward-subject (message-make-forward-subject))
- (if forward-references
- (setq forward-references
- (concat forward-references ", "
- (message-fetch-field "Message-ID")))
- (setq forward-references (message-fetch-field "Message-ID"))))
+ (push (message-fetch-field "Message-ID") forward-references)
+ (push id forward-queries))
;; Make a copy ready to be forwarded in the
;; composition buffer.
(message-forward-make-body temp-buffer)
@@ -516,7 +514,16 @@ the From: address."
(message-remove-header "Subject")
(message-add-header (concat "Subject: " forward-subject))
(message-remove-header "References")
- (message-add-header (concat "References: " forward-references)))
+ (message-add-header (concat "References: "
+ (mapconcat 'identity forward-references ", "))))
+
+ ;; Create a buffer-local queue for tag changes triggered when sending the message
+ (when notmuch-message-forwarded-tags
+ (setq-local notmuch-message-queued-tag-changes
+ (loop for id in forward-queries
+ collect
+ (cons id
+ notmuch-message-forwarded-tags))))
;; `message-forward-make-body' shows the User-agent header. Hide
;; it again.
--
2.20.1
More information about the notmuch
mailing list