--- /dev/null
+Return-Path: <wuzzeb@wuzzeb.org>\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 A87DC431FCF\r
+ for <notmuch@notmuchmail.org>; Mon, 1 Jul 2013 17:19:52 -0700 (PDT)\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\r
+ tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 QGG4L3nO6QAs for <notmuch@notmuchmail.org>;\r
+ Mon, 1 Jul 2013 17:19:45 -0700 (PDT)\r
+Received: from smtp.rcn.com (smtp.rcn.com [69.168.97.78])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1AF50431FC7\r
+ for <notmuch@notmuchmail.org>; Mon, 1 Jul 2013 17:19:45 -0700 (PDT)\r
+X_CMAE_Category: 0,0 Undefined,Undefined\r
+X-CNFS-Analysis: v=2.1 cv=IKk7VGfG c=1 sm=0 tr=0\r
+ a=C2bPeGdon5f+QfTtoGFpIg==:117 a=L41ukIAEf44A:10\r
+ a=97V-WqMTq8EA:10 a=IkcTkHD0fZMA:10 a=3wHbS4G-AAAA:8\r
+ a=7343-z1_AAAA:8 a=pm0CvZHm5i0A:10 a=K-m1EemV6aEvyrkEG1UA:9\r
+ a=QEXdDO2ut3YA:10\r
+X-CM-Score: 0\r
+X-Scanned-by: Cloudmark Authority Engine\r
+Authentication-Results: smtp01.rcn.cmh.synacor.com\r
+ smtp.mail=wuzzeb@wuzzeb.org; spf=pass; sender-id=pass\r
+Authentication-Results: smtp01.rcn.cmh.synacor.com\r
+ header.from=wuzzeb@wuzzeb.org; sender-id=pass\r
+Received-SPF: pass (smtp01.rcn.cmh.synacor.com: domain wuzzeb.org designates\r
+ 205.178.10.182 as permitted sender)\r
+Received: from [205.178.10.182] ([205.178.10.182:45556] helo=wuzzeb.org)\r
+ by smtp.rcn.com (envelope-from <wuzzeb@wuzzeb.org>)\r
+ (ecelerity 2.2.3.49 r(42060/42061)) with ESMTP\r
+ id 17/7B-12322-F9C12D15; Mon, 01 Jul 2013 20:19:43 -0400\r
+Received: from wuzzeb by wuzzeb.org with local (Exim 4.80.1)\r
+ (envelope-from <wuzzeb@wuzzeb.org>) id 1UtoJq-0000IK-Qa\r
+ for notmuch@notmuchmail.org; Mon, 01 Jul 2013 19:19:43 -0500\r
+From: =?utf-8?Q?John_Lenz?= <lenz@math.uic.edu>\r
+To: <notmuch@notmuchmail.org>\r
+Subject: cli: add --include-html option to notmuch show\r
+Message-ID: <notmuch-web-1372724382.450184839@www.wuzzeb.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Sender: <wuzzeb@wuzzeb.org>\r
+Date: Mon, 01 Jul 2013 19:19:42 -0500\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: Tue, 02 Jul 2013 00:19:52 -0000\r
+\r
+For my client, the largest bottleneck for displaying large threads is\r
+exporting each html part individually since by default notmuch will not\r
+show the json parts. For large threads there can be quite a few parts and\r
+each must be exported and decoded one by one. Also, I then have to deal\r
+with all the crazy charsets which I can do through a library but is a\r
+pain.\r
+\r
+Therefore, this patch adds an --include-html option that causes the\r
+text/html parts to be included as part of the output of show.\r
+\r
+\r
+diff man/man1/notmuch-show.1\r
+--- a/man/man1/notmuch-show.1 Sun Jun 23 14:24:02 2013 +1000\r
++++ b/man/man1/notmuch-show.1 Mon Jul 01 18:51:13 2013 -0500\r
+@@ -207,6 +207,20 @@\r
+ output is much faster and substantially smaller.\r
+ .RE\r
+ \r
++.RS 4\r
++.TP 4\r
++.B \-\-include-html\r
++\r
++Include "text/html" parts as part of the output (currently only supported with\r
++--format=json and --format=sexp).\r
++By default, unless\r
++.B --part=N\r
++is used to select a specific part or\r
++.B --include-html\r
++is used to include all "text/html" parts, no part with content type "text/html"\r
++is included in the output.\r
++.RE\r
++\r
+ A common use of\r
+ .B notmuch show\r
+ is to display a single thread of email messages. For this, use a\r
+diff notmuch-client.h\r
+--- a/notmuch-client.h Sun Jun 23 14:24:02 2013 +1000\r
++++ b/notmuch-client.h Mon Jul 01 18:51:13 2013 -0500\r
+@@ -89,6 +89,7 @@\r
+ notmuch_bool_t raw;\r
+ int part;\r
+ notmuch_crypto_t crypto;\r
++ notmuch_bool_t include_html;\r
+ } notmuch_show_params_t;\r
+ \r
+ /* There's no point in continuing when we've detected that we've done\r
+@@ -220,7 +221,8 @@\r
+ \r
+ void\r
+ format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,\r
+- notmuch_bool_t first, notmuch_bool_t output_body);\r
++ notmuch_bool_t first, notmuch_bool_t output_body,\r
++ notmuch_bool_t include_html);\r
+ \r
+ void\r
+ format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,\r
+diff notmuch-reply.c\r
+--- a/notmuch-reply.c Sun Jun 23 14:24:02 2013 +1000\r
++++ b/notmuch-reply.c Mon Jul 01 18:51:13 2013 -0500\r
+@@ -624,7 +624,7 @@\r
+ \r
+ /* Start the original */\r
+ sp->map_key (sp, "original");\r
+- format_part_sprinter (ctx, sp, node, TRUE, TRUE);\r
++ format_part_sprinter (ctx, sp, node, TRUE, TRUE, FALSE);\r
+ \r
+ /* End */\r
+ sp->end (sp);\r
+diff notmuch-show.c\r
+--- a/notmuch-show.c Sun Jun 23 14:24:02 2013 +1000\r
++++ b/notmuch-show.c Mon Jul 01 18:51:13 2013 -0500\r
+@@ -630,7 +630,8 @@\r
+ \r
+ 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
++ notmuch_bool_t first, notmuch_bool_t output_body,\r
++ notmuch_bool_t include_html)\r
+ {\r
+ /* Any changes to the JSON or S-Expression format should be\r
+ * reflected in the file devel/schemata. */\r
+@@ -645,7 +646,7 @@\r
+ if (output_body) {\r
+ sp->map_key (sp, "body");\r
+ sp->begin_list (sp);\r
+- format_part_sprinter (ctx, sp, mime_node_child (node, 0), first, TRUE);\r
++ format_part_sprinter (ctx, sp, mime_node_child (node, 0), first, TRUE, include_html);\r
+ sp->end (sp);\r
+ }\r
+ sp->end (sp);\r
+@@ -700,14 +701,15 @@\r
+ /* For non-HTML text parts, we include the content in the\r
+ * JSON. Since JSON must be Unicode, we handle charset\r
+ * decoding here and do not report a charset to the caller.\r
+- * For text/html parts, we do not include the content. If a\r
+- * caller is interested in text/html parts, it should retrieve\r
+- * them separately and they will not be decoded. Since this\r
+- * makes charset decoding the responsibility on the caller, we\r
++ * For text/html parts, we do not include the content unless\r
++ * the --include-html option has been passed. If a html part\r
++ * is not included, it can be requested directly. This makes\r
++ * charset decoding the responsibility on the caller so we\r
+ * report the charset for text/html parts.\r
+ */\r
+ if (g_mime_content_type_is_type (content_type, "text", "*") &&\r
+- ! g_mime_content_type_is_type (content_type, "text", "html"))\r
++ (include_html ||\r
++ ! g_mime_content_type_is_type (content_type, "text", "html")))\r
+ {\r
+ GMimeStream *stream_memory = g_mime_stream_mem_new ();\r
+ GByteArray *part_content;\r
+@@ -737,7 +739,7 @@\r
+ }\r
+ \r
+ for (i = 0; i < node->nchildren; i++)\r
+- format_part_sprinter (ctx, sp, mime_node_child (node, i), i == 0, TRUE);\r
++ format_part_sprinter (ctx, sp, mime_node_child (node, i), i == 0, TRUE, include_html);\r
+ \r
+ /* Close content structures */\r
+ for (i = 0; i < nclose; i++)\r
+@@ -751,7 +753,7 @@\r
+ mime_node_t *node, unused (int indent),\r
+ const notmuch_show_params_t *params)\r
+ {\r
+- format_part_sprinter (ctx, sp, node, TRUE, params->output_body);\r
++ format_part_sprinter (ctx, sp, node, TRUE, params->output_body, params->include_html);\r
+ \r
+ return NOTMUCH_STATUS_SUCCESS;\r
+ }\r
+@@ -1077,7 +1079,8 @@\r
+ .crypto = {\r
+ .verify = FALSE,\r
+ .decrypt = FALSE\r
+- }\r
++ },\r
++ .include_html = FALSE\r
+ };\r
+ int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
+ int exclude = EXCLUDE_TRUE;\r
+@@ -1105,6 +1108,7 @@\r
+ { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 },\r
+ { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 },\r
+ { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 },\r
++ { NOTMUCH_OPT_BOOLEAN, ¶ms.include_html, "include-html", 0, 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+ };\r
+ \r
+@@ -1176,6 +1180,11 @@\r
+ }\r
+ }\r
+ \r
++ if (params.include_html &&\r
++ (format_sel != NOTMUCH_FORMAT_JSON && format_sel != NOTMUCH_FORMAT_SEXP)) {\r
++ fprintf (stderr, "Warning: --include-html only implemented for format=json and format=sexp\n");\r
++ }\r
++\r
+ if (entire_thread == ENTIRE_THREAD_TRUE)\r
+ params.entire_thread = TRUE;\r
+ else\r