]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Add References header to forwarded messages
authorÖrjan Ekeberg <ekeberg@kth.se>
Fri, 12 Apr 2019 12:01:10 +0000 (14:01 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 14 Apr 2019 10:57:32 +0000 (07:57 -0300)
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

index 708db2487fe519cda6effe05b5bd418101bef172..23f3d8b12cf10dbca3f6e8cdc8079718fbc04ab5 100644 (file)
@@ -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)))))
   (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.
                          ;; applied later.
+        forward-references) ;; List of accumulated message-references of forwarded messages
 
     ;; Generate the template for the outgoing message.
     (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function))
 
     ;; Generate the template for the outgoing message.
     (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function))
@@ -489,7 +490,8 @@ the From: address."
                  ;; Because we process the messages in reverse order,
                  ;; always generate a forwarded subject, then use the
                  ;; last (i.e. first) one.
                  ;; 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))
+                 (push (message-fetch-field "Message-ID") forward-references))
                ;; Make a copy ready to be forwarded in the
                ;; composition buffer.
                (message-forward-make-body temp-buffer)
                ;; Make a copy ready to be forwarded in the
                ;; composition buffer.
                (message-forward-make-body temp-buffer)
@@ -503,7 +505,10 @@ the From: address."
       (save-restriction
        (message-narrow-to-headers)
        (message-remove-header "Subject")
       (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: "
+                                   (mapconcat 'identity forward-references " "))))
 
       ;; `message-forward-make-body' shows the User-agent header.  Hide
       ;; it again.
 
       ;; `message-forward-make-body' shows the User-agent header.  Hide
       ;; it again.