From c5b6e20d3be0391c324440be7c32a5baaffa1fd6 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Wed, 16 Jan 2008 16:47:35 -0800 Subject: [PATCH] Tagger#apply_to_tagged can take an arbitrary action With this change, applying operations to tagged objects can be short-circuited by passing the desired action directly to #apply_to_tagged, rather than requiring it to interactive prompt the user for a command. This class could probably use a little restructuring to divorce it from Mode. --- lib/sup/tagger.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/sup/tagger.rb b/lib/sup/tagger.rb index 6e4bab3..3e72463 100644 --- a/lib/sup/tagger.rb +++ b/lib/sup/tagger.rb @@ -13,7 +13,7 @@ class Tagger def drop_all_tags; @tagged.clear; end def drop_tag_for o; @tagged.delete o; end - def apply_to_tagged + def apply_to_tagged action=nil targets = @tagged.select_by_value num_tagged = targets.size if num_tagged == 0 @@ -22,10 +22,14 @@ class Tagger end noun = num_tagged == 1 ? "thread" : "threads" - c = BufferManager.ask_getch "apply to #{num_tagged} tagged #{noun}:" - return if c.nil? # user cancelled - if(action = @mode.resolve_input(c)) + unless action + c = BufferManager.ask_getch "apply to #{num_tagged} tagged #{noun}:" + return if c.nil? # user cancelled + action = @mode.resolve_input c + end + + if action tagged_sym = "multi_#{action}".intern if @mode.respond_to? tagged_sym @mode.send tagged_sym, targets -- 2.45.2