[notmuch] notmuch vs gmail filters

Anthony Towns aj at erisian.com.au
Thu Apr 1 01:01:16 PDT 2010


Hey *,

I'm currently using gmail for my mail and trying to port its behaviour
to notmuch. I had a go at writing a python script to convert my gmails
to notmuch tag commands along the lines of Carl's post [0]. It uses
the Gmail labs feature to export filters (to an XML file), and then
goes from XML stanzas like:

        <entry>
                <category term='filter'></category>
                <title>Mail Filter</title>
                <id>tag:mail.google.com,2008:filter:1270085835242</id>
                <updated>2010-04-01T05:33:40Z</updated>
                <content></content>
                <apps:property name='from' value='updates at linkedin.com'/>
                <apps:property name='label' value='flyers'/>
                <apps:property name='shouldArchive' value='true'/>
        </entry>

(which says to tag messages from updates at linked.com with "flyers" and
skip the inbox) into a notmuch command like:

    notmuch tag -inbox +flyers -- from:updates at linkedin.com '(' not
tag:flyers or tag:inbox ')'

The bit in brackets makes sure it doesn't tag messages that already
have exactly the right tags -- this coule probably be implied in any
invocation of notmuch tag really...

Anyway, attached. It converts gmail's list: match to a notmuch to:
match, and just gives up on deliveredto: matches. But maybe someone
else finds it useful/interesting too :)

Cheers,
aj

[0] id:87r5o8stbj.fsf at yoom.home.cworth.org

-- 
Anthony Towns <aj at erisian.com.au>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gmail2notmuch.py
Type: text/x-python
Size: 1980 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20100401/63950a4b/attachment.py>


More information about the notmuch mailing list