--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id A5DB86DE02D5\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:34 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.563\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.563 tagged_above=-999 required=5 tests=[AWL=0.157,\r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id GEBj5CuFE9NX for <notmuch@notmuchmail.org>;\r
+ Sat, 18 Jun 2016 14:33:26 -0700 (PDT)\r
+Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
+ [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 13FDB6DE00DF for\r
+ <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:10 -0700 (PDT)\r
+Received: by mail-wm0-f65.google.com with SMTP id r201so5510207wme.0\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:09 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references\r
+ :in-reply-to:references;\r
+ bh=qK/Sq8a9u1XpVLQESV5pNaTbGcGNCTZCBIEd//Ix38A=;\r
+ b=k5FrzhXDGhQGHCaUqVjk3xpJ3Ud0FUQU0/KOv2MSFxS+xELLcLSg+gO2JMunwnJSGL\r
+ 2aBHxw6FnzeDvZ0rWeWSoe77pk9t6zDzk5lQR+nqML9UYpmzkqMqh1tRRMO+1UvTZX9v\r
+ dKaZFIZjDklwMi0WueJZqtfFb5Gk8eBkDt9+mVGuKa8psih+ueHBTsmdcBDBierfOved\r
+ GhNd5+OHODFiyM5kNus+fQO0vib5ZJZQj7WVcz+atLI6xjcZCgx+stEkx3cq/JAWGx4e\r
+ CujzjOm90nF4Hi26JLml4PmDCdtcpPVxc3kvKxV3BiSswPGVAg5LLvyO6ZkBb9WWhr2B\r
+ N48Q==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=qK/Sq8a9u1XpVLQESV5pNaTbGcGNCTZCBIEd//Ix38A=;\r
+ b=CxJwW3gHeiWjdRo0IjK4StIVXZJI9zYV0rjpv0XEV4R+FUB4fGogn5B2WCu9lCrPBH\r
+ LabQMCD0tWS9guZYBi2Fkw6zi98Z9IvbK2qzHr0p0lEMzTltywv0zfFakrxhRf+ilg4l\r
+ apD3VxWPhXeTKVQiGktl42O8ApWUYUOr2MIqTE5MJNo1pOSiZvMtnEhO2QjLkDRd7Nvs\r
+ Wwey/Mf/bX3ZCKFGofgFO2RTEifX2cqW9GoGKnN5jRroEC3pnN9eo040FGCsBSOXvtZw\r
+ b3npBkawsaVzMpAzjF/69eoS5s+fprTR7lQk7vHLIRgVRWFkuP91aZqcANLe2ju4Csjh\r
+ 0kig==\r
+X-Gm-Message-State:\r
+ ALyK8tInCjuaIvxZ2wOt2MlsoyiWY8ShHUhoyM2wYFj8CQ3A0g250fmW4CuMEERvaviZpw==\r
+X-Received: by 10.194.172.36 with SMTP id az4mr8874120wjc.114.1466285588658;\r
+ Sat, 18 Jun 2016 14:33:08 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4e-81.dhcp.inet.fi.\r
+ [188.238.78.81])\r
+ by smtp.gmail.com with ESMTPSA id a84sm5510049wma.0.2016.06.18.14.33.07\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 18 Jun 2016 14:33:08 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Cc: jani@nikula.org,\r
+ Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+Subject: [PATCH 7/7] cli/reply: reduce the reply format abstractions\r
+Date: Sun, 19 Jun 2016 00:31:33 +0300\r
+Message-Id:\r
+ <877365e0fb4a3b0da33db2ce72aa51b16fccbe9a.1466284726.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1466284726.git.jani@nikula.org>\r
+References: <cover.1466284726.git.jani@nikula.org>\r
+In-Reply-To: <cover.1466284726.git.jani@nikula.org>\r
+References: <cover.1466284726.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 18 Jun 2016 21:33:34 -0000\r
+\r
+Now that we've made the various reply formats quite similar to each\r
+other, there's no point in keeping the abstractions. They are now\r
+close enough to be put in one function.\r
+\r
+For now, a mime node will be uselessly created for the headers-only\r
+case, but this is insignificant, and may change in the future.\r
+---\r
+ notmuch-reply.c | 145 ++++++++++++++------------------------------------------\r
+ 1 file changed, 36 insertions(+), 109 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index daad453efb09..b380678e7204 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -599,92 +599,6 @@ create_reply_message(void *ctx,\r
+ return reply;\r
+ }\r
+ \r
+-static int\r
+-notmuch_reply_format_default(void *ctx,\r
+- notmuch_config_t *config,\r
+- notmuch_message_t *message,\r
+- notmuch_show_params_t *params,\r
+- notmuch_bool_t reply_all,\r
+- unused (sprinter_t *sp))\r
+-{\r
+- GMimeMessage *reply;\r
+- mime_node_t *node;\r
+-\r
+- if (mime_node_open (ctx, message, ¶ms->crypto, &node))\r
+- return 1;\r
+-\r
+- reply = create_reply_message (ctx, config, message, reply_all, FALSE);\r
+- if (!reply)\r
+- return 1;\r
+-\r
+- show_reply_headers (reply);\r
+- format_part_reply (node);\r
+-\r
+- g_object_unref (G_OBJECT (reply));\r
+- talloc_free (node);\r
+-\r
+- return 0;\r
+-}\r
+-\r
+-static int\r
+-notmuch_reply_format_sprinter(void *ctx,\r
+- notmuch_config_t *config,\r
+- notmuch_message_t *message,\r
+- notmuch_show_params_t *params,\r
+- notmuch_bool_t reply_all,\r
+- sprinter_t *sp)\r
+-{\r
+- GMimeMessage *reply;\r
+- mime_node_t *node;\r
+-\r
+- if (mime_node_open (ctx, message, ¶ms->crypto, &node))\r
+- return 1;\r
+-\r
+- reply = create_reply_message (ctx, config, message, reply_all, FALSE);\r
+- if (!reply)\r
+- return 1;\r
+-\r
+- sp->begin_map (sp);\r
+-\r
+- /* The headers of the reply message we've created */\r
+- sp->map_key (sp, "reply-headers");\r
+- format_headers_sprinter (sp, reply, TRUE);\r
+-\r
+- /* Start the original */\r
+- sp->map_key (sp, "original");\r
+- format_part_sprinter (ctx, sp, node, TRUE, TRUE, FALSE);\r
+-\r
+- /* End */\r
+- sp->end (sp);\r
+-\r
+- g_object_unref (G_OBJECT (reply));\r
+- talloc_free (node);\r
+-\r
+- return 0;\r
+-}\r
+-\r
+-/* This format is currently tuned for a git send-email --notmuch hook */\r
+-static int\r
+-notmuch_reply_format_headers_only(void *ctx,\r
+- notmuch_config_t *config,\r
+- notmuch_message_t *message,\r
+- unused (notmuch_show_params_t *params),\r
+- notmuch_bool_t reply_all,\r
+- unused (sprinter_t *sp))\r
+-{\r
+- GMimeMessage *reply;\r
+-\r
+- reply = create_reply_message (ctx, config, message, reply_all, TRUE);\r
+- if (!reply)\r
+- return 1;\r
+-\r
+- show_reply_headers (reply);\r
+-\r
+- g_object_unref (G_OBJECT (reply));\r
+-\r
+- return 0;\r
+-}\r
+-\r
+ enum {\r
+ FORMAT_DEFAULT,\r
+ FORMAT_JSON,\r
+@@ -698,17 +612,12 @@ static int do_reply(notmuch_config_t *config,\r
+ int format,\r
+ notmuch_bool_t reply_all)\r
+ {\r
++ GMimeMessage *reply;\r
++ mime_node_t *node;\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
+ notmuch_status_t status;\r
+ struct sprinter *sp = NULL;\r
+- int ret = 0;\r
+- int (*reply_format_func) (void *ctx,\r
+- notmuch_config_t *config,\r
+- notmuch_message_t *message,\r
+- notmuch_show_params_t *params,\r
+- notmuch_bool_t reply_all,\r
+- struct sprinter *sp);\r
+ \r
+ if (format == FORMAT_JSON || format == FORMAT_SEXP) {\r
+ unsigned count;\r
+@@ -721,18 +630,11 @@ static int do_reply(notmuch_config_t *config,\r
+ fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count);\r
+ return 1;\r
+ }\r
+- }\r
+ \r
+- if (format == FORMAT_HEADERS_ONLY) {\r
+- reply_format_func = notmuch_reply_format_headers_only;\r
+- } else if (format == FORMAT_JSON) {\r
+- reply_format_func = notmuch_reply_format_sprinter;\r
+- sp = sprinter_json_create (config, stdout);\r
+- } else if (format == FORMAT_SEXP) {\r
+- reply_format_func = notmuch_reply_format_sprinter;\r
+- sp = sprinter_sexp_create (config, stdout);\r
+- } else {\r
+- reply_format_func = notmuch_reply_format_default;\r
++ if (format == FORMAT_JSON)\r
++ sp = sprinter_json_create (config, stdout);\r
++ else\r
++ sp = sprinter_sexp_create (config, stdout);\r
+ }\r
+ \r
+ status = notmuch_query_search_messages_st (query, &messages);\r
+@@ -745,15 +647,40 @@ static int do_reply(notmuch_config_t *config,\r
+ {\r
+ message = notmuch_messages_get (messages);\r
+ \r
+- ret = reply_format_func(config, config, message, params, reply_all, sp);\r
++ if (mime_node_open (config, message, ¶ms->crypto, &node))\r
++ return 1;\r
+ \r
+- notmuch_message_destroy (message);\r
++ reply = create_reply_message (config, config, message, reply_all,\r
++ format == FORMAT_HEADERS_ONLY);\r
++ if (!reply)\r
++ return 1;\r
+ \r
+- if (ret)\r
+- break;\r
++ if (format == FORMAT_JSON || format == FORMAT_SEXP) {\r
++ sp->begin_map (sp);\r
++\r
++ /* The headers of the reply message we've created */\r
++ sp->map_key (sp, "reply-headers");\r
++ format_headers_sprinter (sp, reply, TRUE);\r
++\r
++ /* Start the original */\r
++ sp->map_key (sp, "original");\r
++ format_part_sprinter (config, sp, node, TRUE, TRUE, FALSE);\r
++\r
++ /* End */\r
++ sp->end (sp);\r
++ } else {\r
++ show_reply_headers (reply);\r
++ if (format == FORMAT_DEFAULT)\r
++ format_part_reply (node);\r
++ }\r
++\r
++ g_object_unref (G_OBJECT (reply));\r
++ talloc_free (node);\r
++\r
++ notmuch_message_destroy (message);\r
+ }\r
+ \r
+- return ret;\r
++ return 0;\r
+ }\r
+ \r
+ int\r
+-- \r
+2.1.4\r
+\r