1 Return-Path: <markwalters1009@gmail.com>
\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 F2FDA431FD6
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Jul 2012 10:57:47 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id ENPp7lbfCoxb for <notmuch@notmuchmail.org>;
\r
18 Mon, 23 Jul 2012 10:57:46 -0700 (PDT)
\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
20 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 006DC431FBC
\r
23 for <notmuch@notmuchmail.org>; Mon, 23 Jul 2012 10:57:45 -0700 (PDT)
\r
24 Received: by weyt57 with SMTP id t57so4988618wey.26
\r
25 for <notmuch@notmuchmail.org>; Mon, 23 Jul 2012 10:57:44 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=sUC2MJN5l21g6QXsVIox02OmEDjessR4wrfOjX1eHQM=;
\r
29 b=Z4CwTGkGbip+s19VUyzpIPX2aROGGRjJPbgh6q5s1BkRBD/17ikCaDPonpRau08tXH
\r
30 XkZzHQYwL2PpOUgNVRnMOWC0dQ+Y2zbgwoxBd00Yf/uO/QrbG662WoCOEl3qdG+EeCdj
\r
31 RSz7SJ5uHSQhrrNh5U4xFWvKy7HzDjkoi2p1oItZeXGtj+B/b8bL4e1c6y1YuoyX9Si5
\r
32 Ko5gnpybdrFvHJ2NOiDB94YBba5vM8RkGQFY3T/feHrPtmiHstutsQZYmb3HelCFGtVb
\r
33 pCY3MvzqEHxqJaYOqPpanNR2m5AVzbpec5PGxqVOnsT5N7oEOv+zlEf26WtvwjixWW7x
\r
35 Received: by 10.216.136.158 with SMTP id w30mr8465810wei.136.1343066264670;
\r
36 Mon, 23 Jul 2012 10:57:44 -0700 (PDT)
\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
38 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
39 y5sm18013155wiw.9.2012.07.23.10.57.42 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Mon, 23 Jul 2012 10:57:43 -0700 (PDT)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v2 1/4] cli: add --body=true|false option to notmuch-show.c
\r
44 Date: Mon, 23 Jul 2012 18:57:36 +0100
\r
45 Message-Id: <1343066259-22523-2-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 In-Reply-To: <1343066259-22523-1-git-send-email-markwalters1009@gmail.com>
\r
48 References: <1343066259-22523-1-git-send-email-markwalters1009@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Mon, 23 Jul 2012 17:57:48 -0000
\r
63 This option allows the caller to suppress the output of the bodies of
\r
64 the messages. Currently this is only implemented for format=json.
\r
66 This is used by notmuch-pick.el (although not needed) because it gives
\r
67 a speed-up of at least a factor of a two (and in some cases a speed up
\r
68 of more than a factor of 8); moreover it reduces the memory usage in
\r
71 notmuch-client.h | 3 ++-
\r
72 notmuch-reply.c | 2 +-
\r
73 notmuch-show.c | 30 ++++++++++++++++++++++--------
\r
74 3 files changed, 25 insertions(+), 10 deletions(-)
\r
76 diff --git a/notmuch-client.h b/notmuch-client.h
\r
77 index 0c17b79..f930798 100644
\r
78 --- a/notmuch-client.h
\r
79 +++ b/notmuch-client.h
\r
80 @@ -87,6 +87,7 @@ typedef struct notmuch_crypto {
\r
81 typedef struct notmuch_show_params {
\r
82 notmuch_bool_t entire_thread;
\r
83 notmuch_bool_t omit_excluded;
\r
84 + notmuch_bool_t output_body;
\r
87 notmuch_crypto_t crypto;
\r
88 @@ -176,7 +177,7 @@ notmuch_status_t
\r
89 show_one_part (const char *filename, int part);
\r
92 -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first);
\r
93 +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body);
\r
96 format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);
\r
97 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
98 index 3a038ed..de21f3b 100644
\r
99 --- a/notmuch-reply.c
\r
100 +++ b/notmuch-reply.c
\r
101 @@ -620,7 +620,7 @@ notmuch_reply_format_json(void *ctx,
\r
102 /* Start the original */
\r
103 printf (", \"original\": ");
\r
105 - format_part_json (ctx, node, TRUE);
\r
106 + format_part_json (ctx, node, TRUE, TRUE);
\r
110 diff --git a/notmuch-show.c b/notmuch-show.c
\r
111 index 8f3c60e..d3419e4 100644
\r
112 --- a/notmuch-show.c
\r
113 +++ b/notmuch-show.c
\r
114 @@ -559,7 +559,7 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
118 -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
119 +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body)
\r
121 /* Any changes to the JSON format should be reflected in the file
\r
122 * devel/schemata. */
\r
123 @@ -571,10 +571,12 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
124 printf ("\"headers\": ");
\r
125 format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE);
\r
127 - printf (", \"body\": [");
\r
128 - format_part_json (ctx, mime_node_child (node, 0), first);
\r
131 + if (output_body) {
\r
132 + printf (", \"body\": [");
\r
133 + format_part_json (ctx, mime_node_child (node, 0), first, TRUE);
\r
140 @@ -652,16 +654,16 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
\r
141 talloc_free (local);
\r
143 for (i = 0; i < node->nchildren; i++)
\r
144 - format_part_json (ctx, mime_node_child (node, i), i == 0);
\r
145 + format_part_json (ctx, mime_node_child (node, i), i == 0, TRUE);
\r
147 printf ("%s}", terminator);
\r
150 static notmuch_status_t
\r
151 format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),
\r
152 - unused (const notmuch_show_params_t *params))
\r
153 + const notmuch_show_params_t *params)
\r
155 - format_part_json (ctx, node, TRUE);
\r
156 + format_part_json (ctx, node, TRUE, params->output_body);
\r
158 return NOTMUCH_STATUS_SUCCESS;
\r
160 @@ -1004,6 +1006,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
161 notmuch_show_params_t params = {
\r
163 .omit_excluded = TRUE,
\r
164 + .output_body = TRUE,
\r
168 @@ -1032,6 +1035,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
169 { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 },
\r
170 { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },
\r
171 { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 },
\r
172 + { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 },
\r
176 @@ -1086,6 +1090,16 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
177 entire_thread = ENTIRE_THREAD_FALSE;
\r
180 + if (!params.output_body) {
\r
181 + if (params.part > 0) {
\r
182 + fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
\r
183 + params.output_body = TRUE;
\r
185 + if (format != &format_json)
\r
186 + fprintf (stderr, "Warning: --body=false only implemented for format=json\n");
\r
190 if (entire_thread == ENTIRE_THREAD_TRUE)
\r
191 params.entire_thread = TRUE;
\r