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 D5379431FAF
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 18:47:57 -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 HANXb8D-7IG6 for <notmuch@notmuchmail.org>;
\r
16 Mon, 23 Apr 2012 18:47:57 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 1BF43431FAE
\r
20 for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 18:47:57 -0700 (PDT)
\r
21 X-AuditID: 12074422-b7fd66d0000008f9-b8-4f96064ba3c2
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 42.B5.02297.B46069F4; Mon, 23 Apr 2012 21:47:55 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3O1ltuf005880;
\r
27 Mon, 23 Apr 2012 21:47:55 -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 q3O1ls3u028479
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Mon, 23 Apr 2012 21:47:54 -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 1SMUrB-0004An-Qz; Mon, 23 Apr 2012 21:47:53 -0400
\r
37 Date: Mon, 23 Apr 2012 21:47:53 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: Mark Walters <markwalters1009@gmail.com>
\r
40 Subject: Re: [PATCH v3 1/2] cli: make --entire-thread=false work for
\r
42 Message-ID: <20120424014753.GI17810@mit.edu>
\r
43 References: <1334999750-21811-1-git-send-email-markwalters1009@gmail.com>
\r
44 <1334999750-21811-2-git-send-email-markwalters1009@gmail.com>
\r
46 Content-Type: text/plain; charset=us-ascii
\r
47 Content-Disposition: inline
\r
48 In-Reply-To: <1334999750-21811-2-git-send-email-markwalters1009@gmail.com>
\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IRYrdT1/Vmm+ZvMOeGlsXquTwW12/OZHZg
\r
52 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4MibcX8BW8FehomfWTcYGxn2SXYycHBICJhKr
\r
53 P09ngrDFJC7cW8/WxcjFISSwj1Fi/u+Z7BDOBkaJGW+amEGqhAROMkmsOmkCkVjCKPHq2R8W
\r
54 kASLgKrE6q1fWUFsNgENiW37lzOC2CICOhK3Dy1gB7GZBaQlvv1uBlsnLBAs8XntWrB6XqCa
\r
55 vQ3zGSGGdjJKLF5+hA0iIShxcuYTFohmLYkb/14CNXOADVr+jwMkzCngJfH1ym+w+aICKhJT
\r
56 Tm5jm8AoNAtJ9ywk3bMQuhcwMq9ilE3JrdLNTczMKU5N1i1OTszLSy3SNdXLzSzRS00p3cQI
\r
57 DmsXpR2MPw8qHWIU4GBU4uHNTJ/qL8SaWFZcmXuIUZKDSUmUl591mr8QX1J+SmVGYnFGfFFp
\r
58 TmrxIUYJDmYlEd5H/4HKeVMSK6tSi/JhUtIcLErivOpa7/yEBNITS1KzU1MLUotgsjIcHEoS
\r
59 vPEgQwWLUtNTK9Iyc0oQ0kwcnCDDeYCGTwGp4S0uSMwtzkyHyJ9i1OW49uXoFUYhlrz8vFQp
\r
60 cd5CkCIBkKKM0jy4ObB09IpRHOgtYd5YkCoeYCqDm/QKaAkT0JKEmEkgS0oSEVJSDYwTav1L
\r
61 3MPqsv4WrrAxDj7SeOiD1vankQ1fTjD89fjfnNlUY1BX3MbLv4At8ewGCRm3vrbHKQKsW78t
\r
62 3zPnpP/N8Fy9m4sbjdf8658U5i+dZbPvAbPEserCFwJdrYseTzkicfi2QkT25AaZC6uTvDzD
\r
63 Pb5mGLumWBcemXE8XKlUMsXg0SxbASWW4oxEQy3mouJEAP73LbYiAwAA
\r
64 Cc: notmuch@notmuchmail.org
\r
65 X-BeenThere: notmuch@notmuchmail.org
\r
66 X-Mailman-Version: 2.1.13
\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: Tue, 24 Apr 2012 01:47:58 -0000
\r
79 Quoth Mark Walters on Apr 21 at 10:15 am:
\r
80 > The --entire-thread option in notmuch-show.c defaults to true when
\r
81 > format=json. Previously there was no way to turn this off. This patch
\r
82 > makes it respect --entire-thread=false.
\r
84 > The one subtlety is that we initialise a notmuch_bool_t to -1 to
\r
85 > indicate that the option parsing has not set it. This allows the code
\r
86 > to distinguish between the option being omitted from the command line,
\r
87 > and the option being set to false on the command line.
\r
89 > Finally, all formats except Json can output empty messages for non
\r
90 > entire-thread, but in Json format we need to output {} to keep the
\r
91 > other elements (e.g. the replies to this message) in the correct
\r
94 > notmuch-show.c | 34 +++++++++++++++++++++++++++++-----
\r
95 > 1 files changed, 29 insertions(+), 5 deletions(-)
\r
97 > diff --git a/notmuch-show.c b/notmuch-show.c
\r
98 > index da4a797..327c263 100644
\r
99 > --- a/notmuch-show.c
\r
100 > +++ b/notmuch-show.c
\r
101 > @@ -800,6 +800,16 @@ format_part_raw (unused (const void *ctx), mime_node_t *node,
\r
104 > static notmuch_status_t
\r
105 > +show_null_message (const notmuch_show_format_t *format)
\r
107 > + /* For all formats except json an empty message output is valid;
\r
108 > + * for json we need the braces.*/
\r
109 > + if (format == &format_json)
\r
111 This should probably be specified as a field in the format, rather
\r
112 than using a hard-coded dispatch. It could even be a plain string
\r
113 field that you could fputs in show_messages.
\r
117 This is a definite improvement over the current strangeness, but I
\r
118 think 'null' would be better than an empty object. null is a clearly
\r
119 distinguished value, rather than something that initially has a
\r
120 message-like type, but then isn't a message.
\r
122 You should also update devel/schemata to reflect this change.
\r
124 > + return NOTMUCH_STATUS_SUCCESS;
\r
127 > +static notmuch_status_t
\r
128 > show_message (void *ctx,
\r
129 > const notmuch_show_format_t *format,
\r
130 > notmuch_message_t *message,
\r
131 > @@ -862,11 +872,13 @@ show_messages (void *ctx,
\r
132 > if (status && !res)
\r
134 > next_indent = indent + 1;
\r
136 > - if (!status && format->message_set_sep)
\r
137 > - fputs (format->message_set_sep, stdout);
\r
139 > + status = show_null_message (format);
\r
142 > + if (!status && format->message_set_sep)
\r
143 > + fputs (format->message_set_sep, stdout);
\r
145 > status = show_messages (ctx,
\r
147 > notmuch_message_get_replies (message),
\r
149 I believe the stuff above could be a separate patch from the stuff
\r
152 > @@ -984,7 +996,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
153 > char *query_string;
\r
154 > int opt_index, ret;
\r
155 > const notmuch_show_format_t *format = &format_text;
\r
156 > - notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };
\r
158 > + /* We abuse the notmuch_bool_t variable params.entire-thread by
\r
159 > + * setting it to -1 to denote that the command line parsing has
\r
160 > + * not set it. We ensure it is set to TRUE or FALSE before passing
\r
161 > + * it to any other function.*/
\r
162 > + notmuch_show_params_t params = { .part = -1, .entire_thread = -1 };
\r
164 > int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
\r
165 > notmuch_bool_t verify = FALSE;
\r
166 > int exclude = EXCLUDE_TRUE;
\r
167 > @@ -1024,7 +1042,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
168 > switch (format_sel) {
\r
169 > case NOTMUCH_FORMAT_JSON:
\r
170 > format = &format_json;
\r
171 > - params.entire_thread = TRUE;
\r
172 > + /* JSON defaults to entire-thread TRUE */
\r
173 > + if (params.entire_thread == -1)
\r
174 > + params.entire_thread = TRUE;
\r
176 > case NOTMUCH_FORMAT_TEXT:
\r
177 > format = &format_text;
\r
178 > @@ -1046,6 +1066,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
179 > params.raw = TRUE;
\r
182 > + /* Default is entire-thread = FALSE except for format=json which
\r
183 > + * is dealt with above. */
\r
184 > + if (params.entire_thread == -1)
\r
185 > + params.entire_thread = FALSE;
\r
187 > if (params.decrypt || verify) {
\r
188 > #ifdef GMIME_ATLEAST_26
\r