From fa48e158820fd931fb6ea2f003a4fcdb1a4f1e8a Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 11 Feb 2012 22:26:09 +0000 Subject: [PATCH] Re: [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'. --- 38/94b56c5c10ad4a0e984dd3ff1b817b3b441ed5 | 235 ++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 38/94b56c5c10ad4a0e984dd3ff1b817b3b441ed5 diff --git a/38/94b56c5c10ad4a0e984dd3ff1b817b3b441ed5 b/38/94b56c5c10ad4a0e984dd3ff1b817b3b441ed5 new file mode 100644 index 000000000..52c3a4027 --- /dev/null +++ b/38/94b56c5c10ad4a0e984dd3ff1b817b3b441ed5 @@ -0,0 +1,235 @@ +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 42367431FB6 + for ; Sat, 11 Feb 2012 14:24:58 -0800 (PST) +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 l78Gjk3UDCac for ; + Sat, 11 Feb 2012 14:24:57 -0800 (PST) +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 1D490431FAE + for ; Sat, 11 Feb 2012 14:24:57 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1RwLNC-0002yX-Os; Sat, 11 Feb 2012 22:24:53 +0000 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1RwLNC-0004Pv-9I; Sat, 11 Feb 2012 22:24:50 +0000 +From: Mark Walters +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 1/2] emacs: Use text properties rather than overlays in + `notmuch-show-mode'. +In-Reply-To: <1328604377-20121-2-git-send-email-dme@dme.org> +References: <1327405007-4026-1-git-send-email-dme@dme.org> + <1328604377-20121-1-git-send-email-dme@dme.org> + <1328604377-20121-2-git-send-email-dme@dme.org> +User-Agent: Notmuch/0.11.1+172~g6a5d2c5 (http://notmuchmail.org) Emacs/23.2.1 + (i486-pc-linux-gnu) +Date: Sat, 11 Feb 2012 22:26:09 +0000 +Message-ID: <87hayxm2gu.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 6e1d7473f94427528500a7fc9a0db091 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +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 -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 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: Sat, 11 Feb 2012 22:24:58 -0000 + + +Hi + +I looked at this and think its ok except for one trivial (but +significant) rebase error. + +Best wishes + +Mark + +On Tue, 7 Feb 2012 08:46:16 +0000, David Edmondson wrote: +> Except for where invisibility is involved, replace the use of overlays +> in `notmuch-show-mode' with text properties, which are more efficient +> and can be merged together more effectively. +> --- +> emacs/notmuch-show.el | 62 +++++++++++++++++++++++++++++++----------------- +> emacs/notmuch-wash.el | 8 ++++- +> 2 files changed, 46 insertions(+), 24 deletions(-) +> +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index 7469e2e..bc1e7db 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -264,10 +264,10 @@ operation on the contents of the current buffer." +> (t +> 'message-header-other)))) +> +> - (overlay-put (make-overlay (point) (re-search-forward ":")) +> - 'face 'message-header-name) +> - (overlay-put (make-overlay (point) (re-search-forward ".*$")) +> - 'face face))) +> + (put-text-property (point) (re-search-forward ":") +> + 'face 'message-header-name) +> + (put-text-property (point) (re-search-forward ".*$") +> + 'face face))) +> +> (defun notmuch-show-colour-headers () +> "Apply some colouring to the current headers." +> @@ -284,12 +284,11 @@ operation on the contents of the current buffer." +> "Update the displayed tags of the current message." +> (save-excursion +> (goto-char (notmuch-show-message-top)) +> - (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) +> - (let ((inhibit-read-only t)) +> - (replace-match (concat "(" +> - (propertize (mapconcat 'identity tags " ") +> - 'face 'notmuch-tag-face) +> - ")")))))) +> + (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) +> + (let ((inhibit-read-only t)) +> + (replace-match (propertize (mapconcat 'identity tags " ") +> + 'face '(notmuch-tag-face notmuch-message-summary-face)) +> + nil nil nil 1))))) +> +> (defun notmuch-show-clean-address (address) +> "Try to clean a single email ADDRESS for display. Return +> @@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails." +> "Insert a notmuch style headerline based on HEADERS for a +> message at DEPTH in the current thread." +> (let ((start (point))) +> - (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth)) +> - (notmuch-show-clean-address (plist-get headers :From)) +> - " (" +> - date +> - ") (" +> - (propertize (mapconcat 'identity tags " ") +> - 'face 'notmuch-tag-face) +> - ")\n") +> - (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) +> + (insert +> + (propertize (concat (notmuch-show-clean-address (plist-get headers :From)) +> + " (" +> + date +> + ") (") +> + 'face 'notmuch-message-summary-face) +> + (propertize (mapconcat 'identity tags " ") +> + 'face '(notmuch-tag-face notmuch-message-summary-face)) +> + (propertize ")\n" +> + 'face 'notmuch-message-summary-face)) +> + +> + ;; Ensure that any insertions at the start of this line (usually +> + ;; just spaces for indentation purposes) inherit the face of the +> + ;; rest of the line... +> + (put-text-property start (1+ start) +> + 'front-sticky '(face)) +> + ;; ...and that insertions at the end of this region do _not_ +> + ;; inherit the face of the rest of this line. +> + (put-text-property (1- (point)) (point) +> + 'rear-nonsticky '(face)))) +> +> (defun notmuch-show-insert-header (header header-value) +> "Insert a single header." +> @@ -796,8 +806,15 @@ current buffer, if possible." +> (defun notmuch-show-insert-bodypart (msg part depth) +> "Insert the body part PART at depth DEPTH in the current thread." +> (let ((content-type (downcase (plist-get part :content-type))) +> - (nth (plist-get part :id))) +> - (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)) +> + (nth (plist-get part :id)) +> + (start (point))) +> + (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type) +> + +> + ;; Ensure that face properties applied to text in the buffer by +> + ;; the part handler don't leak into the following text. +> + (put-text-property start (point-max) +> + 'rear-nonsticky '(face))) +> + +> ;; Some of the body part handlers leave point somewhere up in the +> ;; part, so we make sure that we're down at the end. +> (goto-char (point-max)) +> @@ -889,7 +906,8 @@ current buffer, if possible." +> (setq content-end (point-marker)) +> +> ;; Indent according to the depth in the thread. +> - (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth)) +> + (indent-rigidly message-start message-end +> + (* notmuch-show-indent-messages-width depth)) +> +> (setq message-end (point-max-marker)) + +I think the setq has to come before the indent-rigidly. (Also I think +there is a whitespace error in the second line of the indent-rigidly.) + +> +> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el +> index 56981d0..29a9d45 100644 +> --- a/emacs/notmuch-wash.el +> +++ b/emacs/notmuch-wash.el +> @@ -187,7 +187,9 @@ that PREFIX should not include a newline." +> (let* ((cite-start (match-beginning 0)) +> (cite-end (match-end 0)) +> (cite-lines (count-lines cite-start cite-end))) +> - (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text) +> + (put-text-property cite-start cite-end 'face 'message-cited-text) +> + ;; Ensure that the next line doesn't inherit our face. +> + (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face)) +> (when (> cite-lines (+ notmuch-wash-citation-lines-prefix +> notmuch-wash-citation-lines-suffix +> 1)) +> @@ -209,7 +211,9 @@ that PREFIX should not include a newline." +> (sig-end-marker (make-marker))) +> (set-marker sig-start-marker sig-start) +> (set-marker sig-end-marker (point-max)) +> - (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text) +> + (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text) +> + ;; Ensure that the next line doesn't inherit our face. +> + (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face)) +> (notmuch-wash-region-to-button +> msg sig-start-marker sig-end-marker +> "signature")))))) +> -- +> 1.7.8.3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2