[PATCH v4 6/5] emacs: show: lazy-part bugfix
Mark Walters
markwalters1009 at gmail.com
Sat Jun 1 09:46:30 PDT 2013
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
More information about the notmuch
mailing list