Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f3 / 13c46f430969aea138658e34813dc96baa50a4
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 64667431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 11:25:27 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \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 CwHUuHkNOCZQ for <notmuch@notmuchmail.org>;\r
18         Tue, 24 Jul 2012 11:25:26 -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 911A4431FAF\r
23         for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 11:25:26 -0700 (PDT)\r
24 Received: by weyt57 with SMTP id t57so5939479wey.26\r
25         for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 11:25:25 -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=vZH7MNwQ9HOhYfk9ehFBxubbkUDijz7ECTzrW7fN/IUdLZRsaXXLBIWDlCIRcQMtPy\r
30         1jK1w1q1/ty97I253uZr/9prTIXJC5LZ0xldzI30ouJUs0Jl1+MG3QgU7j14iJLi0HVF\r
31         sD/cBZFGKcL355REOvOFx0Akj1eeePvKTlWgi3AZuLIsxzYNxNdQyhBW3ML2e3KmUrTT\r
32         HE7LQiwfKK4oRv006VO/mODXS8i1+5a8c/tGoRqhzn3Omsj2KMJ31/EbnoBN9I8KMU4i\r
33         PJa7NN+ZYWCAQ7ZCZYbuGRAsJM879S8wqMpOCgWRavIpCsFV3/BsE2RUT9zRSboazsRy\r
34         mjjQ==\r
35 Received: by 10.180.98.200 with SMTP id ek8mr9300914wib.0.1343154325324;\r
36         Tue, 24 Jul 2012 11:25:25 -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  fb20sm8548148wid.1.2012.07.24.11.25.23 (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Tue, 24 Jul 2012 11:25:24 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2 (rebased) 1/4] cli: add --body=true|false option to\r
44         notmuch-show.c\r
45 Date: Tue, 24 Jul 2012 19:23:27 +0100\r
46 Message-Id: <1343154210-26841-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1343154210-26841-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1343154210-26841-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Tue, 24 Jul 2012 18:25:27 -0000\r
63 \r
64 This option allows the caller to suppress the output of the bodies of\r
65 the messages. Currently this is only implemented for format=json.\r
66 \r
67 This is used by notmuch-pick.el (although not needed) because it gives\r
68 a speed-up of at least a factor of a two (and in some cases a speed up\r
69 of more than a factor of 8); moreover it reduces the memory usage in\r
70 emacs hugely.\r
71 ---\r
72  notmuch-client.h |    3 ++-\r
73  notmuch-reply.c  |    2 +-\r
74  notmuch-show.c   |   30 ++++++++++++++++++++++--------\r
75  3 files changed, 25 insertions(+), 10 deletions(-)\r
76 \r
77 diff --git a/notmuch-client.h b/notmuch-client.h\r
78 index 0c17b79..f930798 100644\r
79 --- a/notmuch-client.h\r
80 +++ b/notmuch-client.h\r
81 @@ -87,6 +87,7 @@ typedef struct notmuch_crypto {\r
82  typedef struct notmuch_show_params {\r
83      notmuch_bool_t entire_thread;\r
84      notmuch_bool_t omit_excluded;\r
85 +    notmuch_bool_t output_body;\r
86      notmuch_bool_t raw;\r
87      int part;\r
88      notmuch_crypto_t crypto;\r
89 @@ -176,7 +177,7 @@ notmuch_status_t\r
90  show_one_part (const char *filename, int part);\r
91  \r
92  void\r
93 -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first);\r
94 +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body);\r
95  \r
96  void\r
97  format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);\r
98 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
99 index 3a038ed..de21f3b 100644\r
100 --- a/notmuch-reply.c\r
101 +++ b/notmuch-reply.c\r
102 @@ -620,7 +620,7 @@ notmuch_reply_format_json(void *ctx,\r
103      /* Start the original */\r
104      printf (", \"original\": ");\r
105  \r
106 -    format_part_json (ctx, node, TRUE);\r
107 +    format_part_json (ctx, node, TRUE, TRUE);\r
108  \r
109      /* End */\r
110      printf ("}\n");\r
111 diff --git a/notmuch-show.c b/notmuch-show.c\r
112 index 8f3c60e..d3419e4 100644\r
113 --- a/notmuch-show.c\r
114 +++ b/notmuch-show.c\r
115 @@ -559,7 +559,7 @@ format_part_text (const void *ctx, mime_node_t *node,\r
116  }\r
117  \r
118  void\r
119 -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)\r
120 +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body)\r
121  {\r
122      /* Any changes to the JSON format should be reflected in the file\r
123       * devel/schemata. */\r
124 @@ -571,10 +571,12 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)\r
125         printf ("\"headers\": ");\r
126         format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE);\r
127  \r
128 -       printf (", \"body\": [");\r
129 -       format_part_json (ctx, mime_node_child (node, 0), first);\r
130 -\r
131 -       printf ("]}");\r
132 +       if (output_body) {\r
133 +           printf (", \"body\": [");\r
134 +           format_part_json (ctx, mime_node_child (node, 0), first, TRUE);\r
135 +           printf ("]");\r
136 +       }\r
137 +       printf ("}");\r
138         return;\r
139      }\r
140  \r
141 @@ -652,16 +654,16 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)\r
142      talloc_free (local);\r
143  \r
144      for (i = 0; i < node->nchildren; i++)\r
145 -       format_part_json (ctx, mime_node_child (node, i), i == 0);\r
146 +       format_part_json (ctx, mime_node_child (node, i), i == 0, TRUE);\r
147  \r
148      printf ("%s}", terminator);\r
149  }\r
150  \r
151  static notmuch_status_t\r
152  format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),\r
153 -                       unused (const notmuch_show_params_t *params))\r
154 +                       const notmuch_show_params_t *params)\r
155  {\r
156 -    format_part_json (ctx, node, TRUE);\r
157 +    format_part_json (ctx, node, TRUE, params->output_body);\r
158  \r
159      return NOTMUCH_STATUS_SUCCESS;\r
160  }\r
161 @@ -1004,6 +1006,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
162      notmuch_show_params_t params = {\r
163         .part = -1,\r
164         .omit_excluded = TRUE,\r
165 +       .output_body = TRUE,\r
166         .crypto = {\r
167             .verify = FALSE,\r
168             .decrypt = FALSE\r
169 @@ -1032,6 +1035,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
170         { NOTMUCH_OPT_INT, &params.part, "part", 'p', 0 },\r
171         { NOTMUCH_OPT_BOOLEAN, &params.crypto.decrypt, "decrypt", 'd', 0 },\r
172         { NOTMUCH_OPT_BOOLEAN, &params.crypto.verify, "verify", 'v', 0 },\r
173 +       { NOTMUCH_OPT_BOOLEAN, &params.output_body, "body", 'b', 0 },\r
174         { 0, 0, 0, 0, 0 }\r
175      };\r
176  \r
177 @@ -1086,6 +1090,16 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
178             entire_thread = ENTIRE_THREAD_FALSE;\r
179      }\r
180  \r
181 +    if (!params.output_body) {\r
182 +       if (params.part > 0) {\r
183 +           fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");\r
184 +           params.output_body = TRUE;\r
185 +       } else {\r
186 +           if (format != &format_json)\r
187 +               fprintf (stderr, "Warning: --body=false only implemented for format=json\n");\r
188 +       }\r
189 +    }\r
190 +\r
191      if (entire_thread == ENTIRE_THREAD_TRUE)\r
192         params.entire_thread = TRUE;\r
193      else\r
194 -- \r
195 1.7.9.1\r
196 \r