From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: cworth@cworth.org, aneesh.kumar@linux.vnet.ibm.com
Cc: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>, notmuch@notmuchmail.org
Subject: [PATCH 1/2] notmuch-reply: Add support for replying only to sender
Date: Thu, 3 Dec 2009 14:16:44 +0530 [thread overview]
Message-ID: <1259830005-3439-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
This patch add --format=sender-only option.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
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
next reply other threads:[~2009-12-03 8:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-03 8:46 Aneesh Kumar K.V [this message]
2009-12-03 8:46 ` [PATCH 2/2] notmuch.el: Add support for reply-to sender Aneesh Kumar K.V
2009-12-04 19:07 ` [PATCH 1/2] notmuch-reply: Add support for replying only to sender Carl Worth
2009-12-04 19:21 ` Jed Brown
2009-12-11 5:31 ` Aneesh Kumar K. V
2010-03-09 18:25 ` Carl Worth
2010-03-10 16:31 ` [PATCH -V3 " Aneesh Kumar K.V
2010-03-11 12:45 ` Michal Sojka
2010-03-10 16:31 ` [PATCH -V3 2/2] notmuch.el: Add support for reply-to sender Aneesh Kumar K.V
2009-12-05 9:37 ` [PATCH -V2] notmuch-reply: Add support for replying only to sender Aneesh Kumar K.V
-- strict thread matches above, loose matches on Subject: below --
2010-04-06 7:11 [PATCH -V2 1/2] " Sebastian Spaeth
2010-04-06 7:12 ` [PATCH " Sebastian Spaeth
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=1259830005-3439-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aneesh.kumar@gmail.com \
--cc=cworth@cworth.org \
--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).