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 D662C431FAF for ; Mon, 27 May 2013 15:19:27 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 V+kyC8Rn01G9 for ; Mon, 27 May 2013 15:19:21 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id AE8F0431FAE for ; Mon, 27 May 2013 15:19:21 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1Uh5lA-0001WV-9R; Mon, 27 May 2013 23:19:20 +0100 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1Uh5lA-00064Y-0p; Mon, 27 May 2013 23:19:20 +0100 From: Mark Walters To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH 2/4] emacs: Record part p-list in a text property In-Reply-To: <1369687594-31774-3-git-send-email-amdragon@mit.edu> References: <1369687594-31774-1-git-send-email-amdragon@mit.edu> <1369687594-31774-3-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Mon, 27 May 2013 23:19:18 +0100 Message-ID: <8738t8jcbd.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: c867794f7311dd3a0754b9814b8e1b0a (of first 20000 bytes) X-SpamAssassin-Score: -0.1 X-SpamAssassin-SpamBar: / X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -0.1 points. Summary of the scoring: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.1 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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 22:19:28 -0000 A couple of small nits: Austin Clements writes: > 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. ^^^ existing > + (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." I think something here should say innermost part or something similar. Best wishes Mark > + (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