aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Mark Walters <markwalters1009@gmail.com>2012-03-15 18:28:10 +0000
committerGravatar David Bremner <bremner@debian.org>2012-04-29 15:54:13 -0300
commit94250ac2c59c899812ebc64a6c437c74ff08af30 (patch)
tree6f3ad1eb0d722b0aa6b6fa71ba4e89100e85db8e /emacs
parent77e128a0f0340185af6d393ee6e18e74b17c8de4 (diff)
emacs-show: open excluded matches if no other matches
Currently emacs show does not open matching but excluded messages. This is normally the desired behaviour but is probably not ideal if only excluded messages match. This patch opens all the matching (necessarily excluded) messages in this case and goes to the first one.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/notmuch-show.el14
1 files changed, 12 insertions, 2 deletions
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1e550998..2c0b767f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1568,6 +1568,11 @@ to show, nil otherwise."
(notmuch-show-message-adjust))
(goto-char (point-max)))))
+(defun notmuch-show-open-if-matched ()
+ "Open a message if it is matched (whether or not excluded)."
+ (let ((props (notmuch-show-get-message-properties)))
+ (notmuch-show-message-visible props (plist-get props :match))))
+
(defun notmuch-show-goto-first-wanted-message ()
"Move to the first open message and mark it read"
(goto-char (point-min))
@@ -1575,9 +1580,14 @@ to show, nil otherwise."
(notmuch-show-mark-read)
(notmuch-show-next-open-message))
(when (eobp)
+ ;; There are no matched non-excluded messages so open all matched
+ ;; (necessarily excluded) messages and go to the first.
+ (notmuch-show-mapc 'notmuch-show-open-if-matched)
+ (force-window-update)
(goto-char (point-min))
- (unless (notmuch-show-get-prop :match)
- (notmuch-show-next-matching-message))))
+ (if (notmuch-show-message-visible-p)
+ (notmuch-show-mark-read)
+ (notmuch-show-next-open-message))))
(defun notmuch-show-previous-open-message ()
"Show the previous open message."