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 5EC1B431FB6 for ; Tue, 15 May 2012 03:14:56 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 uAwGQPBZmrZq for ; Tue, 15 May 2012 03:14:54 -0700 (PDT) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id A7BA3431FAE for ; Tue, 15 May 2012 03:14:54 -0700 (PDT) Received: by bkcjk13 with SMTP id jk13so5286220bkc.26 for ; Tue, 15 May 2012 03:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:mime-version; bh=RgKLAc0qbCX/oJxDkrBUner2OzbDfMZmHgi9ixEBVz0=; b=0vfPymXmWwh5YMzVKZhE2Xegj/OZ6fjadrTWUnE5LcgsF4N8brwGpRcyRKdnByg8p6 G1qLCieo5F20ctRF4Z+iJbau7sVXuZL/QK5P+pfXhQ3p1aGLcadOzomVSmrHaUBbwSlr dE/PCcsCJ7eHe15dXWajh42d54k5T121fZfvKcMLxZl9Cvl4Eht3q0JKyQjEJvLI45JX m270Agex+7KaK/8gbRMi+IAtcQC50wItuEqzOrHiubLpllalR/TSD5CilH/IYMoU/iY9 HBR1J5V7rmhtSzaSb9iysfLPXJ3Ze2Xw2iR6PtL81xPSGKz1V+A++Azie11WDKnz0Fy+ GIow== Received: by 10.204.152.199 with SMTP id h7mr4600666bkw.39.1337076893280; Tue, 15 May 2012 03:14:53 -0700 (PDT) Received: from [192.168.0.2] (cpc1-lewi12-0-0-cust882.2-4.cable.virginmedia.com. [82.4.187.115]) by mx.google.com with ESMTPS id fw10sm40425444bkc.11.2012.05.15.03.14.51 (version=SSLv3 cipher=OTHER); Tue, 15 May 2012 03:14:52 -0700 (PDT) Message-ID: <1337076890.12535.2.camel@dsktp> Subject: Re: Using procmail to set tags From: bryan hunt To: Robert Horn Date: Tue, 15 May 2012 11:14:50 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Cc: notmuch@notmuchmail.org 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: Tue, 15 May 2012 10:14:56 -0000 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()