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 1BCF1429E54 for ; Sat, 1 Jun 2013 09:46:43 -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 JqxFqtMLhy-d for ; Sat, 1 Jun 2013 09:46:35 -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 73550431FDE for ; Sat, 1 Jun 2013 09:46:35 -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 1Uiowp-0003YR-D8; Sat, 01 Jun 2013 17:46:31 +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 1Uiowp-0002l1-0a; Sat, 01 Jun 2013 17:46:31 +0100 From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements , Adam Wolfe Gordon Subject: [PATCH v4 6/5] emacs: show: lazy-part bugfix In-Reply-To: <1370074547-24677-1-git-send-email-markwalters1009@gmail.com> References: <1370074547-24677-1-git-send-email-markwalters1009@gmail.com> User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Sat, 01 Jun 2013 17:46:30 +0100 Message-ID: <87mwr97p95.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: 85f0f0cd402e6c847b54dfbcd16b6564 (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: Sat, 01 Jun 2013 16:46:43 -0000 Previously we inserted the lazy part at the start of the line after the part button. But if this line had some text properties (e.g. the colours for a following message header) then the lazy part gets these properties. Thus we start at the end of the part button line, insert a newline, insert the lazy part, and then delete the extra newline at the end of the part. --- I found a bug in the lazy-part patch set (v4): the problem can be seen if you find a multipart/alternative text/plain text/html message with a reply following it. Before this extra patch the lazy-part gets inserted with the wrong text properties: in particular it gets the special background colour that the headerline of a message gets in the show view. I think this was why I had the "lazy part" text before but this is probably better. I can fold this into the main series but I thought I would ask for comments on this change first. Best wishes Mark emacs/notmuch-show.el | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 92f481b..453ff54 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -818,9 +818,15 @@ message at DEPTH in the current thread." t)) (defun notmuch-show-lazy-part (part-args button) - ;; Insert the lazy part after the button for the part. + ;; Insert the lazy part after the button for the part. We would just + ;; move to the start of the new line following the button and insert + ;; the part but that point might have text properties (eg colours + ;; from a message header etc) so instead we start from the last + ;; character of the button by adding a newline and finish by + ;; removing the extra newline from the end of the part. (save-excursion - (goto-char (1+ (button-end button))) + (goto-char (button-end button)) + (insert "\n") (let* ((inhibit-read-only t) ;; We need to use markers for the start and end of the part ;; because the part insertion functions do not guarantee @@ -835,6 +841,8 @@ message at DEPTH in the current thread." (delete-region part-beg part-end) (apply #'notmuch-show-insert-bodypart-internal part-args) (indent-rigidly part-beg part-end depth)) + (goto-char part-end) + (delete-char 1) ;; Create the overlay. If the lazy-part turned out to be empty/not ;; showable this returns nil. (notmuch-show-create-part-overlays button part-beg part-end)))) -- 1.7.9.1