Using procmail to set tags
Austin Clements
amdragon at MIT.EDU
Tue May 15 06:22:38 PDT 2012
Quoth Robert Horn on May 14 at 7:34 pm:
> Is it practical (and has anyone documented) using a procmail setup to
> set initial tags for messages using notmuch?
>
> I've just started using emacs-notmuch to read mail, and I'm using a
> system where I have procmail filters to bin mail by category into
> folders. I can continue this using folder:value for searching, but one
> reason notmuch interests me is the potential to do more.
>
> It's practical for me to assign potentially overlapping tags with a more
> sophisticated procmail setup. Notmuch tags enable having multiple tags
> on one email.
>
> I don't know enough about the procmail/notmuch process to see just how
> to make this happen. I'm hoping that someone has already done something
> similar.
I second Jani's suggestion of using notmuch tag commands from
notmuch's post-new hook if possible (or switching to using searches
instead of tags where that makes sense). However, if you really need
the flexibility of procmail, I can think of two solutions:
You can let procmail deliver to folders, like usual, and then use
notmuch tag tag:inbox folder:X +/-tags
in notmuch's post-new hook to apply tags based on folders (you might
want to add the tag 'new' to your new.tags in ~/.notmuch-config and
filter on tag:new instead of tag:inbox). If you need multiple tags on
a message, let procmail deliver it to multiple folders.
Alternatively, you can have procmail record the message ID and desired
tags of the message in a file and then apply those recorded tags in
your post-new hook. This would achieve the tagging you want more
directly, without mixing in folders and multiple delivery. The
difficulty would be getting a message ID you could later use in an id:
query. Simply grabbing the value of the message-id header would work
most of the time, but there's a fair bit of logic for dealing with
strangely formed or completely malformed message-id headers
(see _parse_message_id).
As far as I know, nobody has tried my second suggestion. Most people
just switch to using notmuch queries (either to tag or simply to
search).
More information about the notmuch
mailing list