--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8C766431FD2\r
+ for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 21:29:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id I+ue9wDsM4j9 for <notmuch@notmuchmail.org>;\r
+ Fri, 27 Jul 2012 21:29:26 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
+ [18.9.25.13])\r
+ by olra.theworths.org (Postfix) with ESMTP id 6F101431FBC\r
+ for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 21:29:25 -0700 (PDT)\r
+X-AuditID: 1209190d-b7fd56d000000933-8b-50136aa44896\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+ by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 76.04.02355.4AA63105; Sat, 28 Jul 2012 00:29:24 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q6S4TNxj002940; \r
+ Sat, 28 Jul 2012 00:29:23 -0400\r
+Received: from drake.dyndns.org\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6S4TKoR027357\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Sat, 28 Jul 2012 00:29:22 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1SuyeW-0002Wx-KH; Sat, 28 Jul 2012 00:29:20 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 06/13] show: Feed the sprinter down to part formatters\r
+Date: Sat, 28 Jul 2012 00:29:07 -0400\r
+Message-Id: <1343449754-9010-7-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1343449754-9010-1-git-send-email-amdragon@mit.edu>\r
+References: <1343449754-9010-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrLIsWRmVeSWpSXmKPExsUixG6norskSzjAYNE3bYu9De2MFqvn8lhc\r
+ vzmT2eLNynmsDiweO2fdZfdYvGk/m8fhrwtZPJ6tusUcwBLFZZOSmpNZllqkb5fAlXFl+QOW\r
+ ghc+FUd3bGZrYFxn28XIwSEhYCLx61xOFyMnkCkmceHeerYuRi4OIYF9jBJzm5exQzgbGCW+\r
+ PV7GCOE8YpI4cuUqK0iLkMBcRolla7VAbDYBDYlt+5czgtgiAtISO+/OZgXZwCyQJ/F4rQSI\r
+ KSzgKXH4JtgyFgFViW1f/oJN4RWwl1i3E2KihIC8xNP7fWwgNqeAg8Tmlx+YITbZS+yevIF1\r
+ AiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmpRbpGermZJXqpKaWbGEGhxinJu4Px3UGlQ4wC\r
+ HIxKPLynrggFCLEmlhVX5h5ilORgUhLljQoXDhDiS8pPqcxILM6ILyrNSS0+xCjBwawkwrtT\r
+ ECjHm5JYWZValA+TkuZgURLnvZJy019IID2xJDU7NbUgtQgmK8PBoSTBuz0TqFGwKDU9tSIt\r
+ M6cEIc3EwQkynAdo+BqQGt7igsTc4sx0iPwpRkUpcd7HIAkBkERGaR5cLywVvGIUB3pFmFcY\r
+ mBiEeIBpBK77FdBgJqDBFtFCIINLEhFSUg2MB3pbnz8xDBV6vm5pzNFzdyoXNexftPSHxxam\r
+ CecW59+8eGPX40rxZbMy7+9NjhfU6pTX/i44XcZlRu2BJS9Ymiumrjt2K3OGr3u+0dPWWJ97\r
+ 86+bTfT9uvWrEdNFv3kcP+7Ze5/gXXH7+9WlV/kUyhjTez4FrVh+ptr7flCMl+7ujGm7z1no\r
+ sSqxFGckGmoxFxUnAgAecisT4AIAAA==\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 28 Jul 2012 04:29:29 -0000\r
+\r
+There are several levels of function calls between where we create the\r
+sprinter and the call to the part formatter in show_message. This\r
+feeds the sprinter through all of them and into the part formatters.\r
+---\r
+ notmuch-client.h | 5 +++--\r
+ notmuch-reply.c | 2 +-\r
+ notmuch-show.c | 50 +++++++++++++++++++++++++++++---------------------\r
+ 3 files changed, 33 insertions(+), 24 deletions(-)\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index e4172a2..8eeedf7 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -72,7 +72,7 @@ struct notmuch_show_params;\r
+ typedef struct notmuch_show_format {\r
+ sprinter_t *(*new_sprinter) (const void *ctx, FILE *stream);\r
+ const char *message_set_start;\r
+- notmuch_status_t (*part) (const void *ctx,\r
++ notmuch_status_t (*part) (const void *ctx, sprinter_t *sprinter,\r
+ struct mime_node *node, int indent,\r
+ const struct notmuch_show_params *params);\r
+ const char *message_set_sep;\r
+@@ -179,7 +179,8 @@ notmuch_status_t\r
+ show_one_part (const char *filename, int part);\r
+ \r
+ void\r
+-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body);\r
++format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
++ notmuch_bool_t first, notmuch_bool_t output_body);\r
+ \r
+ void\r
+ format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index e42ba79..07d4452 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -624,7 +624,7 @@ notmuch_reply_format_json(void *ctx,\r
+ /* Start the original */\r
+ printf (", \"original\": ");\r
+ \r
+- format_part_json (ctx, node, TRUE, TRUE);\r
++ format_part_json (ctx, sp, node, TRUE, TRUE);\r
+ \r
+ /* End */\r
+ printf ("}\n");\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d04943f..b258f65 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -23,7 +23,7 @@\r
+ #include "sprinter.h"\r
+ \r
+ static notmuch_status_t\r
+-format_part_text (const void *ctx, mime_node_t *node,\r
++format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params);\r
+ \r
+ static const notmuch_show_format_t format_text = {\r
+@@ -32,7 +32,7 @@ static const notmuch_show_format_t format_text = {\r
+ };\r
+ \r
+ static notmuch_status_t\r
+-format_part_json_entry (const void *ctx, mime_node_t *node,\r
++format_part_json_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params);\r
+ \r
+ static const notmuch_show_format_t format_json = {\r
+@@ -45,7 +45,7 @@ static const notmuch_show_format_t format_json = {\r
+ };\r
+ \r
+ static notmuch_status_t\r
+-format_part_mbox (const void *ctx, mime_node_t *node,\r
++format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params);\r
+ \r
+ static const notmuch_show_format_t format_mbox = {\r
+@@ -54,7 +54,7 @@ static const notmuch_show_format_t format_mbox = {\r
+ };\r
+ \r
+ static notmuch_status_t\r
+-format_part_raw (unused (const void *ctx), mime_node_t *node,\r
++format_part_raw (unused (const void *ctx), sprinter_t *sp, mime_node_t *node,\r
+ unused (int indent),\r
+ unused (const notmuch_show_params_t *params));\r
+ \r
+@@ -471,7 +471,7 @@ format_part_sigstatus_json (mime_node_t *node)\r
+ #endif\r
+ \r
+ static notmuch_status_t\r
+-format_part_text (const void *ctx, mime_node_t *node,\r
++format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params)\r
+ {\r
+ /* The disposition and content-type metadata are associated with\r
+@@ -553,7 +553,7 @@ format_part_text (const void *ctx, mime_node_t *node,\r
+ }\r
+ \r
+ for (i = 0; i < node->nchildren; i++)\r
+- format_part_text (ctx, mime_node_child (node, i), indent, params);\r
++ format_part_text (ctx, sp, mime_node_child (node, i), indent, params);\r
+ \r
+ if (GMIME_IS_MESSAGE (node->part))\r
+ printf ("\fbody}\n");\r
+@@ -564,7 +564,8 @@ format_part_text (const void *ctx, mime_node_t *node,\r
+ }\r
+ \r
+ void\r
+-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body)\r
++format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
++ notmuch_bool_t first, notmuch_bool_t output_body)\r
+ {\r
+ /* Any changes to the JSON format should be reflected in the file\r
+ * devel/schemata. */\r
+@@ -578,7 +579,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notm\r
+ \r
+ if (output_body) {\r
+ printf (", \"body\": [");\r
+- format_part_json (ctx, mime_node_child (node, 0), first, TRUE);\r
++ format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);\r
+ printf ("]");\r
+ }\r
+ printf ("}");\r
+@@ -659,16 +660,17 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notm\r
+ talloc_free (local);\r
+ \r
+ for (i = 0; i < node->nchildren; i++)\r
+- format_part_json (ctx, mime_node_child (node, i), i == 0, TRUE);\r
++ format_part_json (ctx, sp, mime_node_child (node, i), i == 0, TRUE);\r
+ \r
+ printf ("%s}", terminator);\r
+ }\r
+ \r
+ static notmuch_status_t\r
+-format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),\r
++format_part_json_entry (const void *ctx, sprinter_t *sp,\r
++ mime_node_t *node, unused (int indent),\r
+ const notmuch_show_params_t *params)\r
+ {\r
+- format_part_json (ctx, node, TRUE, params->output_body);\r
++ format_part_json (ctx, sp, node, TRUE, params->output_body);\r
+ \r
+ return NOTMUCH_STATUS_SUCCESS;\r
+ }\r
+@@ -679,7 +681,8 @@ format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),\r
+ * http://qmail.org/qmail-manual-html/man5/mbox.html\r
+ */\r
+ static notmuch_status_t\r
+-format_part_mbox (const void *ctx, mime_node_t *node, unused (int indent),\r
++format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,\r
++ unused (int indent),\r
+ unused (const notmuch_show_params_t *params))\r
+ {\r
+ notmuch_message_t *message = node->envelope_file;\r
+@@ -730,8 +733,8 @@ format_part_mbox (const void *ctx, mime_node_t *node, unused (int indent),\r
+ }\r
+ \r
+ static notmuch_status_t\r
+-format_part_raw (unused (const void *ctx), mime_node_t *node,\r
+- unused (int indent),\r
++format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),\r
++ mime_node_t *node, unused (int indent),\r
+ unused (const notmuch_show_params_t *params))\r
+ {\r
+ if (node->envelope_file) {\r
+@@ -819,6 +822,7 @@ show_null_message (const notmuch_show_format_t *format)\r
+ static notmuch_status_t\r
+ show_message (void *ctx,\r
+ const notmuch_show_format_t *format,\r
++ sprinter_t *sp,\r
+ notmuch_message_t *message,\r
+ int indent,\r
+ notmuch_show_params_t *params)\r
+@@ -832,7 +836,7 @@ show_message (void *ctx,\r
+ goto DONE;\r
+ part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));\r
+ if (part)\r
+- status = format->part (local, part, indent, params);\r
++ status = format->part (local, sp, part, indent, params);\r
+ DONE:\r
+ talloc_free (local);\r
+ return status;\r
+@@ -841,6 +845,7 @@ show_message (void *ctx,\r
+ static notmuch_status_t\r
+ show_messages (void *ctx,\r
+ const notmuch_show_format_t *format,\r
++ sprinter_t *sp,\r
+ notmuch_messages_t *messages,\r
+ int indent,\r
+ notmuch_show_params_t *params)\r
+@@ -874,7 +879,7 @@ show_messages (void *ctx,\r
+ next_indent = indent;\r
+ \r
+ if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) {\r
+- status = show_message (ctx, format, message, indent, params);\r
++ status = show_message (ctx, format, sp, message, indent, params);\r
+ if (status && !res)\r
+ res = status;\r
+ next_indent = indent + 1;\r
+@@ -886,7 +891,7 @@ show_messages (void *ctx,\r
+ fputs (format->message_set_sep, stdout);\r
+ \r
+ status = show_messages (ctx,\r
+- format,\r
++ format, sp,\r
+ notmuch_message_get_replies (message),\r
+ next_indent,\r
+ params);\r
+@@ -910,6 +915,7 @@ static int\r
+ do_show_single (void *ctx,\r
+ notmuch_query_t *query,\r
+ const notmuch_show_format_t *format,\r
++ sprinter_t *sp,\r
+ notmuch_show_params_t *params)\r
+ {\r
+ notmuch_messages_t *messages;\r
+@@ -930,7 +936,8 @@ do_show_single (void *ctx,\r
+ \r
+ notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1);\r
+ \r
+- return show_message (ctx, format, message, 0, params) != NOTMUCH_STATUS_SUCCESS;\r
++ return show_message (ctx, format, sp, message, 0, params)\r
++ != NOTMUCH_STATUS_SUCCESS;\r
+ }\r
+ \r
+ /* Formatted output of threads */\r
+@@ -938,6 +945,7 @@ static int\r
+ do_show (void *ctx,\r
+ notmuch_query_t *query,\r
+ const notmuch_show_format_t *format,\r
++ sprinter_t *sp,\r
+ notmuch_show_params_t *params)\r
+ {\r
+ notmuch_threads_t *threads;\r
+@@ -965,7 +973,7 @@ do_show (void *ctx,\r
+ fputs (format->message_set_sep, stdout);\r
+ first_toplevel = 0;\r
+ \r
+- status = show_messages (ctx, format, messages, 0, params);\r
++ status = show_messages (ctx, format, sp, messages, 0, params);\r
+ if (status && !res)\r
+ res = status;\r
+ \r
+@@ -1141,7 +1149,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ \r
+ /* If a single message is requested we do not use search_excludes. */\r
+ if (params.part >= 0)\r
+- ret = do_show_single (ctx, query, format, ¶ms);\r
++ ret = do_show_single (ctx, query, format, sprinter, ¶ms);\r
+ else {\r
+ /* We always apply set the exclude flag. The\r
+ * exclude=true|false option controls whether or not we return\r
+@@ -1160,7 +1168,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ params.omit_excluded = FALSE;\r
+ }\r
+ \r
+- ret = do_show (ctx, query, format, ¶ms);\r
++ ret = do_show (ctx, query, format, sprinter, ¶ms);\r
+ }\r
+ \r
+ notmuch_crypto_cleanup (¶ms.crypto);\r
+-- \r
+1.7.10\r
+\r