From: Dmitry Kurochkin Date: Tue, 24 May 2011 23:02:43 +0000 (+0400) Subject: Carefully manage save/restore of point in `notmuch-wash-toggle-invisible-action'. X-Git-Tag: debian/0.6_254~115 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=b6862c7eb9bfb00183e568b40d77ea25ade21db2 Carefully manage save/restore of point in `notmuch-wash-toggle-invisible-action'. Before the change, save-excursion was used to save the point. But the marker saved by save-excursion was inside a region that was deleted, so that approach is unreliable, (leading to point jumping to a new position past the button). This patch instead saves point in an integer variable, and when restoring, carefully avoids moving point past the button, (in case the new button label is shorter than the old button label). --- diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index 8455eee0..e8134bf7 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -82,13 +82,14 @@ collapse the remaining lines into a button.") (let* ((new-start (button-start cite-button)) (overlay (button-get cite-button 'overlay)) (button-label (notmuch-wash-button-label overlay)) + (old-point (point)) (inhibit-read-only t)) - (save-excursion - (goto-char new-start) - (insert button-label) - (let ((old-end (button-end cite-button))) - (move-overlay cite-button new-start (point)) - (delete-region (point) old-end)))) + (goto-char new-start) + (insert button-label) + (let ((old-end (button-end cite-button))) + (move-overlay cite-button new-start (point)) + (delete-region (point) old-end)) + (goto-char (min old-point (1- (button-end cite-button))))) (force-window-update) (redisplay t))