sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit c5b6e20d3be0391c324440be7c32a5baaffa1fd6
parent 7027f671c35f4b22c6af5ff0b1a58f79a34d41d0
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Wed, 16 Jan 2008 16:47:35 -0800

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.

Diffstat:
M lib/sup/tagger.rb | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git 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