---
Suppose I have an alias "william" for "William Morgan
<[EMAIL PROTECTED]>".  I hit compose, and in the "To:" field, I type
"wil<TAB>".  Sup has two suggestions, listing the longer one first,
and it autocompletes as far as they match.  So now my text field says,
"To: William", which doesn't match the alias.  If we sort the possible
completions so that aliases are before non-aliases, then the field
would read, "To: william", which would match the alias and work
correctly.

 lib/sup/buffer.rb |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 0447f61..fc9a0a2 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -433,7 +433,9 @@ EOS
       prefix, target = partial.split_on_commas_with_remainder
       target ||= prefix.pop || ""
       prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ")
-      completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| 
[prefix + x, x] }
+      completions.select { |x| x =~ /^#{Regexp::escape target}/i }.
+                  sort { |x,y| x_is_c = ContactManager.contact_for(x); y_is_c 
= ContactManager.contact_for(y); x_is_c && !y_is_c ? -1 : !x_is_c && y_is_c ? 1 
: x <=> y }.
+                  map { |x| [prefix + x, x] }
     end
   end

@@ -501,7 +503,7 @@ EOS
     recent = Index.load_contacts(AccountManager.user_emails, :num => 10).map { 
|c| [c.full_address, c.email] }
     contacts = ContactManager.contacts.map { |c| [ContactManager.alias_for(c), 
c.full_address, c.email] }

-    completions = (recent + contacts).flatten.uniq.sort
+    completions = (contacts + recent).flatten.uniq
     completions += HookManager.run("extra-contact-addresses") || []
     answer = BufferManager.ask_many_emails_with_completions domain, question, 
completions, default

--
1.5.5
-- 

Steve Goldman
[EMAIL PROTECTED]

T: 212.219.6014
F: 212.219.6007

Tower Research Capital, LLC
377 Broadway, 11th Fl.
New York, NY 10013
_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk

Reply via email to