From: wmorgan Date: Sun, 9 Dec 2007 19:12:19 +0000 (+0000) Subject: add tag by match to thread-index-mode X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=924852255e80114d271204a7c3456df49bc6c96d;p=sup add tag by match to thread-index-mode git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@752 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index 8dec42d..8727e24 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -31,6 +31,7 @@ EOS k.add :forward, "Forward latest message in a thread", 'f' k.add :toggle_tagged, "Tag/untag selected thread", 't' k.add :toggle_tagged_all, "Tag/untag all threads", 'T' + k.add :tag_matching, "Tag/untag all threads", 'g' k.add :apply_to_tagged, "Apply next command to all tagged threads", ';' end @@ -351,6 +352,14 @@ EOS regen_text end + def tag_matching + query = BufferManager.ask :search, "tag threads matching: " + return if query.nil? || query.empty? + query = /#{query}/i + @mutex.synchronize { @threads.each { |t| @tags.tag t if thread_match?(t, query) } } + regen_text + end + def apply_to_tagged; @tags.apply_to_tagged; end def edit_labels @@ -465,6 +474,12 @@ EOS protected + ## used to tag threads by query. this can be made a lot more sophisticated, + ## but for right now we'll do the obvious this. + def thread_match? t, query + t.snippet =~ query || t.participants.any? { |x| x.longname =~ query } + end + def size_widget_for_thread t HookManager.run("index-mode-size-widget", :thread => t) || default_size_widget_for(t) end diff --git a/lib/sup/tagger.rb b/lib/sup/tagger.rb index 464f1ac..6e4bab3 100644 --- a/lib/sup/tagger.rb +++ b/lib/sup/tagger.rb @@ -8,6 +8,8 @@ class Tagger def tagged? o; @tagged[o]; end def toggle_tag_for o; @tagged[o] = !@tagged[o]; end + def tag o; @tagged[o] = true; end + def untag o; @tagged[o] = false; end def drop_all_tags; @tagged.clear; end def drop_tag_for o; @tagged.delete o; end