commit 7433ca598a30e01cb2e1ac8dd4093f2e40a3a60f
parent bc54b05853fb885c87d404db7e5efb5b3ffd573e
Author: Gaute Hope <eg@gaute.vetsj.com>
Date: Thu, 4 Nov 2010 14:21:20 +0100
More UTF-8 support; load all labels as UTF-8
Even if the labels.txt file is read as UTF-8 apparantly after a label is
symoblized, it will be US-ASCII on .to_s if possible. This patch forces
UTF-8.
If you use L to select a US-ASCII label (i.e. Sent) then want to narrow
the search by pressing L again and use tab to match against an UTF-8
label sup crashes.
Also fixes one whitespace error in bin/sup
Diffstat:
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -49,7 +49,7 @@ No variables.
No return value.
EOS
-Redwood::HookManager.register "shutdown", <<EOS
+Redwood::HookManager.register "shutdown", <<EOS
Executes when sup is shutting down. May be run when sup is crashing,
so don\'t do anything too important. Run before the label, contacts,
and people are saved.
@@ -299,6 +299,8 @@ begin
SearchResultsMode.spawn_from_query "is:unread"
when :list_labels
labels = LabelManager.all_labels.map { |l| LabelManager.string_for l }
+ labels = labels.each { |l| l.force_encoding 'UTF-8' if l.methods.include?(:encoding) }
+
user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels
unless user_label.nil?
if user_label.empty?
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -454,7 +454,7 @@ EOS
def ask_with_completions domain, question, completions, default=nil
ask domain, question, default do |s|
s.force_encoding 'UTF-8' if s.methods.include?(:encoding)
- completions.select { |x| x =~ /^#{Regexp::escape s}/i }.map { |x| [x, x] }
+ completions.select { |x| x =~ /^#{Regexp::escape s}/iu }.map { |x| [x, x] }
end
end