--- /dev/null
+Return-Path: <wking@tremily.us>\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 239B0431FC9\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 02:47:00 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001]\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 ln8ktshn5u+r for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Feb 2014 02:46:49 -0800 (PST)\r
+Received: from qmta04.westchester.pa.mail.comcast.net\r
+ (qmta04.westchester.pa.mail.comcast.net [76.96.62.40])\r
+ by olra.theworths.org (Postfix) with ESMTP id 4EC40431FDB\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 02:46:49 -0800 (PST)\r
+Received: from omta04.westchester.pa.mail.comcast.net ([76.96.62.35])\r
+ by qmta04.westchester.pa.mail.comcast.net with comcast\r
+ id Mmlh1n0010ldTLk54mmoVz; Mon, 03 Feb 2014 10:46:48 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+ by omta04.westchester.pa.mail.comcast.net with comcast\r
+ id Mmmm1n00L152l3L01mmnZn; Mon, 03 Feb 2014 10:46:48 +0000\r
+Received: from mjolnir.tremily.us (unknown [192.168.0.140])\r
+ by odin.tremily.us (Postfix) with ESMTPS id BE048FB4C6B;\r
+ Mon, 3 Feb 2014 02:46:45 -0800 (PST)\r
+Received: (nullmailer pid 31479 invoked by uid 1000);\r
+ Mon, 03 Feb 2014 10:45:48 -0000\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] notmuch-show: Add content-description output pair\r
+Date: Mon, 3 Feb 2014 02:45:33 -0800\r
+Message-Id:\r
+ <4a916b4f80f5cc9b28ddbb9c3eecdabf914d9641.1391423201.git.wking@tremily.us>\r
+X-Mailer: git-send-email 1.8.5.2.8.g0f6c0d1\r
+In-Reply-To: <cover.1391423201.git.wking@tremily.us>\r
+References: <877g9chbay.fsf@qmul.ac.uk>\r
+ <cover.1391423201.git.wking@tremily.us>\r
+In-Reply-To: <cover.1391423201.git.wking@tremily.us>\r
+References: <cover.1391423201.git.wking@tremily.us>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+ s=q20121106; t=1391424408;\r
+ bh=6cQ+kT34X70UTPaNzC5yeyXhvb2vocR8UUhEtebGZfs=;\r
+ h=Received:Received:Received:Received:From:To:Subject:Date:\r
+ Message-Id:MIME-Version:Content-Type;\r
+ b=Dwo4azb+U3UirA7HukqlGEXyc+7K8W6T9BRICJJhdh83P0M9MzGMiicsNbVX1/QeJ\r
+ NPq/BTLbNGdG+jcOLDtLYn0txamrld2gvQprWPYtCnj3qaYclW3qhjmF/Am8oOQnoN\r
+ /ZSK93gtb3cC3YJf0FpbhPZFob5pG27kjcgGSQe5eNrwl73fWb8i464DrPgY7KmcEZ\r
+ a4phVdPZgFP818naSUkQ2TbpngTmBojPLvb9EwHylfxnitMZ6gOMCXcjlsW2hCcdBX\r
+ w2GagqA1qKVNm5Y2vLVbWSSBMtGvq4/yGf2ip+pXjkKsNccgYZyzLTdwK2I78ghu7y\r
+ Nu9c2H2Y63J1A==\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: Mon, 03 Feb 2014 10:47:00 -0000\r
+\r
+Parse and display the Content-Description header [1,2] so UIs\r
+rendering message parts have easy access to description strings.\r
+Extracting the value is a two-step process (extract [3] and decode\r
+[4]).\r
+\r
+[1]: http://tools.ietf.org/html/rfc2045#section-8\r
+[2]: http://tools.ietf.org/html/rfc2183#section-3\r
+[3]: https://developer.gnome.org/gmime/stable/GMimeObject.html#g-mime-object-get-header\r
+[4]: https://developer.gnome.org/gmime/stable/gmime-gmime-utils.html#g-mime-utils-header-decode-text\r
+---\r
+ NEWS | 2 ++\r
+ notmuch-show.c | 8 ++++++++\r
+ test/T160-json.sh | 4 ++--\r
+ test/T170-sexp.sh | 4 ++--\r
+ 4 files changed, 14 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/NEWS b/NEWS\r
+index 65679eb..0f7b1c8 100644\r
+--- a/NEWS\r
++++ b/NEWS\r
+@@ -8,6 +8,8 @@ Command-Line Interface\r
+ \r
+ The old format is still available with `--format=sup`.\r
+ \r
++`notmuch show` now includes envelope Content-Description headers.\r
++\r
+ Notmuch 0.17 (2013-12-30)\r
+ =========================\r
+ \r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d416fbd..a604227 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -659,6 +659,9 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ GMIME_OBJECT (node->envelope_part) : node->part;\r
+ GMimeContentType *content_type = g_mime_object_get_content_type (meta);\r
+ const char *cid = g_mime_object_get_content_id (meta);\r
++ const char *encoded_description = g_mime_object_get_header (meta, "content-description");\r
++ const char *description = encoded_description ?\r
++ g_mime_utils_header_decode_text (encoded_description) : NULL;\r
+ const char *filename = GMIME_IS_PART (node->part) ?\r
+ g_mime_part_get_filename (GMIME_PART (node->part)) : NULL;\r
+ int nclose = 0;\r
+@@ -692,6 +695,11 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
+ sp->string (sp, cid);\r
+ }\r
+ \r
++ if (description) {\r
++ sp->map_key (sp, "content-description");\r
++ sp->string (sp, description);\r
++ }\r
++\r
+ if (filename) {\r
+ sp->map_key (sp, "filename");\r
+ sp->string (sp, filename);\r
+diff --git a/test/T160-json.sh b/test/T160-json.sh\r
+index c1cf649..53f40ef 100755\r
+--- a/test/T160-json.sh\r
++++ b/test/T160-json.sh\r
+@@ -41,14 +41,14 @@ id="json-show-inline-attachment-filename@notmuchmail.org"\r
+ emacs_fcc_message \\r
+ "$subject" \\r
+ 'This is a test message with inline attachment with a filename' \\r
+- "(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")\r
++ "(mml-attach-file \"$TEST_DIRECTORY/README\" nil \"Test README\" \"inline\")\r
+ (message-goto-eoh)\r
+ (insert \"Message-ID: <$id>\n\")"\r
+ output=$(notmuch show --format=json "id:$id")\r
+ filename=$(notmuch search --output=files "id:$id")\r
+ # Get length of README after base64-encoding, minus additional newline.\r
+ attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))\r
+-test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"content-length\": $attachment_length, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"\r
++test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"content-description\": \"Test README\", \"content-length\": $attachment_length, \"content-transfer-encoding\": \"base64\", \"filename\": \"README\"}]}]}, []]]]"\r
+ \r
+ test_begin_subtest "Search message: json, utf-8"\r
+ add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""\r
+diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh\r
+index 667e319..1c087d6 100755\r
+--- a/test/T170-sexp.sh\r
++++ b/test/T170-sexp.sh\r
+@@ -32,14 +32,14 @@ id="sexp-show-inline-attachment-filename@notmuchmail.org"\r
+ emacs_fcc_message \\r
+ "$subject" \\r
+ 'This is a test message with inline attachment with a filename' \\r
+- "(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")\r
++ "(mml-attach-file \"$TEST_DIRECTORY/README\" nil \"Test README\" \"inline\")\r
+ (message-goto-eoh)\r
+ (insert \"Message-ID: <$id>\n\")"\r
+ output=$(notmuch show --format=sexp "id:$id")\r
+ filename=$(notmuch search --output=files "id:$id")\r
+ # Get length of README after base64-encoding, minus additional newline.\r
+ attachment_length=$(( $(base64 $TEST_DIRECTORY/README | wc -c) - 1 ))\r
+-test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \"$filename\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :filename \"README\" :content-transfer-encoding \"base64\" :content-length $attachment_length))))) ())))"\r
++test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename \"$filename\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :content-description \"Test README\" :filename \"README\" :content-transfer-encoding \"base64\" :content-length $attachment_length))))) ())))"\r
+ \r
+ test_begin_subtest "Search message: sexp, utf-8"\r
+ add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""\r
+-- \r
+1.8.5.2.8.g0f6c0d1\r
+\r