1 Return-Path: <nex@nexoid.at>
\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 5D522431FBF
\r
6 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 03:45:19 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5
\r
13 tests=[FREEMAIL_FROM=0.001] 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 XHHryMqFI+ZM for <notmuch@notmuchmail.org>;
\r
17 Thu, 6 Dec 2012 03:45:17 -0800 (PST)
\r
18 Received: from mail.nexoid.at (www.nexoid.at [178.79.130.240])
\r
19 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 68CF6431FBC
\r
22 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 03:45:17 -0800 (PST)
\r
23 Received: by mail.nexoid.at (Postfix, from userid 1000)
\r
24 id 4C46211C10F; Thu, 6 Dec 2012 12:45:14 +0100 (CET)
\r
25 From: Peter Feigl <craven@gmx.net>
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [PATCH v4 3/5] Use the S-Expression structured printer in
\r
28 notmuch-show, notmuch-reply and notmuch-search.
\r
29 Date: Thu, 6 Dec 2012 12:44:57 +0100
\r
31 <9cb474a271c471f8bae8b55b0148bb970ba78ceb.1354794428.git.craven@gmx.net>
\r
32 X-Mailer: git-send-email 1.8.0
\r
33 In-Reply-To: <cover.1354794428.git.craven@gmx.net>
\r
34 References: <cover.1354794428.git.craven@gmx.net>
\r
35 In-Reply-To: <cover.1354794428.git.craven@gmx.net>
\r
36 References: <cover.1354794428.git.craven@gmx.net>
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.13
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Thu, 06 Dec 2012 11:45:19 -0000
\r
51 This patch uses the new S-Expression printer in the notmuch CLI (show,
\r
52 search and reply). You can now use --format=sexp for any of them.
\r
54 devel/schemata | 8 +++++++-
\r
55 notmuch-reply.c | 5 +++++
\r
56 notmuch-search.c | 6 +++++-
\r
57 notmuch-show.c | 35 +++++++++++++++++++++++------------
\r
58 4 files changed, 40 insertions(+), 14 deletions(-)
\r
60 diff --git a/devel/schemata b/devel/schemata
\r
61 index e44da71..01181d4 100644
\r
62 --- a/devel/schemata
\r
63 +++ b/devel/schemata
\r
65 This file describes the schemata used for notmuch's structured output
\r
66 -format (currently JSON).
\r
67 +format (currently JSON and S-Expressions).
\r
69 []'s indicate lists. List items can be marked with a '?', meaning
\r
70 they are optional; or a '*', meaning there can be zero or more of that
\r
71 @@ -8,6 +8,12 @@ values. An object field marked '?' is optional. |'s indicate
\r
72 alternates (e.g., int|string means something can be an int or a
\r
75 +For S-Expression output, lists are printed delimited by () instead of
\r
76 +[]. Objects are printed as p-lists, i.e. lists where the keys and values
\r
77 +are interleaved. Keys are printed as keywords (symbols preceded by a
\r
78 +colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
\r
79 +nil, true as t and false as nil.
\r
81 Common non-terminals
\r
82 --------------------
\r
84 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
85 index 6103d6e..5f3e46c 100644
\r
86 --- a/notmuch-reply.c
\r
87 +++ b/notmuch-reply.c
\r
88 @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx,
\r
93 FORMAT_HEADERS_ONLY,
\r
96 @@ -729,6 +730,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
97 { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
\r
98 (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
\r
99 { "json", FORMAT_JSON },
\r
100 + { "sexp", FORMAT_SEXP },
\r
101 { "headers-only", FORMAT_HEADERS_ONLY },
\r
103 { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',
\r
104 @@ -750,6 +752,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
105 } else if (format == FORMAT_JSON) {
\r
106 reply_format_func = notmuch_reply_format_sprinter;
\r
107 sp = sprinter_json_create (ctx, stdout);
\r
108 + } else if (format == FORMAT_SEXP) {
\r
109 + reply_format_func = notmuch_reply_format_sprinter;
\r
110 + sp = sprinter_sexp_create (ctx, stdout);
\r
112 reply_format_func = notmuch_reply_format_default;
\r
114 diff --git a/notmuch-search.c b/notmuch-search.c
\r
115 index 830c4e4..6218622 100644
\r
116 --- a/notmuch-search.c
\r
117 +++ b/notmuch-search.c
\r
118 @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
119 int exclude = EXCLUDE_TRUE;
\r
122 - enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
\r
123 + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }
\r
124 format_sel = NOTMUCH_FORMAT_TEXT;
\r
126 notmuch_opt_desc_t options[] = {
\r
127 @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
129 { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
\r
130 (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
\r
131 + { "sexp", NOTMUCH_FORMAT_SEXP },
\r
132 { "text", NOTMUCH_FORMAT_TEXT },
\r
134 { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
\r
135 @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
136 case NOTMUCH_FORMAT_JSON:
\r
137 format = sprinter_json_create (ctx, stdout);
\r
139 + case NOTMUCH_FORMAT_SEXP:
\r
140 + format = sprinter_sexp_create (ctx, stdout);
\r
143 /* this should never happen */
\r
144 INTERNAL_ERROR("no output format selected");
\r
145 diff --git a/notmuch-show.c b/notmuch-show.c
\r
146 index 38c621f..2bd09f3 100644
\r
147 --- a/notmuch-show.c
\r
148 +++ b/notmuch-show.c
\r
149 @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = {
\r
150 .part = format_part_sprinter_entry,
\r
153 +static const notmuch_show_format_t format_sexp = {
\r
154 + .new_sprinter = sprinter_sexp_create,
\r
155 + .part = format_part_sprinter_entry,
\r
158 static notmuch_status_t
\r
159 format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
160 int indent, const notmuch_show_params_t *params);
\r
161 @@ -110,8 +115,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
163 format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)
\r
165 - /* Any changes to the JSON format should be reflected in the file
\r
166 - * devel/schemata. */
\r
167 + /* Any changes to the JSON or S-Expression format should be
\r
168 + * reflected in the file devel/schemata. */
\r
170 void *local = talloc_new (NULL);
\r
171 notmuch_tags_t *tags;
\r
172 @@ -211,8 +216,8 @@ void
\r
173 format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
\r
174 notmuch_bool_t reply)
\r
176 - /* Any changes to the JSON format should be reflected in the file
\r
177 - * devel/schemata. */
\r
178 + /* Any changes to the JSON or S-Expression format should be
\r
179 + * reflected in the file devel/schemata. */
\r
181 InternetAddressList *recipients;
\r
182 const char *recipients_string;
\r
183 @@ -365,8 +370,8 @@ signer_status_to_string (GMimeSignerStatus x)
\r
185 format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
\r
187 - /* Any changes to the JSON format should be reflected in the file
\r
188 - * devel/schemata. */
\r
189 + /* Any changes to the JSON or S-Expression format should be
\r
190 + * reflected in the file devel/schemata. */
\r
192 GMimeSignatureList *siglist = node->sig_list;
\r
194 @@ -598,8 +603,8 @@ void
\r
195 format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
196 notmuch_bool_t first, notmuch_bool_t output_body)
\r
198 - /* Any changes to the JSON format should be reflected in the file
\r
199 - * devel/schemata. */
\r
200 + /* Any changes to the JSON or S-Expression format should be
\r
201 + * reflected in the file devel/schemata. */
\r
203 if (node->envelope_file) {
\r
204 sp->begin_map (sp);
\r
205 @@ -1012,6 +1017,7 @@ do_show (void *ctx,
\r
207 NOTMUCH_FORMAT_NOT_SPECIFIED,
\r
208 NOTMUCH_FORMAT_JSON,
\r
209 + NOTMUCH_FORMAT_SEXP,
\r
210 NOTMUCH_FORMAT_TEXT,
\r
211 NOTMUCH_FORMAT_MBOX,
\r
213 @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
214 { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
\r
215 (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
\r
216 { "text", NOTMUCH_FORMAT_TEXT },
\r
217 + { "sexp", NOTMUCH_FORMAT_SEXP },
\r
218 { "mbox", NOTMUCH_FORMAT_MBOX },
\r
219 { "raw", NOTMUCH_FORMAT_RAW },
\r
221 @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
222 case NOTMUCH_FORMAT_TEXT:
\r
223 format = &format_text;
\r
225 + case NOTMUCH_FORMAT_SEXP:
\r
226 + format = &format_sexp;
\r
228 case NOTMUCH_FORMAT_MBOX:
\r
229 if (params.part > 0) {
\r
230 fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");
\r
231 @@ -1118,9 +1128,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
235 - /* Default is entire-thread = FALSE except for format=json. */
\r
236 + /* Default is entire-thread = FALSE except for format=json and format=sexp. */
\r
237 if (entire_thread == ENTIRE_THREAD_DEFAULT) {
\r
238 - if (format == &format_json)
\r
239 + if (format == &format_json || format == &format_sexp)
\r
240 entire_thread = ENTIRE_THREAD_TRUE;
\r
242 entire_thread = ENTIRE_THREAD_FALSE;
\r
243 @@ -1131,8 +1141,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
244 fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
\r
245 params.output_body = TRUE;
\r
247 - if (format != &format_json)
\r
248 - fprintf (stderr, "Warning: --body=false only implemented for format=json\n");
\r
249 + if (format != &format_json && format != &format_sexp)
\r
251 + "Warning: --body=false only implemented for format=json and format=sexp\n");
\r