From: Austin Clements Date: Thu, 30 May 2013 01:13:45 +0000 (+2000) Subject: [PATCH v2 2/5] emacs: Record part p-list in a text property X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b2f16f7eae6d6008b8a65c9af313aef364f40498;p=notmuch-archives.git [PATCH v2 2/5] emacs: Record part p-list in a text property --- diff --git a/02/961c97fe7f52fb6abf93235a8c1776fa800d55 b/02/961c97fe7f52fb6abf93235a8c1776fa800d55 new file mode 100644 index 000000000..5ffcf2928 --- /dev/null +++ b/02/961c97fe7f52fb6abf93235a8c1776fa800d55 @@ -0,0 +1,144 @@ +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 24F1F431FDD + for ; Wed, 29 May 2013 18:14:14 -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 Marq7Ctqxuib for ; + Wed, 29 May 2013 18:14:06 -0700 (PDT) +Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id 331B8431FC2 + for ; Wed, 29 May 2013 18:14:00 -0700 (PDT) +X-AuditID: 12074425-b7f986d00000082c-99-51a6a7d5f4c2 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id B8.BF.02092.5D7A6A15; Wed, 29 May 2013 21:13:58 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4U1DtHn031313; + Wed, 29 May 2013 21:13:56 -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 r4U1DqiK003006 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Wed, 29 May 2013 21:13:54 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1UhrRA-0003Ys-3c; Wed, 29 May 2013 21:13:52 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 2/5] emacs: Record part p-list in a text property +Date: Wed, 29 May 2013 21:13:45 -0400 +Message-Id: <1369876428-13537-3-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1369876428-13537-1-git-send-email-amdragon@mit.edu> +References: <1369876428-13537-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsUixCmqrXtt+bJAgz3TmS1Wz+WxuH5zJrMD + k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlXHsylSWgsPiFZ2bdrI2ML4V6mLk5JAQMJG4 + OGM2K4QtJnHh3no2EFtIYB+jRFencBcjF5C9Ech+cIsJwjnNJNFws58FwpnLKPHoXQMLSAub + gIbEtv3LGUFsEQFpiZ13IcYyCzhKfN6/CGyssICLxMYZz8HqWQRUJR5/PgNWwyvgIHFx5n1G + iDMUJbqfTQCr5wTqfd92nRHiJAeJ5m99TBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszLSy3S + tdDLzSzRS00p3cQICiR2F9UdjBMOKR1iFOBgVOLh5dBdFijEmlhWXJl7iFGSg0lJlHfNUqAQ + X1J+SmVGYnFGfFFpTmrxIUYJDmYlEd412kA53pTEyqrUonyYlDQHi5I4742Um/5CAumJJanZ + qakFqUUwWRkODiUJ3qJlQI2CRanpqRVpmTklCGkmDk6Q4TxAw5VAaniLCxJzizPTIfKnGHU5 + Np+f/I5RiCUvPy9VSpzXFqRIAKQoozQPbg4sAbxiFAd6SxhiHQ8wecBNegW0hAloiTjzYpAl + JYkIKakGRq4JMc3r7/lHOCz4zd327/r6f0J+NWw2n57s2L7I+Ne5CrHdL3h+zbNNXW3MNzfZ + qU2w/NoTo9r/as8rDh5JuH5hvdO+p+pTmBq+nI+a8HvGb9bA8M4vYhbGD6OaNvZtSZlwYmdk + avrj48zBXPOWXT7PMd/I9T9biFbb853xb6xnGCo/Oxhk26jEUpyRaKjFXFScCAAYsH+82wIA 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: Thu, 30 May 2013 01:14:14 -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 | 12 ++++++++++++ + emacs/notmuch-show.el | 20 +++++++++++++++++++- + 2 files changed, 31 insertions(+), 1 deletion(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 790136e..2186783 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -360,6 +360,18 @@ OBJECT." + below + string)) + ++(defun notmuch-map-text-property (start end prop func &optional object) ++ "Transform text property PROP using FUNC. ++ ++Applies FUNC to each distinct value of the text property PROP ++between START and END of OBJECT, setting PROP to the value ++returned by FUNC." ++ (while (< start end) ++ (let ((value (get-text-property start prop object)) ++ (next (next-single-property-change start prop object end))) ++ (put-text-property start next prop (funcall func value) object) ++ (setq start next)))) ++ + (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..e84e1ba 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -900,7 +900,17 @@ 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 existing :notmuch-part properties. ++ (notmuch-map-text-property beg (point) :notmuch-part ++ (lambda (v) (or v part))) ++ ;; Make :notmuch-part front sticky and rear non-sticky so it stays ++ ;; applied to the beginning of each line when we indent the message. ++ (notmuch-map-text-property beg (point) 'front-sticky ++ (lambda (v) (pushnew :notmuch-part v))) ++ (notmuch-map-text-property beg (point) 'rear-nonsticky ++ (lambda (v) (pushnew :notmuch-part v))))) + + (defun notmuch-show-insert-body (msg body depth) + "Insert the body BODY at depth DEPTH in the current thread." +@@ -1404,6 +1414,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 innermost 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 +