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 BF50A431FCF
\r
6 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 13:12:27 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5
\r
12 tests=[FREEMAIL_FROM=0.001] 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 bQ9qXHzu32Uz for <notmuch@notmuchmail.org>;
\r
16 Thu, 6 Dec 2012 13:12:25 -0800 (PST)
\r
17 Received: from mail.nexoid.at (www.nexoid.at [178.79.130.240])
\r
18 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 8068B431FBC
\r
21 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 13:12:25 -0800 (PST)
\r
22 Received: by mail.nexoid.at (Postfix, from userid 1000)
\r
23 id 421CC11C10B; Thu, 6 Dec 2012 22:12:23 +0100 (CET)
\r
24 From: Peter Feigl <craven@gmx.net>
\r
25 To: notmuch@notmuchmail.org
\r
26 Subject: [PATCH v5 3/5] Use the S-Expression structured printer in
\r
27 notmuch-show, notmuch-reply and notmuch-search.
\r
28 Date: Thu, 6 Dec 2012 22:12:13 +0100
\r
29 Message-Id: <1354828335-18151-4-git-send-email-craven@gmx.net>
\r
30 X-Mailer: git-send-email 1.8.0
\r
31 In-Reply-To: <1354828335-18151-1-git-send-email-craven@gmx.net>
\r
32 References: <1354828335-18151-1-git-send-email-craven@gmx.net>
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.13
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Thu, 06 Dec 2012 21:12:28 -0000
\r
47 This patch uses the new S-Expression printer in the notmuch CLI (show,
\r
48 search and reply). You can now use --format=sexp for any of them.
\r
50 devel/schemata | 8 +++++++-
\r
51 notmuch-reply.c | 5 +++++
\r
52 notmuch-search.c | 6 +++++-
\r
53 notmuch-show.c | 36 ++++++++++++++++++++++++------------
\r
54 4 files changed, 41 insertions(+), 14 deletions(-)
\r
56 diff --git a/devel/schemata b/devel/schemata
\r
57 index e5c5505..d1ab983 100644
\r
58 --- a/devel/schemata
\r
59 +++ b/devel/schemata
\r
61 This file describes the schemata used for notmuch's structured output
\r
62 -format (currently JSON).
\r
63 +format (currently JSON and S-Expressions).
\r
65 []'s indicate lists. List items can be marked with a '?', meaning
\r
66 they are optional; or a '*', meaning there can be zero or more of that
\r
67 @@ -8,6 +8,12 @@ values. An object field marked '?' is optional. |'s indicate
\r
68 alternates (e.g., int|string means something can be an int or a
\r
71 +For S-Expression output, lists are printed delimited by () instead of
\r
72 +[]. Objects are printed as p-lists, i.e. lists where the keys and values
\r
73 +are interleaved. Keys are printed as keywords (symbols preceded by a
\r
74 +colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
\r
75 +nil, true as t and false as nil.
\r
77 Common non-terminals
\r
78 --------------------
\r
80 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
81 index ef450b2..720749d 100644
\r
82 --- a/notmuch-reply.c
\r
83 +++ b/notmuch-reply.c
\r
84 @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx,
\r
89 FORMAT_HEADERS_ONLY,
\r
92 @@ -729,6 +730,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
93 { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
\r
94 (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
\r
95 { "json", FORMAT_JSON },
\r
96 + { "sexp", FORMAT_SEXP },
\r
97 { "headers-only", FORMAT_HEADERS_ONLY },
\r
99 { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',
\r
100 @@ -750,6 +752,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
101 } else if (format == FORMAT_JSON) {
\r
102 reply_format_func = notmuch_reply_format_sprinter;
\r
103 sp = sprinter_json_create (ctx, stdout);
\r
104 + } else if (format == FORMAT_SEXP) {
\r
105 + reply_format_func = notmuch_reply_format_sprinter;
\r
106 + sp = sprinter_sexp_create (ctx, stdout);
\r
108 reply_format_func = notmuch_reply_format_default;
\r
110 diff --git a/notmuch-search.c b/notmuch-search.c
\r
111 index 830c4e4..6218622 100644
\r
112 --- a/notmuch-search.c
\r
113 +++ b/notmuch-search.c
\r
114 @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
115 int exclude = EXCLUDE_TRUE;
\r
118 - enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
\r
119 + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }
\r
120 format_sel = NOTMUCH_FORMAT_TEXT;
\r
122 notmuch_opt_desc_t options[] = {
\r
123 @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
125 { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
\r
126 (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
\r
127 + { "sexp", NOTMUCH_FORMAT_SEXP },
\r
128 { "text", NOTMUCH_FORMAT_TEXT },
\r
130 { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
\r
131 @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
132 case NOTMUCH_FORMAT_JSON:
\r
133 format = sprinter_json_create (ctx, stdout);
\r
135 + case NOTMUCH_FORMAT_SEXP:
\r
136 + format = sprinter_sexp_create (ctx, stdout);
\r
139 /* this should never happen */
\r
140 INTERNAL_ERROR("no output format selected");
\r
141 diff --git a/notmuch-show.c b/notmuch-show.c
\r
142 index d3f08bc..34a0355 100644
\r
143 --- a/notmuch-show.c
\r
144 +++ b/notmuch-show.c
\r
145 @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = {
\r
146 .part = format_part_sprinter_entry,
\r
149 +static const notmuch_show_format_t format_sexp = {
\r
150 + .new_sprinter = sprinter_sexp_create,
\r
151 + .part = format_part_sprinter_entry,
\r
154 static notmuch_status_t
\r
155 format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
156 int indent, const notmuch_show_params_t *params);
\r
157 @@ -110,8 +115,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
159 format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)
\r
161 - /* Any changes to the JSON format should be reflected in the file
\r
162 - * devel/schemata. */
\r
163 + /* Any changes to the JSON or S-Expression format should be
\r
164 + * reflected in the file devel/schemata. */
\r
166 void *local = talloc_new (NULL);
\r
167 notmuch_tags_t *tags;
\r
168 @@ -211,8 +216,8 @@ void
\r
169 format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
\r
170 notmuch_bool_t reply)
\r
172 - /* Any changes to the JSON format should be reflected in the file
\r
173 - * devel/schemata. */
\r
174 + /* Any changes to the JSON or S-Expression format should be
\r
175 + * reflected in the file devel/schemata. */
\r
177 InternetAddressList *recipients;
\r
178 const char *recipients_string;
\r
179 @@ -365,8 +370,8 @@ signer_status_to_string (GMimeSignerStatus x)
\r
181 format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
\r
183 - /* Any changes to the JSON format should be reflected in the file
\r
184 - * devel/schemata. */
\r
185 + /* Any changes to the JSON or S-Expression format should be
\r
186 + * reflected in the file devel/schemata. */
\r
188 GMimeSignatureList *siglist = node->sig_list;
\r
190 @@ -598,8 +603,8 @@ void
\r
191 format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
192 notmuch_bool_t first, notmuch_bool_t output_body)
\r
194 - /* Any changes to the JSON format should be reflected in the file
\r
195 - * devel/schemata. */
\r
196 + /* Any changes to the JSON or S-Expression format should be
\r
197 + * reflected in the file devel/schemata. */
\r
199 if (node->envelope_file) {
\r
200 sp->begin_map (sp);
\r
201 @@ -1012,6 +1017,7 @@ do_show (void *ctx,
\r
203 NOTMUCH_FORMAT_NOT_SPECIFIED,
\r
204 NOTMUCH_FORMAT_JSON,
\r
205 + NOTMUCH_FORMAT_SEXP,
\r
206 NOTMUCH_FORMAT_TEXT,
\r
207 NOTMUCH_FORMAT_MBOX,
\r
209 @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
210 { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
\r
211 (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
\r
212 { "text", NOTMUCH_FORMAT_TEXT },
\r
213 + { "sexp", NOTMUCH_FORMAT_SEXP },
\r
214 { "mbox", NOTMUCH_FORMAT_MBOX },
\r
215 { "raw", NOTMUCH_FORMAT_RAW },
\r
217 @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
218 case NOTMUCH_FORMAT_TEXT:
\r
219 format = &format_text;
\r
221 + case NOTMUCH_FORMAT_SEXP:
\r
222 + format = &format_sexp;
\r
224 case NOTMUCH_FORMAT_MBOX:
\r
225 if (params.part > 0) {
\r
226 fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");
\r
227 @@ -1118,9 +1128,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
231 - /* Default is entire-thread = FALSE except for format=json. */
\r
232 + /* Default is entire-thread = FALSE except for format=json and
\r
233 + * format=sexp. */
\r
234 if (entire_thread == ENTIRE_THREAD_DEFAULT) {
\r
235 - if (format == &format_json)
\r
236 + if (format == &format_json || format == &format_sexp)
\r
237 entire_thread = ENTIRE_THREAD_TRUE;
\r
239 entire_thread = ENTIRE_THREAD_FALSE;
\r
240 @@ -1131,8 +1142,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
241 fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
\r
242 params.output_body = TRUE;
\r
244 - if (format != &format_json)
\r
245 - fprintf (stderr, "Warning: --body=false only implemented for format=json\n");
\r
246 + if (format != &format_json && format != &format_sexp)
\r
248 + "Warning: --body=false only implemented for format=json and format=sexp\n");
\r