From 6bbb91f8b64c20a491cc3501b625753f97e52882 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 29 May 2013 21:13:44 -0400 Subject: [PATCH] emacs: Retain text properties when toggling buttons Previously, we lost any text properties applied to part buttons or wash buttons when they were toggled because `insert' directly copies the text properties of the string being inserted. Fix this by capturing the properties applied to the button beforehand and re-applying them after inserting the new text. --- emacs/notmuch-show.el | 2 ++ emacs/notmuch-wash.el | 2 ++ 2 files changed, 4 insertions(+) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index b0a8d8ab..a080134f 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -559,10 +559,12 @@ message at DEPTH in the current thread." (new-start (button-start button)) (button-label (button-get button :base-label)) (old-point (point)) + (properties (text-properties-at (point))) (inhibit-read-only t)) (overlay-put overlay 'invisible (not show)) (goto-char new-start) (insert "[ " button-label (if show " ]" " (hidden) ]")) + (set-text-properties new-start (point) properties) (let ((old-end (button-end button))) (move-overlay button new-start (point)) (delete-region (point) old-end)) diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index 8a68819c..8fe91e14 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -104,9 +104,11 @@ lower).") (overlay (button-get cite-button 'overlay)) (button-label (notmuch-wash-button-label overlay)) (old-point (point)) + (properties (text-properties-at (point))) (inhibit-read-only t)) (goto-char new-start) (insert button-label) + (set-text-properties new-start (point) properties) (let ((old-end (button-end cite-button))) (move-overlay cite-button new-start (point)) (delete-region (point) old-end)) -- 2.43.0