1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id C874F429E3B
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:24 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id jKC1cLeFwHTg for <notmuch@notmuchmail.org>;
\r
16 Thu, 2 Aug 2012 18:15:23 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 091A6429E3C
\r
20 for <notmuch@notmuchmail.org>; Thu, 2 Aug 2012 18:15:10 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-c5-501b261e4ae9
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 1A.BD.02244.E162B105; Thu, 2 Aug 2012 21:15:10 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q731FA6S019979;
\r
27 Thu, 2 Aug 2012 21:15:10 -0400
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q731F9YJ002825
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Thu, 2 Aug 2012 21:15:10 -0400 (EDT)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1Sx6To-0003wG-5F; Thu, 02 Aug 2012 21:15:04 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v3 04/13] show: Associate an sprinter with each format
\r
41 Date: Thu, 2 Aug 2012 21:14:50 -0400
\r
42 Message-Id: <1343956499-14543-5-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10
\r
44 In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1343956499-14543-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixG6noiunJh1gsOCMmcXquTwW12/OZLZ4
\r
48 s3IeqwOzx85Zd9k9Dn9dyOLxbNUt5gDmKC6blNSczLLUIn27BK6MI1PfsBXcEqu4+PsWSwNj
\r
49 s1AXIyeHhICJRNO6h0wQtpjEhXvr2boYuTiEBPYxSkzq/cAO4axnlFj6cBIzhPOQSeLXl7+s
\r
50 EM5cRok3Z/4yg/SzCWhIbNu/nBHEFhGQlth5dzYriM0sECexZcp/sLiwgJtE26kPYHEWAVWJ
\r
51 b0+/g+3mFXCQ+H+4gxXiDnmJp/f72EBsTgFHiddvX4H1CgHVLG/rZp3AyL+AkWEVo2xKbpVu
\r
52 bmJmTnFqsm5xcmJeXmqRroVebmaJXmpK6SZGcHi5qO5gnHBI6RCjAAejEg+vkaR0gBBrYllx
\r
53 Ze4hRkkOJiVRXmYloBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3qolUgFCvCmJlVWpRfkwKWkO
\r
54 FiVx3hspN/2FBNITS1KzU1MLUotgsjIcHEoSvLKqQEMFi1LTUyvSMnNKENJMHJwgw3mAhtuD
\r
55 1PAWFyTmFmemQ+RPMSpKifOygyQEQBIZpXlwvbD4f8UoDvSKMO8FFaAqHmDqgOt+BTSYCWiw
\r
56 nRnI1cUliQgpqQbG2S2BtXaGkydeeiEU+dDSe+Pm5Ib8QtczfgEisnNKz267NFO6Lk3Rzqvw
\r
57 DZ/Rm+sxC2/9dfPNZH96/kLT3J7KL9zthccS37xyfmBWHeVtdEJQ49KNoz5LxCZYMSxv2Hv8
\r
58 SJD+tGMiKg6LwzNCKvX5TnYLXrGVeeUoKThxzdFKbq6M9NCgmFQlluKMREMt5qLiRAA1UrJU
\r
60 Cc: tomi.ollila@iki.fi
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Fri, 03 Aug 2012 01:15:25 -0000
\r
75 This associates an sprinter constructor with each show format and uses
\r
76 this to construct the appropriate sprinter. Currently nothing is done
\r
77 with this sprinter, but the following patches will weave it through
\r
78 the layers of notmuch show.
\r
80 notmuch-client.h | 1 +
\r
81 notmuch-show.c | 9 +++++++++
\r
82 2 files changed, 10 insertions(+)
\r
84 diff --git a/notmuch-client.h b/notmuch-client.h
\r
85 index f930798..bbc0a11 100644
\r
86 --- a/notmuch-client.h
\r
87 +++ b/notmuch-client.h
\r
88 @@ -69,6 +69,7 @@ typedef struct mime_node mime_node_t;
\r
89 struct notmuch_show_params;
\r
91 typedef struct notmuch_show_format {
\r
92 + struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);
\r
93 const char *message_set_start;
\r
94 notmuch_status_t (*part) (const void *ctx,
\r
95 struct mime_node *node, int indent,
\r
96 diff --git a/notmuch-show.c b/notmuch-show.c
\r
97 index d3419e4..d04943f 100644
\r
98 --- a/notmuch-show.c
\r
99 +++ b/notmuch-show.c
\r
100 @@ -20,12 +20,14 @@
\r
102 #include "notmuch-client.h"
\r
103 #include "gmime-filter-reply.h"
\r
104 +#include "sprinter.h"
\r
106 static notmuch_status_t
\r
107 format_part_text (const void *ctx, mime_node_t *node,
\r
108 int indent, const notmuch_show_params_t *params);
\r
110 static const notmuch_show_format_t format_text = {
\r
111 + .new_sprinter = sprinter_text_create,
\r
112 .part = format_part_text,
\r
115 @@ -34,6 +36,7 @@ format_part_json_entry (const void *ctx, mime_node_t *node,
\r
116 int indent, const notmuch_show_params_t *params);
\r
118 static const notmuch_show_format_t format_json = {
\r
119 + .new_sprinter = sprinter_json_create,
\r
120 .message_set_start = "[",
\r
121 .part = format_part_json_entry,
\r
122 .message_set_sep = ", ",
\r
123 @@ -46,6 +49,7 @@ format_part_mbox (const void *ctx, mime_node_t *node,
\r
124 int indent, const notmuch_show_params_t *params);
\r
126 static const notmuch_show_format_t format_mbox = {
\r
127 + .new_sprinter = sprinter_text_create,
\r
128 .part = format_part_mbox,
\r
131 @@ -55,6 +59,7 @@ format_part_raw (unused (const void *ctx), mime_node_t *node,
\r
132 unused (const notmuch_show_params_t *params));
\r
134 static const notmuch_show_format_t format_raw = {
\r
135 + .new_sprinter = sprinter_text_create,
\r
136 .part = format_part_raw,
\r
139 @@ -1003,6 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
140 char *query_string;
\r
141 int opt_index, ret;
\r
142 const notmuch_show_format_t *format = &format_text;
\r
143 + sprinter_t *sprinter;
\r
144 notmuch_show_params_t params = {
\r
146 .omit_excluded = TRUE,
\r
147 @@ -1130,6 +1136,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
151 + /* Create structure printer. */
\r
152 + sprinter = format->new_sprinter(ctx, stdout);
\r
154 /* If a single message is requested we do not use search_excludes. */
\r
155 if (params.part >= 0)
\r
156 ret = do_show_single (ctx, query, format, ¶ms);
\r