--- /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 87323431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 27 May 2013 13:47:00 -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 xEIJti9UVYMp for <notmuch@notmuchmail.org>;\r
+ Mon, 27 May 2013 13:46:55 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+ [18.7.68.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 9AAEF431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 27 May 2013 13:46:49 -0700 (PDT)\r
+X-AuditID: 12074424-b7f8c6d0000028c4-22-51a3c639ae72\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 59.E5.10436.936C3A15; Mon, 27 May 2013 16:46:49 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r4RKkgmF008815; \r
+ Mon, 27 May 2013 16:46:43 -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 r4RKkepZ026421\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 27 May 2013 16:46:42 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1Uh4JT-0008ND-QD; Mon, 27 May 2013 16:46:39 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] emacs: Record part p-list in a text property\r
+Date: Mon, 27 May 2013 16:46:32 -0400\r
+Message-Id: <1369687594-31774-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1369687594-31774-1-git-send-email-amdragon@mit.edu>\r
+References: <1369687594-31774-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrGt5bHGgwYleKYvVc3ksrt+cyezA\r
+ 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZexdfY+5YLFoxYTty9gaGBsFuxg5OSQETCR6\r
+ 919ggrDFJC7cW8/WxcjFISSwj1Fi0p/rrCAJIYGNjBIrX7tAJE4zSTx9fZMNIjGXUWL3AnMQ\r
+ m01AQ2Lb/uWMILaIgLTEzruzwZqZBRwlPu9fBFYvDGQfPzMbrIZFQFVi140dQDUcHLwCDhJn\r
+ thlAHKEo0f1sAlg5J1D5lV2/oW5wkFj9uoNpAiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmp\r
+ RbrmermZJXqpKaWbGEFBxO6isoOx+ZDSIUYBDkYlHl6LzMWBQqyJZcWVuYcYJTmYlER52Y8A\r
+ hfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwbl8BlONNSaysSi3Kh0lJc7AoifNeT7npLySQnliS\r
+ mp2aWpBaBJOV4eBQkuCVAxkqWJSanlqRlplTgpBm4uAEGc4DNDwDpIa3uCAxtzgzHSJ/ilGX\r
+ Y/P5ye8YhVjy8vNSpcR5y0GKBECKMkrz4ObAov8VozjQW8K8TiBVPMDEATfpFdASJqAl4sxg\r
+ S0oSEVJSDYy1hj1zluTYhm7Ye6AiQab1UfQrg9UPMrcaaZ9bW7E8tbtwZYcM3+TtwUXVxw4d\r
+ FevNX+hfJTWLxfWzj4lQ2MZ1z+vbTbQvOSzyPHz0d+eBjAqxklV/nq1OiZasNf5kUHj4Zu3u\r
+ H+nmdz6Yqu1jOXO9a2swX0S1if2Ns9c/ynO83cTJnTVdQ0qJpTgj0VCLuag4EQAO4lda2QIA 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: Mon, 27 May 2013 20:47:00 -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 | 16 ++++++++++++++++\r
+ emacs/notmuch-show.el | 13 ++++++++++++-\r
+ 2 files changed, 28 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 790136e..09ce25e 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -360,6 +360,22 @@ OBJECT."\r
+ below\r
+ string))\r
+ \r
++(defun notmuch-put-text-property-if-nil (start end property value\r
++ &optional object)\r
++ "Like `put-text-property', but only set the property where it is nil."\r
++ (while (< start end)\r
++ (let ((start-nil (text-property-any start end property nil object)))\r
++ (if (null start-nil)\r
++ ;; There are no more nil regions; exit the loop\r
++ (setq start end)\r
++ ;; Find the end of the nil region\r
++ (let ((end-nil\r
++ (or (text-property-not-all start-nil end property nil object)\r
++ end)))\r
++ ;; Set the property\r
++ (put-text-property start-nil end-nil property value object)\r
++ (setq start end-nil))))))\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..acd0b55 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -900,7 +900,10 @@ 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 exiting :notmuch-part properties.\r
++ (notmuch-put-text-property-if-nil beg (point) :notmuch-part part)))\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 +1407,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 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