sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit e7508e52a32509f8bcca403f638252cc9995aefa
parent 6c8e3b84e90505127c7e8bccdea6729c222e46c8
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Thu, 24 Jan 2008 20:57:53 -0800

Merge branch 'from-additions' into next

Diffstat:
M lib/sup/index.rb | 6 +++---
M lib/sup/message.rb | 11 ++++++-----
M lib/sup/person.rb | 4 ++++
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -183,11 +183,11 @@ EOS
       :source_id => source_id,
       :source_info => m.source_info,
       :date => m.date.to_indexable_s,
-      :body => m.content,
+      :body => m.indexable_content,
       :snippet => snippet,
       :label => m.labels.uniq.join(" "),
-      :from => m.from ? m.from.email : "",
-      :to => (m.to + m.cc + m.bcc).map { |x| x.email }.join(" "),
+      :from => m.from ? m.from.indexable_content : "",
+      :to => (m.to + m.cc + m.bcc).map { |x| x.indexable_content }.join(" "),
       :subject => wrap_subj(m.subj),
       :refs => (m.refs + m.replytos).uniq.join(" "),
     }
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -248,13 +248,14 @@ EOS
     with_source_errors_handled { @source.each_raw_message_line(@source_info, &b) }
   end
 
-  def content
+  ## returns all the content from a message that will be indexed
+  def indexable_content
     load_from_source!
     [
-      from && "#{from.name} #{from.email}",
-      to.map { |p| "#{p.name} #{p.email}" },
-      cc.map { |p| "#{p.name} #{p.email}" },
-      bcc.map { |p| "#{p.name} #{p.email}" },
+      from && from.indexable_content,
+      to.map { |p| p.indexable_content },
+      cc.map { |p| p.indexable_content },
+      bcc.map { |p| p.indexable_content },
       chunks.select { |c| c.is_a? Chunk::Text }.map { |c| c.lines },
       Message.normalize_subj(subj),
     ].flatten.compact.join " "
diff --git a/lib/sup/person.rb b/lib/sup/person.rb
@@ -162,6 +162,10 @@ class Person
     Person.new name, email
   end
 
+  def indexable_content
+    [name, email, email.split(/@/).first].join(" ")
+  end
+
   def eql? o; email.eql? o.email end
   def hash; email.hash end
 end