sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 73d08e78060a37a0bfc9b3f1ccf2ee6d1e57df14
parent 00bd7e6466f2fd698d5d3389072de37f74736f01
Author: Timon Vonk <timonv@gmail.com>
Date:   Fri, 14 Mar 2014 16:46:29 +0100

Move mark as read and archive to thread mode

This allows me to do searches to refine the crap in my inbox, and
-a them right away, instead of `| => is:unread label: =>
-T =N => | -label: | -T =a`

All I did was copy over the code to Thread Index Mode and test it. Would
love to write some tests for this if required.

Cheers guys, love sup :-)

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