sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit ea4f9c9aeca93104ddfd4804cec9e2004f7fca0f
parent 974c3731a0a91fca5dfef766d519ea108f0cbb68
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Wed, 24 Jan 2007 21:20:04 +0000

added deletion (but it doesn't do anything different from :spam right now)


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

Diffstat:
M doc/FAQ.txt | 15 +++++++++++++++
M lib/sup/index.rb | 1 +
M lib/sup/label.rb | 4 ++--
M lib/sup/modes/inbox-mode.rb | 2 --
M lib/sup/modes/thread-index-mode.rb | 14 ++++++++++++++
5 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/doc/FAQ.txt b/doc/FAQ.txt
@@ -22,6 +22,21 @@ A: You can manually mark messages as spam, which prevents them from
    showing up in future searches, but that's all that Sup does. Spam
    filtering should be done by a dedicated tool like SpamAssassin.
 
+Q: How do I delete a message?
+A: Press the 'd' key.
+
+Q: But I want to delete it for real, not just add a 'deleted' flag in
+   the index. I want it gone from disk!
+A: Deleting a message is an old-fashioned concept. In the modern
+   world, disk space is cheap enough that you should never have to
+   delete a message. If it's spam, save it for future analysis.
+
+Q: C'mon, really!
+A: Ok, at some point I plan to have a batch deletion tool that will
+   run through a source and delete all messages that have a 'spam' or
+   'deleted' tags (and, for mbox sources, will update the offsets of
+   all later messages). But that doesn't exist yet.
+
 Q: What are all these "Redwood" references I see in the code?
 A: That was Sup's original name. (Think pine, elm. Although I am a
    Mutt user, I couldn't think of a good progression there.) But it was
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -294,6 +294,7 @@ protected
     end
         
     query.add_query Ferret::Search::TermQuery.new("label", "spam"), :must_not unless opts[:load_spam] || labels.include?(:spam)
+    query.add_query Ferret::Search::TermQuery.new("label", "deleted"), :must_not unless opts[:load_deleted] || labels.include?(:deleted)
     query.add_query Ferret::Search::TermQuery.new("label", "killed"), :must_not unless opts[:load_killed] || labels.include?(:killed)
     query
   end
diff --git a/lib/sup/label.rb b/lib/sup/label.rb
@@ -5,10 +5,10 @@ class LabelManager
 
   ## labels that have special semantics. user will be unable to
   ## add/remove these via normal label mechanisms.
-  RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent ]
+  RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted ]
 
   ## labels which it nonetheless makes sense to search for by
-  LISTABLE_LABELS = [ :starred, :spam, :draft, :sent ]
+  LISTABLE_LABELS = [ :starred, :spam, :draft, :sent, :deleted ]
 
   ## labels that will never be displayed to the user
   HIDDEN_LABELS = [ :starred, :unread ]
diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb
@@ -33,8 +33,6 @@ class InboxMode < ThreadIndexMode
   def load_threads opts={}
     n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
     load_n_threads_background n, :label => :inbox,
-                                 :load_killed => false,
-                                 :load_spam => false,
                                  :when_done => (lambda do |num|
       opts[:when_done].call if opts[:when_done]
       BufferManager.flash "Added #{num} threads."
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -17,6 +17,7 @@ class ThreadIndexMode < LineCursorMode
     k.add :edit_labels, "Edit or add labels for a thread", 'l'
     k.add :edit_message, "Edit message (drafts only)", 'e'
     k.add :mark_as_spam, "Mark thread as spam", 'S'
+    k.add :delete, "Mark thread for deletion", 'd'
     k.add :kill, "Kill thread (never to be seen in inbox again)", '&'
     k.add :save, "Save changes now", '$'
     k.add :jump_to_next_new, "Jump to next new thread", :tab
@@ -194,6 +195,19 @@ class ThreadIndexMode < LineCursorMode
     regen_text
   end
 
+  def delete
+    t = @threads[curpos] or return
+    multi_delete [t]
+  end
+
+  def multi_delete threads
+    threads.each do |t|
+      t.toggle_label :deleted
+      hide_thread t
+    end
+    regen_text
+  end
+
   def kill
     t = @threads[curpos] or return
     multi_kill [t]