sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 72d4238fca642bd7cb6a7c125c1df1152cce8536
parent 7911b63604832e89fdc6050c244c6b5f799716b2
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Wed,  4 Dec 2013 15:39:56 +0100

Merge branch 'develop'

Diffstat:
M History.txt | 4 ++++
M ReleaseNotes | 4 ++++
M lib/sup/crypto.rb | 6 +++++-
M lib/sup/maildir.rb | 2 +-
M lib/sup/modes/text_mode.rb | 2 +-
M lib/sup/person.rb | 3 +++
M lib/sup/thread.rb | 6 +++++-
7 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/History.txt b/History.txt
@@ -1,3 +1,7 @@
+== 0.15.1 / 2013-12-04
+
+* Thread children are sorted last-activity latest (bottom).
+
 == 0.15.0 / 2013-11-07
 
 * Maildir Syncback has now been merged into main sup! This is a
diff --git a/ReleaseNotes b/ReleaseNotes
@@ -1,3 +1,7 @@
+Release 0.15.1:
+
+Sort threads last-activity-first and bug fix.
+
 Release 0.15.0:
 
 Maildir Syncback has been included. Refer to the wiki for more information on
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -261,7 +261,11 @@ EOS
       plain_data = nil
     else
       signed_text_data = nil
-      plain_data = GPGME::Data.empty
+      if GPGME::Data.respond_to?('empty')
+        plain_data = GPGME::Data.empty
+      else
+        plain_data = GPGME::Data.empty!
+      end
     end
     begin
       ctx.verify(sig_data, signed_text_data, plain_data)
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -119,7 +119,7 @@ class Maildir < Source
       next if prev_ctime >= ctime
       @ctimes[d] = ctime
 
-      old_ids = benchmark(:maildir_read_index) { Enumerator.new(Index.instance, :each_source_info, self.id, "#{d}/").to_a }
+      old_ids = benchmark(:maildir_read_index) { Index.instance.enum_for(:each_source_info, self.id, "#{d}/").to_a }
       new_ids = benchmark(:maildir_read_dir) { Dir.glob("#{subdir}/*").map { |x| File.join(d,File.basename(x)) }.sort }
       added += new_ids - old_ids
       deleted += old_ids - new_ids
diff --git a/lib/sup/modes/text_mode.rb b/lib/sup/modes/text_mode.rb
@@ -46,7 +46,7 @@ class TextMode < ScrollMode
 
   def << line
     @lines = [0] if @text.empty?
-    @text << line
+    @text << line.fix_encoding!
     @lines << @text.length
     if buffer
       ensure_mode_validity
diff --git a/lib/sup/person.rb b/lib/sup/person.rb
@@ -6,7 +6,10 @@ class Person
   def initialize name, email
     raise ArgumentError, "email can't be nil" unless email
 
+    email.fix_encoding!
+
     @name = if name
+      name.fix_encoding!
       name = name.strip.gsub(/\s+/, " ")
       name =~ /^(['"]\s*)(.*?)(\s*["'])$/ ? $2 : name
       name.gsub('\\\\', '\\')
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -172,7 +172,7 @@ class Container
 
   def each_with_stuff parent=nil
     yield self, 0, parent
-    @children.each do |c|
+    @children.sort_by(&:sort_key).each do |c|
       c.each_with_stuff(self) { |cc, d, par| yield cc, d + 1, par }
     end
   end
@@ -239,6 +239,10 @@ class Container
     indent += 3
     @children.each { |c| c.dump_recursive f, indent, false, self }
   end
+
+  def sort_key
+    empty? ? [Time.now.to_i, ""] : [@message.date.to_i, @message.id]
+  end
 end
 
 ## A set of threads, so a forest. Is integrated with the index and