From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Cc: jani@nikula.org, Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Subject: [PATCH 6/7] cli/reply: reuse create_reply_message() also for headers-only format
Date: Sun, 19 Jun 2016 00:31:32 +0300 [thread overview]
Message-ID: <954d507f5a0eff70abb2d818850b62763c6dfffe.1466284726.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1466284726.git.jani@nikula.org>
In-Reply-To: <cover.1466284726.git.jani@nikula.org>
Add an option for "limited" headers for the (slightly misleadingly
named) headers-only format. There should be no functional changes.
---
notmuch-reply.c | 46 +++++++++++++++-------------------------------
1 file changed, 15 insertions(+), 31 deletions(-)
diff --git a/notmuch-reply.c b/notmuch-reply.c
index c2d7402d40ae..daad453efb09 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -520,13 +520,17 @@ static GMimeMessage *
create_reply_message(void *ctx,
notmuch_config_t *config,
notmuch_message_t *message,
- notmuch_bool_t reply_all)
+ notmuch_bool_t reply_all,
+ notmuch_bool_t limited)
{
const char *subject, *from_addr = NULL;
const char *in_reply_to, *orig_references, *references;
- /* The 1 means we want headers in a "pretty" order. */
- GMimeMessage *reply = g_mime_message_new (1);
+ /*
+ * Use the below header order for limited headers, "pretty" order
+ * otherwise.
+ */
+ GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1);
if (reply == NULL) {
fprintf (stderr, "Out of memory\n");
return NULL;
@@ -549,6 +553,10 @@ create_reply_message(void *ctx,
from_addr = add_recipients_from_message (reply, config,
message, reply_all);
+ /* The above is all that is needed for limited headers. */
+ if (limited)
+ return reply;
+
/*
* Sadly, there is no standard way to find out to which email
* address a mail was delivered - what is in the headers depends
@@ -605,7 +613,7 @@ notmuch_reply_format_default(void *ctx,
if (mime_node_open (ctx, message, ¶ms->crypto, &node))
return 1;
- reply = create_reply_message (ctx, config, message, reply_all);
+ reply = create_reply_message (ctx, config, message, reply_all, FALSE);
if (!reply)
return 1;
@@ -632,7 +640,7 @@ notmuch_reply_format_sprinter(void *ctx,
if (mime_node_open (ctx, message, ¶ms->crypto, &node))
return 1;
- reply = create_reply_message (ctx, config, message, reply_all);
+ reply = create_reply_message (ctx, config, message, reply_all, FALSE);
if (!reply)
return 1;
@@ -665,34 +673,10 @@ notmuch_reply_format_headers_only(void *ctx,
unused (sprinter_t *sp))
{
GMimeMessage *reply;
- const char *in_reply_to, *orig_references, *references;
- /* The 0 means we do not want headers in a "pretty" order. */
- reply = g_mime_message_new (0);
- if (reply == NULL) {
- fprintf (stderr, "Out of memory\n");
+ reply = create_reply_message (ctx, config, message, reply_all, TRUE);
+ if (!reply)
return 1;
- }
-
- 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");
-
- /*
- * We print In-Reply-To followed by References because git
- * format-patch treats them specially. Git does not interpret the
- * other headers specially.
- */
- 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);
-
- (void)add_recipients_from_message (reply, config, message, reply_all);
show_reply_headers (reply);
--
2.1.4
next prev parent reply other threads:[~2016-06-18 21:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-18 21:31 [PATCH 0/7] cli/reply: refactoring Jani Nikula
2016-06-18 21:31 ` [PATCH 1/7] cli/reply: push notmuch reply format abstraction lower in the stack Jani Nikula
2016-06-18 21:31 ` [PATCH 2/7] cli/reply: reuse show_reply_headers() in headers-only format Jani Nikula
2016-06-18 21:31 ` [PATCH 3/7] cli/reply: unify reply format functions Jani Nikula
2016-06-18 21:31 ` [PATCH 4/7] cli/reply: reorganize create_reply_message() Jani Nikula
2016-06-18 21:31 ` [PATCH 5/7] cli/reply: make references header creation easier to follow Jani Nikula
2016-06-18 21:31 ` Jani Nikula [this message]
2016-06-18 21:31 ` [PATCH 7/7] cli/reply: reduce the reply format abstractions Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 0/6] cli/reply: refactoring part 2 Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 1/6] cli/reply: use dedicated functions for reply to mapping Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 2/6] cli/reply: check for NULL list first in scan_address_list() Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 3/6] cli/reply: return internet address list from get header funcs Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 4/6] cli/reply: pass internet address list to munge detect Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 5/6] cli/reply: pass gmime message to munge detection Jani Nikula
2016-06-19 20:15 ` [RFC PATCH 6/6] cli/reply: only pass gmime message to add recipients to reply message Jani Nikula
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=954d507f5a0eff70abb2d818850b62763c6dfffe.1466284726.git.jani@nikula.org \
--to=jani@nikula.org \
--cc=dkg@fifthhorseman.net \
--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).