hide_thread t
     end
     regen_text
-    BufferManager.flash "Thread#{threads.size == 1 ? '' : 's'} killed."
+    BufferManager.flash "#{threads.size.pluralize 'Thread'} killed."
   end
 
   def save
     last_update = Time.now
     @ts.load_n_threads(@ts.size + n, opts) do |i|
       if (Time.now - last_update) >= 0.25
-        BufferManager.say "Loaded #{i} threads...", @mbid
+        BufferManager.say "Loaded #{i.pluralize 'thread'}...", @mbid
         update
         BufferManager.draw_screen
         last_update = Time.now
     myopts = @load_thread_opts.merge({ :when_done => (lambda do |num|
       opts[:when_done].call(num) if opts[:when_done]
       if num > 0
-        BufferManager.flash "Found #{num} threads."
+        BufferManager.flash "Found #{num.pluralize 'thread'}."
       else
         BufferManager.flash "No matches."
       end
 
     BufferManager.flash "Polling for new messages..."
     num, numi, from_and_subj, from_and_subj_inbox = buffer.mode.poll
     if num > 0
-      BufferManager.flash "Loaded #{num} new messages, #{numi} to inbox." 
+      BufferManager.flash "Loaded #{num.pluralize 'new message'}, #{numi} to inbox." 
     else
       BufferManager.flash "No new messages." 
     end
 
     ret
   end
 
+  ## one of the few things i miss from perl
   def ucfirst
     self[0 .. 0].upcase + self[1 .. -1]
   end
     split(/,\s*(?=(?:[^"]*"[^"]*")*(?![^"]*"))/)
   end
 
+  ## ok, here we do it the hard way. got to have a remainder for purposes of
+  ## tab-completing full email addresses
+  def split_on_commas_with_remainder
+    ret = []
+    state = :outstring
+    pos = 0
+    region_start = 0
+    while pos <= length
+      newpos = case state
+        when :escaped_instring, :escaped_outstring: pos
+        else index(/[,"\\]/, pos)
+      end 
+      
+      if newpos
+        char = self[newpos]
+      else
+        char = nil
+        newpos = length
+      end
+        
+      $stderr.puts "pos #{newpos} (len #{length}), state #{state}, char #{(char || ?$).chr}, region_start #{region_start}"
+      case char
+      when ?"
+        state = case state
+          when :outstring: :instring
+          when :instring: :outstring
+          when :escaped_instring: :instring
+          when :escaped_outstring: :outstring
+        end
+      when ?,, nil
+        state = case state
+          when :outstring, :escaped_outstring:
+            ret << self[region_start ... newpos]
+            region_start = newpos + 1
+            :outstring
+          when :instring: :instring
+          when :escaped_instring: :instring
+        end
+      when ?\\
+        state = case state
+          when :instring: :escaped_instring
+          when :outstring: :escaped_outstring
+          when :escaped_instring: :instring
+          when :escaped_outstring: :outstring
+        end
+      end
+      pos = newpos + 1
+    end
+
+    remainder = case state
+      when :instring
+        self[region_start .. -1]
+      else
+        nil
+      end
+
+    [ret, remainder]
+  end
+
   def wrap len
     ret = []
     s = self
       "<#{self}>"
     end
   end
+
+  def pluralize s
+    to_s + " " + (self == 1 ? s : s + "s")
+  end
 end
 
 class Hash