sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit cbd7e6929d03121678efa922f0eaabec58b76ff2
parent 60c3c3c2eaca6dabd2cec13199edf31b98bf04a8
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Sun, 14 Nov 2010 20:11:25 -0800

Merge branch 'master' into next

Diffstat:
M lib/sup/buffer.rb | 21 ++++++++++++---------
M lib/sup/message-chunks.rb | 2 +-
M lib/sup/modes/edit-message-mode.rb | 2 +-
M lib/sup/util.rb | 4 ++--
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -100,7 +100,7 @@ class Buffer
 
   def redraw status
     if @dirty
-      draw status 
+      draw status
     else
       draw_status status
     end
@@ -226,7 +226,7 @@ EOS
 
   def focus_on buf
     return unless @buffers.member? buf
-    return if buf == @focus_buf 
+    return if buf == @focus_buf
     @focus_buf.blur if @focus_buf
     @focus_buf = buf
     @focus_buf.focus
@@ -352,7 +352,7 @@ EOS
   ## creates a new buffer. returns two things: the buffer, and a boolean
   ## indicating whether it's a new buffer or not.
   def spawn_unless_exists title, opts={}
-    new = 
+    new =
       if @name_map.member? title
         raise_to_front @name_map[title] unless opts[:hidden]
         false
@@ -460,7 +460,7 @@ EOS
 
   def ask_many_with_completions domain, question, completions, default=nil
     ask domain, question, default do |partial|
-      prefix, target = 
+      prefix, target =
         case partial
         when /^\s*$/
           ["", ""]
@@ -481,7 +481,10 @@ EOS
       prefix, target = partial.split_on_commas_with_remainder
       target ||= prefix.pop || ""
       target.force_encoding 'UTF-8' if target.methods.include?(:encoding)
+
       prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ")
+      prefix.force_encoding 'UTF-8' if prefix.methods.include?(:encoding)
+
       completions.select { |x| x =~ /^#{Regexp::escape target}/i }.sort_by { |c| [ContactManager.contact_for(c) ? 0 : 1, c] }.map { |x| [prefix + x, x] }
     end
   end
@@ -595,7 +598,7 @@ EOS
 
       if tf.new_completions?
         kill_buffer completion_buf if completion_buf
-        
+
         shorts = tf.completions.map { |full, short| short }
         prefix_len = shorts.shared_prefix.length
 
@@ -612,7 +615,7 @@ EOS
 
       Ncurses.sync { Ncurses.refresh }
     end
-    
+
     kill_buffer completion_buf if completion_buf
 
     @dirty = true
@@ -693,12 +696,12 @@ EOS
 
   def minibuf_lines
     @minibuf_mutex.synchronize do
-      [(@flash ? 1 : 0) + 
+      [(@flash ? 1 : 0) +
        (@asking ? 1 : 0) +
        @minibuf_stack.compact.size, 1].max
     end
   end
-  
+
   def draw_minibuf opts={}
     m = nil
     @minibuf_mutex.synchronize do
@@ -800,7 +803,7 @@ private
 
     statusbar_text = HookManager.run("status-bar-text", opts) || default_status_bar(buf)
     term_title_text = HookManager.run("terminal-title-text", opts) || default_terminal_title(buf)
-    
+
     [statusbar_text, term_title_text]
   end
 
diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
@@ -165,7 +165,7 @@ EOS
     end
 
     def write_to_disk
-      file = Tempfile.new(["sup", @filename || "sup-attachment"])
+      file = Tempfile.new(["sup", @filename.gsub("/", "_") || "sup-attachment"])
       file.print @raw_content
       file.close
       file.path
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -518,7 +518,7 @@ private
              AccountManager.default_account).signature
 
     if sigfn && File.exists?(sigfn)
-      ["", "--"] + File.readlines(sigfn).map { |l| l.chomp }
+      ["", "-- "] + File.readlines(sigfn).map { |l| l.chomp }
     else
       []
     end
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -712,9 +712,9 @@ class Iconv
     end
 
     begin
-      returning(Iconv.iconv(target, charset, text + " ").join[0 .. -2]) { |str| str.check }
+      returning(Iconv.iconv(target + "//IGNORE", charset, text + " ").join[0 .. -2]) { |str| str.check }
     rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::InvalidCharacter, Iconv::IllegalSequence, String::CheckError
-      debug "couldn't transcode text from #{orig_charset} (#{charset}) to #{target}) (#{text[0 ... 20].inspect}...) (got #{$!.message} (#{$!.class}))"
+      debug "couldn't transcode text from #{orig_charset} (#{charset}) to #{target} (#{text[0 ... 20].inspect}...): got #{$!.class} (#{$!.message})"
       text.ascii
     end
   end