unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs-show: open excluded matches if no other matches
@ 2012-03-15 18:28 Mark Walters
  2012-04-12 19:08 ` Jameson Graef Rollins
  2012-04-12 19:10 ` Tomi Ollila
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Walters @ 2012-03-15 18:28 UTC (permalink / raw)
  To: notmuch

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.
---
 emacs/notmuch-show.el |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4a60631..bd4ba0f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1608,6 +1608,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))
@@ -1615,9 +1620,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."
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-13  9:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-15 18:28 [PATCH] emacs-show: open excluded matches if no other matches Mark Walters
2012-04-12 19:08 ` Jameson Graef Rollins
2012-04-12 19:20   ` Tomi Ollila
2012-04-13  8:57     ` Jani Nikula
2012-04-13  9:29       ` Mark Walters
2012-04-12 19:10 ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).