unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: ekeberg@kth.se
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: Add References header to forwarded messages
Date: Fri, 29 Mar 2019 13:01:09 +0100	[thread overview]
Message-ID: <20190329120109.3477-1-ekeberg@kth.se> (raw)

From: Örjan Ekeberg <ekeberg@kth.se>

Include the message-id of forwarded messages in the new message.
This ensures that the new (forwarding) message is linked to the
same thread as the message being forwarded.
---
 emacs/notmuch-mua.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 708db248..ed15bbb2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -470,8 +470,9 @@ the From: address."
   (let* ((other-headers
 	  (when (or prompt-for-sender notmuch-always-prompt-for-sender)
 	    (list (cons 'From (notmuch-mua-prompt-for-sender)))))
-	 forward-subject) ;; Comes from the first message and is
+	 forward-subject  ;; Comes from the first message and is
 			  ;; applied later.
+	 forward-references) ;; Accumulated message-ids of forwarded messages
 
     ;; Generate the template for the outgoing message.
     (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function))
@@ -489,7 +490,12 @@ the From: address."
 		  ;; Because we process the messages in reverse order,
 		  ;; always generate a forwarded subject, then use the
 		  ;; last (i.e. first) one.
-		  (setq forward-subject (message-make-forward-subject)))
+		  (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"))))
 		;; Make a copy ready to be forwarded in the
 		;; composition buffer.
 		(message-forward-make-body temp-buffer)
@@ -503,7 +509,9 @@ the From: address."
       (save-restriction
 	(message-narrow-to-headers)
 	(message-remove-header "Subject")
-	(message-add-header (concat "Subject: " forward-subject)))
+	(message-add-header (concat "Subject: " forward-subject))
+	(message-remove-header "References")
+	(message-add-header (concat "References: " forward-references)))
 
       ;; `message-forward-make-body' shows the User-agent header.  Hide
       ;; it again.
-- 
2.20.1

             reply	other threads:[~2019-03-29 12:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 12:01 ekeberg [this message]
2019-03-31 23:32 ` [PATCH] emacs: Add References header to forwarded messages Daniel Kahn Gillmor
2019-04-01 13:23   ` Örjan Ekeberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190329120109.3477-1-ekeberg@kth.se \
    --to=ekeberg@kth.se \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).