unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Implement reply to sender
@ 2011-05-26 16:06 Mark Walters
  2011-05-26 16:06 ` [PATCH 1/2] Command line changes for reply-to-sender Mark Walters
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 16:06 UTC (permalink / raw)
  To: notmuch

These patches implement a reply to sender function.
On the command line this is done via a new format
"--format=one" to notmuch reply.
In emacs it is bound to the key R

I have been running a similar patch set for some time but 
only tidied it up today. It compiles and works for me.

This is my first submission to the project so I hope that I
have done everything right.

Signed-off-by: Mark Walters <markwalters1009@gmail.com>

Mark Walters (2):
  Command line changes for reply-to-sender
  Emacs changes for reply to sender

 emacs/notmuch-mua.el  |    6 ++++--
 emacs/notmuch-show.el |    6 ++++++
 notmuch-reply.c       |   38 +++++++++++++++++++++++++++-----------
 3 files changed, 37 insertions(+), 13 deletions(-)

-- 
1.7.2.5

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

* [PATCH 1/2] Command line changes for reply-to-sender
  2011-05-26 16:06 [PATCH 0/2] Implement reply to sender Mark Walters
@ 2011-05-26 16:06 ` Mark Walters
  2011-05-26 16:06 ` [PATCH 2/2] Emacs changes for reply to sender Mark Walters
  2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
  2 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 16:06 UTC (permalink / raw)
  To: notmuch

Adds the format "--format=one" to possible reply formats which only
replies to the sender.

More precisely the function follows these rules:
reply only to sender unless it was the user
reply only to all people on the to line unless they were all the user
reply to all people on the cc line

The most common expected case is we just reply to sender, but if we reply to
our own email then we reply to the whole to line.

Implementation details

Note we continue parsing addresses beyond the ones we reply to because
we want to make sure the from address is correct. (At the very least it
is the same as it would be if we replied to all.)

We overload the message variable in add_recipients_for_address_list so
if it is NULL we parse the address (looking for the users address)
but do not add to the message recipients list

We add the variable reply_to_all to the function chain to keep track
of whether we should reply to everyone.
---
 notmuch-reply.c |   38 +++++++++++++++++++++++++++-----------
 1 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index ab15650..3df3b52 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -191,7 +191,8 @@ add_recipients_for_address_list (GMimeMessage *message,
 		if (ret == NULL)
 		    ret = addr;
 	    } else {
-		g_mime_message_add_recipient (message, type, name, addr);
+		 if (message) 
+		      g_mime_message_add_recipient (message, type, name, addr);
 	    }
 	}
     }
@@ -271,7 +272,8 @@ reply_to_header_is_redundant (notmuch_message_t *message)
 static const char *
 add_recipients_from_message (GMimeMessage *reply,
 			     notmuch_config_t *config,
-			     notmuch_message_t *message)
+			     notmuch_message_t *message,
+			     int reply_to_all)
 {
     struct {
 	const char *header;
@@ -311,9 +313,20 @@ add_recipients_from_message (GMimeMessage *reply,
 	    recipients = notmuch_message_get_header (message,
 						     reply_to_map[i].fallback);
 
-	addr = add_recipients_for_string (reply, config,
-					  reply_to_map[i].recipient_type,
-					  recipients);
+
+	/* We add the addresses if we are replying to all or we have not yet found
+	 * a non-user address. We have to keep parsing to make sure we do find the 
+	 * correct from address for the user, but we pass a NULL message
+	 */
+	if ((reply_to_all) || (g_mime_message_get_all_recipients (reply) == NULL))
+	    addr = add_recipients_for_string (reply, config,
+					      reply_to_map[i].recipient_type,
+					      recipients);
+	else
+	     addr = add_recipients_for_string (NULL, config,
+					       reply_to_map[i].recipient_type,
+					       recipients);
+
 	if (from_addr == NULL)
 	    from_addr = addr;
     }
@@ -453,7 +466,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
 }
 
 static int
-notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
+notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all)
 {
     GMimeMessage *reply;
     notmuch_messages_t *messages;
@@ -484,7 +497,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
 	    g_mime_message_set_subject (reply, subject);
 	}
 
-	from_addr = add_recipients_from_message (reply, config, message);
+	from_addr = add_recipients_from_message (reply, config, message, reply_to_all);
 
 	if (from_addr == NULL)
 	    from_addr = guess_from_received_header (config, message);
@@ -531,7 +544,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
 
 /* This format is currently tuned for a git send-email --notmuch hook */
 static int
-notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
+notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all)
 {
     GMimeMessage *reply;
     notmuch_messages_t *messages;
@@ -571,7 +584,7 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q
 	g_mime_object_set_header (GMIME_OBJECT (reply),
 				  "References", references);
 
-	(void)add_recipients_from_message (reply, config, message);
+	(void)add_recipients_from_message (reply, config, message, reply_to_all);
 
 	reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
 	printf ("%s", reply_headers);
@@ -593,7 +606,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
     notmuch_query_t *query;
     char *opt, *query_string;
     int i, ret = 0;
-    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query);
+    int reply_to_all = 1;
+    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all);
 
     reply_format_func = notmuch_reply_format_default;
 
@@ -608,6 +622,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 		reply_format_func = notmuch_reply_format_default;
 	    } else if (strcmp (opt, "headers-only") == 0) {
 		reply_format_func = notmuch_reply_format_headers_only;
+	    } else if (strcmp (opt, "one") == 0) {
+		reply_to_all = 0;
 	    } else {
 		fprintf (stderr, "Invalid value for --format: %s\n", opt);
 		return 1;
@@ -647,7 +663,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 	return 1;
     }
 
-    if (reply_format_func (ctx, config, query) != 0)
+    if (reply_format_func (ctx, config, query, reply_to_all) != 0)
 	return 1;
 
     notmuch_query_destroy (query);
-- 
1.7.2.5

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

* [PATCH 2/2] Emacs changes for reply to sender
  2011-05-26 16:06 [PATCH 0/2] Implement reply to sender Mark Walters
  2011-05-26 16:06 ` [PATCH 1/2] Command line changes for reply-to-sender Mark Walters
@ 2011-05-26 16:06 ` Mark Walters
  2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
  2 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 16:06 UTC (permalink / raw)
  To: notmuch

Reply to sender is currently bound to R
---
 emacs/notmuch-mua.el  |    6 ++++--
 emacs/notmuch-show.el |    6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index dc7b386..4b8590f 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -69,13 +69,15 @@ list."
 	    (push header message-hidden-headers)))
 	notmuch-mua-hidden-headers))
 
-(defun notmuch-mua-reply (query-string)
+(defun notmuch-mua-reply (query-string &optional option-string)
   (let (headers body)
     ;; This make assumptions about the output of `notmuch reply', but
     ;; really only that the headers come first followed by a blank
     ;; line and then the body.
     (with-temp-buffer
-      (call-process notmuch-command nil t nil "reply" query-string)
+      (if option-string
+	  (call-process notmuch-command nil t nil "reply" option-string query-string)
+	(call-process notmuch-command nil t nil "reply" query-string))
       (goto-char (point-min))
       (if (re-search-forward "^$" nil t)
 	  (save-excursion
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9a38d9c..5dbc103 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -795,6 +795,7 @@ function is used. "
 	(define-key map "m" 'notmuch-mua-mail)
 	(define-key map "f" 'notmuch-show-forward-message)
 	(define-key map "r" 'notmuch-show-reply)
+	(define-key map "R" 'notmuch-show-reply-one)
 	(define-key map "|" 'notmuch-show-pipe-message)
 	(define-key map "w" 'notmuch-show-save-attachments)
 	(define-key map "V" 'notmuch-show-view-raw-message)
@@ -1103,6 +1104,11 @@ any effects from previous calls to
   (interactive)
   (notmuch-mua-reply (notmuch-show-get-message-id)))
 
+(defun notmuch-show-reply-one ()
+  "Reply to the current message."
+  (interactive)
+  (notmuch-mua-reply (notmuch-show-get-message-id) "--format=one"))
+
 (defun notmuch-show-forward-message ()
   "Forward the current message."
   (interactive)
-- 
1.7.2.5

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

* Re: [PATCH 0/2] Implement reply to sender
  2011-05-26 16:06 [PATCH 0/2] Implement reply to sender Mark Walters
  2011-05-26 16:06 ` [PATCH 1/2] Command line changes for reply-to-sender Mark Walters
  2011-05-26 16:06 ` [PATCH 2/2] Emacs changes for reply to sender Mark Walters
@ 2011-05-26 21:21 ` Carl Worth
  2011-05-26 23:31   ` [PATCH v2 0/3] " Mark Walters
                     ` (3 more replies)
  2 siblings, 4 replies; 8+ messages in thread
From: Carl Worth @ 2011-05-26 21:21 UTC (permalink / raw)
  To: Mark Walters, notmuch

[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]

On Thu, 26 May 2011 17:06:50 +0100, Mark Walters <markwalters1009@gmail.com> wrote:
> These patches implement a reply to sender function.
> On the command line this is done via a new format
> "--format=one" to notmuch reply.
> In emacs it is bound to the key R

I like the feature (at the emacs level). Doing this with "--format=one"
isn't correct though. This new functionality should be orthogonal to
format, (for example, one might want --format=headers-only and still
reply only to the sender).

How about:

	--reply-to=sender
vs.
	--reply-to=all	# Which would be the default

Also, the patch should update the documentation for "notmuch reply",
(both in notmuch.c and notmuch.1).

> I have been running a similar patch set for some time but 
> only tidied it up today. It compiles and works for me.

Thanks for sharing this.

> This is my first submission to the project so I hope that I
> have done everything right.

Perfectly. Keep up the good work.

> Signed-off-by: Mark Walters <markwalters1009@gmail.com>

We don't actually require signed-off-by lines in the notmuch project. I
know the notmuchmail.org website currently points to the git project's
patch submission guidelines. We should really write our own such
guidelines, (which would be dramatically simpler than those from the git
project).

-Carl

-- 
carl.d.worth@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* [PATCH v2 0/3] Implement reply to sender
  2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
@ 2011-05-26 23:31   ` Mark Walters
  2011-05-26 23:31   ` [PATCH v2 1/3] Adds the option "--reply-to=" to notmuch reply Mark Walters
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 23:31 UTC (permalink / raw)
  To: notmuch

Many thanks for the rapid response: I have modified the
patches as suggested and this version includes the
necessary documentation changes. I have also modified the
emacs portion to apply to current master.

Best wishes

Mark


These patches implement a reply to sender function.

On the command line this is done via a new option
to notmuch-reply: --reply-to=(sender|all) with all being
the default (as suggested).

In emacs it is bound to the key R. (Note it does not touch the
reply to thread command from notmuch-search: it is unclear to me
what reply to sender would mean there.)

Mark Walters (3):
  Adds the option "--reply-to" to notmuch reply.
  Documentation changes for --reply-to= option to notmuch reply.
  Emacs changes for reply to sender

 emacs/notmuch-mua.el  |   10 ++++++----
 emacs/notmuch-show.el |    8 +++++++-
 emacs/notmuch.el      |    2 +-
 notmuch-reply.c       |   46 +++++++++++++++++++++++++++++++++++-----------
 notmuch.1             |   13 +++++++++++++
 notmuch.c             |   10 ++++++++++
 6 files changed, 72 insertions(+), 17 deletions(-)

-- 
1.7.2.5

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

* [PATCH v2 1/3] Adds the option "--reply-to=" to notmuch reply.
  2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
  2011-05-26 23:31   ` [PATCH v2 0/3] " Mark Walters
@ 2011-05-26 23:31   ` Mark Walters
  2011-05-26 23:31   ` [PATCH v2 2/3] Documentation changes for --reply-to= option " Mark Walters
  2011-05-26 23:31   ` [PATCH v2 3/3] Emacs changes for reply to sender Mark Walters
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 23:31 UTC (permalink / raw)
  To: notmuch

Possible values are "sender" which replies just to sender and
"all" (the default).

More precisely reply to sender follows these rules:
reply only to sender unless it was the user
reply only to all people on the to line unless they were all the user
reply to all people on the cc line

Implementation details

Note we continue parsing addresses beyond the ones we reply to because
we want to make sure the from address is correct. (At the very least it
is the same as it would be if we replied to all.)

We overload the message variable in add_recipients_for_address_list so
if it is NULL we parse the address (looking for the users address)
but do not add to the message recipients list

We add the variable reply_to_all to the function chain to keep track
of whether we should reply to everyone.
---
 notmuch-reply.c |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index ab15650..98ae94a 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -191,7 +191,8 @@ add_recipients_for_address_list (GMimeMessage *message,
 		if (ret == NULL)
 		    ret = addr;
 	    } else {
-		g_mime_message_add_recipient (message, type, name, addr);
+		 if (message)
+		      g_mime_message_add_recipient (message, type, name, addr);
 	    }
 	}
     }
@@ -271,7 +272,8 @@ reply_to_header_is_redundant (notmuch_message_t *message)
 static const char *
 add_recipients_from_message (GMimeMessage *reply,
 			     notmuch_config_t *config,
-			     notmuch_message_t *message)
+			     notmuch_message_t *message,
+			     int reply_to_all)
 {
     struct {
 	const char *header;
@@ -311,9 +313,20 @@ add_recipients_from_message (GMimeMessage *reply,
 	    recipients = notmuch_message_get_header (message,
 						     reply_to_map[i].fallback);
 
-	addr = add_recipients_for_string (reply, config,
-					  reply_to_map[i].recipient_type,
-					  recipients);
+
+	/* We add the addresses if we are replying to all or we have not yet found
+	 * a non-user address. We have to keep parsing to make sure we do find the
+	 * correct from address for the user, but we pass a NULL message
+	 */
+	if ((reply_to_all) || (g_mime_message_get_all_recipients (reply) == NULL))
+	    addr = add_recipients_for_string (reply, config,
+					      reply_to_map[i].recipient_type,
+					      recipients);
+	else
+	     addr = add_recipients_for_string (NULL, config,
+					       reply_to_map[i].recipient_type,
+					       recipients);
+
 	if (from_addr == NULL)
 	    from_addr = addr;
     }
@@ -453,7 +466,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
 }
 
 static int
-notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
+notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all)
 {
     GMimeMessage *reply;
     notmuch_messages_t *messages;
@@ -484,7 +497,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
 	    g_mime_message_set_subject (reply, subject);
 	}
 
-	from_addr = add_recipients_from_message (reply, config, message);
+	from_addr = add_recipients_from_message (reply, config, message, reply_to_all);
 
 	if (from_addr == NULL)
 	    from_addr = guess_from_received_header (config, message);
@@ -531,7 +544,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_
 
 /* This format is currently tuned for a git send-email --notmuch hook */
 static int
-notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)
+notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all)
 {
     GMimeMessage *reply;
     notmuch_messages_t *messages;
@@ -571,7 +584,7 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q
 	g_mime_object_set_header (GMIME_OBJECT (reply),
 				  "References", references);
 
-	(void)add_recipients_from_message (reply, config, message);
+	(void)add_recipients_from_message (reply, config, message, reply_to_all);
 
 	reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
 	printf ("%s", reply_headers);
@@ -593,7 +606,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
     notmuch_query_t *query;
     char *opt, *query_string;
     int i, ret = 0;
-    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query);
+    int reply_to_all = 1;
+    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all);
 
     reply_format_func = notmuch_reply_format_default;
 
@@ -612,6 +626,16 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 		fprintf (stderr, "Invalid value for --format: %s\n", opt);
 		return 1;
 	    }
+	} else if (STRNCMP_LITERAL (argv[i], "--reply-to=") == 0) {
+	    opt = argv[i] + sizeof ("--reply-to=") - 1;
+	    if (strcmp (opt, "sender") == 0) {
+		 reply_to_all = 0;
+	    } else if (strcmp (opt, "all") == 0) {
+		 reply_to_all = 1;
+	    } else {
+		 fprintf (stderr, "Invalid value for --reply-to: %s\n", opt);
+		 return 1;
+	    }
 	} else {
 	    fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
 	    return 1;
@@ -647,7 +671,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 	return 1;
     }
 
-    if (reply_format_func (ctx, config, query) != 0)
+    if (reply_format_func (ctx, config, query, reply_to_all) != 0)
 	return 1;
 
     notmuch_query_destroy (query);
-- 
1.7.2.5

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

* [PATCH v2 2/3] Documentation changes for --reply-to= option to notmuch reply.
  2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
  2011-05-26 23:31   ` [PATCH v2 0/3] " Mark Walters
  2011-05-26 23:31   ` [PATCH v2 1/3] Adds the option "--reply-to=" to notmuch reply Mark Walters
@ 2011-05-26 23:31   ` Mark Walters
  2011-05-26 23:31   ` [PATCH v2 3/3] Emacs changes for reply to sender Mark Walters
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 23:31 UTC (permalink / raw)
  To: notmuch

---
 notmuch.1 |   13 +++++++++++++
 notmuch.c |   10 ++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/notmuch.1 b/notmuch.1
index a1c7fa8..c434e77 100644
--- a/notmuch.1
+++ b/notmuch.1
@@ -388,6 +388,19 @@ Includes subject and quoted message body.
 .BR headers\-only
 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
 .RE
+.RE
+.RS
+.TP 4
+.BR \-\-reply\-to= ( sender | all )
+.RS
+.TP 4
+.BR sender
+Replies only to the sender (or to all addresses in the To header if
+the sending address is one of the user's email addresses).
+.TP
+.BR all " (default)"
+Replies to all addresses.
+.RE
 
 See the
 .B "SEARCH SYNTAX"
diff --git a/notmuch.c b/notmuch.c
index 262d677..631f8e7 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -338,6 +338,16 @@ static command_t commands[] = {
       "\t\t\tOnly produces In-Reply-To, References, To\n"
       "\t\t\tCc, and Bcc headers.\n"
       "\n"
+      "\t--reply-to=(sender|all)\n"
+      "\n"
+      "\t\tsender:\n"
+      "\t\t\tReplies  only  to the sender (or to all addresses in the\n"
+      "\t\t\tTo header if the sending address is one of the user's\n"
+      "\t\t\temail addresses).\n"
+      "\n"
+      "\t\tall: (default)\n"
+      "\t\t\tReplies to all recipients.\n"
+      "\n"
       "\tSee \"notmuch help search-terms\" for details of the search\n"
       "\tterms syntax." },
     { "tag", notmuch_tag_command,
-- 
1.7.2.5

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

* [PATCH v2 3/3] Emacs changes for reply to sender
  2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
                     ` (2 preceding siblings ...)
  2011-05-26 23:31   ` [PATCH v2 2/3] Documentation changes for --reply-to= option " Mark Walters
@ 2011-05-26 23:31   ` Mark Walters
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2011-05-26 23:31 UTC (permalink / raw)
  To: notmuch

Reply to sender is currently bound to R
---
 emacs/notmuch-mua.el  |   10 ++++++----
 emacs/notmuch-show.el |    8 +++++++-
 emacs/notmuch.el      |    2 +-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 61a723b..c9c5854 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -69,13 +69,15 @@ list."
 	    (push header message-hidden-headers)))
 	notmuch-mua-hidden-headers))
 
-(defun notmuch-mua-reply (query-string &optional sender)
+(defun notmuch-mua-reply (query-string option-string &optional sender)
   (let (headers body)
     ;; This make assumptions about the output of `notmuch reply', but
     ;; really only that the headers come first followed by a blank
     ;; line and then the body.
     (with-temp-buffer
-      (call-process notmuch-command nil t nil "reply" query-string)
+      (if option-string
+	  (call-process notmuch-command nil t nil "reply" option-string query-string)
+	(call-process notmuch-command nil t nil "reply" query-string))
       (goto-char (point-min))
       (if (re-search-forward "^$" nil t)
 	  (save-excursion
@@ -194,13 +196,13 @@ the From: address first."
 	(notmuch-mua-forward-message))
     (notmuch-mua-forward-message)))
 
-(defun notmuch-mua-new-reply (query-string &optional prompt-for-sender)
+(defun notmuch-mua-new-reply (query-string option-string &optional prompt-for-sender)
   "Invoke the notmuch reply window."
   (interactive "P")
   (let ((sender
 	 (when (or prompt-for-sender notmuch-always-prompt-for-sender)
 	   (notmuch-mua-prompt-for-sender))))
-    (notmuch-mua-reply query-string sender)))
+    (notmuch-mua-reply query-string option-string sender)))
 
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 2ba151e..852dadf 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -795,6 +795,7 @@ function is used. "
 	(define-key map "m" 'notmuch-mua-new-mail)
 	(define-key map "f" 'notmuch-show-forward-message)
 	(define-key map "r" 'notmuch-show-reply)
+	(define-key map "R" 'notmuch-show-reply-sender)
 	(define-key map "|" 'notmuch-show-pipe-message)
 	(define-key map "w" 'notmuch-show-save-attachments)
 	(define-key map "V" 'notmuch-show-view-raw-message)
@@ -1101,7 +1102,12 @@ any effects from previous calls to
 (defun notmuch-show-reply (&optional prompt-for-sender)
   "Reply to the current message."
   (interactive "P")
-  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))
+  (notmuch-mua-new-reply (notmuch-show-get-message-id) nil prompt-for-sender))
+
+(defun notmuch-show-reply-sender (&optional prompt-for-sender)
+  "Reply to the current message."
+  (interactive "P")
+  (notmuch-mua-new-reply (notmuch-show-get-message-id) "--reply-to=sender" prompt-for-sender))
 
 (defun notmuch-show-forward-message (&optional prompt-for-sender)
   "Forward the current message."
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c22add7..e956420 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -440,7 +440,7 @@ Complete list of currently available key bindings:
   "Begin composing a reply to the entire current thread in a new buffer."
   (interactive "P")
   (let ((message-id (notmuch-search-find-thread-id)))
-    (notmuch-mua-new-reply message-id prompt-for-sender)))
+    (notmuch-mua-new-reply message-id nil prompt-for-sender)))
 
 (defun notmuch-call-notmuch-process (&rest args)
   "Synchronously invoke \"notmuch\" with the given list of arguments.
-- 
1.7.2.5

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

end of thread, other threads:[~2011-05-26 23:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-26 16:06 [PATCH 0/2] Implement reply to sender Mark Walters
2011-05-26 16:06 ` [PATCH 1/2] Command line changes for reply-to-sender Mark Walters
2011-05-26 16:06 ` [PATCH 2/2] Emacs changes for reply to sender Mark Walters
2011-05-26 21:21 ` [PATCH 0/2] Implement " Carl Worth
2011-05-26 23:31   ` [PATCH v2 0/3] " Mark Walters
2011-05-26 23:31   ` [PATCH v2 1/3] Adds the option "--reply-to=" to notmuch reply Mark Walters
2011-05-26 23:31   ` [PATCH v2 2/3] Documentation changes for --reply-to= option " Mark Walters
2011-05-26 23:31   ` [PATCH v2 3/3] Emacs changes for reply to sender Mark Walters

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