Sha256: 1dedd6dc600273c460189068332f328825741ec79e755169c93d8c694aa4ddc6

Contents?: true

Size: 1.09 KB

Versions: 37

Compression:

Stored size: 1.09 KB

Contents

module Redwood

class LabelSearchResultsMode < ThreadIndexMode
  def initialize labels
    @labels = labels
    opts = { :labels => @labels }
    opts[:load_deleted] = true if labels.include? :deleted
    opts[:load_spam] = true if labels.include? :spam
    super [], opts
  end

  register_keymap do |k|
    k.add :refine_search, "Refine search", '|'
  end

  def refine_search
    label_query = @labels.size > 1 ? "(#{@labels.join('||')})" : @labels.first
    query = BufferManager.ask :search, "refine query: ", "+label:#{label_query} "
    return unless query && query !~ /^\s*$/
    SearchResultsMode.spawn_from_query query
  end

  def is_relevant? m; @labels.all? { |l| m.has_label? l } end

  def self.spawn_nicely label
    label = LabelManager.label_for(label) unless label.is_a?(Symbol)
    case label
    when nil
    when :inbox
      BufferManager.raise_to_front InboxMode.instance.buffer
    else
      b, new = BufferManager.spawn_unless_exists("All threads with label '#{label}'") { LabelSearchResultsMode.new [label] }
      b.mode.load_threads :num => b.content_height if new
    end
  end
end

end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
sup-1.2 lib/sup/modes/label_search_results_mode.rb
sup-1.1 lib/sup/modes/label_search_results_mode.rb
sup-1.0 lib/sup/modes/label_search_results_mode.rb
sup-0.23 lib/sup/modes/label_search_results_mode.rb
sup-0.22.1 lib/sup/modes/label_search_results_mode.rb
sup-0.22.0 lib/sup/modes/label_search_results_mode.rb
sup-0.21.0 lib/sup/modes/label_search_results_mode.rb
sup-0.20.0 lib/sup/modes/label_search_results_mode.rb
sup-0.19.0 lib/sup/modes/label_search_results_mode.rb
sup-0.18.0 lib/sup/modes/label_search_results_mode.rb
sup-0.17.0 lib/sup/modes/label_search_results_mode.rb
sup-0.16.0 lib/sup/modes/label_search_results_mode.rb
sup-0.15.4 lib/sup/modes/label_search_results_mode.rb
sup-0.15.3 lib/sup/modes/label_search_results_mode.rb
sup-0.15.2 lib/sup/modes/label_search_results_mode.rb
sup-0.15.1 lib/sup/modes/label_search_results_mode.rb
sup-0.15.0 lib/sup/modes/label_search_results_mode.rb
sup-0.14.1.1 lib/sup/modes/label_search_results_mode.rb
sup-0.13.2.1 lib/sup/modes/label_search_results_mode.rb
sup-0.14.1 lib/sup/modes/label_search_results_mode.rb