From: Gregor Hoffleit <hoffleit@mediasupervision.de>
To: sup-talk <sup-talk@rubyforge.org>
Subject: Re: [sup-talk] Ruby question: before-add-message.rb and adding multiple labels at once
Date: Fri, 15 Jan 2010 16:51:46 +0100 [thread overview]
Message-ID: <1263570054-sup-9348@sam.mediasupervision.de> (raw)
In-Reply-To: <1263396697-sup-5561@changeling.local>
Ok. I ended up with
([:list,:"sup-devel"].each {|l| message.add_label l}; message.remove_label :inbox) if message.subj =~ /\[sup-devel\]/
May I request a new function "message.edit_labels" that groks the syntax
of the 'edit labels' command (cf. multi_edit_labels in thread-index-mode.rb):
message.edit_labels "list sup-devel -inbox" if message.subj =~ /\[sup-devel\]/
Comments?
Regards,
Gregor Hoffleit
* Eric Sherman <hyperbolist@gmail.com> [Mi Jan 13 16:49:00 +0100 2010]
> You could try this:
> [:list, :sup-devel].each { |l| message.add_label l } if condition
> [:inbox, :unread].each { |l| message.remove_label l } if condition
>
> Or something like this:
> case [message.from, message.subj].flatten.to_s
> when /foo/ then
> [:label1, :label2].each { |l| message.add_label l }
> [:inbox, :unread].each { |l| message.remove_label l }
> when /bar/ then
> [:label3, :label4].each { |l| message.add_label l }
> [:inbox, :unread].each { |l| message.remove_label l }
> end
>
> Excerpts from Gregor Hoffleit's message of Wed Jan 13 08:13:18 -0500 2010:
> > In order to keep before-add-message.rb readable, I was using one-line
> > filters like:
> >
> > message.add_label "ad apple" if message.from.email =~ /@insideapple.apple.com/
> > message.add_label "ad amazon" if message.from.email =~ /promotion.*@amazon.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
> > verbose:
> >
> > if message.subj =~ /\[sup-devel\]/
> > message.add_label :list
> > message.add_label :"sup-devel"
> > end
> >
> > Removing a message from the inbox ("message.remove_label :inbox") while
> > applying a label leads to a similar 'code bloat'.
>
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
next prev parent reply other threads:[~2010-01-17 14:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 13:13 Gregor Hoffleit
2010-01-13 15:49 ` Eric Sherman
2010-01-15 15:51 ` Gregor Hoffleit [this message]
2010-01-17 15:29 ` William Morgan
2010-01-15 17:01 Gregor Hoffleit
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=1263570054-sup-9348@sam.mediasupervision.de \
--to=hoffleit@mediasupervision.de \
--cc=sup-talk@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