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 D69A6431FC3
\r
6 for <notmuch@notmuchmail.org>; Wed, 5 Dec 2012 23:33:28 -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 QJdtbzzPFQ+D for <notmuch@notmuchmail.org>;
\r
17 Wed, 5 Dec 2012 23:33:25 -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 19EBB431FC9
\r
22 for <notmuch@notmuchmail.org>; Wed, 5 Dec 2012 23:33:19 -0800 (PST)
\r
23 Received: by mail.nexoid.at (Postfix, from userid 1000)
\r
24 id AF79811C10F; Thu, 6 Dec 2012 08:33:12 +0100 (CET)
\r
25 From: Peter Feigl <craven@gmx.net>
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [PATCH v3 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 08:33:07 +0100
\r
30 Message-Id: <1354779189-12231-4-git-send-email-craven@gmx.net>
\r
31 X-Mailer: git-send-email 1.8.0
\r
32 In-Reply-To: <1354779189-12231-1-git-send-email-craven@gmx.net>
\r
33 References: <1354779189-12231-1-git-send-email-craven@gmx.net>
\r
34 In-Reply-To: <1354632382-15609-1-git-send-email-craven@gmx.net>
\r
35 References: <1354632382-15609-1-git-send-email-craven@gmx.net>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Thu, 06 Dec 2012 07:33:29 -0000
\r
50 This patch uses the new S-Expression printer in the notmuch CLI (show,
\r
51 search and reply). You can now use --format=sexp for any of them.
\r
53 devel/schemata | 8 +++++++-
\r
54 notmuch-reply.c | 5 +++++
\r
55 notmuch-search.c | 6 +++++-
\r
56 notmuch-show.c | 35 +++++++++++++++++++++++------------
\r
57 4 files changed, 40 insertions(+), 14 deletions(-)
\r
59 diff --git a/devel/schemata b/devel/schemata
\r
60 index e44da71..01181d4 100644
\r
61 --- a/devel/schemata
\r
62 +++ b/devel/schemata
\r
64 This file describes the schemata used for notmuch's structured output
\r
65 -format (currently JSON).
\r
66 +format (currently JSON and S-Expressions).
\r
68 []'s indicate lists. List items can be marked with a '?', meaning
\r
69 they are optional; or a '*', meaning there can be zero or more of that
\r
70 @@ -8,6 +8,12 @@ values. An object field marked '?' is optional. |'s indicate
\r
71 alternates (e.g., int|string means something can be an int or a
\r
74 +For S-Expression output, lists are printed delimited by () instead of
\r
75 +[]. Objects are printed as p-lists, i.e. lists where the keys and values
\r
76 +are interleaved. Keys are printed as keywords (symbols preceded by a
\r
77 +colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
\r
78 +nil, true as t and false as nil.
\r
80 Common non-terminals
\r
81 --------------------
\r
83 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
84 index 6103d6e..5f3e46c 100644
\r
85 --- a/notmuch-reply.c
\r
86 +++ b/notmuch-reply.c
\r
87 @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx,
\r
92 FORMAT_HEADERS_ONLY,
\r
95 @@ -729,6 +730,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
96 { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
\r
97 (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
\r
98 { "json", FORMAT_JSON },
\r
99 + { "sexp", FORMAT_SEXP },
\r
100 { "headers-only", FORMAT_HEADERS_ONLY },
\r
102 { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',
\r
103 @@ -750,6 +752,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
104 } else if (format == FORMAT_JSON) {
\r
105 reply_format_func = notmuch_reply_format_sprinter;
\r
106 sp = sprinter_json_create (ctx, stdout);
\r
107 + } else if (format == FORMAT_SEXP) {
\r
108 + reply_format_func = notmuch_reply_format_sprinter;
\r
109 + sp = sprinter_sexp_create (ctx, stdout);
\r
111 reply_format_func = notmuch_reply_format_default;
\r
113 diff --git a/notmuch-search.c b/notmuch-search.c
\r
114 index 830c4e4..6218622 100644
\r
115 --- a/notmuch-search.c
\r
116 +++ b/notmuch-search.c
\r
117 @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
118 int exclude = EXCLUDE_TRUE;
\r
121 - enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
\r
122 + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }
\r
123 format_sel = NOTMUCH_FORMAT_TEXT;
\r
125 notmuch_opt_desc_t options[] = {
\r
126 @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
128 { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
\r
129 (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
\r
130 + { "sexp", NOTMUCH_FORMAT_SEXP },
\r
131 { "text", NOTMUCH_FORMAT_TEXT },
\r
133 { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
\r
134 @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
135 case NOTMUCH_FORMAT_JSON:
\r
136 format = sprinter_json_create (ctx, stdout);
\r
138 + case NOTMUCH_FORMAT_SEXP:
\r
139 + format = sprinter_sexp_create (ctx, stdout);
\r
142 /* this should never happen */
\r
143 INTERNAL_ERROR("no output format selected");
\r
144 diff --git a/notmuch-show.c b/notmuch-show.c
\r
145 index 38c621f..2bd09f3 100644
\r
146 --- a/notmuch-show.c
\r
147 +++ b/notmuch-show.c
\r
148 @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = {
\r
149 .part = format_part_sprinter_entry,
\r
152 +static const notmuch_show_format_t format_sexp = {
\r
153 + .new_sprinter = sprinter_sexp_create,
\r
154 + .part = format_part_sprinter_entry,
\r
157 static notmuch_status_t
\r
158 format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
159 int indent, const notmuch_show_params_t *params);
\r
160 @@ -110,8 +115,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
162 format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)
\r
164 - /* Any changes to the JSON format should be reflected in the file
\r
165 - * devel/schemata. */
\r
166 + /* Any changes to the JSON or S-Expression format should be
\r
167 + * reflected in the file devel/schemata. */
\r
169 void *local = talloc_new (NULL);
\r
170 notmuch_tags_t *tags;
\r
171 @@ -211,8 +216,8 @@ void
\r
172 format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
\r
173 notmuch_bool_t reply)
\r
175 - /* Any changes to the JSON format should be reflected in the file
\r
176 - * devel/schemata. */
\r
177 + /* Any changes to the JSON or S-Expression format should be
\r
178 + * reflected in the file devel/schemata. */
\r
180 InternetAddressList *recipients;
\r
181 const char *recipients_string;
\r
182 @@ -365,8 +370,8 @@ signer_status_to_string (GMimeSignerStatus x)
\r
184 format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
\r
186 - /* Any changes to the JSON format should be reflected in the file
\r
187 - * devel/schemata. */
\r
188 + /* Any changes to the JSON or S-Expression format should be
\r
189 + * reflected in the file devel/schemata. */
\r
191 GMimeSignatureList *siglist = node->sig_list;
\r
193 @@ -598,8 +603,8 @@ void
\r
194 format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
195 notmuch_bool_t first, notmuch_bool_t output_body)
\r
197 - /* Any changes to the JSON format should be reflected in the file
\r
198 - * devel/schemata. */
\r
199 + /* Any changes to the JSON or S-Expression format should be
\r
200 + * reflected in the file devel/schemata. */
\r
202 if (node->envelope_file) {
\r
203 sp->begin_map (sp);
\r
204 @@ -1012,6 +1017,7 @@ do_show (void *ctx,
\r
206 NOTMUCH_FORMAT_NOT_SPECIFIED,
\r
207 NOTMUCH_FORMAT_JSON,
\r
208 + NOTMUCH_FORMAT_SEXP,
\r
209 NOTMUCH_FORMAT_TEXT,
\r
210 NOTMUCH_FORMAT_MBOX,
\r
212 @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
213 { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
\r
214 (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
\r
215 { "text", NOTMUCH_FORMAT_TEXT },
\r
216 + { "sexp", NOTMUCH_FORMAT_SEXP },
\r
217 { "mbox", NOTMUCH_FORMAT_MBOX },
\r
218 { "raw", NOTMUCH_FORMAT_RAW },
\r
220 @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
221 case NOTMUCH_FORMAT_TEXT:
\r
222 format = &format_text;
\r
224 + case NOTMUCH_FORMAT_SEXP:
\r
225 + format = &format_sexp;
\r
227 case NOTMUCH_FORMAT_MBOX:
\r
228 if (params.part > 0) {
\r
229 fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");
\r
230 @@ -1118,9 +1128,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
234 - /* Default is entire-thread = FALSE except for format=json. */
\r
235 + /* Default is entire-thread = FALSE except for format=json and format=sexp. */
\r
236 if (entire_thread == ENTIRE_THREAD_DEFAULT) {
\r
237 - if (format == &format_json)
\r
238 + if (format == &format_json || format == &format_sexp)
\r
239 entire_thread = ENTIRE_THREAD_TRUE;
\r
241 entire_thread = ENTIRE_THREAD_FALSE;
\r
242 @@ -1131,8 +1141,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
243 fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
\r
244 params.output_body = TRUE;
\r
246 - if (format != &format_json)
\r
247 - fprintf (stderr, "Warning: --body=false only implemented for format=json\n");
\r
248 + if (format != &format_json && format != &format_sexp)
\r
250 + "Warning: --body=false only implemented for format=json and format=sexp\n");
\r