If we retain state while refreshing a show buffer, it should not mark any messages read since it's not a navigation operation (it especially shouldn't mark the first message matching the query read, which is what it did previously). If the user or caller requests that refresh reset the state of the buffer, then we consider that a navigation operation, so we do mark the message under point after the refresh read. This is implemented by moving responsibility for read-marking out of notmuch-show-worker and into its caller. --- emacs/notmuch-show.el | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index aa9ccee..d036c54 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1047,7 +1047,10 @@ function is used." (setq notmuch-show-thread-id thread-id notmuch-show-parent-buffer parent-buffer notmuch-show-query-context query-context) - (notmuch-show-worker))) + (notmuch-show-worker) + + ;; Mark the first open message read + (notmuch-show-mark-read))) (defun notmuch-show-worker () (let ((inhibit-read-only t)) @@ -1081,9 +1084,7 @@ function is used." (notmuch-show-next-open-message)) ;; Set the header line to the subject of the first open message. - (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject))) - - (notmuch-show-mark-read))) + (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject))))) (defun notmuch-show-capture-state () "Capture the state of the current buffer. @@ -1132,7 +1133,10 @@ buffer is stored and re-applied after the refresh." (erase-buffer) (notmuch-show-worker) (if state - (notmuch-show-apply-state state)))) + (notmuch-show-apply-state state) + ;; Refreshing with state reset navigates to the first open + ;; message, so mark read like any other navigation operation. + (notmuch-show-mark-read)))) (defvar notmuch-show-stash-map (let ((map (make-sparse-keymap))) -- 1.7.7.3