unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Threading of forwarded messages
@ 2019-01-22 22:15 Örjan Ekeberg
  2019-01-23 21:46 ` Tomi Ollila
  2019-09-03 10:17 ` David Bremner
  0 siblings, 2 replies; 6+ messages in thread
From: Örjan Ekeberg @ 2019-01-22 22:15 UTC (permalink / raw)
  To: notmuch

Hi,

Let me first say that I am a very happy user of notmuch+emacs.  Once the
initial setup and configuration was done, usage has been a very pleasant
experience.  It daily saves me from getting lost in the constant torrent
of incoming e-mail, where most need replies or to be forwarded to others
to deal with.

One thing that I have not been able to configure is the handling of
forwarded messages.  Forwarded messages are archived as new messages,
not linked to the messages being forwarded.  This makes it hard to keep
track of which messages I have forwarded (and therefore is in the hands
of someone else).  I would like the messages to be linked into the same
thread.

From what I understand, it would be sufficient if
notmuch-mua-new-forward-messages (or something further down the call
chain) would add the Message-Id of the forwarded message to the
References header line of the new message.  This is what happens when
using reply instead of forward.

Manually adding such a references-head before sending seems to have
the desired effect of linking them into the same thread.  Also, from
what I can see, gmail does indeed include such a Refrerences-head when
doing forward.

Adding to the wishlist; it would be nice if forwarded messages could
also be tagged as "forwarded", much like how replied messages are tagged
"replied".  I guess this could be done via some sort of forward-hook,
but I can not find anything like this.

/Örjan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Threading of forwarded messages
  2019-01-22 22:15 Threading of forwarded messages Örjan Ekeberg
@ 2019-01-23 21:46 ` Tomi Ollila
  2019-01-23 23:28   ` Örjan Ekeberg
  2019-01-24 10:08   ` Threading of " David Edmondson
  2019-09-03 10:17 ` David Bremner
  1 sibling, 2 replies; 6+ messages in thread
From: Tomi Ollila @ 2019-01-23 21:46 UTC (permalink / raw)
  To: Örjan Ekeberg, notmuch

On Tue, Jan 22 2019, Örjan Ekeberg wrote:

> Hi,
>
> Let me first say that I am a very happy user of notmuch+emacs.  Once the
> initial setup and configuration was done, usage has been a very pleasant
> experience.  It daily saves me from getting lost in the constant torrent
> of incoming e-mail, where most need replies or to be forwarded to others
> to deal with.
>
> One thing that I have not been able to configure is the handling of
> forwarded messages.  Forwarded messages are archived as new messages,
> not linked to the messages being forwarded.  This makes it hard to keep
> track of which messages I have forwarded (and therefore is in the hands
> of someone else).  I would like the messages to be linked into the same
> thread.
>
> From what I understand, it would be sufficient if
> notmuch-mua-new-forward-messages (or something further down the call
> chain) would add the Message-Id of the forwarded message to the
> References header line of the new message.  This is what happens when
> using reply instead of forward.

notmuch-mua-new-forward-messages would be the place adding message-id's
to the references header (perhaps where 'appropriate subject' is added)
probably not much work but SMOP anyway ;/

>
> Manually adding such a references-head before sending seems to have
> the desired effect of linking them into the same thread.  Also, from
> what I can see, gmail does indeed include such a Refrerences-head when
> doing forward.
>
> Adding to the wishlist; it would be nice if forwarded messages could
> also be tagged as "forwarded", much like how replied messages are tagged
> "replied".  I guess this could be done via some sort of forward-hook,
> but I can not find anything like this.

replied is added in notmuch-message-mark-replied called via 
message-send-hook -- and notmuch-message-mark-replied looks for In-Reply-To
header and some other stuff (did not look deeply enough) to determine
whether to add notmuch-message-replied-tags... and it looks this hook
is run to all messages to be send...

...cannot say directly whether some other message processing could be used
to do to add "forwarded-tags" -- or alternatively making notmuch-send-hook
buffer-local to the message buffer created by
notmuch-mua-new-forward-messages and then just add-hook'ing code to 
do the tagging operation at send time.

Marked the replied message with notmuch::wishlist in 
https://nmbug.notmuchmail.org/status/

Tomi

>
> /Örjan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Threading of forwarded messages
  2019-01-23 21:46 ` Tomi Ollila
@ 2019-01-23 23:28   ` Örjan Ekeberg
  2019-01-24 21:20     ` [RFC PATCH] forward: Add References header to " Örjan Ekeberg
  2019-01-24 10:08   ` Threading of " David Edmondson
  1 sibling, 1 reply; 6+ messages in thread
From: Örjan Ekeberg @ 2019-01-23 23:28 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:
> notmuch-mua-new-forward-messages would be the place adding message-id's
> to the references header (perhaps where 'appropriate subject' is added)
> probably not much work but SMOP anyway ;/

Indeed.  Here is an attempt that seems to do the trick.
This is a modified version of notmuch-mua-new-forward-messages
(extracted from notmuch-mua-el).  Sorry for not posting it as a patch.
Changes are the lines involving the variable forward-references.
Please check if this is the right approach.


(defun notmuch-mua-new-forward-messages (messages &optional prompt-for-sender)
  "Compose a new message forwarding MESSAGES.

If PROMPT-FOR-SENDER is non-nil, the user will be prompteed for
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
			  ;; 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))

    (save-excursion
      ;; Insert all of the forwarded messages.
      (mapc (lambda (id)
	      (let ((temp-buffer (get-buffer-create
				  (concat "*notmuch-fwd-raw-" id "*"))))
		;; Get the raw version of this message in the buffer.
		(with-current-buffer temp-buffer
		  (erase-buffer)
		  (let ((coding-system-for-read 'no-conversion))
		    (call-process notmuch-command nil t nil "show" "--format=raw" id))
		  ;; 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))
		  (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)
		;; Kill the temporary buffer.
		(kill-buffer temp-buffer)))
	    ;; `message-forward-make-body' always puts the message at
	    ;; the top, so do them in reverse order.
	    (reverse messages))

      ;; Add in the appropriate subject.
      (save-restriction
	(message-narrow-to-headers)
	(message-remove-header "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.
      (message-hide-headers)
      (set-buffer-modified-p nil))))

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Threading of forwarded messages
  2019-01-23 21:46 ` Tomi Ollila
  2019-01-23 23:28   ` Örjan Ekeberg
@ 2019-01-24 10:08   ` David Edmondson
  1 sibling, 0 replies; 6+ messages in thread
From: David Edmondson @ 2019-01-24 10:08 UTC (permalink / raw)
  To: Tomi Ollila, Örjan Ekeberg, notmuch

On Wednesday, 2019-01-23 at 23:46:24 +02, Tomi Ollila wrote:

> On Tue, Jan 22 2019, Örjan Ekeberg wrote:
>> Adding to the wishlist; it would be nice if forwarded messages could
>> also be tagged as "forwarded", much like how replied messages are tagged
>> "replied".  I guess this could be done via some sort of forward-hook,
>> but I can not find anything like this.
>
> replied is added in notmuch-message-mark-replied called via 
> message-send-hook -- and notmuch-message-mark-replied looks for In-Reply-To
> header and some other stuff (did not look deeply enough) to determine
> whether to add notmuch-message-replied-tags... and it looks this hook
> is run to all messages to be send...
>
> ...cannot say directly whether some other message processing could be used
> to do to add "forwarded-tags" -- or alternatively making notmuch-send-hook
> buffer-local to the message buffer created by
> notmuch-mua-new-forward-messages and then just add-hook'ing code to 
> do the tagging operation at send time.
>
> Marked the replied message with notmuch::wishlist in 
> https://nmbug.notmuchmail.org/status/

Having a standard hook that adds tags when the message is sent based on
a (typically buffer local) variable would be a convenient and generally
useful approach.

dme.
-- 
Ah, oh your hair is beautiful.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC PATCH] forward: Add References header to forwarded messages
  2019-01-23 23:28   ` Örjan Ekeberg
@ 2019-01-24 21:20     ` Örjan Ekeberg
  0 siblings, 0 replies; 6+ messages in thread
From: Örjan Ekeberg @ 2019-01-24 21:20 UTC (permalink / raw)
  To: notmuch


Include the message-id of forwarded messages in the new message.
This ensures that the new message is linked to the same thread.
---
 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 e205fa4c..1ba9317e 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -433,8 +433,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))
@@ -452,7 +453,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)
@@ -466,7 +472,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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Threading of forwarded messages
  2019-01-22 22:15 Threading of forwarded messages Örjan Ekeberg
  2019-01-23 21:46 ` Tomi Ollila
@ 2019-09-03 10:17 ` David Bremner
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2019-09-03 10:17 UTC (permalink / raw)
  To: Örjan Ekeberg, notmuch

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

> Hi,
>
> Let me first say that I am a very happy user of notmuch+emacs.  Once the
> initial setup and configuration was done, usage has been a very pleasant
> experience.  It daily saves me from getting lost in the constant torrent
> of incoming e-mail, where most need replies or to be forwarded to others
> to deal with.
>
> One thing that I have not been able to configure is the handling of
> forwarded messages.  Forwarded messages are archived as new messages,
> not linked to the messages being forwarded.  This makes it hard to keep
> track of which messages I have forwarded (and therefore is in the hands
> of someone else).  I would like the messages to be linked into the same
> thread.

This feature should be available in notmuch 0.29.

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-03 10:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-22 22:15 Threading of forwarded messages Örjan Ekeberg
2019-01-23 21:46 ` Tomi Ollila
2019-01-23 23:28   ` Örjan Ekeberg
2019-01-24 21:20     ` [RFC PATCH] forward: Add References header to " Örjan Ekeberg
2019-01-24 10:08   ` Threading of " David Edmondson
2019-09-03 10:17 ` David Bremner

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).