Re: Using procmail to set tags
authorbryan hunt <mafubryan@gmail.com>
Tue, 15 May 2012 10:14:50 +0000 (11:14 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:06 +0000 (09:47 -0800)
ff/dc79c4c1e289edfb3a8122309869ccf50134a1 [new file with mode: 0644]

diff --git a/ff/dc79c4c1e289edfb3a8122309869ccf50134a1 b/ff/dc79c4c1e289edfb3a8122309869ccf50134a1
new file mode 100644 (file)
index 0000000..b890579
--- /dev/null
@@ -0,0 +1,123 @@
+Return-Path: <mafubryan@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5EC1B431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 03:14:56 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id uAwGQPBZmrZq for <notmuch@notmuchmail.org>;\r
+       Tue, 15 May 2012 03:14:54 -0700 (PDT)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A7BA3431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 03:14:54 -0700 (PDT)\r
+Received: by bkcjk13 with SMTP id jk13so5286220bkc.26\r
+       for <notmuch@notmuchmail.org>; Tue, 15 May 2012 03:14:53 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=message-id:subject:from:to:cc:date:in-reply-to:references\r
+       :content-type:x-mailer:content-transfer-encoding:mime-version;\r
+       bh=RgKLAc0qbCX/oJxDkrBUner2OzbDfMZmHgi9ixEBVz0=;\r
+       b=0vfPymXmWwh5YMzVKZhE2Xegj/OZ6fjadrTWUnE5LcgsF4N8brwGpRcyRKdnByg8p6\r
+       G1qLCieo5F20ctRF4Z+iJbau7sVXuZL/QK5P+pfXhQ3p1aGLcadOzomVSmrHaUBbwSlr\r
+       dE/PCcsCJ7eHe15dXWajh42d54k5T121fZfvKcMLxZl9Cvl4Eht3q0JKyQjEJvLI45JX\r
+       m270Agex+7KaK/8gbRMi+IAtcQC50wItuEqzOrHiubLpllalR/TSD5CilH/IYMoU/iY9\r
+       HBR1J5V7rmhtSzaSb9iysfLPXJ3Ze2Xw2iR6PtL81xPSGKz1V+A++Azie11WDKnz0Fy+\r
+       GIow==\r
+Received: by 10.204.152.199 with SMTP id h7mr4600666bkw.39.1337076893280;\r
+       Tue, 15 May 2012 03:14:53 -0700 (PDT)\r
+Received: from [192.168.0.2]\r
+       (cpc1-lewi12-0-0-cust882.2-4.cable.virginmedia.com. [82.4.187.115])\r
+       by mx.google.com with ESMTPS id\r
+       fw10sm40425444bkc.11.2012.05.15.03.14.51\r
+       (version=SSLv3 cipher=OTHER); Tue, 15 May 2012 03:14:52 -0700 (PDT)\r
+Message-ID: <1337076890.12535.2.camel@dsktp>\r
+Subject: Re: Using procmail to set tags\r
+From: bryan hunt <mafubryan@gmail.com>\r
+To: Robert Horn <rjhorn@alum.mit.edu>\r
+Date: Tue, 15 May 2012 11:14:50 +0100\r
+In-Reply-To: <m3vcjyl4kg.fsf@quad.robs.office>\r
+References: <m3vcjyl4kg.fsf@quad.robs.office>\r
+Content-Type: text/plain; charset="UTF-8"\r
+X-Mailer: Evolution 3.2.3-0ubuntu6 \r
+Content-Transfer-Encoding: 7bit\r
+Mime-Version: 1.0\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 15 May 2012 10:14:56 -0000\r
+\r
+On Mon, 2012-05-14 at 19:34 -0400, Robert Horn wrote:\r
+> Is it practical (and has anyone documented) using a procmail setup to\r
+> set initial tags for messages using notmuch?\r
+> \r
+> I've just started using emacs-notmuch to read mail, and I'm using a\r
+> system where I have procmail filters to bin mail by category into\r
+> folders.  I can continue this using folder:value for searching, but one\r
+> reason notmuch interests me is the potential to do more.\r
+> \r
+> It's practical for me to assign potentially overlapping tags with a more\r
+> sophisticated procmail setup.  Notmuch tags enable having multiple tags\r
+> on one email.\r
+> \r
+> I don't know enough about the procmail/notmuch process to see just how\r
+> to make this happen.  I'm hoping that someone has already done something\r
+> similar.\r
+> \r
+> R Horn\r
+> rjhorn@alum.mit.edu\r
+\r
+You could have procmail fire a python script to add or remove tags based\r
+upon message content. \r
+\r
+Here's a python script I tried using to untag messages from the Lift\r
+mailing list, there was a problem when I wrote it, but it's probably\r
+been fixed by now.\r
+\r
+#!/usr/bin/env python\r
+\r
+from notmuch import *\r
+\r
+'''\r
+The idea of this script is that it will untag mailing list messages,\r
+keeping them from my inbox unless they are directly related to me.\r
+\r
+The problem is that the tag removal isn't being saved. \r
+I've created a bug report with the developer:\r
+\r
+https://bitbucket.org/spaetz/cnotmuch/issue/1/removing-tags-doesnt-seem-to-be-saving\r
+\r
+'''\r
+db = Database('/home/bryan/.maildb',False, 'READ_WRITE')\r
+q=db.create_query("'[lift]' -from:bryan tag:inbox")\r
+\r
+for msg in q.search_messages():\r
+    print msg.get_tags()\r
+    msg.freeze()\r
+    msg.remove_tag("inbox")\r
+    print msg.get_tags()\r
+    msg.remove_tag("unread")\r
+    print msg.get_tags()\r
+    msg.add_tag("lift")\r
+    print msg.get_tags()\r
+    msg.thaw()\r
+exit()\r
+\r