EOS
opt :list_hooks, "List all hooks and descriptions thereof, and quit."
opt :no_threads, "Turn of threading. Helps with debugging. (Necessarily disables background polling for new messages.)"
+ opt :search, "Search for threads ", :type => String
end
if $opts[:list_hooks]
Index.start_lock_update_thread
end
+ if $opts[:search]
+ SearchResultsMode.spawn_from_query $opts[:search]
+ end
+
until $exception || SuicideManager.die?
c = Ncurses.nonblocking_getch
next unless c
b = bm.spawn_unless_exists("Contact List") { ContactListMode.new }
b.mode.load_in_background
when :search
- SearchResultsMode.spawn_by_query
+ query = BufferManager.ask :search, "query: "
+ next unless query && query !~ /^\s*$/
+ SearchResultsMode.spawn_from_query query
when :list_labels
labels = LabelManager.listable_labels.map { |l| LabelManager.string_for l }
user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels
end
def refine_search
- SearchResultsMode.spawn_by_query(@qobj.to_s + " ")
+ query = BufferManager.ask :search, "query: ", (@qobj.to_s + " ")
+ return unless query && query !~ /^\s*$/
+ SearchResultsMode.spawn_from_query query
end
## a proper is_relevant? method requires some way of asking ferret
## the message, and search against it to see if i have > 0 results,
## but that seems pretty insane.
- def self.spawn_by_query default=""
- text = BufferManager.ask :search, "query: ", default
- return unless text && text !~ /^\s*$/
-
+ def self.spawn_from_query text
begin
qobj = Index.parse_user_query_string text
short_text = text.length < 20 ? text : text[0 ... 20] + "..."