Re: Avoiding the "huge INBOX of death"
[notmuch-archives.git] / da / 4247ceb5f878aa6c3cc4f4d6db9ac02c96773d
1 Return-Path: <tomi.ollila@iki.fi>\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 9FD68431FBC\r
6         for <notmuch@notmuchmail.org>; Fri, 20 Jul 2012 02:08:59 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 6OhAR-PXdlpA for <notmuch@notmuchmail.org>;\r
16         Fri, 20 Jul 2012 02:08:58 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 39A80431FAE\r
19         for <notmuch@notmuchmail.org>; Fri, 20 Jul 2012 02:08:58 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 96BF710014D; Fri, 20 Jul 2012 12:09:07 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: craven@gmx.net, notmuch@notmuchmail.org\r
24 Subject: Re: [PATCH v7 1/3] Add support for structured output formatters.\r
25 In-Reply-To: <1342766173-1344-2-git-send-email-craven@gmx.net>\r
26 References: <20120718194819.GP31670@mit.edu>\r
27         <1342766173-1344-1-git-send-email-craven@gmx.net>\r
28         <1342766173-1344-2-git-send-email-craven@gmx.net>\r
29 User-Agent: Notmuch/0.13.2+93~ge4fdd97 (http://notmuchmail.org) Emacs/23.1.1\r
30         (x86_64-redhat-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Fri, 20 Jul 2012 12:09:07 +0300\r
35 Message-ID: <m2txx294uk.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain; charset=us-ascii\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Fri, 20 Jul 2012 09:08:59 -0000\r
51 \r
52 On Fri, Jul 20 2012, craven@gmx.net wrote:\r
53 \r
54 > From: <craven@gmx.net>\r
55 >\r
56 > This patch adds a new struct type sprinter_t, which is used for\r
57 > structured formatting, e.g. JSON or S-Expressions. The structure printer\r
58 > is heavily based on code from Austin Clements\r
59 > (id:87d34hsdx8.fsf@awakening.csail.mit.edu).\r
60 >\r
61 > It includes the following functions:\r
62 >\r
63 >     /* Start a new map/dictionary structure. This should be followed by\r
64 >      * a sequence of alternating calls to map_key and one of the\r
65 >      * value-printing functions until the map is ended by end.\r
66 >      */\r
67 >     void (*begin_map) (struct sprinter *);\r
68 >\r
69 >     /* Start a new list/array structure.\r
70 >      */\r
71 >     void (*begin_list) (struct sprinter *);\r
72 >\r
73 >     /* End the last opened list or map structure.\r
74 >      */\r
75 >     void (*end) (struct sprinter *);\r
76 >\r
77 >     /* Print one string/integer/boolean/null element (possibly inside a\r
78 >      * list or map, followed or preceded by separators).\r
79 >      * For string, the char * must be UTF-8 encoded.\r
80 >      */\r
81 >     void (*string) (struct sprinter *, const char *);\r
82 >     void (*integer) (struct sprinter *, int);\r
83 >     void (*boolean) (struct sprinter *, notmuch_bool_t);\r
84 >     void (*null) (struct sprinter *);\r
85 >\r
86 >     /* Print the key of a map's key/value pair. The char * must be UTF-8\r
87 >      * encoded.\r
88 >      */\r
89 >     void (*map_key) (struct sprinter *, const char *);\r
90 >\r
91 >     /* Insert a separator (usually extra whitespace) for improved\r
92 >      * readability without affecting the abstract syntax of the\r
93 >      * structure being printed.\r
94 >      * For JSON, this could simply be a line break.\r
95 >      */\r
96 >     void (*separator) (struct sprinter *);\r
97 >\r
98 >     /* Set the current string prefix. This only affects the text\r
99 >      * printer, which will print this string, followed by a colon,\r
100 >      * before any string. For other printers, this does nothing.\r
101 >      */\r
102 >     void (*set_prefix) (struct sprinter *, const char *);\r
103 \r
104 The above block duplicated below. Otherwise this LGTM.\r
105 \r
106 I presume the patch 3/3 emails\r
107 \r
108 id:"1342766173-1344-4-git-send-email-craven@gmx.net"\r
109 id:"1342772624-23329-1-git-send-email-craven@gmx.net"\r
110 \r
111 have identical content ?\r
112 \r
113 > To support the plain text format properly, the following additional\r
114 > function must also be implemented:\r
115 >\r
116 >     /* Set the current string prefix. This only affects the text\r
117 >      * printer, which will print this string, followed by a colon,\r
118 >      * before any string. For other printers, this does nothing.\r
119 >      */\r
120 >     void (*set_prefix) (struct sprinter *, const char *);\r
121 >\r
122 > The structure also contains a flag that should be set to FALSE in all\r
123 > custom printers and to TRUE in the plain text formatter.\r
124 >\r
125 >     /* True if this is the special-cased plain text printer.\r
126 >      */\r
127 >     notmuch_bool_t is_text_printer;\r
128 >\r
129 > The printer can (and should) use internal state to insert delimiters\r
130 > and syntax at the correct places.\r
131 >\r
132 > Example:\r
133 >\r
134 > format->begin_map(format);\r
135 > format->map_key(format, "foo");\r
136 > format->begin_list(format);\r
137 > format->integer(format, 1);\r
138 > format->integer(format, 2);\r
139 > format->integer(format, 3);\r
140 > format->end(format);\r
141 > format->map_key(format, "bar");\r
142 > format->begin_map(format);\r
143 > format->map_key(format, "baaz");\r
144 > format->string(format, "hello world");\r
145 > format->end(format);\r
146 > format->end(format);\r
147 >\r
148 > would output JSON as follows:\r
149 >\r
150 > {"foo": [1, 2, 3], "bar": { "baaz": "hello world"}}\r
151 > ---\r
152 >  sprinter.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
153 >  1 file changed, 58 insertions(+)\r
154 >  create mode 100644 sprinter.h\r
155 >\r
156 > diff --git a/sprinter.h b/sprinter.h\r
157 > new file mode 100644\r
158 > index 0000000..77dc26f\r
159 > --- /dev/null\r
160 > +++ b/sprinter.h\r
161 > @@ -0,0 +1,58 @@\r
162 > +#ifndef NOTMUCH_SPRINTER_H\r
163 > +#define NOTMUCH_SPRINTER_H\r
164 > +\r
165 > +/* Necessary for notmuch_bool_t */\r
166 > +#include "notmuch-client.h"\r
167 > +\r
168 > +/* Structure printer interface. This is used to create output\r
169 > + * structured as maps (with key/value pairs), lists and primitives\r
170 > + * (strings, integers and booleans).\r
171 > + */\r
172 > +typedef struct sprinter {\r
173 > +    /* Start a new map/dictionary structure. This should be followed by\r
174 > +     * a sequence of alternating calls to map_key and one of the\r
175 > +     * value-printing functions until the map is ended by end.\r
176 > +     */\r
177 > +    void (*begin_map) (struct sprinter *);\r
178 > +\r
179 > +    /* Start a new list/array structure.\r
180 > +     */\r
181 > +    void (*begin_list) (struct sprinter *);\r
182 > +\r
183 > +    /* End the last opened list or map structure.\r
184 > +     */\r
185 > +    void (*end) (struct sprinter *);\r
186 > +\r
187 > +    /* Print one string/integer/boolean/null element (possibly inside a\r
188 > +     * list or map, followed or preceded by separators).\r
189 > +     * For string, the char * must be UTF-8 encoded.\r
190 > +     */\r
191 > +    void (*string) (struct sprinter *, const char *);\r
192 > +    void (*integer) (struct sprinter *, int);\r
193 > +    void (*boolean) (struct sprinter *, notmuch_bool_t);\r
194 > +    void (*null) (struct sprinter *);\r
195 > +\r
196 > +    /* Print the key of a map's key/value pair. The char * must be UTF-8\r
197 > +     * encoded.\r
198 > +     */\r
199 > +    void (*map_key) (struct sprinter *, const char *);\r
200 > +\r
201 > +    /* Insert a separator (usually extra whitespace) for improved\r
202 > +     * readability without affecting the abstract syntax of the\r
203 > +     * structure being printed.\r
204 > +     * For JSON, this could simply be a line break.\r
205 > +     */\r
206 > +    void (*separator) (struct sprinter *);\r
207 > +\r
208 > +    /* Set the current string prefix. This only affects the text\r
209 > +     * printer, which will print this string, followed by a colon,\r
210 > +     * before any string. For other printers, this does nothing.\r
211 > +     */\r
212 > +    void (*set_prefix) (struct sprinter *, const char *);\r
213 > +\r
214 > +    /* True if this is the special-cased plain text printer.\r
215 > +     */\r
216 > +    notmuch_bool_t is_text_printer;\r
217 > +} sprinter_t;\r
218 > +\r
219 > +#endif // NOTMUCH_SPRINTER_H\r
220 > -- \r
221 > 1.7.11.2\r
222 >\r
223 > _______________________________________________\r
224 > notmuch mailing list\r
225 > notmuch@notmuchmail.org\r
226 > http://notmuchmail.org/mailman/listinfo/notmuch\r