sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 7073de5752ed295dc7b325a8e9dde946141ef1e3
parent 7a42b566ab28bb0be1783f3b26b6e79abe662472
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Fri, 26 Feb 2010 23:49:04 -0800

Merge branch 'master' into next

Diffstat:
M bin/sup | 10 ++++++++++
M lib/sup/modes/thread-index-mode.rb | 2 +-
M lib/sup/textfield.rb | 4 +++-
M lib/sup/xapian_index.rb | 9 +++++++--
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -14,6 +14,11 @@ require 'fileutils'
 require 'trollop'
 require "sup"; Redwood::check_library_version_against "git"
 
+if ENV['SUP_PROFILE']
+  require 'ruby-prof'
+  RubyProf.start
+end
+
 if no_ncursesw
   debug "No 'ncursesw' gem detected. Install it for wide character support."
 end
@@ -402,6 +407,11 @@ ensure
   end
 
   Index.unlock
+
+  if (fn = ENV['SUP_PROFILE'])
+    result = RubyProf.stop
+    File.open(fn, 'w') { |io| RubyProf::CallTreePrinter.new(result).print(io) }
+  end
 end
 
 unless Redwood::exceptions.empty?
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -651,7 +651,7 @@ EOS
     if (l = lines) == 0
       "line 0 of 0"
     else
-      "line #{curpos + 1} of #{l} #{dirty? ? '*modified*' : ''}"
+      "line #{curpos + 1} of #{l}"
     end
   end
 
diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb
@@ -33,7 +33,9 @@ class TextField
     @w, @y, @x, @width = window, y, x, width
     @question = question
     @completion_block = block
-    @field = Ncurses::Form.new_field 1, @width - question.length, @y, @x + question.length, 256, 0
+    @field = Ncurses::Form.new_field 1, @width - question.length, @y, @x + question.length, 0, 0
+    @field.opts_off Ncurses::Form::O_STATIC
+    @field.opts_off Ncurses::Form::O_BLANK
     @form = Ncurses::Form.new_form [@field]
     @value = default || ''
     Ncurses::Form.post_form @form
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
@@ -273,7 +273,12 @@ EOS
     qp.add_valuerangeprocessor(Xapian::NumberValueRangeProcessor.new(DATE_VALUENO, 'date:', true))
     NORMAL_PREFIX.each { |k,vs| vs.each { |v| qp.add_prefix k, v } }
     BOOLEAN_PREFIX.each { |k,vs| vs.each { |v| qp.add_boolean_prefix k, v } }
-    xapian_query = qp.parse_query(subs, Xapian::QueryParser::FLAG_PHRASE|Xapian::QueryParser::FLAG_BOOLEAN|Xapian::QueryParser::FLAG_LOVEHATE|Xapian::QueryParser::FLAG_WILDCARD)
+
+    begin
+      xapian_query = qp.parse_query(subs, Xapian::QueryParser::FLAG_PHRASE|Xapian::QueryParser::FLAG_BOOLEAN|Xapian::QueryParser::FLAG_LOVEHATE|Xapian::QueryParser::FLAG_WILDCARD)
+    rescue RuntimeError => e
+      raise ParseError, "xapian query parser error: #{e}"
+    end
 
     debug "parsed xapian query: #{xapian_query.description}"
 
@@ -435,7 +440,7 @@ EOS
       :message_id => m.id,
       :source_id => m.source.id,
       :source_info => m.source_info,
-      :date => m.date,
+      :date => truncate_date(m.date),
       :snippet => snippet,
       :labels => m.labels.to_a,
       :from => [m.from.email, m.from.name],