Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Gaute Hope <eg@gaute.vetsj.com>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [PATCH] More UTF-8 support; load all labels as UTF-8
Date: Thu, 04 Nov 2010 14:21:20 +0100	[thread overview]
Message-ID: <1288876769-sup-4049@qwerzila> (raw)

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

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
---
 bin/sup           |    4 +++-
 lib/sup/buffer.rb |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bin/sup b/bin/sup
index fd1dde8..10be161 100755
--- 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
index f3cfb8a..c36ca56 100644
--- 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
 
-- 
1.7.3.2


[-- Attachment #2: 0001-More-UTF-8-support-load-all-labels-as-UTF-8.patch --]
[-- Type: application/octet-stream, Size: 2061 bytes --]

From 13258929b9083a88ad9c6ba924e1093fe032e899 Mon Sep 17 00:00:00 2001
From: Gaute Hope <eg@gaute.vetsj.com>
Date: Thu, 4 Nov 2010 14:12:09 +0100
Subject: [PATCH] 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
---
 bin/sup           |    4 +++-
 lib/sup/buffer.rb |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bin/sup b/bin/sup
index fd1dde8..10be161 100755
--- 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
index f3cfb8a..c36ca56 100644
--- 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
 
-- 
1.7.3.2


             reply	other threads:[~2010-11-04 13:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 13:21 Gaute Hope [this message]
2010-11-04 16:03 ` [sup-devel] " Rich Lane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288876769-sup-4049@qwerzila \
    --to=eg@gaute.vetsj.com \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox