[PATCH v3 1/3] emacs: When refreshing a show buffer, only mark read when resetting state
Austin Clements
amdragon at MIT.EDU
Tue Feb 21 07:42:31 PST 2012
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 initial positioning
and read-marking out of notmuch-show-worker and into its caller.
Since notmuch-show-worker is now exclusively about building the show
buffer, we rename it to notmuch-show-build-buffer.
---
emacs/notmuch-show.el | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index aa9ccee..f759351 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1047,9 +1047,14 @@ 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-build-buffer)
-(defun notmuch-show-worker ()
+ ;; Move to the first open message and mark it read
+ (if (notmuch-show-message-visible-p)
+ (notmuch-show-mark-read)
+ (notmuch-show-next-open-message))))
+
+(defun notmuch-show-build-buffer ()
(let ((inhibit-read-only t))
(notmuch-show-mode)
@@ -1076,14 +1081,8 @@ function is used."
(run-hooks 'notmuch-show-hook))
- ;; Move straight to the first open message
- (unless (notmuch-show-message-visible-p)
- (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.
@@ -1130,9 +1129,14 @@ buffer is stored and re-applied after the refresh."
(if retain-state
(setq state (notmuch-show-capture-state)))
(erase-buffer)
- (notmuch-show-worker)
+ (notmuch-show-build-buffer)
(if state
- (notmuch-show-apply-state state))))
+ (notmuch-show-apply-state state)
+ ;; We're resetting state, so navigate to the first open message
+ ;; and mark it read, just like opening a new show buffer.
+ (if (notmuch-show-message-visible-p)
+ (notmuch-show-mark-read)
+ (notmuch-show-next-open-message)))))
(defvar notmuch-show-stash-map
(let ((map (make-sparse-keymap)))
--
1.7.7.3
More information about the notmuch
mailing list