]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-show.el
Merge branch 'release'
[notmuch] / emacs / notmuch-show.el
index dd1fb8313604c8720e8d48ca610893e2dc420d74..4a60631002590e6b26d7dc0e76344751d5a04cb2 100644 (file)
@@ -981,7 +981,8 @@ current buffer, if possible."
 
     ;; Message visibility depends on whether it matched the search
     ;; criteria.
-    (notmuch-show-message-visible msg (plist-get msg :match))))
+    (notmuch-show-message-visible msg (and (plist-get msg :match)
+                                          (not (plist-get msg :excluded))))))
 
 (defun notmuch-show-toggle-process-crypto ()
   "Toggle the processing of cryptographic MIME parts."
@@ -1081,11 +1082,7 @@ function is used."
          notmuch-show-parent-buffer parent-buffer
          notmuch-show-query-context query-context)
     (notmuch-show-build-buffer)
-
-    ;; 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))))
+    (notmuch-show-goto-first-wanted-message)))
 
 (defun notmuch-show-build-buffer ()
   (let ((inhibit-read-only t))
@@ -1114,7 +1111,7 @@ function is used."
 
       (run-hooks 'notmuch-show-hook))
 
-    ;; Set the header line to the subject of the first open message.
+    ;; Set the header line to the subject of the first message.
     (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))))
 
 (defun notmuch-show-capture-state ()
@@ -1167,9 +1164,7 @@ reset based on the original query."
        (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)))))
+      (notmuch-show-goto-first-wanted-message))))
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
@@ -1601,6 +1596,29 @@ to show, nil otherwise."
        (goto-char (point-max))))
     r))
 
+(defun notmuch-show-next-matching-message ()
+  "Show the next matching message."
+  (interactive)
+  (let (r)
+    (while (and (setq r (notmuch-show-goto-message-next))
+               (not (notmuch-show-get-prop :match))))
+    (if r
+       (progn
+         (notmuch-show-mark-read)
+         (notmuch-show-message-adjust))
+      (goto-char (point-max)))))
+
+(defun notmuch-show-goto-first-wanted-message ()
+  "Move to the first open message and mark it read"
+  (goto-char (point-min))
+  (if (notmuch-show-message-visible-p)
+      (notmuch-show-mark-read)
+    (notmuch-show-next-open-message))
+  (when (eobp)
+    (goto-char (point-min))
+    (unless (notmuch-show-get-prop :match)
+      (notmuch-show-next-matching-message))))
+
 (defun notmuch-show-previous-open-message ()
   "Show the previous open message."
   (interactive)
@@ -1672,7 +1690,7 @@ TAG-CHANGES is a list of tag operations for `notmuch-tag'."
     (apply 'notmuch-show-tag-message tag-changes)))
 
 (defun notmuch-show-tag-all (&rest tag-changes)
-  "Change tags for all messages in the current thread.
+  "Change tags for all messages in the current buffer.
 
 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
   (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
@@ -1765,13 +1783,13 @@ buffer."
     (notmuch-show-tag-all (concat op "inbox"))))
 
 (defun notmuch-show-archive-thread-then-next ()
-  "Archive each message in thread, then show next thread from search."
+  "Archive all messages in the current buffer, then show next thread from search."
   (interactive)
   (notmuch-show-archive-thread)
   (notmuch-show-next-thread t))
 
 (defun notmuch-show-archive-thread-then-exit ()
-  "Archive each message in thread, then exit back to search results."
+  "Archive all messages in the current buffer, then exit back to search results."
   (interactive)
   (notmuch-show-archive-thread)
   (notmuch-show-next-thread))