sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 9cc5af0aeecef802cbbbc078692163b8bf0dbe4b
parent 4f60a9edc6ed003c69c0200dae955522a81ed5d8
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Mon, 12 Feb 2007 22:56:52 +0000

final (?) 0.0.7 updates

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@323 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M History.txt | 7 ++++---
M doc/TODO | 5 +----
M lib/sup.rb | 2 +-
M lib/sup/modes/inbox-mode.rb | 8 +++++---
M lib/sup/modes/thread-index-mode.rb | 24 +++++++++++++++++-------
M lib/sup/thread.rb | 6 ++++++
6 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/History.txt b/History.txt
@@ -1,9 +1,10 @@
-== 0.0.7 / XXXXXX
-* Moving messages between sources now preserves state.
+== 0.0.7 / 2007-02-12
 * Split sup-import into two bits: sup-import and sup-add.
 * Command-line arguments now handled by trollop.
 * Better error handling for IMAP and svn+ssh.
-* New commands in thread-view-mode
+* Messages can now be moved between sources while preserving all
+  message state.
+* New commands in thread-view-mode:
   - 'a' to add an email to the addressbook
   - 'S' to search for all email to/from an email address
   - 'A' to kill buffer and archive thread in one swell foop
diff --git a/doc/TODO b/doc/TODO
@@ -1,7 +1,3 @@
-for 0.0.7
-----------------
-de-archived messages should be auto-added to inbox
-
 for 0.0.8
 ---------
 message attachments
@@ -34,6 +30,7 @@ annotations on messages
 pop
 be able to mark individual messages as spam in thread-view-mode
 toggle wrapping
+maybe: de-archived messages auto-added to inbox
 
 done
 ----
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -13,7 +13,7 @@ class Object
 end
 
 module Redwood
-  VERSION = "0.0.6"
+  VERSION = "0.0.7"
 
   BASE_DIR   = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup")
   CONFIG_FN  = File.join(BASE_DIR, "config.yaml")
diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb
@@ -29,9 +29,11 @@ class InboxMode < ThreadIndexMode
     hide_thread t if contains_thread? t
   end
 
-  def handle_unarchived_update sender, t
-    ## XXX todo: fill me in
-  end
+# not quite working, and not sure if i like it anyways
+#   def handle_unarchived_update sender, t
+#     Redwood::log "unarchived #{t.subj}"
+#     show_thread t
+#   end
 
   def status
     super + "    #{Index.size} messages in index"
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -82,18 +82,19 @@ class ThreadIndexMode < LineCursorMode
   end
   
   def handle_starred_update sender, m
-    return unless(t = @ts.thread_for m)
-    update_text_for_line @lines[t]
+    t = @ts.thread_for(m) or return
+    l = @lines[t] or return
+    update_text_for_line l
     BufferManager.draw_screen
   end
 
   def handle_read_update sender, t
-    return unless @lines[t]
+    l = @lines[t] or return
     update_text_for_line @lines[t]
     BufferManager.draw_screen
   end
 
-  def handle_archived_update *a; handle_read_update *a; end
+  def handle_archived_update *a; handle_read_update(*a); end
 
   ## overwrite me!
   def is_relevant? m; false; end
@@ -155,10 +156,10 @@ class ThreadIndexMode < LineCursorMode
   def actually_toggle_archived t
     if t.has_label? :inbox
       t.remove_label :inbox
-      UpdateManager.relay self, :unarchived, t
-    else
-      t.add_label :inbox
       UpdateManager.relay self, :archived, t
+    else
+      t.apply_label :inbox
+      UpdateManager.relay self, :unarchived, t
     end
   end
 
@@ -383,6 +384,15 @@ protected
     @tags.drop_tag_for t
   end
 
+  def show_thread t
+    if @hidden_threads[t]
+      @hidden_threads.delete t
+    else
+      @ts.add_thread t
+    end
+    update
+  end
+
   def update_text_for_line l
     return unless l # not sure why this happens, but it does, occasionally
     @text[l] = text_for_thread @threads[l]
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -303,6 +303,12 @@ class ThreadSet
     end
   end
 
+  ## merges in a pre-loaded thread
+  def add_thread t
+    raise "duplicate" if @subj_thread.values.member? t
+    t.each { |m, *o| add_message m }
+  end
+
   def is_relevant? m
     m.refs.any? { |ref_id| @messages[ref_id] }
   end