[sup-talk] Ruby question: before-add-message.rb and adding multiple labels at once
gregor at hoffleit.de
Wed Jan 13 08:13:18 EST 2010
In order to keep before-add-message.rb readable, I was using one-line
message.add_label "ad apple" if message.from.email =~ /@insideapple.apple.com/
message.add_label "ad amazon" if message.from.email =~ /email@example.com/
message.add_label "list sup" if message.subj =~ /\[sup-talk\]/
message.add_label "list sup-devel" if message.subj =~ /\[sup-devel\]/
That seemed to work, somehow. Only now I realized that message.add_label
in fact only takes a single label as argument.
Is it true that I have to change the above syntax into the much more
if message.subj =~ /\[sup-devel\]/
Removing a message from the inbox ("message.remove_label :inbox") while
applying a label leads to a similar 'code bloat'.
Also, it took me a while to realize that errors in before-add-message.rb
won't lead to a visible error message, but that before-add-message.rb
just silently quits.
The examples in http://sup.rubyforge.org/wiki/wiki.pl?Hooks are a very
Still, perhaps somebody with robust Ruby skills could add in a section
about the exact usage of message.add_label and message.remove_label,
- What's the difference between "label" and :label?
- Can I use multiple labels in one invocation?
- How about dashes in labels? Is :sup-devel valid, or should I use
- How about spaces in label?
- How about "-inbox"? Does it work?
More information about the sup-talk