--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 24F1F431FDD\r
+ for <notmuch@notmuchmail.org>; Wed, 29 May 2013 18:14:14 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 Marq7Ctqxuib for <notmuch@notmuchmail.org>;\r
+ Wed, 29 May 2013 18:14:06 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+ [18.7.68.37])\r
+ by olra.theworths.org (Postfix) with ESMTP id 331B8431FC2\r
+ for <notmuch@notmuchmail.org>; Wed, 29 May 2013 18:14:00 -0700 (PDT)\r
+X-AuditID: 12074425-b7f986d00000082c-99-51a6a7d5f4c2\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id B8.BF.02092.5D7A6A15; Wed, 29 May 2013 21:13:58 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4U1DtHn031313; \r
+ Wed, 29 May 2013 21:13:56 -0400\r
+Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net\r
+ [76.21.105.205]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4U1DqiK003006\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Wed, 29 May 2013 21:13:54 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1UhrRA-0003Ys-3c; Wed, 29 May 2013 21:13:52 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/5] emacs: Record part p-list in a text property\r
+Date: Wed, 29 May 2013 21:13:45 -0400\r
+Message-Id: <1369876428-13537-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
+References: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsUixCmqrXtt+bJAgz3TmS1Wz+WxuH5zJrMD\r
+ k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlXHsylSWgsPiFZ2bdrI2ML4V6mLk5JAQMJG4\r
+ OGM2K4QtJnHh3no2EFtIYB+jRFencBcjF5C9Ech+cIsJwjnNJNFws58FwpnLKPHoXQMLSAub\r
+ gIbEtv3LGUFsEQFpiZ13IcYyCzhKfN6/CGyssICLxMYZz8HqWQRUJR5/PgNWwyvgIHFx5n1G\r
+ iDMUJbqfTQCr5wTqfd92nRHiJAeJ5m99TBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszLSy3S\r
+ tdDLzSzRS00p3cQICiR2F9UdjBMOKR1iFOBgVOLh5dBdFijEmlhWXJl7iFGSg0lJlHfNUqAQ\r
+ X1J+SmVGYnFGfFFpTmrxIUYJDmYlEd412kA53pTEyqrUonyYlDQHi5I4742Um/5CAumJJanZ\r
+ qakFqUUwWRkODiUJ3qJlQI2CRanpqRVpmTklCGkmDk6Q4TxAw5VAaniLCxJzizPTIfKnGHU5\r
+ Np+f/I5RiCUvPy9VSpzXFqRIAKQoozQPbg4sAbxiFAd6SxhiHQ8wecBNegW0hAloiTjzYpAl\r
+ JYkIKakGRq4JMc3r7/lHOCz4zd327/r6f0J+NWw2n57s2L7I+Ne5CrHdL3h+zbNNXW3MNzfZ\r
+ qU2w/NoTo9r/as8rDh5JuH5hvdO+p+pTmBq+nI+a8HvGb9bA8M4vYhbGD6OaNvZtSZlwYmdk\r
+ avrj48zBXPOWXT7PMd/I9T9biFbb853xb6xnGCo/Oxhk26jEUpyRaKjFXFScCAAYsH+82wIA AA==\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: Thu, 30 May 2013 01:14:14 -0000\r
+\r
+This is similar to what we already do with the message p-list, though\r
+we apply the part's text property to the whole part's text, in\r
+contrast with the message p-list, which is (rather obscurely) only\r
+applied to the first character.\r
+---\r
+ emacs/notmuch-lib.el | 12 ++++++++++++\r
+ emacs/notmuch-show.el | 20 +++++++++++++++++++-\r
+ 2 files changed, 31 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 790136e..2186783 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -360,6 +360,18 @@ OBJECT."\r
+ below\r
+ string))\r
+ \r
++(defun notmuch-map-text-property (start end prop func &optional object)\r
++ "Transform text property PROP using FUNC.\r
++\r
++Applies FUNC to each distinct value of the text property PROP\r
++between START and END of OBJECT, setting PROP to the value\r
++returned by FUNC."\r
++ (while (< start end)\r
++ (let ((value (get-text-property start prop object))\r
++ (next (next-single-property-change start prop object end)))\r
++ (put-text-property start next prop (funcall func value) object)\r
++ (setq start next))))\r
++\r
+ (defun notmuch-logged-error (msg &optional extra)\r
+ "Log MSG and EXTRA to *Notmuch errors* and signal MSG.\r
+ \r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index a080134..e84e1ba 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -900,7 +900,17 @@ If HIDE is non-nil then initially hide this part."\r
+ ;; Ensure that the part ends with a carriage return.\r
+ (unless (bolp)\r
+ (insert "\n"))\r
+- (notmuch-show-create-part-overlays msg beg (point) hide)))\r
++ (notmuch-show-create-part-overlays msg beg (point) hide)\r
++ ;; Record part information. Since we already inserted subparts,\r
++ ;; don't override existing :notmuch-part properties.\r
++ (notmuch-map-text-property beg (point) :notmuch-part\r
++ (lambda (v) (or v part)))\r
++ ;; Make :notmuch-part front sticky and rear non-sticky so it stays\r
++ ;; applied to the beginning of each line when we indent the message.\r
++ (notmuch-map-text-property beg (point) 'front-sticky\r
++ (lambda (v) (pushnew :notmuch-part v)))\r
++ (notmuch-map-text-property beg (point) 'rear-nonsticky\r
++ (lambda (v) (pushnew :notmuch-part v)))))\r
+ \r
+ (defun notmuch-show-insert-body (msg body depth)\r
+ "Insert the body BODY at depth DEPTH in the current thread."\r
+@@ -1404,6 +1414,14 @@ Some useful entries are:\r
+ (notmuch-show-move-to-message-top)\r
+ (get-text-property (point) :notmuch-message-properties)))\r
+ \r
++(defun notmuch-show-get-part-properties ()\r
++ "Return the properties of the innermost part containing point.\r
++\r
++This is the part property list retrieved from the CLI. Signals\r
++an error if there is no part containing point."\r
++ (or (get-text-property (point) :notmuch-part)\r
++ (error "No message part here")))\r
++\r
+ (defun notmuch-show-set-prop (prop val &optional props)\r
+ (let ((inhibit-read-only t)\r
+ (props (or props\r
+-- \r
+1.7.10.4\r
+\r