From: Michal Vyskocil Date: Fri, 22 Mar 2013 11:56:23 +0000 (+0100) Subject: funcmail.py: generate notmuch-tags based on headers X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=0423281f10fd58a77c765bcf50c97d9ad80bf37e;p=notmuch-archives.git funcmail.py: generate notmuch-tags based on headers --- diff --git a/90/c5f2c4d7cfed1c857c2585aebcba6bdb920972 b/90/c5f2c4d7cfed1c857c2585aebcba6bdb920972 new file mode 100644 index 000000000..be6ff8ee6 --- /dev/null +++ b/90/c5f2c4d7cfed1c857c2585aebcba6bdb920972 @@ -0,0 +1,96 @@ +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 4FDDF431FB6 + for ; Fri, 22 Mar 2013 04:56:32 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -5 +X-Spam-Level: +X-Spam-Status: No, score=-5 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_HI=-5] autolearn=disabled +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 O2-bor-GV6yR for ; + Fri, 22 Mar 2013 04:56:31 -0700 (PDT) +Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) + by olra.theworths.org (Postfix) with ESMTP id 8412F431FAF + for ; Fri, 22 Mar 2013 04:56:31 -0700 (PDT) +Received: from relay1.suse.de (unknown [195.135.220.254]) + by mx2.suse.de (Postfix) with ESMTP id 32C72A4C0E + for ; Fri, 22 Mar 2013 12:56:28 +0100 (CET) +Date: Fri, 22 Mar 2013 12:56:23 +0100 +From: Michal Vyskocil +To: notmuch@notmuchmail.org +Subject: funcmail.py: generate notmuch-tags based on headers +Message-ID: <20130322115623.GA18329@linux-xtv2.site> +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="BOKacYhQ+x31HxR3" +Content-Disposition: inline +User-Agent: Mutt/1.5.21 (2010-09-15) +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: Fri, 22 Mar 2013 11:56:32 -0000 + + +--BOKacYhQ+x31HxR3 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +Hi, + +because it seems that notmuch does not index all headers, I've written a +simple, but quite usable tool, which goes through a maildir and generate +an output for notmuch-tag --batch according a simple rules. I've +borrowed the syntax from notmuch-tag --batch format, so it should be +very easy for any notmuch user to configure. + +You can query the content of a paricular header +# tags will be applied when string is in header ++notmuch -inbox -- 'notmuch.notmuchmail.org' in 'List-Id' + +or in more than one header ++notmuch -inbox -- 'notmuch.notmuchmail.org' in ('List-Id', +'X-Mailinglist') + +Or use the procmail-like grep, where a whole email will be searched for +a pattern. + +# procmail-like rule, the whole email is searched for a pattern ++notmuch -inbox -- 'List-Id.*notmuch.notmuchmail.org' + +Note the matchin rule is a normal Python expression, so everything +Python interpreted can evaluate, should be used. I've ever wanted to +learn about those parts of a Python, so this was a nice opportunity to +learn. + +https://gist.github.com/mvyskocil/5220690 + +Regards +Michal Vyskocil + +--BOKacYhQ+x31HxR3 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.19 (GNU/Linux) + +iEYEARECAAYFAlFMRuYACgkQGwzgx2QvQgQkqACgg4h8pMh9uRXI7juOzicq2IjJ +RSQAnj8ypjW7x7sQG1gkrwKulvWS/gUA +=rkN0 +-----END PGP SIGNATURE----- + +--BOKacYhQ+x31HxR3--