Re: Hi all
[notmuch-archives.git] / ff / dc79c4c1e289edfb3a8122309869ccf50134a1
1 Return-Path: <mafubryan@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 5EC1B431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 15 May 2012 03:14:56 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id uAwGQPBZmrZq for <notmuch@notmuchmail.org>;\r
17         Tue, 15 May 2012 03:14:54 -0700 (PDT)\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id A7BA3431FAE\r
22         for <notmuch@notmuchmail.org>; Tue, 15 May 2012 03:14:54 -0700 (PDT)\r
23 Received: by bkcjk13 with SMTP id jk13so5286220bkc.26\r
24         for <notmuch@notmuchmail.org>; Tue, 15 May 2012 03:14:53 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=message-id:subject:from:to:cc:date:in-reply-to:references\r
27         :content-type:x-mailer:content-transfer-encoding:mime-version;\r
28         bh=RgKLAc0qbCX/oJxDkrBUner2OzbDfMZmHgi9ixEBVz0=;\r
29         b=0vfPymXmWwh5YMzVKZhE2Xegj/OZ6fjadrTWUnE5LcgsF4N8brwGpRcyRKdnByg8p6\r
30         G1qLCieo5F20ctRF4Z+iJbau7sVXuZL/QK5P+pfXhQ3p1aGLcadOzomVSmrHaUBbwSlr\r
31         dE/PCcsCJ7eHe15dXWajh42d54k5T121fZfvKcMLxZl9Cvl4Eht3q0JKyQjEJvLI45JX\r
32         m270Agex+7KaK/8gbRMi+IAtcQC50wItuEqzOrHiubLpllalR/TSD5CilH/IYMoU/iY9\r
33         HBR1J5V7rmhtSzaSb9iysfLPXJ3Ze2Xw2iR6PtL81xPSGKz1V+A++Azie11WDKnz0Fy+\r
34         GIow==\r
35 Received: by 10.204.152.199 with SMTP id h7mr4600666bkw.39.1337076893280;\r
36         Tue, 15 May 2012 03:14:53 -0700 (PDT)\r
37 Received: from [192.168.0.2]\r
38         (cpc1-lewi12-0-0-cust882.2-4.cable.virginmedia.com. [82.4.187.115])\r
39         by mx.google.com with ESMTPS id\r
40         fw10sm40425444bkc.11.2012.05.15.03.14.51\r
41         (version=SSLv3 cipher=OTHER); Tue, 15 May 2012 03:14:52 -0700 (PDT)\r
42 Message-ID: <1337076890.12535.2.camel@dsktp>\r
43 Subject: Re: Using procmail to set tags\r
44 From: bryan hunt <mafubryan@gmail.com>\r
45 To: Robert Horn <rjhorn@alum.mit.edu>\r
46 Date: Tue, 15 May 2012 11:14:50 +0100\r
47 In-Reply-To: <m3vcjyl4kg.fsf@quad.robs.office>\r
48 References: <m3vcjyl4kg.fsf@quad.robs.office>\r
49 Content-Type: text/plain; charset="UTF-8"\r
50 X-Mailer: Evolution 3.2.3-0ubuntu6 \r
51 Content-Transfer-Encoding: 7bit\r
52 Mime-Version: 1.0\r
53 Cc: notmuch@notmuchmail.org\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\r
57 List-Id: "Use and development of the notmuch mail system."\r
58         <notmuch.notmuchmail.org>\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
62 List-Post: <mailto:notmuch@notmuchmail.org>\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
66 X-List-Received-Date: Tue, 15 May 2012 10:14:56 -0000\r
67 \r
68 On Mon, 2012-05-14 at 19:34 -0400, Robert Horn wrote:\r
69 > Is it practical (and has anyone documented) using a procmail setup to\r
70 > set initial tags for messages using notmuch?\r
71\r
72 > I've just started using emacs-notmuch to read mail, and I'm using a\r
73 > system where I have procmail filters to bin mail by category into\r
74 > folders.  I can continue this using folder:value for searching, but one\r
75 > reason notmuch interests me is the potential to do more.\r
76\r
77 > It's practical for me to assign potentially overlapping tags with a more\r
78 > sophisticated procmail setup.  Notmuch tags enable having multiple tags\r
79 > on one email.\r
80\r
81 > I don't know enough about the procmail/notmuch process to see just how\r
82 > to make this happen.  I'm hoping that someone has already done something\r
83 > similar.\r
84\r
85 > R Horn\r
86 > rjhorn@alum.mit.edu\r
87 \r
88 You could have procmail fire a python script to add or remove tags based\r
89 upon message content. \r
90 \r
91 Here's a python script I tried using to untag messages from the Lift\r
92 mailing list, there was a problem when I wrote it, but it's probably\r
93 been fixed by now.\r
94 \r
95 #!/usr/bin/env python\r
96 \r
97 from notmuch import *\r
98 \r
99 '''\r
100 The idea of this script is that it will untag mailing list messages,\r
101 keeping them from my inbox unless they are directly related to me.\r
102 \r
103 The problem is that the tag removal isn't being saved. \r
104 I've created a bug report with the developer:\r
105 \r
106 https://bitbucket.org/spaetz/cnotmuch/issue/1/removing-tags-doesnt-seem-to-be-saving\r
107 \r
108 '''\r
109 db = Database('/home/bryan/.maildb',False, 'READ_WRITE')\r
110 q=db.create_query("'[lift]' -from:bryan tag:inbox")\r
111 \r
112 for msg in q.search_messages():\r
113     print msg.get_tags()\r
114     msg.freeze()\r
115     msg.remove_tag("inbox")\r
116     print msg.get_tags()\r
117     msg.remove_tag("unread")\r
118     print msg.get_tags()\r
119     msg.add_tag("lift")\r
120     print msg.get_tags()\r
121     msg.thaw()\r
122 exit()\r
123 \r