Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: web-sup@superscript.com (William Erik Baxter)
Subject: [sup-talk] Hello, and before-add-message hook for applying labels per CDB
Date: Fri, 18 Sep 2009 15:50:13 -0400	[thread overview]
Message-ID: <1253303164-sup-1138@kronos> (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) }
  }
}


             reply	other threads:[~2009-09-18 19:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-18 19:50 William Erik Baxter [this message]
2009-09-26 13:58 ` William Morgan

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=1253303164-sup-1138@kronos \
    --to=web-sup@superscript.com \
    /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