sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 0b9f650d6f20e547c4258a5885afe37bf8a86961
parent 6afbce7e388901b5d7eef2bdfc7120dbaa443a13
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Thu, 19 Nov 2009 23:43:00 -0500

Merge branch 'thread-view-mode-undo'

Diffstat:
M lib/sup/modes/thread-view-mode.rb | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -249,7 +249,8 @@ EOS
   end    
 
   def edit_labels
-    reserved_labels = @thread.labels.select { |l| LabelManager::RESERVED_LABELS.include? l }
+    old_labels = @thread.labels
+    reserved_labels = old_labels.select { |l| LabelManager::RESERVED_LABELS.include? l }
     new_labels = BufferManager.ask_for_labels :label, "Labels for thread: ", @thread.labels
 
     return unless new_labels
@@ -257,6 +258,10 @@ EOS
     new_labels.each { |l| LabelManager << l }
     update
     UpdateManager.relay self, :labeled, @thread.first
+    UndoManager.register "labeling thread" do
+      @thread.labels = old_labels
+      UpdateManager.relay self, :labeled, @thread.first
+    end
   end
 
   def toggle_starred
@@ -471,6 +476,10 @@ EOS
     dispatch op do
       @thread.remove_label :inbox
       UpdateManager.relay self, :archived, @thread.first
+      UndoManager.register "archiving 1 thread" do
+        @thread.apply_label :inbox
+        UpdateManager.relay self, :unarchived, @thread.first
+      end
     end
   end
 
@@ -478,6 +487,10 @@ EOS
     dispatch op do
       @thread.apply_label :spam
       UpdateManager.relay self, :spammed, @thread.first
+      UndoManager.register "marking 1 thread as spam" do
+        @thread.remove_label :spam
+        UpdateManager.relay self, :unspammed, @thread.first
+      end
     end
   end
 
@@ -485,6 +498,10 @@ EOS
     dispatch op do
       @thread.apply_label :deleted
       UpdateManager.relay self, :deleted, @thread.first
+      UndoManager.register "deleting 1 thread" do
+        @thread.remove_label :deleted
+        UpdateManager.relay self, :undeleted, @thread.first
+      end
     end
   end