Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id ED0D6431FB6 for ; Tue, 4 Dec 2012 11:22:50 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JuhNdl0LzDd2 for ; Tue, 4 Dec 2012 11:22:47 -0800 (PST) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id 07A67431FAE for ; Tue, 4 Dec 2012 11:22:46 -0800 (PST) X-AuditID: 1209190d-b7f266d00000092b-d5-50be4d85bb38 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id 5F.E9.02347.58D4EB05; Tue, 4 Dec 2012 14:22:45 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qB4JMjsI026875; Tue, 4 Dec 2012 14:22:45 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB4JMi8s009547 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Tue, 4 Dec 2012 14:22:45 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1Tfy4p-0001nP-Qt; Tue, 04 Dec 2012 14:22:43 -0500 From: Austin Clements To: Peter Feigl , notmuch@notmuchmail.org Subject: Re: [PATCH v2 3/5] Use the S-Expression structured printer in notmuch-show, notmuch-reply and notmuch-search. In-Reply-To: <1354632382-15609-4-git-send-email-craven@gmx.net> References: <1354632382-15609-1-git-send-email-craven@gmx.net> <1354632382-15609-4-git-send-email-craven@gmx.net> User-Agent: Notmuch/0.14+100~gcb9b0b0 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Tue, 04 Dec 2012 14:22:43 -0500 Message-ID: <87d2ypy64c.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsUixCmqrdvquy/A4EaLnsXehnZGi+s3ZzI7 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBk3191kLlhgULG18yJrA+NF1S5GTg4JAROJ x5feMUPYYhIX7q1nA7GFBPYxSux9ltDFyAVkr2eU+LJ8ISOEc4FJ4vTBqywQzhJGiY+TvrGD tLAJ6EusWDuJFcQWEbCUmPrlEtgoYYEyiaaHvUBxDg5OAXuJ9y36EBsKJa6sOcQIEhYViJe4 vFQBJMwioCqxc9IhsIN4gY6bsauLBcIWlDg58wmYzSygJXHj30umCYwCs5CkZiFJLWBkWsUo m5JbpZubmJlTnJqsW5ycmJeXWqRrpJebWaKXmlK6iREcjpK8OxjfHVQ6xCjAwajEwytpvC9A iDWxrLgy9xCjJAeTkijvP0+gEF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHef3ZAOd6UxMqq1KJ8 mJQ0B4uSOO+VlJv+QgLpiSWp2ampBalFMFkZDg4lCd6LPkCNgkWp6akVaZk5JQhpJg5OkOE8 QMPngtTwFhck5hZnpkPkTzEqSonzfgZJCIAkMkrz4Hph6eIVozjQK8K8/0CqeICpBq77FdBg JqDBL4R2gwwuSURISTUwlnVzPrXJZPdlWPNXJTja8EtuQezJc3ZZm23qLy9oCX1RMz8v4J9d qLxzS8Il73juNf4X/tzsvbdgr6iK1f5vqfM0XJ4kO5jOL9lyYqnbp9euftongtnWMudaZEw9 9Wyfp+l1rZlVuRcWpEtmvv3ecz1l6WO5z0efa7prCIXucd6Z95TBUaFDiaU4I9FQi7moOBEA 1rGbRPICAAA= X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Dec 2012 19:22:51 -0000 On Tue, 04 Dec 2012, Peter Feigl wrote: > This patch uses the new S-Expression printer in the notmuch CLI (show, > search and reply). You can now use --format=sexp for any of them. > --- > notmuch-reply.c | 5 +++++ > notmuch-search.c | 6 +++++- > notmuch-show.c | 18 ++++++++++++++---- > 3 files changed, 24 insertions(+), 5 deletions(-) > > diff --git a/notmuch-reply.c b/notmuch-reply.c > index 53aefa7..69fd256 100644 > --- a/notmuch-reply.c > +++ b/notmuch-reply.c > @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx, > enum { > FORMAT_DEFAULT, > FORMAT_JSON, > + FORMAT_SEXP, > FORMAT_HEADERS_ONLY, > }; > > @@ -724,6 +725,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > { NOTMUCH_OPT_KEYWORD, &format, "format", 'f', > (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT }, > { "json", FORMAT_JSON }, > + { "sexp", FORMAT_SEXP }, "sexpa" if we're going to support both alists and plists? Same for the others. > { "headers-only", FORMAT_HEADERS_ONLY }, > { 0, 0 } } }, > { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r', > @@ -745,6 +747,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) > } else if (format == FORMAT_JSON) { > reply_format_func = notmuch_reply_format_sprinter; > sp = sprinter_json_create (ctx, stdout); > + } else if (format == FORMAT_SEXP) { > + reply_format_func = notmuch_reply_format_sprinter; > + sp = sprinter_sexp_create (ctx, stdout); > } else { > reply_format_func = notmuch_reply_format_default; > } > diff --git a/notmuch-search.c b/notmuch-search.c > index 830c4e4..6218622 100644 > --- a/notmuch-search.c > +++ b/notmuch-search.c > @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) > int exclude = EXCLUDE_TRUE; > unsigned int i; > > - enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } > + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP } > format_sel = NOTMUCH_FORMAT_TEXT; > > notmuch_opt_desc_t options[] = { > @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) > { 0, 0 } } }, > { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', > (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, > + { "sexp", NOTMUCH_FORMAT_SEXP }, > { "text", NOTMUCH_FORMAT_TEXT }, > { 0, 0 } } }, > { NOTMUCH_OPT_KEYWORD, &output, "output", 'o', > @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) > case NOTMUCH_FORMAT_JSON: > format = sprinter_json_create (ctx, stdout); > break; > + case NOTMUCH_FORMAT_SEXP: > + format = sprinter_sexp_create (ctx, stdout); > + break; > default: > /* this should never happen */ > INTERNAL_ERROR("no output format selected"); > diff --git a/notmuch-show.c b/notmuch-show.c > index 38c621f..d4860f1 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = { > .part = format_part_sprinter_entry, > }; > > +static const notmuch_show_format_t format_sexp = { > + .new_sprinter = sprinter_sexp_create, > + .part = format_part_sprinter_entry, > +}; > + > static notmuch_status_t > format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node, > int indent, const notmuch_show_params_t *params); > @@ -110,7 +115,7 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message) > static void > format_message_sprinter (sprinter_t *sp, notmuch_message_t *message) > { > - /* Any changes to the JSON format should be reflected in the file > + /* Any changes to the JSON or S-Expression format should be reflected in the file > * devel/schemata. */ Please re-wrap this comment to 72 columns. > > void *local = talloc_new (NULL); > @@ -1012,6 +1017,7 @@ do_show (void *ctx, > enum { > NOTMUCH_FORMAT_NOT_SPECIFIED, > NOTMUCH_FORMAT_JSON, > + NOTMUCH_FORMAT_SEXP, > NOTMUCH_FORMAT_TEXT, > NOTMUCH_FORMAT_MBOX, > NOTMUCH_FORMAT_RAW > @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) > { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', > (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, > { "text", NOTMUCH_FORMAT_TEXT }, > + { "sexp", NOTMUCH_FORMAT_SEXP }, > { "mbox", NOTMUCH_FORMAT_MBOX }, > { "raw", NOTMUCH_FORMAT_RAW }, > { 0, 0 } } }, > @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) > case NOTMUCH_FORMAT_TEXT: > format = &format_text; > break; > + case NOTMUCH_FORMAT_SEXP: > + format = &format_sexp; > + break; > case NOTMUCH_FORMAT_MBOX: > if (params.part > 0) { > fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n"); > @@ -1120,7 +1130,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) > > /* Default is entire-thread = FALSE except for format=json. */ > if (entire_thread == ENTIRE_THREAD_DEFAULT) { > - if (format == &format_json) > + if (format == &format_json || format == &format_sexp) Good catch. > entire_thread = ENTIRE_THREAD_TRUE; > else > entire_thread = ENTIRE_THREAD_FALSE; > @@ -1131,8 +1141,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) > fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n"); > params.output_body = TRUE; > } else { > - if (format != &format_json) > - fprintf (stderr, "Warning: --body=false only implemented for format=json\n"); > + if (format != &format_json && format != &format_sexp) > + fprintf (stderr, "Warning: --body=false only implemented for format=json and format=sexp\n"); > } > } > > -- > 1.8.0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch