Subject: [sup-talk] sup crash on tab completion

From: [email-masked] (John Bent)
Date: Fri, 18 Jan 2008 22:21:44 -0700

Hey William,

I'm just trying out sup and I'm really excited about it so far.  My deal is
that I really like gmail but my work doesn't allow us to use any external
web servers so I can't forward my work email to gmail.  My work's webmail
absolutely sucks so I want to run some client on my own computer but I also
want to use it when I'm on a different computer.  So I need something that
works over X-windows or in the console.  I was using pine but I got
completely frustrated by the lack of search.  So sup looks really great.
I'm only just starting to mess with it and some things do seem a little
strange.  For example, can I remove a label?  By I'm hoping that most of the
problems I'm seeing so far are just learning curve.  So really, thank you so
much for writing sup - it's exactly what I want / need.

Anyway, I did just crash it when I was doing tab completion on a contact.
The two possible contacts were:
John Bent <johnbent at lanl.gov> and John Bent (gmail) <johnbent at gmail.com>.
It was prompting me to
either add a < or a (.  It died when I added the ( and hit TAB:

--- RegexpError from thread: main
premature end of regular expression: /^John Bent (/
/opt/local/lib/ruby/gems/1.8/gems/sup-0.3/lib/sup/buffer.rb:426:in
`ask_many_emails_with_completions'

Also, I can't figure out how to search on the from field.  I'm doing
from:Username and getting an empty thing.
Also, can I automatically archive sent-messages that aren't part of a thread
that includes received messages?

Thanks again!

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/sup-talk/attachments/20080118/57f947c7/attachment.html

---

From: [email-masked] (William Morgan)
Date: Mon, 21 Jan 2008 23:41:43 -0800

Hi John,

Reformatted excerpts from John Bent's message of 2008-01-18:
> I'm just trying out sup and I'm really excited about it so far.

Great!

> My deal is that I really like gmail but my work doesn't allow us to
> use any external web servers so I can't forward my work email to
> gmail.  My work's webmail absolutely sucks so I want to run some
> client on my own computer but I also want to use it when I'm on a
> different computer.  So I need something that works over X-windows or
> in the console.  I was using pine but I got completely frustrated by
> the lack of search.

Sounds like Sup is perfect for you.

> I'm only just starting to mess with it and some things do seem a
> little strange.  For example, can I remove a label?

You can remove labels by editing the labels for a thread. If you press
'l' while in a thread-index-mode, you can then backspace over any labels
you don't want.

> `ask_many_emails_with_completions'

I have a fix for this that I've just applied to master. I've attached
the patch below if you just want to update your local copy, or you can
wait for the next release (any day now), or you can get the latest
version form git.

> from:Username and getting an empty thing.

Searcing on from: currently requires a full email address or a contact
nickname. Hm, I should improve this.

> Also, can I automatically archive sent-messages that aren't part of a
> thread that includes received messages?

I'm not sure I entirely understand. Currently, sent messages appear in
your inbox. Do you want sent messages to instead be archived
automatically, unless they're part of a thread that already appears in
your inbox?

If so, this would be a pretty easy change, and possibly worthy of a
config option.

Here's the patch that fixes tab completion:

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

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 2a78787..4374fa8 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -398,7 +398,7 @@ EOS
 
   def ask_with_completions domain, question, completions, default=nil
     ask domain, question, default do |s|
-      completions.select { |x| x =~ /^#{s}/i }.map { |x| [x, x] }
+      completions.select { |x| x =~ /^#{Regexp::escape s}/i }.map { |x| [x, x] }
     end
   end
 
@@ -414,7 +414,7 @@ EOS
           raise "william screwed up completion: #{partial.inspect}"
         end
 
-      completions.select { |x| x =~ /^#{target}/i }.map { |x| [prefix + x, x] }
+      completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] }
     end
   end
 
@@ -423,7 +423,7 @@ EOS
       prefix, target = partial.split_on_commas_with_remainder
       target ||= prefix.pop || ""
       prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ")
-      completions.select { |x| x =~ /^#{target}/i }.map { |x| [prefix + x, x] }
+      completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] }
     end
   end
 
@@ -436,7 +436,7 @@ EOS
         if dir
           [[s.sub(full, dir), "~#{name}"]]
         else
-          users.select { |u| u =~ /^#{name}/ }.map do |u|
+          users.select { |u| u =~ /^#{Regexp::escape name}/ }.map do |u|
             [s.sub("~#{name}", "~#{u}"), "~#{u}"]
           end
         end
-- 
1.5.4.rc2.69.g10f0

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Marcus Williams)
Date: Tue, 22 Jan 2008 09:40:57 +0000

> nickname. Hm, I should improve this.

Note that you can use wildcards... "from:joe*" will find emails from
joey/joe.bloggs/joel etc. Although it must be said I was pondering
yesterday whether it was possible to get searches assume wildcards
some how so when you searched for from:joe you would actually be
searching for from:*joe* or maybe from:joe* automagically. I dug
around in the ferret docs to see if this was possible but only came up
with the fuzzy operators and you might as well use a wildcard instead.

Marcus

---

From: [email-masked] (William Morgan)
Date: Tue, 22 Jan 2008 23:09:10 -0800

Reformatted excerpts from Marcus Williams's message of 2008-01-22:
> joey/joe.bloggs/joel etc.

Wow, I totally forgot about that.

> Although it must be said I was pondering yesterday whether it was
> possible to get searches assume wildcards some how so when you
> searched for from:joe you would actually be searching for from:*joe*
> or maybe from:joe* automagically. I dug around in the ferret docs to
> see if this was possible but only came up with the fuzzy operators and
> you might as well use a wildcard instead.

I don't recall seeing anything like this in the Ferret docs, so it's
probably not possible. What I'm thinking of doing, which will kind of
approximate this, is adding the LHS of the email address and the
sender's name to the from: field at index time, so that email from you
would match e.g. from:marcus, from:williams, and from:marcus-sup.

---

From: [email-masked] (Grant Hollingworth)
Date: Wed, 23 Jan 2008 07:41:58 -0500

> would match e.g. from:marcus, from:williams, and from:marcus-sup. 

That would be excellent. I try to search like that all the time.

---

From: [email-masked] (Gabriel Sean Farrell)
Date: Wed, 23 Jan 2008 14:25:21 -0500

> would match e.g. from:marcus, from:williams, and from:marcus-sup. 

Using Ferret's LetterAnalyzer on the "from" and "to" fields should do
this for you (i.e., create the appropriate tokens).  I've stuck it in
the code, but I haven't been able to make it work.  Something to do with
the twice-over query parsing, I think.

gsf

---

From: [email-masked] (William Morgan)
Date: Thu, 24 Jan 2008 21:04:30 -0800

Reformatted excerpts from Gabriel Sean Farrell's message of 2008-01-23:
> the code, but I haven't been able to make it work.  Something to do
> with the twice-over query parsing, I think.

I don't think we even need to be so sophisticated. Check out commits
d09d4afbeb035c497f3682559ecb30ab42c009c6 and
360e105c0d08a5765b23c37b2026bff586b3d136 which I just merged into next.

You should be able to search the from: field with email address LHSes
and first and last names.

Of course you will need to run sup-sync --all to reindex the sources
you're interested in, if you want to apply this retroactively.