From: Austin Clements Date: Mon, 27 May 2013 20:46:32 +0000 (+2000) Subject: [PATCH 2/4] emacs: Record part p-list in a text property X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c54027abd3074a5ba40f35e0b6d1cb745e4e1af6;p=notmuch-archives.git [PATCH 2/4] emacs: Record part p-list in a text property --- diff --git a/60/3c732dfab372f2f3fc488ae39ef34454cdedd9 b/60/3c732dfab372f2f3fc488ae39ef34454cdedd9 new file mode 100644 index 000000000..84037af82 --- /dev/null +++ b/60/3c732dfab372f2f3fc488ae39ef34454cdedd9 @@ -0,0 +1,141 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 87323431FAE + for ; Mon, 27 May 2013 13:47:00 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id xEIJti9UVYMp for ; + Mon, 27 May 2013 13:46:55 -0700 (PDT) +Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU + [18.7.68.36]) + by olra.theworths.org (Postfix) with ESMTP id 9AAEF431FB6 + for ; Mon, 27 May 2013 13:46:49 -0700 (PDT) +X-AuditID: 12074424-b7f8c6d0000028c4-22-51a3c639ae72 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id 59.E5.10436.936C3A15; Mon, 27 May 2013 16:46:49 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r4RKkgmF008815; + Mon, 27 May 2013 16:46:43 -0400 +Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net + [76.21.105.205]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4RKkepZ026421 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 27 May 2013 16:46:42 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1Uh4JT-0008ND-QD; Mon, 27 May 2013 16:46:39 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 2/4] emacs: Record part p-list in a text property +Date: Mon, 27 May 2013 16:46:32 -0400 +Message-Id: <1369687594-31774-3-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1369687594-31774-1-git-send-email-amdragon@mit.edu> +References: <1369687594-31774-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrGt5bHGgwYleKYvVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZexdfY+5YLFoxYTty9gaGBsFuxg5OSQETCR6 + 919ggrDFJC7cW8/WxcjFISSwj1Fi0p/rrCAJIYGNjBIrX7tAJE4zSTx9fZMNIjGXUWL3AnMQ + m01AQ2Lb/uWMILaIgLTEzruzwZqZBRwlPu9fBFYvDGQfPzMbrIZFQFVi140dQDUcHLwCDhJn + thlAHKEo0f1sAlg5J1D5lV2/oW5wkFj9uoNpAiP/AkaGVYyyKblVurmJmTnFqcm6xcmJeXmp + RbrmermZJXqpKaWbGEFBxO6isoOx+ZDSIUYBDkYlHl6LzMWBQqyJZcWVuYcYJTmYlER52Y8A + hfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwbl8BlONNSaysSi3Kh0lJc7AoifNeT7npLySQnliS + mp2aWpBaBJOV4eBQkuCVAxkqWJSanlqRlplTgpBm4uAEGc4DNDwDpIa3uCAxtzgzHSJ/ilGX + Y/P5ye8YhVjy8vNSpcR5y0GKBECKMkrz4ObAov8VozjQW8K8TiBVPMDEATfpFdASJqAl4sxg + S0oSEVJSDYy1hj1zluTYhm7Ye6AiQab1UfQrg9UPMrcaaZ9bW7E8tbtwZYcM3+TtwUXVxw4d + FevNX+hfJTWLxfWzj4lQ2MZ1z+vbTbQvOSzyPHz0d+eBjAqxklV/nq1OiZasNf5kUHj4Zu3u + H+nmdz6Yqu1jOXO9a2swX0S1if2Ns9c/ynO83cTJnTVdQ0qJpTgj0VCLuag4EQAO4lda2QIA AA== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 27 May 2013 20:47:00 -0000 + +This is similar to what we already do with the message p-list, though +we apply the part's text property to the whole part's text, in +contrast with the message p-list, which is (rather obscurely) only +applied to the first character. +--- + emacs/notmuch-lib.el | 16 ++++++++++++++++ + emacs/notmuch-show.el | 13 ++++++++++++- + 2 files changed, 28 insertions(+), 1 deletion(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 790136e..09ce25e 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -360,6 +360,22 @@ OBJECT." + below + string)) + ++(defun notmuch-put-text-property-if-nil (start end property value ++ &optional object) ++ "Like `put-text-property', but only set the property where it is nil." ++ (while (< start end) ++ (let ((start-nil (text-property-any start end property nil object))) ++ (if (null start-nil) ++ ;; There are no more nil regions; exit the loop ++ (setq start end) ++ ;; Find the end of the nil region ++ (let ((end-nil ++ (or (text-property-not-all start-nil end property nil object) ++ end))) ++ ;; Set the property ++ (put-text-property start-nil end-nil property value object) ++ (setq start end-nil)))))) ++ + (defun notmuch-logged-error (msg &optional extra) + "Log MSG and EXTRA to *Notmuch errors* and signal MSG. + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index a080134..acd0b55 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -900,7 +900,10 @@ If HIDE is non-nil then initially hide this part." + ;; Ensure that the part ends with a carriage return. + (unless (bolp) + (insert "\n")) +- (notmuch-show-create-part-overlays msg beg (point) hide))) ++ (notmuch-show-create-part-overlays msg beg (point) hide) ++ ;; Record part information. Since we already inserted subparts, ++ ;; don't override exiting :notmuch-part properties. ++ (notmuch-put-text-property-if-nil beg (point) :notmuch-part part))) + + (defun notmuch-show-insert-body (msg body depth) + "Insert the body BODY at depth DEPTH in the current thread." +@@ -1404,6 +1407,14 @@ Some useful entries are: + (notmuch-show-move-to-message-top) + (get-text-property (point) :notmuch-message-properties))) + ++(defun notmuch-show-get-part-properties () ++ "Return the properties of the part containing point. ++ ++This is the part property list retrieved from the CLI. Signals ++an error if there is no part containing point." ++ (or (get-text-property (point) :notmuch-part) ++ (error "No message part here"))) ++ + (defun notmuch-show-set-prop (prop val &optional props) + (let ((inhibit-read-only t) + (props (or props +-- +1.7.10.4 +