unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org,
	Austin Clements <aclements@csail.mit.edu>,
	Adam Wolfe Gordon <awg+notmuch@xvx.ca>
Subject: [PATCH v4 6/5] emacs: show: lazy-part bugfix
Date: Sat, 01 Jun 2013 17:46:30 +0100	[thread overview]
Message-ID: <87mwr97p95.fsf@qmul.ac.uk> (raw)
In-Reply-To: <1370074547-24677-1-git-send-email-markwalters1009@gmail.com>


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

  parent reply	other threads:[~2013-06-01 16:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-01  8:15 [PATCH v4 0/5] emacs: show: lazy handling of hidden parts Mark Walters
2013-06-01  8:15 ` [PATCH v4 1/5] emacs: show: fake wash parts are handled at insert-bodypart level Mark Walters
2013-06-01  8:15 ` [PATCH v4 2/5] emacs: show: move the insertion of the header button to the top level Mark Walters
2013-06-01  8:15 ` [PATCH v4 3/5] emacs: show: pass button to create-overlays Mark Walters
2013-06-01  8:15 ` [PATCH v4 4/5] emacs: show: modify the way hidden state is recorded Mark Walters
2013-06-01  8:15 ` [PATCH v4 5/5] emacs: show: implement lazy hidden part handling Mark Walters
2013-06-01 16:46 ` Mark Walters [this message]
2013-06-10  2:39 ` [PATCH v4 0/5] emacs: show: lazy handling of hidden parts Austin Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwr97p95.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=aclements@csail.mit.edu \
    --cc=awg+notmuch@xvx.ca \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).