sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 5a30520d4890dc8207fa4507e9d89ceb981b4c23
parent 7f394ad567fc7615137dba10d5397b675b93e63f
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Tue,  5 Jan 2010 13:33:17 -0800

Merge branch 'master' into next

Diffstat:
M lib/sup.rb | 3 ++-
M lib/sup/logger.rb | 3 ++-
M lib/sup/modes/console-mode.rb | 4 ++++
M lib/sup/poll.rb | 2 +-
M lib/sup/util.rb | 6 ++++++
5 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -229,7 +229,8 @@ else
     :confirm_top_posting => true,
     :discard_snippets_from_encrypted_messages => false,
     :default_attachment_save_dir => "",
-    :sent_source => "sup://sent"
+    :sent_source => "sup://sent",
+    :poll_interval => 300
   }
   begin
     FileUtils.mkdir_p Redwood::BASE_DIR
diff --git a/lib/sup/logger.rb b/lib/sup/logger.rb
@@ -14,13 +14,14 @@ class Logger
 
   def initialize level=nil
     level ||= ENV["SUP_LOG_LEVEL"] || "info"
-    @level = LEVELS.index(level) or raise ArgumentError, "invalid log level #{level.inspect}: should be one of #{LEVELS * ', '}"
+    self.level = level
     @mutex = Mutex.new
     @buf = StringIO.new
     @sinks = []
   end
 
   def level; LEVELS[@level] end
+  def level=(level); @level = LEVELS.index(level) || raise(ArgumentError, "invalid log level #{level.inspect}: should be one of #{LEVELS * ', '}"); end
 
   def add_sink s, copy_current=true
     @mutex.synchronize do
diff --git a/lib/sup/modes/console-mode.rb b/lib/sup/modes/console-mode.rb
@@ -21,6 +21,10 @@ class Console
 
   def xapian; Index.instance.instance_variable_get :@xapian; end
   def ferret; Index.instance.instance_variable_get :@index; end
+
+  def loglevel; Redwood::Logger.level; end
+  def set_loglevel(level); Redwood::Logger.level = level; end
+
   def special_methods; methods - Object.methods end
 
   ## files that won't cause problems when reloaded
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -28,7 +28,7 @@ num_inbox_total_unread: the total number of unread messages in the inbox
                         only those messages appearing in the inbox
 EOS
 
-  DELAY = 300
+  DELAY = $config[:poll_interval] || 300
 
   def initialize
     @mutex = Mutex.new
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -290,6 +290,12 @@ class String
     end
   end
 
+  unless method_defined? :each
+    def each &b
+      each_line &b
+    end
+  end
+
   ## takes a list of words, and returns an array of symbols.  typically used in
   ## Sup for translating Ferret's representation of a list of labels (a string)
   ## to an array of label symbols.