From 65cec2ba572d5e63a49777517e93d869deb62d1e Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 24 Jul 2012 12:43:53 +2000 Subject: [PATCH] Re: [PATCH 1/4] cli: add --body=true|false option to notmuch-show.c --- a3/53ee9c36a1cda0cf69ae889360ca5391ebf1f5 | 211 ++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 a3/53ee9c36a1cda0cf69ae889360ca5391ebf1f5 diff --git a/a3/53ee9c36a1cda0cf69ae889360ca5391ebf1f5 b/a3/53ee9c36a1cda0cf69ae889360ca5391ebf1f5 new file mode 100644 index 000000000..97ebef2ab --- /dev/null +++ b/a3/53ee9c36a1cda0cf69ae889360ca5391ebf1f5 @@ -0,0 +1,211 @@ +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 BBBAB431FAF + for ; Mon, 23 Jul 2012 09:43:57 -0700 (PDT) +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 R4TRyH-Cwbkz for ; + Mon, 23 Jul 2012 09:43:56 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id 2CC6C431FAE + for ; Mon, 23 Jul 2012 09:43:56 -0700 (PDT) +X-AuditID: 1209190f-b7f306d0000008b4-50-500d7f4babb3 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id 30.D1.02228.B4F7D005; Mon, 23 Jul 2012 12:43:55 -0400 (EDT) +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 q6NGhs9O020707; + Mon, 23 Jul 2012 12:43:55 -0400 +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 q6NGhrAW020709 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 23 Jul 2012 12:43:54 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1StLjd-0002fa-LA; Mon, 23 Jul 2012 12:43:53 -0400 +Date: Mon, 23 Jul 2012 12:43:53 -0400 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH 1/4] cli: add --body=true|false option to notmuch-show.c +Message-ID: <20120723164353.GG31834@mit.edu> +References: <1343060241-18283-1-git-send-email-markwalters1009@gmail.com> + <1343060241-18283-2-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1343060241-18283-2-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IR4hTV1vWu5w0weNKsbrF6Lo/F9ZszmR2Y + PHbOusvu8WzVLeYApigum5TUnMyy1CJ9uwSujMvt99kKXqhVvJ39l6WBcYtcFyMnh4SAicT3 + uQtZIGwxiQv31rN1MXJxCAnsY5T4Mf82M4SzgVFi864FLBDOSSaJWe/2sUI4SxglOrZPZ+9i + 5OBgEVCVaDjEDzKKTUBDYtv+5YwgtoiAjsTtQwvYQWxmAWmJb7+bmUBsYQEfiQWLv7CBtPIC + 1ey5xgMxspNRoufmf2aQGl4BQYmTM5+wQPRqSdz495IJpB5kzvJ/HCBhTgEvieOzfoGViwqo + SEw5uY1tAqPQLCTds5B0z0LoXsDIvIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXRC83s0QvNaV0 + EyM4qCX5dzB+O6h0iFGAg1GJh9eqiidAiDWxrLgy9xCjJAeTkiivaAVvgBBfUn5KZUZicUZ8 + UWlOavEhRgkOZiUR3tXVQDnelMTKqtSifJiUNAeLkjjv1ZSb/kIC6YklqdmpqQWpRTBZGQ4O + JQle3TqgRsGi1PTUirTMnBKENBMHJ8hwHqDh3iA1vMUFibnFmekQ+VOMilLivFIgCQGQREZp + HlwvLOm8YhQHekWYNw6kigeYsOC6XwENZgIaLJ3FBTK4JBEhJdXAGG1/WzZ7t9T3aZ8lF+/8 + f+1LTsE58x7/8sazH1qfbfbUjC0vXLzEs0nJpKdUlvnPHR/GcGvvcgeGSJvky1aaHeEf1f7m + yVamL/3+8AzrRn7HvewHu0I/pK42/rHp4wYrnh9ZGp21bfMOmO/iF0jM6+pXnDjnctHytQUp + J//O4ecoKWCJDa9TYinOSDTUYi4qTgQA68HV0BUDAAA= +Cc: notmuch@notmuchmail.org +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: Mon, 23 Jul 2012 16:43:57 -0000 + +Quoth Mark Walters on Jul 23 at 5:17 pm: +> This option allows the caller to suppress the output of the bodies of +> the messages. Currently this is only implemented for format=json. +> +> This is used by notmuch-pick.el (although not needed) because it gives +> a speed-up of at least a factor of a two (and in some cases a speed up +> of more than a factor of 8); moreover it reduces the memory usage in +> emacs hugely. +> --- +> notmuch-client.h | 3 ++- +> notmuch-reply.c | 2 +- +> notmuch-show.c | 23 +++++++++++++++-------- +> 3 files changed, 18 insertions(+), 10 deletions(-) +> +> diff --git a/notmuch-client.h b/notmuch-client.h +> index 0c17b79..f930798 100644 +> --- a/notmuch-client.h +> +++ b/notmuch-client.h +> @@ -87,6 +87,7 @@ typedef struct notmuch_crypto { +> typedef struct notmuch_show_params { +> notmuch_bool_t entire_thread; +> notmuch_bool_t omit_excluded; +> + notmuch_bool_t output_body; +> notmuch_bool_t raw; +> int part; +> notmuch_crypto_t crypto; +> @@ -176,7 +177,7 @@ notmuch_status_t +> show_one_part (const char *filename, int part); +> +> void +> -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first); +> +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body); +> +> void +> format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply); +> diff --git a/notmuch-reply.c b/notmuch-reply.c +> index 3a038ed..de21f3b 100644 +> --- a/notmuch-reply.c +> +++ b/notmuch-reply.c +> @@ -620,7 +620,7 @@ notmuch_reply_format_json(void *ctx, +> /* Start the original */ +> printf (", \"original\": "); +> +> - format_part_json (ctx, node, TRUE); +> + format_part_json (ctx, node, TRUE, TRUE); +> +> /* End */ +> printf ("}\n"); +> diff --git a/notmuch-show.c b/notmuch-show.c +> index 8f3c60e..c2ad4fb 100644 +> --- a/notmuch-show.c +> +++ b/notmuch-show.c +> @@ -559,7 +559,7 @@ format_part_text (const void *ctx, mime_node_t *node, +> } +> +> void +> -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first) +> +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body) +> { +> /* Any changes to the JSON format should be reflected in the file +> * devel/schemata. */ +> @@ -571,10 +571,12 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first) +> printf ("\"headers\": "); +> format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE); +> +> - printf (", \"body\": ["); +> - format_part_json (ctx, mime_node_child (node, 0), first); +> - +> - printf ("]}"); +> + if (output_body) { +> + printf (", \"body\": ["); +> + format_part_json (ctx, mime_node_child (node, 0), first, TRUE); +> + printf ("]"); +> + } +> + printf ("}"); +> return; +> } +> +> @@ -652,16 +654,16 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first) +> talloc_free (local); +> +> for (i = 0; i < node->nchildren; i++) +> - format_part_json (ctx, mime_node_child (node, i), i == 0); +> + format_part_json (ctx, mime_node_child (node, i), i == 0, TRUE); +> +> printf ("%s}", terminator); +> } +> +> static notmuch_status_t +> format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent), +> - unused (const notmuch_show_params_t *params)) +> + const notmuch_show_params_t *params) +> { +> - format_part_json (ctx, node, TRUE); +> + format_part_json (ctx, node, TRUE, params->output_body); +> +> return NOTMUCH_STATUS_SUCCESS; +> } +> @@ -1004,6 +1006,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) +> notmuch_show_params_t params = { +> .part = -1, +> .omit_excluded = TRUE, +> + .output_body = TRUE, +> .crypto = { +> .verify = FALSE, +> .decrypt = FALSE +> @@ -1032,6 +1035,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) +> { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, +> { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, +> { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, +> + { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'h', 0 }, + +Why 'h' for the short option? + +> { 0, 0, 0, 0, 0 } +> }; +> +> @@ -1086,6 +1090,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) +> entire_thread = ENTIRE_THREAD_FALSE; +> } +> +> + if (!params.output_body && format != &format_json) +> + fprintf (stderr,"Warning: --body=false only implemented for format=json\n"); + +Missing space after comma. + +Should we consider how --part and --body interact? Maybe specifying +--part is incompatible with --body=false? Or specifying a part > 0 is +incompatible with --body=false? + +> + +> if (entire_thread == ENTIRE_THREAD_TRUE) +> params.entire_thread = TRUE; +> else -- 2.26.2