aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-reply.c
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-11-10 18:46:26 -0800
committerGravatar Carl Worth <cworth@cworth.org>2009-11-10 18:46:26 -0800
commitdfc0780cbab2106a9d8fca69cefae02d4102f397 (patch)
treef9acf7f54a05383eb4b4d2bb5c775bf102f868d0 /notmuch-reply.c
parent54d79f60a19566493593c0399a27ced0f0aa72e2 (diff)
notmuch reply: Process headers a bit more accurately.
We know take the original From: and all recipients and put them on the To: line. We also add a "Re: " to the subject, and we add In-Reply-To: and References: headers.
Diffstat (limited to 'notmuch-reply.c')
-rw-r--r--notmuch-reply.c65
1 files changed, 53 insertions, 12 deletions
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 0c3ea13f..40ef4c64 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -81,13 +81,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
notmuch_messages_t *messages;
notmuch_message_t *message;
int ret = 0;
-
- const char *headers[] = {
- "Subject", "From", "To", "Cc", "Bcc", "Date",
- "In-Reply-To", "References"
- };
- const char *name, *value;
- unsigned int i;
+ int has_recipient;
+ const char *subject, *to, *references;
notmuch = notmuch_database_open (NULL);
if (notmuch == NULL) {
@@ -115,12 +110,58 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
{
message = notmuch_messages_get (messages);
- for (i = 0; i < ARRAY_SIZE (headers); i++) {
- name = headers[i];
- value = notmuch_message_get_header (message, name);
- if (value)
- printf ("%s: %s\n", name, value);
+ subject = notmuch_message_get_header (message, "subject");
+
+ /* XXX: Should have the user's email address(es) configured
+ * somewhere, and should fish it out of any recipient headers
+ * to reply by default from the same address that the original
+ * email was sent to */
+ printf ("From: \n");
+
+ /* XXX: Should fold long recipient lists. */
+ printf ("To:");
+ has_recipient = 0;
+
+ to = notmuch_message_get_header (message, "from");
+ if (to) {
+ printf (" %s", to);
+ has_recipient = 1;
+ }
+ to = notmuch_message_get_header (message, "to");
+ if (to) {
+ printf ("%s%s",
+ has_recipient ? ", " : " ", to);
+ has_recipient = 1;
+ }
+ to = notmuch_message_get_header (message, "cc");
+ if (to) {
+ printf ("%s%s",
+ has_recipient ? ", " : " ", to);
+ has_recipient = 1;
}
+ to = notmuch_message_get_header (message, "bcc");
+ if (to) {
+ printf ("%s%s",
+ has_recipient ? ", " : " ", to);
+ has_recipient = 1;
+ }
+
+ printf ("\n");
+
+ if (strncasecmp (subject, "Re:", 3))
+ subject = talloc_asprintf (ctx, "Re: %s", subject);
+ printf ("Subject: %s\n", subject);
+
+ printf ("In-Reply-To: <%s>\n",
+ notmuch_message_get_message_id (message));
+
+ /* XXX: Should fold long references lists. */
+ references = notmuch_message_get_header (message, "references");
+ printf ("References: %s <%s>\n",
+ references ? references : "",
+ notmuch_message_get_message_id (message));
+
+ printf ("--text follows this line--\n");
show_message_body (notmuch_message_get_filename (message), reply_part);