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: [PATCHES] more utf + whitespace
Date: Tue, 09 Nov 2010 11:19:47 +0100	[thread overview]
Message-ID: <1289297820-sup-9801@qwerzila> (raw)

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

Hi,

attached is another patch fixing a crash first tab completing an UTF-8
contact; then an ASCII contact.

Also some whitespace corrections for lib/sup/buffer.rb

Also available on:
http://git.gitorious.org/~gauteh/sup/gautehs-mainline.git (master)


- gaute

[-- Attachment #2: 0001-Fix-Whitespace-errors-in-buffer.rb.patch --]
[-- Type: application/octet-stream, Size: 2393 bytes --]

From 7c5bcb6d41698a565f99c1ea3e25e170402e7ba6 Mon Sep 17 00:00:00 2001
From: Gaute Hope <eg@gaute.vetsj.com>
Date: Tue, 9 Nov 2010 11:05:10 +0100
Subject: [PATCH 1/2] Fix Whitespace errors in buffer.rb

---
 lib/sup/buffer.rb |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index c36ca56..ee32f1e 100644
--- 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*$/
           ["", ""]
@@ -595,7 +595,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 +612,7 @@ EOS
 
       Ncurses.sync { Ncurses.refresh }
     end
-    
+
     kill_buffer completion_buf if completion_buf
 
     @dirty = true
@@ -693,12 +693,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 +800,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
 
-- 
1.7.3.2


[-- Attachment #3: 0002-UTF-8-Force-UTF-8-in-ask_many_emails.patch --]
[-- Type: application/octet-stream, Size: 1199 bytes --]

From 4f552d9ac51fe200c5cbef3f8a5a3cf875a563af Mon Sep 17 00:00:00 2001
From: Gaute Hope <eg@gaute.vetsj.com>
Date: Tue, 9 Nov 2010 11:06:04 +0100
Subject: [PATCH 2/2] [UTF-8] Force UTF-8 in ask_many_emails..

A mix-up occurs when you first tab complete a UTF-8 contact, then try to
complete an ASCII encoded contact.

They are all stored as UTF-8 in file and when loaded - but will
apparently be converted to ASCII if possible when a Person object is
created.
---
 lib/sup/buffer.rb |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index ee32f1e..d1fef5a 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -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
-- 
1.7.3.2


             reply	other threads:[~2010-11-09 10:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-09 10:19 Gaute Hope [this message]
2010-11-15  4:16 ` [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=1289297820-sup-9801@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