--- /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 C874F429E3B\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:24 -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 jKC1cLeFwHTg for <notmuch@notmuchmail.org>;\r
+ Thu, 2 Aug 2012 18:15:23 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
+ [18.7.68.37])\r
+ by olra.theworths.org (Postfix) with ESMTP id 091A6429E3C\r
+ for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:10 -0700 (PDT)\r
+X-AuditID: 12074425-b7f9b6d0000008c4-c5-501b261e4ae9\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+ by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 1A.BD.02244.E162B105; Thu, 2 Aug 2012 21:15:10 -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 q731FA6S019979; \r
+ Thu, 2 Aug 2012 21:15:10 -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 q731F9YJ002825\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Thu, 2 Aug 2012 21:15:10 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1Sx6To-0003wG-5F; Thu, 02 Aug 2012 21:15:04 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 04/13] show: Associate an sprinter with each format\r
+Date: Thu, 2 Aug 2012 21:14:50 -0400\r
+Message-Id: <1343956499-14543-5-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu>\r
+References: <1343956499-14543-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixG6noiunJh1gsOCMmcXquTwW12/OZLZ4\r
+ s3IeqwOzx85Zd9k9Dn9dyOLxbNUt5gDmKC6blNSczLLUIn27BK6MI1PfsBXcEqu4+PsWSwNj\r
+ s1AXIyeHhICJRNO6h0wQtpjEhXvr2boYuTiEBPYxSkzq/cAO4axnlFj6cBIzhPOQSeLXl7+s\r
+ EM5cRok3Z/4yg/SzCWhIbNu/nBHEFhGQlth5dzYriM0sECexZcp/sLiwgJtE26kPYHEWAVWJ\r
+ b0+/g+3mFXCQ+H+4gxXiDnmJp/f72EBsTgFHiddvX4H1CgHVLG/rZp3AyL+AkWEVo2xKbpVu\r
+ bmJmTnFqsm5xcmJeXmqRroVebmaJXmpK6SZGcHi5qO5gnHBI6RCjAAejEg+vkaR0gBBrYllx\r
+ Ze4hRkkOJiVRXmYloBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3qolUgFCvCmJlVWpRfkwKWkO\r
+ FiVx3hspN/2FBNITS1KzU1MLUotgsjIcHEoSvLKqQEMFi1LTUyvSMnNKENJMHJwgw3mAhtuD\r
+ 1PAWFyTmFmemQ+RPMSpKifOygyQEQBIZpXlwvbD4f8UoDvSKMO8FFaAqHmDqgOt+BTSYCWiw\r
+ nRnI1cUliQgpqQbG2S2BtXaGkydeeiEU+dDSe+Pm5Ib8QtczfgEisnNKz267NFO6Lk3Rzqvw\r
+ DZ/Rm+sxC2/9dfPNZH96/kLT3J7KL9zthccS37xyfmBWHeVtdEJQ49KNoz5LxCZYMSxv2Hv8\r
+ SJD+tGMiKg6LwzNCKvX5TnYLXrGVeeUoKThxzdFKbq6M9NCgmFQlluKMREMt5qLiRAA1UrJU\r
+ 2gIAAA==\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: Fri, 03 Aug 2012 01:15:25 -0000\r
+\r
+This associates an sprinter constructor with each show format and uses\r
+this to construct the appropriate sprinter. Currently nothing is done\r
+with this sprinter, but the following patches will weave it through\r
+the layers of notmuch show.\r
+---\r
+ notmuch-client.h | 1 +\r
+ notmuch-show.c | 9 +++++++++\r
+ 2 files changed, 10 insertions(+)\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index f930798..bbc0a11 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -69,6 +69,7 @@ typedef struct mime_node mime_node_t;\r
+ struct notmuch_show_params;\r
+ \r
+ typedef struct notmuch_show_format {\r
++ struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);\r
+ const char *message_set_start;\r
+ notmuch_status_t (*part) (const void *ctx,\r
+ struct mime_node *node, int indent,\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d3419e4..d04943f 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -20,12 +20,14 @@\r
+ \r
+ #include "notmuch-client.h"\r
+ #include "gmime-filter-reply.h"\r
++#include "sprinter.h"\r
+ \r
+ static notmuch_status_t\r
+ format_part_text (const void *ctx, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params);\r
+ \r
+ static const notmuch_show_format_t format_text = {\r
++ .new_sprinter = sprinter_text_create,\r
+ .part = format_part_text,\r
+ };\r
+ \r
+@@ -34,6 +36,7 @@ format_part_json_entry (const void *ctx, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params);\r
+ \r
+ static const notmuch_show_format_t format_json = {\r
++ .new_sprinter = sprinter_json_create,\r
+ .message_set_start = "[",\r
+ .part = format_part_json_entry,\r
+ .message_set_sep = ", ",\r
+@@ -46,6 +49,7 @@ format_part_mbox (const void *ctx, mime_node_t *node,\r
+ int indent, const notmuch_show_params_t *params);\r
+ \r
+ static const notmuch_show_format_t format_mbox = {\r
++ .new_sprinter = sprinter_text_create,\r
+ .part = format_part_mbox,\r
+ };\r
+ \r
+@@ -55,6 +59,7 @@ format_part_raw (unused (const void *ctx), mime_node_t *node,\r
+ unused (const notmuch_show_params_t *params));\r
+ \r
+ static const notmuch_show_format_t format_raw = {\r
++ .new_sprinter = sprinter_text_create,\r
+ .part = format_part_raw,\r
+ };\r
+ \r
+@@ -1003,6 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ char *query_string;\r
+ int opt_index, ret;\r
+ const notmuch_show_format_t *format = &format_text;\r
++ sprinter_t *sprinter;\r
+ notmuch_show_params_t params = {\r
+ .part = -1,\r
+ .omit_excluded = TRUE,\r
+@@ -1130,6 +1136,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ return 1;\r
+ }\r
+ \r
++ /* Create structure printer. */\r
++ sprinter = format->new_sprinter(ctx, stdout);\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
+-- \r
+1.7.10\r
+\r