--- /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 23442431FB6\r
+ for <notmuch@notmuchmail.org>; Sun, 4 Aug 2013 12:47:29 -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 I8e6iQqAscYn for <notmuch@notmuchmail.org>;\r
+ Sun, 4 Aug 2013 12:47:19 -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 9A478431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 4 Aug 2013 12:47:18 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id E8A551000B2;\r
+ Sun, 4 Aug 2013 22:47:10 +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-1374719771.1588310986@www.wuzzeb.org>\r
+References: <notmuch-web-1372724382.450184839@www.wuzzeb.org>\r
+ <m27ggj1x29.fsf@guru.guru-group.fi>\r
+ <notmuch-web-1374719771.1588310986@www.wuzzeb.org>\r
+User-Agent: Notmuch/0.16+2~g0418bb2 (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, 04 Aug 2013 22:47:10 +0300\r
+Message-ID: <m2zjsxs0g1.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, 04 Aug 2013 19:47:29 -0000\r
+\r
+On Thu, Jul 25 2013, John Lenz <lenz@math.uic.edu> wrote:\r
+\r
+> On Sun Jul 21 15:23 -0500 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:\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
+\r
+> Here is a test I wrote. I tried to follow the other tests in formatting.\r
+> Let me know if you want this as a single patch combined with the code\r
+> to enable the option, I can resend it.\r
+\r
+I took your patch, modified it a bit and put it at the end of 'multipart'\r
+test. The diff for viewing is attached at the end.\r
+\r
+The next question is should we have new option as\r
+\r
+--include-html\r
+\r
+or as\r
+\r
+--include-html=(true|false)\r
+\r
+or even\r
+\r
+--body=(true|false|text-and-html)\r
+\r
+See --exclude option in http://notmuchmail.org/manpages/notmuch-search-1/\r
+and --body option in http://notmuchmail.org/manpages/notmuch-show-1/\r
+for comparison...\r
+\r
+\r
+Tomi\r
+\r
+--8<----8<----8<----8<----8<--\r
+\r
+diff --git a/test/multipart b/test/multipart\r
+index c974226..11f10bd 100755\r
+--- a/test/multipart\r
++++ b/test/multipart\r
+@@ -647,4 +647,84 @@ notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out\r
+ echo -n -e "\xEF\x0D\x0A" > crlf.expected\r
+ test_expect_equal_file crlf.out crlf.expected\r
+ \r
+-test_done\r
+\ No newline at end of file\r
++\r
++# The ISO-8859-1 encoding of U+00BD is a single byte: octal 275\r
++# (Portability note: Dollar-Single ($'...', ANSI C-style escape sequences)\r
++# quoting works on bash, ksh, zsh, *BSD sh but not on dash, ash nor busybox sh)\r
++readonly u_00bd_latin1=$'\275'\r
++\r
++# The Unicode fraction symbol 1/2 is U+00BD and is encoded\r
++# in UTF-8 as two bytes: octal 302 275\r
++readonly u_00bd_utf8=$'\302\275'\r
++\r
++cat <<EOF > ${MAIL_DIR}/include-html\r
++From: A <a@example.com>\r
++To: B <b@example.com>\r
++Subject: html message\r
++Date: Sat, 01 January 2000 00:00:00 +0000\r
++Message-ID: <htmlmessage>\r
++MIME-Version: 1.0\r
++Content-Type: multipart/alternative; boundary="==-=="\r
++\r
++--==-==\r
++Content-Type: text/html; charset=UTF-8\r
++\r
++<p>0.5 equals ${u_00bd_utf8}</p>\r
++\r
++--==-==\r
++Content-Type: text/html; charset=ISO-8859-1\r
++\r
++<p>0.5 equals ${u_00bd_latin1}</p>\r
++\r
++--==-==\r
++Content-Type: text/plain; charset=UTF-8\r
++\r
++0.5 equals ${u_00bd_utf8}\r
++\r
++--==-==--\r
++EOF\r
++\r
++notmuch new > /dev/null\r
++\r
++cat_expected_head ()\r
++{\r
++ cat <<EOF\r
++[[[{"id": "htmlmessage", "match":true, "excluded": false, "date_relative":"2000-01-01",\r
++ "timestamp": 946684800,\r
++ "filename": "${MAIL_DIR}/include-html",\r
++ "tags": ["inbox", "unread"],\r
++ "headers": { "Date": "Sat, 01 Jan 2000 00:00:00 +0000", "From": "A <a@example.com>",\r
++ "Subject": "html message", "To": "B <b@example.com>"},\r
++ "body": [{\r
++ "content-type": "multipart/alternative", "id": 1,\r
++EOF\r
++}\r
++\r
++cat_expected_head > EXPECTED.nohtml\r
++cat <<EOF >> EXPECTED.nohtml\r
++"content": [\r
++ { "id": 2, "content-charset": "UTF-8", "content-length": 21, "content-type": "text/html"},\r
++ { "id": 3, "content-charset": "ISO-8859-1", "content-length": 20, "content-type": "text/html"},\r
++ { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}\r
++]}]},[]]]]\r
++EOF\r
++\r
++# Both the UTF-8 and ISO-8859-1 part should have U+00BD\r
++cat_expected_head > EXPECTED.withhtml\r
++cat <<EOF >> EXPECTED.withhtml\r
++"content": [\r
++ { "id": 2, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},\r
++ { "id": 3, "content-type": "text/html", "content": "<p>0.5 equals \\u00bd</p>\\n"},\r
++ { "id": 4, "content-type": "text/plain", "content": "0.5 equals \\u00bd\\n"}\r
++]}]},[]]]]\r
++EOF\r
++\r
++test_begin_subtest "html parts excluded by default"\r
++notmuch show --format=json id:htmlmessage > OUTPUT\r
++test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.nohtml)"\r
++\r
++test_begin_subtest "html parts included"\r
++notmuch show --format=json --include-html id:htmlmessage > OUTPUT\r
++test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"\r
++\r
++test_done\r