Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / c8 / c22242c18f7e1d274a7b24fa7e3b53fd06f6be
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 D2F0F431FB6\r
6         for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 18:46:33 -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.7\r
10 X-Spam-Level: \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 MxJB49XwDqnA for <notmuch@notmuchmail.org>;\r
16         Fri, 13 Jul 2012 18:46:33 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
18         [18.9.25.13])\r
19         by olra.theworths.org (Postfix) with ESMTP id D4B58431FAE\r
20         for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 18:46:32 -0700 (PDT)\r
21 X-AuditID: 1209190d-b7fd56d000000933-f4-5000cf77a7e0\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 4C.B7.02355.77FC0005; Fri, 13 Jul 2012 21:46:31 -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 q6E1kUSS006235; \r
27         Fri, 13 Jul 2012 21:46:31 -0400\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6E1kTIw007839\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Fri, 13 Jul 2012 21:46:30 -0400 (EDT)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1SprRF-0000cE-DJ; Fri, 13 Jul 2012 21:46:29 -0400\r
37 Date: Fri, 13 Jul 2012 21:46:29 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Peter Feigl <craven@gmx.net>\r
40 Subject: Re: [PATCH v5 1/3] Add support for structured output formatters.\r
41 Message-ID: <20120714014629.GB31670@mit.edu>\r
42 References: <20120710191331.GE7332@mit.edu>\r
43         <1342167097-25012-1-git-send-email-craven@gmx.net>\r
44         <1342167097-25012-2-git-send-email-craven@gmx.net>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To: <1342167097-25012-2-git-send-email-craven@gmx.net>\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT0S0/zxBg8PKlgsXehnZGi+s3ZzI7\r
52         MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBk7D69lLniqUbFgzmG2BsYH8l2MnBwSAiYS\r
53         m280skPYYhIX7q1n62Lk4hAS2McocXjNS7CEkMAGRomJ74shEieZJObefcEM4SxhlHh29jZY\r
54         FYuAqkRXYwsriM0moCGxbf9yRhBbREBB4tm6JjCbWUBa4tvvZiYQW1jAU2Lv3e1sIDavgI5E\r
55         y5XprBBDpzJKzH97khUiIShxcuYTFohmLYkb/14CNXOADVr+jwMkzClgL/H82zFmEFtUQEVi\r
56         ysltbBMYhWYh6Z6FpHsWQvcCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFukZ6uZkleqkppZsY\r
57         QYHNKcm7g/HdQaVDjAIcjEo8vKn+DAFCrIllxZW5hxglOZiURHlrjwOF+JLyUyozEosz4otK\r
58         c1KLDzFKcDArifCatwHleFMSK6tSi/JhUtIcLErivFdSbvoLCaQnlqRmp6YWpBbBZGU4OJQk\r
59         eE+fA2oULEpNT61Iy8wpQUgzcXCCDOcBGv4QpIa3uCAxtzgzHSJ/ilFRSpz3LUhCACSRUZoH\r
60         1wtLPK8YxYFeEeb9BVLFA0xacN2vgAYzAQ2e9fOfP9DgkkSElFQD4/ZFzH9eP5t19mR9dLyR\r
61         97T9FzyZbm3JP71eYf+BiD3nj8ZErnis6mw3VW02V+HcZTEMX24Vr+b76WN0YM2Smf/vT7g/\r
62         42hiwlGn0Bk7dnPLRdqJ3FHs32OdzKzscVhMYuuThmKdiww9/M4W+n7ZdndTozjDO456Jb2a\r
63         u3zr9zcp+j0TAn/wPlZiKc5INNRiLipOBACWAzoyFwMAAA==\r
64 Cc: notmuch@notmuchmail.org\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Sat, 14 Jul 2012 01:46:34 -0000\r
78 \r
79 Quoth Peter Feigl on Jul 13 at 10:11 am:\r
80 > From: <craven@gmx.net>\r
81\r
82 > This patch adds a new type sprinter_t, which is used for structured\r
83 > formatting, e.g. JSON or S-Expressions. The structure printer is the\r
84 > code from Austin Clements (id:87d34hsdx8.fsf@awakening.csail.mit.edu)\r
85 > with minor modifications.\r
86\r
87 > The structure printer contains the following function pointers:\r
88\r
89 > /* Start a new map/dictionary structure. This should be followed by\r
90 >  * a sequence of alternating calls to map_key and one of the\r
91 >  * value-printing functions until the map is ended by end.\r
92 >  */\r
93 > void (*begin_map)(struct sprinter *);\r
94\r
95 > /* Start a new list/array structure.\r
96 >  */\r
97 > void (*begin_list)(struct sprinter *);\r
98\r
99 > /* End the last opened list or map structure.\r
100 >  */\r
101 > void (*end)(struct sprinter *);\r
102\r
103 > /* Set the prefix of the next component. This is purely for\r
104 >  * debugging purposes and for the unstructured text formatter.\r
105 >  */\r
106 > void (*set_prefix)(struct sprinter *, const char *);\r
107\r
108 > /* Print one string/integer/boolean/null element (possibly inside a\r
109 >  * list or map, followed or preceded by separators).\r
110 >  * For string, the char * must be UTF-8 encoded.\r
111 >  */\r
112 > void (*string)(struct sprinter *, const char *);\r
113 > void (*integer)(struct sprinter *, int);\r
114 > void (*boolean)(struct sprinter *, notmuch_bool_t);\r
115 > void (*null)(struct sprinter *);\r
116\r
117 > /* Print the key of a map's key/value pair. The char * must be UTF-8\r
118 >  * encoded.\r
119 >  */\r
120 > void (*map_key)(struct sprinter *, const char *);\r
121\r
122 > /* Insert a separator (usually extra whitespace) for improved\r
123 >  * readability without affecting the abstract syntax of the\r
124 >  * structure being printed.\r
125 >  * For JSON, this could simply be a line break.\r
126 >  */\r
127 > void (*separator)(struct sprinter *);\r
128\r
129 > The printer can (and should) use internal state to insert delimiters and\r
130 > 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 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
153 >  1 file changed, 50 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..c9cd6a6\r
159 > --- /dev/null\r
160 > +++ b/sprinter.h\r
161 > @@ -0,0 +1,50 @@\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 */\r
169 > +typedef struct sprinter {\r
170 > +    /* Start a new map/dictionary structure. This should be followed by\r
171 > +     * a sequence of alternating calls to map_key and one of the\r
172 > +     * value-printing functions until the map is ended by end.\r
173 > +     */\r
174 > +    void (*begin_map)(struct sprinter *);\r
175 \r
176 It looks like you lost the spaces before the argument lists, which\r
177 your previous version had.  Was this from uncrustify?  The few other\r
178 places that notmuch had function pointers do put a space here.\r
179 \r
180 > +\r
181 > +    /* Start a new list/array structure.\r
182 > +     */\r
183 > +    void (*begin_list)(struct sprinter *);\r
184 > +\r
185 > +    /* End the last opened list or map structure.\r
186 > +     */\r
187 > +    void (*end)(struct sprinter *);\r
188 > +\r
189 > +    /* Set the prefix of the next component. This is purely for\r
190 > +     * debugging purposes and for the unstructured text formatter.\r
191 \r
192 This should probably be more specific about what this operation does\r
193 and under what circumstances.  It also makes it sound like it only\r
194 applies to the next component, which I think is not the case.  Maybe\r
195 \r
196 /* Set the current string prefix.  This only affects the text\r
197  * printer, which will print this string, followed by a colon, before\r
198  * any string.  For other printers, this does nothing.\r
199  */\r
200 \r
201 ?\r
202 \r
203 > +     */\r
204 > +    void (*set_prefix)(struct sprinter *, const char *);\r
205 > +\r
206 > +    /* Print one string/integer/boolean/null element (possibly inside a\r
207 > +     * list or map, followed or preceded by separators).\r
208 > +     * For string, the char * must be UTF-8 encoded.\r
209 > +     */\r
210 > +    void (*string)(struct sprinter *, const char *);\r
211 > +    void (*integer)(struct sprinter *, int);\r
212 > +    void (*boolean)(struct sprinter *, notmuch_bool_t);\r
213 > +    void (*null)(struct sprinter *);\r
214 > +\r
215 > +    /* Print the key of a map's key/value pair. The char * must be UTF-8\r
216 > +     * encoded.\r
217 > +     */\r
218 > +    void (*map_key)(struct sprinter *, const char *);\r
219 > +\r
220 > +    /* Insert a separator (usually extra whitespace) for improved\r
221 > +     * readability without affecting the abstract syntax of the\r
222 > +     * structure being printed.\r
223 > +     * For JSON, this could simply be a line break.\r
224 > +     */\r
225 > +    void (*separator)(struct sprinter *);\r
226 > +} sprinter_t;\r
227 > +\r
228 > +#endif // NOTMUCH_SPRINTER_H\r