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 D07C6431FC3 for ; Fri, 13 Jul 2012 11:43:13 -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 U7AtCs89czgo for ; Fri, 13 Jul 2012 11:43:13 -0700 (PDT) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 110CA431FAE for ; Fri, 13 Jul 2012 11:43:13 -0700 (PDT) X-AuditID: 1209190c-b7f806d000006b87-f9-50006c3e29f1 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 90.EB.27527.F3C60005; Fri, 13 Jul 2012 14:43:11 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6DIhAmL010142; Fri, 13 Jul 2012 14:43:10 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6DIh9iV020003 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Fri, 13 Jul 2012 14:43:09 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1SpkpY-0008D3-RJ; Fri, 13 Jul 2012 14:43:08 -0400 Date: Fri, 13 Jul 2012 14:43:08 -0400 From: Austin Clements To: Mark Walters Subject: Re: [PATCH 2/7] emacs: Use text properties instead of overlays for tag coloring Message-ID: <20120713184308.GB31182@mit.edu> References: <1342140319-19859-1-git-send-email-amdragon@mit.edu> <1342140319-19859-3-git-send-email-amdragon@mit.edu> <877gu78ruk.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877gu78ruk.fsf@qmul.ac.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1rXPYQgwuLec2WL1XB6L6zdnMjsw eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGUun32Up2Kla8eT8FfYGxkuyXYycHBICJhK7 f15jhrDFJC7cW8/WxcjFISSwj1Fi7e9uZghnA6PEy0+LmCCck0wS827fZodwljBKzPi8E6yf RUBV4ueBV6wgNpuAhsS2/csZQWwRAR2J24cWsIPYzALSEt9+NwNN4uAQFoiS2Ho6AiTMC1Ry 5fQhRoiZUxklTvzZyg6REJQ4OfMJC0SvlsSNfy/BekHmLP/HARLmBFrVPHU+G4gtKqAiMeXk NrYJjEKzkHTPQtI9C6F7ASPzKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl1DvdzMEr3UlNJNjOCw luTZwfjmoNIhRgEORiUe3nR/hgAh1sSy4srcQ4ySHExKorw/M4FCfEn5KZUZicUZ8UWlOanF hxglOJiVRHh1jIFyvCmJlVWpRfkwKWkOFiVx3sspN/2FBNITS1KzU1MLUotgsjIcHEoSvAnZ QI2CRanpqRVpmTklCGkmDk6Q4TxAw4NAaniLCxJzizPTIfKnGBWlxHlngyQEQBIZpXlwvbC0 84pRHOgVYd4wkCoeYMqC634FNJgJaPCsn//8gQaXJCKkpBoYk5++fXFC0cpWkMHi0P95saKR GnpP7mU3s2Yy/I7z4W27EnPQ5NICD/5d+zur7EI6/R+cufvy+J34PpuvIc+m7JY2UTOVUuro lf10oMri3ddd/9WzvrgInwpjmBe9LefgrdonFx9lFDFEHHZtidXk/X1curi91vPSSvG7kn8F C6MV43Xkj2QqsRRnJBpqMRcVJwIARt2fIhYDAAA= Cc: notmuch@notmuchmail.org 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: Fri, 13 Jul 2012 18:43:14 -0000 Quoth Mark Walters on Jul 13 at 6:59 pm: > On Fri, 13 Jul 2012, Austin Clements wrote: > > Previously, tag-based search result highlighting was done by creating > > an overlay over each search result. However, overlays have annoying > > front- and rear-advancement semantics that make it difficult to > > manipulate text at their boundaries, which the next patch will do. > > They also have performance problems (creating an overlay is linear in > > the number of overlays between point and the new overlay, making > > highlighting a search buffer quadratic in the number of results). > > > > Text properties have neither problem. However, text properties make > > it more difficult to apply multiple faces since, unlike with overlays, > > a given character can only have a single 'face text property. Hence, > > we introduce a utility function that combines faces into any existing > > 'face text properties. > > > > Using this utility function, it's straightforward to apply all of the > > appropriate tag faces in notmuch-search-color-line. > > I have some recollection of people talking about text properties as > opposed to overlays some time ago but saying one problem was you > couldn't do invisibility with text properties. Is that correct and is it > a concern? (Otherwise it all looks good) I believe the problem was that isearch can only automatically expand invisible text that's marked invisible using overlays. Regardless, this shouldn't be an issue for this patch because invisibility and faces are controlled by different text properties. It also shouldn't be a problem for the next patch because, while we do use overlays to hide authors, that overlay should always be strictly within the search result (even if it's at the end of the result format, we'll follow it with a newline) and hence deleting the entire search result region should also delete the author invisibility overlay. > Best wishes > > Mark > > --- > > emacs/notmuch-lib.el | 15 +++++++++++++++ > > emacs/notmuch.el | 21 +++++++-------------- > > 2 files changed, 22 insertions(+), 14 deletions(-) > > > > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el > > index aa25513..30db58f 100644 > > --- a/emacs/notmuch-lib.el > > +++ b/emacs/notmuch-lib.el > > @@ -269,6 +269,21 @@ current buffer, if possible." > > (loop for (key value . rest) on plist by #'cddr > > collect (cons (intern (substring (symbol-name key) 1)) value))) > > > > +(defun notmuch-combine-face-text-property (start end face) > > + "Combine FACE into the 'face text property between START and END. > > + > > +This function combines FACE with any existing faces between START > > +and END. Attributes specified by FACE take precedence over > > +existing attributes. FACE must be a face name (a symbol or > > +string), a property list of face attributes, or a list of these." > > + > > + (let ((pos start)) > > + (while (< pos end) > > + (let ((cur (get-text-property pos 'face)) > > + (next (next-single-property-change pos 'face nil end))) > > + (put-text-property pos next 'face (cons face cur)) > > + (setq pos next))))) > > + > > ;; Compatibility functions for versions of emacs before emacs 23. > > ;; > > ;; Both functions here were copied from emacs 23 with the following copyright: > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > > index ef18927..82c148d 100644 > > --- a/emacs/notmuch.el > > +++ b/emacs/notmuch.el > > @@ -633,20 +633,13 @@ foreground and blue background." > > > > (defun notmuch-search-color-line (start end line-tag-list) > > "Colorize lines in `notmuch-show' based on tags." > > - ;; Create the overlay only if the message has tags which match one > > - ;; of those specified in `notmuch-search-line-faces'. > > - (let (overlay) > > - (mapc (lambda (elem) > > - (let ((tag (car elem)) > > - (attributes (cdr elem))) > > - (when (member tag line-tag-list) > > - (when (not overlay) > > - (setq overlay (make-overlay start end))) > > - ;; Merge the specified properties with any already > > - ;; applied from an earlier match. > > - (overlay-put overlay 'face > > - (append (overlay-get overlay 'face) attributes))))) > > - notmuch-search-line-faces))) > > + (mapc (lambda (elem) > > + (let ((tag (car elem)) > > + (attributes (cdr elem))) > > + (when (member tag line-tag-list) > > + (notmuch-combine-face-text-property start end attributes)))) > > + ;; Reverse the list so earlier entries take precedence > > + (reverse notmuch-search-line-faces))) > > > > (defun notmuch-search-author-propertize (authors) > > "Split `authors' into matching and non-matching authors and