--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 E882C431FBD\r
+ for <notmuch@notmuchmail.org>; Sun, 21 Jul 2013 13:24:14 -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 tests=[none]\r
+ 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 3h1WQCsT7yZs for <notmuch@notmuchmail.org>;\r
+ Sun, 21 Jul 2013 13:24:05 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id A0FFE431FB6\r
+ for <notmuch@notmuchmail.org>; Sun, 21 Jul 2013 13:24:04 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 7DABB10005D;\r
+ Sun, 21 Jul 2013 23:23:58 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: John Lenz <lenz@math.uic.edu>, notmuch@notmuchmail.org\r
+Subject: Re: cli: add --include-html option to notmuch show\r
+In-Reply-To: <notmuch-web-1372724382.450184839@www.wuzzeb.org>\r
+References: <notmuch-web-1372724382.450184839@www.wuzzeb.org>\r
+User-Agent: Notmuch/0.15.2+225~g6062adf (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sun, 21 Jul 2013 23:23:58 +0300\r
+Message-ID: <m27ggj1x29.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Sun, 21 Jul 2013 20:24:15 -0000\r
+\r
+On Tue, Jul 02 2013, John Lenz <lenz@math.uic.edu> wrote:\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
+This looks like a useful option. I just wonder what effect does different\r
+charsets do to the output (is text/html content output verbatim (with just\r
+json/sexp escaping of '"' -characters). \r
+\r
+If you added test(s) showing what happens with different charsets\r
+(like one message having 3 text/html parts, one us-ascii, one iso-8859-1\r
+and one utf-8) that would make things clearer and (also) protect us from \r
+regressions.\r
+\r
+Tomi\r
+\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r