Re: My mail configuration

Subject: Re: My mail configuration

Date: Sun, 06 Mar 2011 22:34:13 +0100

To: Ben Gamari, notmuch

Cc:

From: Michal Sojka


On Wed, 23 Feb 2011, Ben Gamari wrote:
> Here is my mail sorting script that has been slowly evolving for almost
> a year now. It uses the Python bindings, along with Bogofilter for spam
> filtering. There is also an update-spam script which brings the
> Bogofilter database in to synchronization with the notmuch tags. On this
> note, if someone wants to implement the ability to hide certain tags
> (say, those matching /\..+/) in the emacs interface it would be greatly
> appreciated. I have notmuch configured such that all new mail starts
> with just the "new" tag. The sorting script then takes it from
> there. Hope this will give folks some ideas.

Hi Ben,

thanks for sharing your setup. It seems really interesting and probably
useful for many people. I'd propose to put it to wiki at
http://notmuchmail.org/initial_tagging/.

When compared to shell scripts for initial tagging, this seems to be
much faster because of freezing all new messages and thawing them after
all tagging is done. Also the handling of watch and unseen tag is
interesting.

The only thing I missed in your email is the definition of tag_search().
You probably define it in notmuch_utils similarly to this:

def tag_search(db, query, *tags):
    logging.debug('tagging %s %s' % (query, tags))
    q = notmuch.Query(db, query)
    for msg in q.search_messages():
        for tagop in tags:
            if tagop[0] == '+':
                msg.add_tag(tagop[1:])
            elif tagop[0] == '-':
                msg.remove_tag(tagop[1:])
            else:
                msg.add_tag(tagop)

> # Tag things
> for filter, tags in _tags:
>         tag_search(db, '%s and tag:new' % filter, *tags)

Here I would suggest to add parentheses around %s like:

     tag_search(db, '( %s ) and tag:new' % filter, *tags)

I use the 'or' operator in a few of my filters and without the
parentheses the query would be interpreted incorrectly.

-Michal

Thread: