Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 49BAB4196F0 for ; Thu, 1 Apr 2010 01:01:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.801 X-Spam-Level: X-Spam-Status: No, score=0.801 tagged_above=-999 required=5 tests=[BAYES_50=0.8, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mB4VH5nbUlvb for ; Thu, 1 Apr 2010 01:01:17 -0700 (PDT) Received: from mail-gy0-f181.google.com (mail-gy0-f181.google.com [209.85.160.181]) by olra.theworths.org (Postfix) with ESMTP id 40D24431FC1 for ; Thu, 1 Apr 2010 01:01:17 -0700 (PDT) Received: by gyg8 with SMTP id 8so324354gyg.26 for ; Thu, 01 Apr 2010 01:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:received:message-id:subject:from:to :content-type; bh=XdYNNm71eBHiJAbnxngWRb57VopaER5kkDYNTUvZi9w=; b=rOjZfFj/mZCL1pjzxLJ6NOUT1O+vxYXOGMKcekoT2E4irvzJbs/bXvRDx7rk84ozkz ICxGDsuF8T4KsqNHC3PpX49nOUrzAv5HMftFbfxUh0m9xA5kjtKBJlGkghrsOQyYs8jH 62HMmrAPinE05RaV3UvLg0uVIpsiYRsWukUUM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=ERE/7GLG72oxNv774ta4srDNfV/hDILhekT71whsnJd3Ledxv7IjLvqrvnSgigGzPS X5WRM5LHbP/7zW2wae61R4HVqbKGoSEtKFev78lBYIfMienPVzyGtvaQNGDunZbOUtlb UPMSFJESyUqugWxkvDUTysb9DT0AUCilPuIh8= MIME-Version: 1.0 Sender: anthony.j.towns@gmail.com Received: by 10.90.32.14 with HTTP; Thu, 1 Apr 2010 01:01:16 -0700 (PDT) Date: Thu, 1 Apr 2010 18:01:16 +1000 X-Google-Sender-Auth: 42ed67876eae44a5 Received: by 10.91.55.25 with SMTP id h25mr1522371agk.61.1270108876405; Thu, 01 Apr 2010 01:01:16 -0700 (PDT) Message-ID: From: Anthony Towns To: notmuch@notmuchmail.org Content-Type: multipart/mixed; boundary=0016e641dace67919304832844ba Subject: [notmuch] notmuch vs gmail filters X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2010 08:01:18 -0000 --0016e641dace67919304832844ba Content-Type: text/plain; charset=ISO-8859-1 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: Mail Filter tag:mail.google.com,2008:filter:1270085835242 2010-04-01T05:33:40Z (which says to tag messages from updates@linked.com with "flyers" and skip the inbox) into a notmuch command like: notmuch tag -inbox +flyers -- from:updates@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@yoom.home.cworth.org -- Anthony Towns --0016e641dace67919304832844ba Content-Type: text/x-python; charset=US-ASCII; name="gmail2notmuch.py" Content-Disposition: attachment; filename="gmail2notmuch.py" Content-Transfer-Encoding: base64 X-Attachment-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sZXRlZCIpCiAgICAgICAgZWxpZiBuID09ICJzaG91bGRNYXJrQXNSZWFkIiBhbmQgdiA9PSAi dHJ1ZSI6CiAgICAgICAgICAgIGRlbHRhZ3MuYXBwZW5kKCJ1bnJlYWQiKQogICAgICAgIGVsaWYg biA9PSAiZnJvbSI6CiAgICAgICAgICAgIHNlYXJjaC5hcHBlbmQoImZyb206JXMiICUgdikKICAg ICAgICBlbGlmIG4gPT0gInN1YmplY3QiOgogICAgICAgICAgICBzZWFyY2guYXBwZW5kKCJzdWJq ZWN0OiVzIiAlIHYpCiAgICAgICAgZWxpZiBuID09ICJkb2VzTm90SGF2ZVRoZVdvcmQiIGFuZCAn OicgaW4gdjoKICAgICAgICAgICAgc2VhcmNoLmFwcGVuZCgibm90IikKCSAgICBzZWFyY2guYXBw ZW5kKGdvb2cybm90bXVjaCgqdi5zcGxpdCgnOicsMSkpKQogICAgICAgIGVsaWYgbiA9PSAiaGFz VGhlV29yZCIgYW5kICc6JyBpbiB2OgoJICAgIHNlYXJjaC5hcHBlbmQoZ29vZzJub3RtdWNoKCp2 LnNwbGl0KCc6JywxKSkpCiAgICAgICAgZWxpZiBuID09ICJoYXNUaGVXb3JkIjoKICAgICAgICAg ICAgc2VhcmNoLmFwcGVuZCh2KQogICAgICAgIGVsaWYgbiA9PSAiZG9lc05vdEhhdmVUaGVXb3Jk IjoKICAgICAgICAgICAgc2VhcmNoLmFwcGVuZCgibm90IikKICAgICAgICAgICAgc2VhcmNoLmFw cGVuZCh2KQogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHByaW50ICJYWFggJXMgOiAlcyIgJSAo bix2KQogICAgdGFncyA9IFsiLSIreCBmb3IgeCBpbiBkZWx0YWdzXSArIFsiKyIreCBmb3IgeCBp biBhZGR0YWdzXQogICAgaWYgdGFncyA9PSBbXToKCXByaW50ICJXVEY/PyBOTyBUQUdTIgoJY29u dGludWUKICAgIHRhZ3NlYXJjaCA9IHN1bShbIFsibm90IiwgInRhZzoiK3gsICJvciJdIGZvciB4 IGluIGFkZHRhZ3MgXSwgW10pCiAgICB0YWdzZWFyY2ggKz0gc3VtKFsgWyJ0YWc6Iit4LCAib3Ii XSBmb3IgeCBpbiBkZWx0YWdzIF0sIFtdKQogICAgdGFnc2VhcmNoID0gdGFnc2VhcmNoWzotMV0K ICAgIGlmIGxlbih0YWdzKSA+IDE6CiAgICAgICAgdGFnc2VhcmNoID0gWyIoIl0gKyB0YWdzZWFy Y2ggKyBbIikiXQogICAgc2VhcmNoICs9IHRhZ3NlYXJjaAogICAgcHJpbnQgIm5vdG11Y2ggdGFn ICVzIC0tICVzIiAlICgKCSIgIi5qb2luKHBpcGVzLnF1b3RlKHgpIGZvciB4IGluIHRhZ3MpLAoJ IiAiLmpvaW4ocGlwZXMucXVvdGUoeCkgZm9yIHggaW4gc2VhcmNoKSkKCg== --0016e641dace67919304832844ba--