* [sup-talk] Hello, and before-add-message hook for applying labels per CDB
@ 2009-09-18 19:50 William Erik Baxter
2009-09-26 13:58 ` William Morgan
0 siblings, 1 reply; 2+ messages in thread
From: William Erik Baxter @ 2009-09-18 19:50 UTC (permalink / raw)
Hello fellow sup users. I began using sup last week, spent some time setting
it up in parallel with mutt, and have not used mutt since, except through
accident of habit. Thanks to all developers for your excellent work.
A before-add-message hook follows. It applies labels per entries in a CDB
constructed externally. I hope you find it useful.
Cheers, W.
#### Automatically add labels.
require 'cdb';
@cdb ||= CDB.new("/home/web/Mail/suplabel.cdb");
# Mark by a recipient (to/cc)
# Construct [ [ prefix, string ] ... ].
# Look up "prefix:string" in CDB to obtain a list of labels to apply.
a = []
a += [ [ "from", message.from.email ] ]
a += message.recipients.map{ |x| [ "recipient", x.email ] }
a.each { |pair|
key = pair[0] + ":" + pair[1];
@cdb.each(key) { |value|
value.split.each { |label| message.add_label(label) }
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [sup-talk] Hello, and before-add-message hook for applying labels per CDB
2009-09-18 19:50 [sup-talk] Hello, and before-add-message hook for applying labels per CDB William Erik Baxter
@ 2009-09-26 13:58 ` William Morgan
0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2009-09-26 13:58 UTC (permalink / raw)
Reformatted excerpts from William Erik Baxter's message of 2009-09-18:
> Hello fellow sup users. I began using sup last week, spent some time setting
> it up in parallel with mutt, and have not used mutt since, except through
> accident of habit. Thanks to all developers for your excellent work.
Great! Welcome!
> A before-add-message hook follows. It applies labels per entries in a CDB
> constructed externally. I hope you find it useful.
Thanks! If you get a chance, please add it to the wiki:
http://sup.rubyforge.org/wiki/wiki.pl?Hooks
--
William <wmorgan-sup at masanjin.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-26 13:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-18 19:50 [sup-talk] Hello, and before-add-message hook for applying labels per CDB William Erik Baxter
2009-09-26 13:58 ` William Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox