sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 630ffe9b14c9880c9bfe7f8180f46e913ed27703
parent ef020962c5155a2916cc45857a941abc3ca73aaa
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Wed, 19 Mar 2014 08:19:56 +0100

Merge #259: Move mark as read and archive to thread mode

Diffstat:
M lib/sup/modes/inbox_mode.rb | 42 ------------------------------------------
M lib/sup/modes/thread_index_mode.rb | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/lib/sup/modes/inbox_mode.rb b/lib/sup/modes/inbox_mode.rb
@@ -6,7 +6,6 @@ class InboxMode < ThreadIndexMode
   register_keymap do |k|
     ## overwrite toggle_archived with archive
     k.add :archive, "Archive thread (remove from inbox)", 'a'
-    k.add :read_and_archive, "Archive thread (remove from inbox) and mark read", 'A'
     k.add :refine_search, "Refine search", '|'
   end
 
@@ -64,47 +63,6 @@ class InboxMode < ThreadIndexMode
     threads.each { |t| Index.save_thread t }
   end
 
-  def read_and_archive
-    return unless cursor_thread
-    thread = cursor_thread # to make sure lambda only knows about 'old' cursor_thread
-
-    was_unread = thread.labels.member? :unread
-    UndoManager.register "reading and archiving thread" do
-      thread.apply_label :inbox
-      thread.apply_label :unread if was_unread
-      add_or_unhide thread.first
-      Index.save_thread thread
-    end
-
-    cursor_thread.remove_label :unread
-    cursor_thread.remove_label :inbox
-    hide_thread cursor_thread
-    regen_text
-    Index.save_thread thread
-  end
-
-  def multi_read_and_archive threads
-    old_labels = threads.map { |t| t.labels.dup }
-
-    threads.each do |t|
-      t.remove_label :unread
-      t.remove_label :inbox
-      hide_thread t
-    end
-    regen_text
-
-    UndoManager.register "reading and archiving #{threads.size.pluralize 'thread'}" do
-      threads.zip(old_labels).each do |t, l|
-        t.labels = l
-        add_or_unhide t.first
-        Index.save_thread t
-      end
-      regen_text
-    end
-
-    threads.each { |t| Index.save_thread t }
-  end
-
   def handle_unarchived_update sender, m
     add_or_unhide m
   end
diff --git a/lib/sup/modes/thread_index_mode.rb b/lib/sup/modes/thread_index_mode.rb
@@ -33,6 +33,7 @@ EOS
     k.add_multi "Load all threads (! to confirm) :", '!' do |kk|
       kk.add :load_all_threads, "Load all threads (may list a _lot_ of threads)", '!'
     end
+    k.add :read_and_archive, "Archive thread (remove from inbox) and mark read", 'A'
     k.add :cancel_search, "Cancel current search", :ctrl_g
     k.add :reload, "Refresh view", '@'
     k.add :toggle_archived, "Toggle archived status", 'a'
@@ -732,6 +733,47 @@ EOS
   end
   ignore_concurrent_calls :load_threads
 
+  def read_and_archive
+    return unless cursor_thread
+    thread = cursor_thread # to make sure lambda only knows about 'old' cursor_thread
+
+    was_unread = thread.labels.member? :unread
+    UndoManager.register "reading and archiving thread" do
+      thread.apply_label :inbox
+      thread.apply_label :unread if was_unread
+      add_or_unhide thread.first
+      Index.save_thread thread
+    end
+
+    cursor_thread.remove_label :unread
+    cursor_thread.remove_label :inbox
+    hide_thread cursor_thread
+    regen_text
+    Index.save_thread thread
+  end
+
+  def multi_read_and_archive threads
+    old_labels = threads.map { |t| t.labels.dup }
+
+    threads.each do |t|
+      t.remove_label :unread
+      t.remove_label :inbox
+      hide_thread t
+    end
+    regen_text
+
+    UndoManager.register "reading and archiving #{threads.size.pluralize 'thread'}" do
+      threads.zip(old_labels).each do |t, l|
+        t.labels = l
+        add_or_unhide t.first
+        Index.save_thread t
+      end
+      regen_text
+    end
+
+    threads.each { |t| Index.save_thread t }
+  end
+
   def resize rows, cols
     regen_text
     super