sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 0c67162c72d7f837e32d758a15abdf7953d94db1
parent c924164c22a7bdb3fb66f9ce4ca5ac8b19dfcccf
Author: Carl Worth <cworth@cworth.org>
Date:   Wed, 26 Aug 2009 10:17:20 -0700

add a refine_search command to InboxMode

This is just a copy of SearchResultsMode's refine_search command.
A much cleaner, but more involved, approach would be to rework
InboxMode to derive from SearchResultsMode in the first place.

Diffstat:
M lib/sup/modes/inbox-mode.rb | 7 +++++++
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb
@@ -7,6 +7,7 @@ class InboxMode < ThreadIndexMode
     ## overwrite toggle_archived with archive
     k.add :archive, "Archive thread (remove from inbox)", 'a'
     k.add :read_and_archive, "Archive thread (remove from inbox) and mark read", 'A'
+    k.add :refine_search, "Refine search", '|'
   end
 
   def initialize
@@ -17,6 +18,12 @@ class InboxMode < ThreadIndexMode
 
   def is_relevant? m; (m.labels & [:spam, :deleted, :killed, :inbox]) == Set.new([:inbox]) end
 
+  def refine_search
+    text = BufferManager.ask :search, "refine query: ", "label:inbox -label:spam -label:deleted -label:killed "
+    return unless text && text !~ /^\s*$/
+    SearchResultsMode.spawn_from_query text
+  end
+
   ## label-list-mode wants to be able to raise us if the user selects
   ## the "inbox" label, so we need to keep our singletonness around
   def self.instance; @@instance; end