--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 2BEEA431FBC\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 07:17:34 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id gChsgBz3gRmD for <notmuch@notmuchmail.org>;\r
+ Thu, 6 Dec 2012 07:17:33 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 23F9E431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 07:17:33 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 0467E100045;\r
+ Thu, 6 Dec 2012 17:17:30 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Peter Feigl <craven@gmx.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 3/5] Use the S-Expression structured printer in\r
+ notmuch-show, notmuch-reply and notmuch-search.\r
+In-Reply-To:\r
+ <9cb474a271c471f8bae8b55b0148bb970ba78ceb.1354794428.git.craven@gmx.net>\r
+References: <cover.1354794428.git.craven@gmx.net>\r
+ <9cb474a271c471f8bae8b55b0148bb970ba78ceb.1354794428.git.craven@gmx.net>\r
+User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Thu, 06 Dec 2012 17:17:29 +0200\r
+Message-ID: <m2y5hbp5va.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 06 Dec 2012 15:17:34 -0000\r
+\r
+On Thu, Dec 06 2012, Peter Feigl <craven@gmx.net> wrote:\r
+\r
+> This patch uses the new S-Expression printer in the notmuch CLI (show,\r
+> search and reply). You can now use --format=sexp for any of them.\r
+> ---\r
+> devel/schemata | 8 +++++++-\r
+> notmuch-reply.c | 5 +++++\r
+> notmuch-search.c | 6 +++++-\r
+> notmuch-show.c | 35 +++++++++++++++++++++++------------\r
+> 4 files changed, 40 insertions(+), 14 deletions(-)\r
+>\r
+> diff --git a/devel/schemata b/devel/schemata\r
+> index e44da71..01181d4 100644\r
+> --- a/devel/schemata\r
+> +++ b/devel/schemata\r
+> @@ -1,5 +1,5 @@\r
+> This file describes the schemata used for notmuch's structured output\r
+> -format (currently JSON).\r
+> +format (currently JSON and S-Expressions).\r
+> \r
+> []'s indicate lists. List items can be marked with a '?', meaning\r
+> they are optional; or a '*', meaning there can be zero or more of that\r
+> @@ -8,6 +8,12 @@ values. An object field marked '?' is optional. |'s indicate\r
+> alternates (e.g., int|string means something can be an int or a\r
+> string).\r
+> \r
+> +For S-Expression output, lists are printed delimited by () instead of\r
+> +[]. Objects are printed as p-lists, i.e. lists where the keys and values\r
+> +are interleaved. Keys are printed as keywords (symbols preceded by a\r
+> +colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as\r
+> +nil, true as t and false as nil.\r
+> +\r
+> Common non-terminals\r
+> --------------------\r
+> \r
+> diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> index 6103d6e..5f3e46c 100644\r
+> --- a/notmuch-reply.c\r
+> +++ b/notmuch-reply.c\r
+> @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx,\r
+> enum {\r
+> FORMAT_DEFAULT,\r
+> FORMAT_JSON,\r
+> + FORMAT_SEXP,\r
+> FORMAT_HEADERS_ONLY,\r
+> };\r
+> \r
+> @@ -729,6 +730,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+> { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
+> (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },\r
+> { "json", FORMAT_JSON },\r
+> + { "sexp", FORMAT_SEXP },\r
+> { "headers-only", FORMAT_HEADERS_ONLY },\r
+> { 0, 0 } } },\r
+> { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',\r
+> @@ -750,6 +752,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+> } else if (format == FORMAT_JSON) {\r
+> reply_format_func = notmuch_reply_format_sprinter;\r
+> sp = sprinter_json_create (ctx, stdout);\r
+> + } else if (format == FORMAT_SEXP) {\r
+> + reply_format_func = notmuch_reply_format_sprinter;\r
+> + sp = sprinter_sexp_create (ctx, stdout);\r
+> } else {\r
+> reply_format_func = notmuch_reply_format_default;\r
+> }\r
+> diff --git a/notmuch-search.c b/notmuch-search.c\r
+> index 830c4e4..6218622 100644\r
+> --- a/notmuch-search.c\r
+> +++ b/notmuch-search.c\r
+> @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+> int exclude = EXCLUDE_TRUE;\r
+> unsigned int i;\r
+> \r
+> - enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
+> + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }\r
+> format_sel = NOTMUCH_FORMAT_TEXT;\r
+> \r
+> notmuch_opt_desc_t options[] = {\r
+> @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+> { 0, 0 } } },\r
+> { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
+> (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
+> + { "sexp", NOTMUCH_FORMAT_SEXP },\r
+> { "text", NOTMUCH_FORMAT_TEXT },\r
+> { 0, 0 } } },\r
+> { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',\r
+> @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+> case NOTMUCH_FORMAT_JSON:\r
+> format = sprinter_json_create (ctx, stdout);\r
+> break;\r
+> + case NOTMUCH_FORMAT_SEXP:\r
+> + format = sprinter_sexp_create (ctx, stdout);\r
+> + break;\r
+> default:\r
+> /* this should never happen */\r
+> INTERNAL_ERROR("no output format selected");\r
+> diff --git a/notmuch-show.c b/notmuch-show.c\r
+> index 38c621f..2bd09f3 100644\r
+> --- a/notmuch-show.c\r
+> +++ b/notmuch-show.c\r
+> @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = {\r
+> .part = format_part_sprinter_entry,\r
+> };\r
+> \r
+> +static const notmuch_show_format_t format_sexp = {\r
+> + .new_sprinter = sprinter_sexp_create,\r
+> + .part = format_part_sprinter_entry,\r
+> +};\r
+> +\r
+> static notmuch_status_t\r
+> format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+> int indent, const notmuch_show_params_t *params);\r
+> @@ -110,8 +115,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)\r
+> static void\r
+> format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)\r
+> {\r
+> - /* Any changes to the JSON format should be reflected in the file\r
+> - * devel/schemata. */\r
+> + /* Any changes to the JSON or S-Expression format should be\r
+> + * reflected in the file devel/schemata. */\r
+> \r
+> void *local = talloc_new (NULL);\r
+> notmuch_tags_t *tags;\r
+> @@ -211,8 +216,8 @@ void\r
+> format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,\r
+> notmuch_bool_t reply)\r
+> {\r
+> - /* Any changes to the JSON format should be reflected in the file\r
+> - * devel/schemata. */\r
+> + /* Any changes to the JSON or S-Expression format should be\r
+> + * reflected in the file devel/schemata. */\r
+> \r
+> InternetAddressList *recipients;\r
+> const char *recipients_string;\r
+> @@ -365,8 +370,8 @@ signer_status_to_string (GMimeSignerStatus x)\r
+> static void\r
+> format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)\r
+> {\r
+> - /* Any changes to the JSON format should be reflected in the file\r
+> - * devel/schemata. */\r
+> + /* Any changes to the JSON or S-Expression format should be\r
+> + * reflected in the file devel/schemata. */\r
+> \r
+> GMimeSignatureList *siglist = node->sig_list;\r
+> \r
+> @@ -598,8 +603,8 @@ void\r
+> format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+> notmuch_bool_t first, notmuch_bool_t output_body)\r
+> {\r
+> - /* Any changes to the JSON format should be reflected in the file\r
+> - * devel/schemata. */\r
+> + /* Any changes to the JSON or S-Expression format should be\r
+> + * reflected in the file devel/schemata. */\r
+> \r
+> if (node->envelope_file) {\r
+> sp->begin_map (sp);\r
+> @@ -1012,6 +1017,7 @@ do_show (void *ctx,\r
+> enum {\r
+> NOTMUCH_FORMAT_NOT_SPECIFIED,\r
+> NOTMUCH_FORMAT_JSON,\r
+> + NOTMUCH_FORMAT_SEXP,\r
+> NOTMUCH_FORMAT_TEXT,\r
+> NOTMUCH_FORMAT_MBOX,\r
+> NOTMUCH_FORMAT_RAW\r
+> @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+> { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
+> (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
+> { "text", NOTMUCH_FORMAT_TEXT },\r
+> + { "sexp", NOTMUCH_FORMAT_SEXP },\r
+> { "mbox", NOTMUCH_FORMAT_MBOX },\r
+> { "raw", NOTMUCH_FORMAT_RAW },\r
+> { 0, 0 } } },\r
+> @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+> case NOTMUCH_FORMAT_TEXT:\r
+> format = &format_text;\r
+> break;\r
+> + case NOTMUCH_FORMAT_SEXP:\r
+> + format = &format_sexp;\r
+> + break;\r
+> case NOTMUCH_FORMAT_MBOX:\r
+> if (params.part > 0) {\r
+> fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");\r
+> @@ -1118,9 +1128,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+> break;\r
+> }\r
+> \r
+> - /* Default is entire-thread = FALSE except for format=json. */\r
+> + /* Default is entire-thread = FALSE except for format=json and format=sexp. */\r
+\r
+... and the last formatting comment: re-fill comment so that it fits\r
+into 80 columns (as new patch series is needed to fix the cardinal\r
+errors w/ 'for(' & 'if(' before :) (not counting the findings others might\r
+find). \r
+\r
+> if (entire_thread == ENTIRE_THREAD_DEFAULT) {\r
+> - if (format == &format_json)\r
+> + if (format == &format_json || format == &format_sexp)\r
+> entire_thread = ENTIRE_THREAD_TRUE;\r
+> else\r
+> entire_thread = ENTIRE_THREAD_FALSE;\r
+> @@ -1131,8 +1141,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+> fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");\r
+> params.output_body = TRUE;\r
+> } else {\r
+> - if (format != &format_json)\r
+> - fprintf (stderr, "Warning: --body=false only implemented for format=json\n");\r
+> + if (format != &format_json && format != &format_sexp)\r
+> + fprintf (stderr,\r
+> + "Warning: --body=false only implemented for format=json and format=sexp\n");\r
+> }\r
+> }\r
+> \r
+> -- \r
+> 1.8.0\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r