1 Return-Path: <m.walters@qmul.ac.uk>
\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 594D8431FC9
\r
6 for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 02:14:35 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id mcpx+Y2e0J9b for <notmuch@notmuchmail.org>;
\r
17 Thu, 12 Jul 2012 02:14:34 -0700 (PDT)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 67C2C431FC7
\r
22 for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 02:14:34 -0700 (PDT)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1SpFTg-0001A2-BR; Thu, 12 Jul 2012 10:14:30 +0100
\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]
\r
29 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
30 (envelope-from <m.walters@qmul.ac.uk>)
\r
31 id 1SpFTf-000139-Vu; Thu, 12 Jul 2012 10:14:28 +0100
\r
32 From: Mark Walters <markwalters1009@gmail.com>
\r
33 To: craven@gmx.net, notmuch@notmuchmail.org
\r
34 Subject: Re: [PATCH v4 1/3] Add support for structured output formatters.
\r
35 In-Reply-To: <1342079004-5300-2-git-send-email-craven@gmx.net>
\r
36 References: <87d34hsdx8.fsf@awakening.csail.mit.edu>
\r
37 <1342079004-5300-1-git-send-email-craven@gmx.net>
\r
38 <1342079004-5300-2-git-send-email-craven@gmx.net>
\r
39 User-Agent: Notmuch/0.13.2+61~gf708609 (http://notmuchmail.org) Emacs/23.4.1
\r
40 (x86_64-pc-linux-gnu)
\r
41 Date: Thu, 12 Jul 2012 10:14:25 +0100
\r
42 Message-ID: <87sjcxtk7i.fsf@qmul.ac.uk>
\r
44 Content-Type: text/plain; charset=us-ascii
\r
45 X-Sender-Host-Address: 94.192.233.223
\r
46 X-QM-SPAM-Info: Sender has good ham record. :)
\r
47 X-QM-Body-MD5: d142ed23e5c2bb358bdbbe3f3c369ec6 (of first 20000 bytes)
\r
48 X-SpamAssassin-Score: -1.8
\r
49 X-SpamAssassin-SpamBar: -
\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
52 spam. We require at least 5.0 points to mark a message as spam.
\r
53 This message scored -1.8 points.
\r
54 Summary of the scoring:
\r
55 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
57 * [138.37.6.40 listed in list.dnswl.org]
\r
58 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
59 provider * (markwalters1009[at]gmail.com)
\r
60 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
62 * 0.5 AWL AWL: From: address is in the auto white-list
\r
63 X-QM-Scan-Virus: ClamAV says the message is clean
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Thu, 12 Jul 2012 09:14:35 -0000
\r
81 this definitely looks nice. I have a couple of suggestions for the
\r
84 On Thu, 12 Jul 2012, craven@gmx.net wrote:
\r
85 > This patch adds a new type sprinter_t, which is used for structured
\r
86 > formatting, e.g. JSON or S-Expressions. The structure printer is the
\r
87 > code from Austin Clements (id:87d34hsdx8.fsf@awakening.csail.mit.edu).
\r
89 > The structure printer contains the following function pointers:
\r
91 > /* start a new map/dictionary structure.
\r
93 > void (*begin_map) (struct sprinter *);
\r
95 > /* start a new list/array structure
\r
97 > void (*begin_list) (struct sprinter *);
\r
99 > /* end the last opened list or map structure
\r
101 > void (*end) (struct sprinter *);
\r
103 > /* print one string/integer/boolean/null element (possibly inside a
\r
106 > void (*string) (struct sprinter *, const char *);
\r
107 > void (*integer) (struct sprinter *, int);
\r
108 > void (*boolean) (struct sprinter *, notmuch_bool_t);
\r
109 > void (*null) (struct sprinter *);
\r
111 > /* print the key of a map's key/value pair.
\r
113 > void (*map_key) (struct sprinter *, const char *);
\r
115 > /* print a frame delimiter (such as a newline or extra whitespace)
\r
117 > void (*frame) (struct sprinter *);
\r
119 > The printer can (and should) use internal state to insert delimiters and
\r
120 > syntax at the correct places.
\r
124 > format->begin_map(format);
\r
125 > format->map_key(format, "foo");
\r
126 > format->begin_list(format);
\r
127 > format->integer(format, 1);
\r
128 > format->integer(format, 2);
\r
129 > format->integer(format, 3);
\r
130 > format->end(format);
\r
131 > format->map_key(format, "bar");
\r
132 > format->begin_map(format);
\r
133 > format->map_key(format, "baaz");
\r
134 > format->string(format, "hello world");
\r
135 > format->end(format);
\r
136 > format->end(format);
\r
138 > would output JSON as follows:
\r
140 > {"foo": [1, 2, 3], "bar": { "baaz": "hello world"}}
\r
142 > sprinter.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
\r
143 > 1 file changed, 49 insertions(+)
\r
144 > create mode 100644 sprinter.h
\r
146 > diff --git a/sprinter.h b/sprinter.h
\r
147 > new file mode 100644
\r
148 > index 0000000..1dad9a0
\r
152 > +#ifndef NOTMUCH_SPRINTER_H
\r
153 > +#define NOTMUCH_SPRINTER_H
\r
155 > +/* for notmuch_bool_t */
\r
156 > +#include "notmuch-client.h"
\r
158 > +/* Structure printer interface */
\r
159 > +typedef struct sprinter
\r
161 > + /* start a new map/dictionary structure.
\r
163 > + void (*begin_map) (struct sprinter *);
\r
165 > + /* start a new list/array structure
\r
167 > + void (*begin_list) (struct sprinter *);
\r
169 > + /* end the last opened list or map structure
\r
171 > + void (*end) (struct sprinter *);
\r
173 > + /* print one string/integer/boolean/null element (possibly inside a
\r
177 I think this should say that it also prints any separator necessary.
\r
179 > + void (*string) (struct sprinter *, const char *);
\r
180 > + void (*integer) (struct sprinter *, int);
\r
181 > + void (*boolean) (struct sprinter *, notmuch_bool_t);
\r
182 > + void (*null) (struct sprinter *);
\r
184 > + /* print the key of a map's key/value pair.
\r
186 > + void (*map_key) (struct sprinter *, const char *);
\r
188 > + /* print a frame delimiter (such as a newline or extra whitespace)
\r
190 > + void (*frame) (struct sprinter *);
\r
192 I think this should say that the intention is that this only prints
\r
193 non-syntactic stuff.
\r
202 > +/* Create a new structure printer that emits JSON */
\r
203 > +struct sprinter *
\r
204 > +sprinter_json_new(const void *ctx, FILE *stream);
\r
206 > +/* A dummy structure printer that signifies that standard text output is
\r
207 > + * to be used instead of any structured format.
\r
209 > +struct sprinter *
\r
212 > +#endif // NOTMUCH_SPRINTER_H
\r
216 > _______________________________________________
\r
217 > notmuch mailing list
\r
218 > notmuch@notmuchmail.org
\r
219 > http://notmuchmail.org/mailman/listinfo/notmuch
\r