commit b76b7a9600583ce25560a759a3fcd237e707ebce
parent 9a544e3d2fca52eaa493e2585d475eb239f3bd26
Author: Whyme Lyu <callme5long@gmail.com>
Date: Sun, 14 Jul 2013 20:38:35 +0800
Collect query prefixes in Index::COMPL_PREFIXES
Diffstat:
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/bin/sup b/bin/sup
@@ -291,7 +291,7 @@ begin
when :search
completions = LabelManager.all_labels.map { |l| "label:#{LabelManager.string_for l}" }
completions = completions.each { |l| l.force_encoding 'UTF-8' if l.respond_to?(:encoding) }
- completions += ["from:", "to:", "after:", "before:", "date:", "limit:", "AND", "OR", "NOT"]
+ completions += Index::COMPL_PREFIXES
query = BufferManager.ask_many_with_completions :search, "Search all messages (enter for saved searches): ", completions
unless query.nil?
if query.empty?
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -352,6 +352,17 @@ EOS
PREFIX = NORMAL_PREFIX.merge BOOLEAN_PREFIX
+ COMPL_OPERATORS = %w[AND OR NOT]
+ COMPL_PREFIXES = (
+ %w[
+ from to
+ is has label
+ filename filetypem
+ before on in during after
+ limit
+ ] + NORMAL_PREFIX.keys + BOOLEAN_PREFIX.keys
+ ).map{|p|"#{p}:"} + COMPL_OPERATORS
+
## parse a query string from the user. returns a query object
## that can be passed to any index method with a 'query'
## argument.