]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-show.el
emacs: Reverse the meaning of notmuch-show-refresh-view's argument
[notmuch] / emacs / notmuch-show.el
index aa98eff8a8850ae8ad633afa8a90ea6b8d5730c3..dd1fb8313604c8720e8d48ca610893e2dc420d74 100644 (file)
@@ -990,7 +990,7 @@ current buffer, if possible."
   (message (if notmuch-show-process-crypto
               "Processing cryptographic MIME parts."
             "Not processing cryptographic MIME parts."))
-  (notmuch-show-refresh-view t))
+  (notmuch-show-refresh-view))
 
 (defun notmuch-show-toggle-elide-non-matching ()
   "Toggle the display of non-matching messages."
@@ -999,7 +999,7 @@ current buffer, if possible."
   (message (if notmuch-show-elide-non-matching-messages
               "Showing matching messages only."
             "Showing all messages."))
-  (notmuch-show-refresh-view t))
+  (notmuch-show-refresh-view))
 
 (defun notmuch-show-toggle-thread-indentation ()
   "Toggle the indentation of threads."
@@ -1008,7 +1008,7 @@ current buffer, if possible."
   (message (if notmuch-show-indent-content
               "Content is indented."
             "Content is not indented."))
-  (notmuch-show-refresh-view t))
+  (notmuch-show-refresh-view))
 
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
@@ -1080,9 +1080,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)
@@ -1109,14 +1114,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.
@@ -1151,21 +1150,26 @@ This includes:
       (message "Previously current message not found."))
     (notmuch-show-message-adjust)))
 
-(defun notmuch-show-refresh-view (&optional retain-state)
+(defun notmuch-show-refresh-view (&optional reset-state)
   "Refresh the current view.
 
 Refreshes the current view, observing changes in display
-preferences. If RETAIN-STATE is non-nil then the state of the
-buffer is stored and re-applied after the refresh."
+preferences. If invoked with a prefix argument (or RESET-STATE is
+non-nil) then the state of the buffer (open/closed messages) is
+reset based on the original query."
   (interactive "P")
   (let ((inhibit-read-only t)
-       state)
-    (if retain-state
-       (setq state (notmuch-show-capture-state)))
+       (state (unless reset-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)))