- def load_threads opts={}
- n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
- load_n_threads_background n, :qobj => @qobj,
- :load_killed => true,
- :load_spam => false,
- :when_done =>(lambda do |num|
- opts[:when_done].call if opts[:when_done]
- if num > 0
- BufferManager.flash "Found #{num} threads"
- else
- BufferManager.flash "No matches"
- end
- end)
+ def self.spawn_from_query text
+ begin
+ qobj, extraopts = Index.parse_user_query_string(text)
+ return unless qobj
+ short_text = text.length < 20 ? text : text[0 ... 20] + "..."
+ mode = SearchResultsMode.new qobj, extraopts
+ BufferManager.spawn "search: \"#{short_text}\"", mode
+ mode.load_threads :num => mode.buffer.content_height
+ rescue Ferret::QueryParser::QueryParseException => e
+ BufferManager.flash "Couldn't parse query."
+ end