]> git.cworth.org Git - sup/commitdiff
Add a refine_search command to InboxMode
authorCarl Worth <cworth@cworth.org>
Wed, 26 Aug 2009 17:17:20 +0000 (10:17 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 17 Sep 2009 16:31:52 +0000 (09:31 -0700)
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.

lib/sup/modes/inbox-mode.rb

index ba095dab7c09696f60efb7e68c993d614da9e7b8..51f3a515c63949f31a959e0b0aaa7e70779459d4 100644 (file)
@@ -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 AND "
+    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