X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-reply.c;h=eb07405591fd55185337612c2b3a8e5259d633e1;hp=847e306f94d2b740fd3b1fd7765769b00c098e3a;hb=b1aca0e502e97ab822da60aa4217d4b0bdb33543;hpb=0c5840862e2f8802b2d280dbf77da908d3617b10 diff --git a/notmuch-reply.c b/notmuch-reply.c index 847e306f..eb074055 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -532,12 +532,20 @@ create_reply_message(void *ctx, return NULL; } - subject = notmuch_message_get_header (message, "subject"); - if (subject) { - if (strncasecmp (subject, "Re:", 3)) - subject = talloc_asprintf (ctx, "Re: %s", subject); - g_mime_message_set_subject (reply, subject); - } + 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"); + if (!orig_references) + /* Treat errors like missing References headers. */ + orig_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); from_addr = add_recipients_from_message (reply, config, message, reply_all); @@ -572,25 +580,14 @@ create_reply_message(void *ctx, 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); - - 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); + g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr); - orig_references = notmuch_message_get_header (message, "references"); - if (!orig_references) - /* Treat errors like missing References headers. */ - orig_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); + subject = notmuch_message_get_header (message, "subject"); + if (subject) { + if (strncasecmp (subject, "Re:", 3)) + subject = talloc_asprintf (ctx, "Re: %s", subject); + g_mime_message_set_subject (reply, subject); + } return reply; } @@ -604,20 +601,20 @@ notmuch_reply_format_default(void *ctx, unused (sprinter_t *sp)) { GMimeMessage *reply; - mime_node_t *root; + mime_node_t *node; + + if (mime_node_open (ctx, message, ¶ms->crypto, &node)) + return 1; reply = create_reply_message (ctx, config, message, reply_all); if (!reply) return 1; show_reply_headers (reply); + format_part_reply (node); g_object_unref (G_OBJECT (reply)); - - if (mime_node_open (ctx, message, ¶ms->crypto, &root) == NOTMUCH_STATUS_SUCCESS) { - format_part_reply (root); - talloc_free (root); - } + talloc_free (node); return 0; } @@ -633,7 +630,7 @@ notmuch_reply_format_sprinter(void *ctx, GMimeMessage *reply; mime_node_t *node; - if (mime_node_open (ctx, message, ¶ms->crypto, &node) != NOTMUCH_STATUS_SUCCESS) + if (mime_node_open (ctx, message, ¶ms->crypto, &node)) return 1; reply = create_reply_message (ctx, config, message, reply_all); @@ -645,7 +642,6 @@ notmuch_reply_format_sprinter(void *ctx, /* The headers of the reply message we've created */ sp->map_key (sp, "reply-headers"); format_headers_sprinter (sp, reply, TRUE); - g_object_unref (G_OBJECT (reply)); /* Start the original */ sp->map_key (sp, "original"); @@ -654,6 +650,9 @@ notmuch_reply_format_sprinter(void *ctx, /* End */ sp->end (sp); + g_object_unref (G_OBJECT (reply)); + talloc_free (node); + return 0; } @@ -668,7 +667,6 @@ notmuch_reply_format_headers_only(void *ctx, { GMimeMessage *reply; const char *in_reply_to, *orig_references, *references; - char *reply_headers; /* The 0 means we do not want headers in a "pretty" order. */ reply = g_mime_message_new (0); @@ -697,9 +695,7 @@ notmuch_reply_format_headers_only(void *ctx, (void)add_recipients_from_message (reply, config, message, reply_all); - reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply)); - printf ("%s", reply_headers); - free (reply_headers); + show_reply_headers (reply); g_object_unref (G_OBJECT (reply));