1 Return-Path: <mir@spieleck.de>
\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 62699431FB6
\r
6 for <notmuch@notmuchmail.org>; Sat, 16 Apr 2011 15:44:15 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id sIE0dYLLuWHK for <notmuch@notmuchmail.org>;
\r
16 Sat, 16 Apr 2011 15:44:11 -0700 (PDT)
\r
17 Received: from spieleck.de (mx.spieleck.de [213.95.6.62])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 4925F431FB5
\r
21 for <notmuch@notmuchmail.org>; Sat, 16 Apr 2011 15:44:11 -0700 (PDT)
\r
22 Received: from turtur.spieleck.de (unknown [212.114.251.147])
\r
23 by spieleck.de (spieleck.de Postfix) with ESMTP id E486AD80AF;
\r
24 Sun, 17 Apr 2011 00:44:06 +0200 (CEST)
\r
25 Received: by turtur.spieleck.de (Postfix, from userid 1000)
\r
26 id 1395D378F; Sun, 17 Apr 2011 00:44:06 +0200 (CEST)
\r
27 From: Michael Radziej <mir@spieleck.de>
\r
28 To: Florian Friesdorf <flo@chaoflow.net>, notmuch@notmuchmail.org
\r
29 Subject: Re: (auto-)tagging sent messages
\r
30 In-Reply-To: <8739ll8dkv.fsf@eve.chaoflow.net>
\r
31 References: <8739ll8dkv.fsf@eve.chaoflow.net>
\r
32 User-Agent: Notmuch/0.5-63-g62725a5 (http://notmuchmail.org) Emacs/23.3.1
\r
33 (x86_64-unknown-linux-gnu)
\r
34 Date: Sun, 17 Apr 2011 00:44:06 +0200
\r
35 Message-ID: <87mxjphl55.fsf@spieleck.de>
\r
37 Content-Type: multipart/mixed; boundary="=-=-="
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Sat, 16 Apr 2011 22:44:16 -0000
\r
56 On Thu, 14 Apr 2011 10:03:12 +0200, Florian Friesdorf <flo@chaoflow.net> wrote:
\r
57 > Further, for certain mails I sent (like this one ) I would like a
\r
58 > WAITING tag (or similar) in order to indicate that I am waiting for an
\r
59 > answer. Currently I set this manually. Could this be achieved through
\r
60 > some indicators via message mode or similar means? e.g.:
\r
62 I use a X-Wait header (like X-Wait: 2, meaning to wait for 2 days). If
\r
63 there is no activity in the thread within time, it receives additional tags
\r
64 "late" and "inbox". If an answer to a waiting mail arrives, it receives a tag "expected".
\r
66 Here's some python code that does the tagging (I haven't tested it):
\r
70 Content-Type: text/x-python
\r
71 Content-Disposition: inline; filename=tagging-wait.py
\r
72 Content-Description: python code
\r
74 import notmuch, re, time
\r
76 MY_ADDR = 'my email address'
\r
78 db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
\r
81 return db.create_query(qstring).search_messages()
\r
83 def query_threads(qstring):
\r
84 return db.create_query(qstring).search_threads()
\r
88 wait_days = msg.get_header('X-Wait')
\r
90 wait_days = int(wait_days)
\r
91 return time.time() > msg.get_date() + 24 * 60 * 60 * int(wait_days)
\r
96 new_thread_ids = set(t.get_thread_id() for t in query_threads('tag:new'))
\r
97 new_thread_clause = '(%s)' % " or ".join("thread:%s" % t for t in new_thread_ids)
\r
99 # checking all "wait" and "late" threads
\r
100 for msg in query('tag:wait'):
\r
101 thread_id = msg.get_thread_id()
\r
102 if thread_id in new_thread_ids:
\r
103 msg.remove_tag('wait')
\r
104 msg.remove_tag('late')
\r
105 for new_msg in query('thread:%s and tag:new' % thread_id):
\r
106 new_msg.add_tag('expected')
\r
108 if 'late' not in msg.get_tags() and timeout(msg):
\r
109 msg.add_tag('late')
\r
110 msg.add_tag('inbox')
\r
111 msg.remove_tag('wait')
\r
113 # handle sent messages
\r
114 for msg in query('tag:new and (tag:sent or from:%s)' % MY_ADDR):
\r
115 msg.add_tag('sent')
\r
116 if msg.get_header('X-Wait'):
\r
117 msg.add_tag('wait')
\r