sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 8f824bab067844e24b6bdbcf9d5067047bc2fa54
parent 84d9313bfd73e86c8fea95fabc8ff8544f70b1f0
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Mon, 19 Oct 2009 23:14:07 -0700

xapian: replace DocumentMethods module with plain monkeypatching

Diffstat:
M lib/sup/xapian_index.rb | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
@@ -560,7 +560,32 @@ EOS
       raise "Invalid term type #{type}"
     end
   end
+end
 
 end
 
+class Xapian::Document
+  def entry
+    Marshal.load data
+  end
+
+  def entry=(x)
+    self.data = Marshal.dump x
+  end
+
+  def index_text text, prefix, weight=1
+    term_generator = Xapian::TermGenerator.new
+    term_generator.stemmer = Xapian::Stem.new(Redwood::XapianIndex::STEM_LANGUAGE)
+    term_generator.document = self
+    term_generator.index_text text, weight, prefix
+  end
+
+  alias old_add_term add_term
+  def add_term term
+    if term.length <= Redwood::XapianIndex::MAX_TERM_LENGTH
+      old_add_term term
+    else
+      warn "dropping excessively long term #{term}"
+    end
+  end
 end