unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: bryan hunt <mafubryan@gmail.com>
To: Robert Horn <rjhorn@alum.mit.edu>
Cc: notmuch@notmuchmail.org
Subject: Re: Using procmail to set tags
Date: Tue, 15 May 2012 11:14:50 +0100	[thread overview]
Message-ID: <1337076890.12535.2.camel@dsktp> (raw)
In-Reply-To: <m3vcjyl4kg.fsf@quad.robs.office>

On Mon, 2012-05-14 at 19:34 -0400, Robert Horn wrote:
> 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.
> 
> R Horn
> rjhorn@alum.mit.edu

You could have procmail fire a python script to add or remove tags based
upon message content. 

Here's a python script I tried using to untag messages from the Lift
mailing list, there was a problem when I wrote it, but it's probably
been fixed by now.

#!/usr/bin/env python

from notmuch import *

'''
The idea of this script is that it will untag mailing list messages,
keeping them from my inbox unless they are directly related to me.

The problem is that the tag removal isn't being saved. 
I've created a bug report with the developer:

https://bitbucket.org/spaetz/cnotmuch/issue/1/removing-tags-doesnt-seem-to-be-saving

'''
db = Database('/home/bryan/.maildb',False, 'READ_WRITE')
q=db.create_query("'[lift]' -from:bryan tag:inbox")

for msg in q.search_messages():
    print msg.get_tags()
    msg.freeze()
    msg.remove_tag("inbox")
    print msg.get_tags()
    msg.remove_tag("unread")
    print msg.get_tags()
    msg.add_tag("lift")
    print msg.get_tags()
    msg.thaw()
exit()

  parent reply	other threads:[~2012-05-15 10:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-14 23:34 Using procmail to set tags Robert Horn
2012-05-15  7:20 ` Jani Nikula
2012-05-15 10:14 ` bryan hunt [this message]
2012-05-15 10:57   ` Jani Nikula
2012-05-15 13:22 ` Austin Clements
2012-05-15 13:43   ` Tomi Ollila
2012-05-18 14:48     ` Robert Horn

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

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337076890.12535.2.camel@dsktp \
    --to=mafubryan@gmail.com \
    --cc=notmuch@notmuchmail.org \
    --cc=rjhorn@alum.mit.edu \
    /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.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).