[notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2010-03-09 Thread Carl Worth
On Fri, 11 Dec 2009 11:01:15 +0530, "Aneesh Kumar K. V"  wrote:
> On Fri, 04 Dec 2009 11:07:54 -0800, Carl Worth  wrote:
> > On Thu,  3 Dec 2009 14:16:44 +0530, "Aneesh Kumar K.V"  > linux.vnet.ibm.com> wrote:
> > > 
> > > This patch add --format=sender-only option.
> > 
> > I like the idea here, (and agree that an 'R' keybinding would be great).
> > 
> > But surely there's a way to implement this with dramatically less code
> > duplication?
> 
> I sent an updated patch which did the above with less code duplication. Any
> chance of getting this merged ?

Thanks for the updated patch, (and I sincerely apologize for my late
response).

I still like the functionality and keybinding, and it's great to see
less code duplication in this patch, but I also agree with the point Jed
made:

  I think --format= should not be used for this, formatting is orthogonal
  to selecting recipients.

We're already using --format for selection JSON output, for example. And
it's not totally unreasonable to expect that someone might want JSON
output from "notmuch reply" as well. So let's use a separate option
here.

Perhaps:

--recipient=all|sender

or so?

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2010-03-09 Thread Carl Worth
On Fri, 11 Dec 2009 11:01:15 +0530, Aneesh Kumar K. V 
aneesh.ku...@linux.vnet.ibm.com wrote:
 On Fri, 04 Dec 2009 11:07:54 -0800, Carl Worth cwo...@cworth.org wrote:
  On Thu,  3 Dec 2009 14:16:44 +0530, Aneesh Kumar K.V 
  aneesh.ku...@linux.vnet.ibm.com wrote:
   
   This patch add --format=sender-only option.
  
  I like the idea here, (and agree that an 'R' keybinding would be great).
  
  But surely there's a way to implement this with dramatically less code
  duplication?
 
 I sent an updated patch which did the above with less code duplication. Any
 chance of getting this merged ?

Thanks for the updated patch, (and I sincerely apologize for my late
response).

I still like the functionality and keybinding, and it's great to see
less code duplication in this patch, but I also agree with the point Jed
made:

  I think --format= should not be used for this, formatting is orthogonal
  to selecting recipients.

We're already using --format for selection JSON output, for example. And
it's not totally unreasonable to expect that someone might want JSON
output from notmuch reply as well. So let's use a separate option
here.

Perhaps:

--recipient=all|sender

or so?

-Carl


pgpXF5iihtCV1.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2009-12-11 Thread Aneesh Kumar K. V
On Fri, 04 Dec 2009 11:07:54 -0800, Carl Worth  wrote:
> On Thu,  3 Dec 2009 14:16:44 +0530, "Aneesh Kumar K.V"  linux.vnet.ibm.com> wrote:
> > From: Aneesh Kumar K.V 
> > 
> > This patch add --format=sender-only option.
> 
> I like the idea here, (and agree that an 'R' keybinding would be great).
> 
> But surely there's a way to implement this with dramatically less code
> duplication?

I sent an updated patch which did the above with less code duplication. Any
chance of getting this merged ?

-aneesh


Re: [notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2009-12-10 Thread Aneesh Kumar K. V
On Fri, 04 Dec 2009 11:07:54 -0800, Carl Worth cwo...@cworth.org wrote:
 On Thu,  3 Dec 2009 14:16:44 +0530, Aneesh Kumar K.V 
 aneesh.ku...@linux.vnet.ibm.com wrote:
  From: Aneesh Kumar K.V aneesh.ku...@gmail.com
  
  This patch add --format=sender-only option.
 
 I like the idea here, (and agree that an 'R' keybinding would be great).
 
 But surely there's a way to implement this with dramatically less code
 duplication?

I sent an updated patch which did the above with less code duplication. Any
chance of getting this merged ?

-aneesh
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2009-12-04 Thread Jed Brown
On Fri, 04 Dec 2009 11:07:54 -0800, Carl Worth  wrote:

> But surely there's a way to implement this with dramatically less code
> duplication?

It should just be very short after this series

  id:1259450376-24523-1-git-send-email-jed at 59A2.org

I think --format= should not be used for this, formatting is orthogonal
to selecting recipients.

Speaking of code duplication, perhaps it is worth abstracting options
parsing (or using an existing library).

Jed


[notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2009-12-04 Thread Carl Worth
On Thu,  3 Dec 2009 14:16:44 +0530, "Aneesh Kumar K.V"  wrote:
> From: Aneesh Kumar K.V 
> 
> This patch add --format=sender-only option.

I like the idea here, (and agree that an 'R' keybinding would be great).

But surely there's a way to implement this with dramatically less code
duplication?

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2009-12-04 Thread Jed Brown
On Fri, 04 Dec 2009 11:07:54 -0800, Carl Worth cwo...@cworth.org wrote:

 But surely there's a way to implement this with dramatically less code
 duplication?

It should just be very short after this series

  id:1259450376-24523-1-git-send-email-...@59a2.org

I think --format= should not be used for this, formatting is orthogonal
to selecting recipients.

Speaking of code duplication, perhaps it is worth abstracting options
parsing (or using an existing library).

Jed
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 1/2] notmuch-reply: Add support for replying only to sender

2009-12-03 Thread Aneesh Kumar K.V
From: Aneesh Kumar K.V 

This patch add --format=sender-only option.

Signed-off-by: Aneesh Kumar K.V 
---
 notmuch-reply.c |   76 +++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 9ca1236..9d96ef1 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -354,6 +354,80 @@ notmuch_reply_format_headers_only(void *ctx, 
notmuch_config_t *config, notmuch_q
 }
 return 0;
 }
+static int
+notmuch_reply_format_sender_only(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query)
+{
+GMimeMessage *reply;
+notmuch_messages_t *messages;
+notmuch_message_t *message;
+const char *subject, *recipient, *from_addr = NULL;
+const char *in_reply_to, *orig_references, *references;
+char *reply_headers;
+
+for (messages = notmuch_query_search_messages (query);
+notmuch_messages_has_more (messages);
+notmuch_messages_advance (messages))
+{
+   message = notmuch_messages_get (messages);
+
+   /* The 1 means we want headers in a "pretty" order. */
+   reply = g_mime_message_new (1);
+   if (reply == NULL) {
+   fprintf (stderr, "Out of memory\n");
+   return 1;
+   }
+
+   subject = notmuch_message_get_header (message, "subject");
+
+   if (strncasecmp (subject, "Re:", 3))
+   subject = talloc_asprintf (ctx, "Re: %s", subject);
+   g_mime_message_set_subject (reply, subject);
+
+   recipient = notmuch_message_get_header (message, "From");
+   g_mime_object_set_header (GMIME_OBJECT (reply),
+   "To", recipient);
+
+   from_addr = notmuch_config_get_user_primary_email (config);
+   from_addr = talloc_asprintf (ctx, "%s <%s>",
+notmuch_config_get_user_name (config),
+from_addr);
+   g_mime_object_set_header (GMIME_OBJECT (reply),
+ "From", from_addr);
+
+   g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc",
+  notmuch_config_get_user_primary_email (config));
+
+   in_reply_to = talloc_asprintf (ctx, "<%s>",
+notmuch_message_get_message_id (message));
+
+   g_mime_object_set_header (GMIME_OBJECT (reply),
+ "In-Reply-To", in_reply_to);
+
+   orig_references = notmuch_message_get_header (message, "references");
+   references = talloc_asprintf (ctx, "%s%s%s",
+ orig_references ? orig_references : "",
+ orig_references ? " " : "",
+ in_reply_to);
+   g_mime_object_set_header (GMIME_OBJECT (reply),
+ "References", references);
+
+   reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
+   printf ("%s", reply_headers);
+   free (reply_headers);
+
+   g_object_unref (G_OBJECT (reply));
+   reply = NULL;
+
+   printf ("On %s, %s wrote:\n",
+   notmuch_message_get_header (message, "date"),
+   notmuch_message_get_header (message, "from"));
+
+   show_message_body (notmuch_message_get_filename (message), reply_part);
+
+   notmuch_message_destroy (message);
+}
+return 0;
+}

 int
 notmuch_reply_command (void *ctx, int argc, char *argv[])
@@ -378,6 +452,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, "sender-only") == 0) {
+   reply_format_func = notmuch_reply_format_sender_only;
} else {
fprintf (stderr, "Invalid value for --format: %s\n", opt);
return 1;
-- 
1.6.5.2.74.g610f9