Re: [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show...
authorMark Walters <markwalters1009@gmail.com>
Sat, 11 Feb 2012 22:26:09 +0000 (22:26 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:21 +0000 (09:44 -0800)
38/94b56c5c10ad4a0e984dd3ff1b817b3b441ed5 [new file with mode: 0644]

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