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 62699431FB6 for ; Sat, 16 Apr 2011 15:44:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 sIE0dYLLuWHK for ; Sat, 16 Apr 2011 15:44:11 -0700 (PDT) Received: from spieleck.de (mx.spieleck.de [213.95.6.62]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 4925F431FB5 for ; Sat, 16 Apr 2011 15:44:11 -0700 (PDT) Received: from turtur.spieleck.de (unknown [212.114.251.147]) by spieleck.de (spieleck.de Postfix) with ESMTP id E486AD80AF; Sun, 17 Apr 2011 00:44:06 +0200 (CEST) Received: by turtur.spieleck.de (Postfix, from userid 1000) id 1395D378F; Sun, 17 Apr 2011 00:44:06 +0200 (CEST) From: Michael Radziej To: Florian Friesdorf , notmuch@notmuchmail.org Subject: Re: (auto-)tagging sent messages In-Reply-To: <8739ll8dkv.fsf@eve.chaoflow.net> References: <8739ll8dkv.fsf@eve.chaoflow.net> User-Agent: Notmuch/0.5-63-g62725a5 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Sun, 17 Apr 2011 00:44:06 +0200 Message-ID: <87mxjphl55.fsf@spieleck.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: Sat, 16 Apr 2011 22:44:16 -0000 --=-=-= Hi Florian! On Thu, 14 Apr 2011 10:03:12 +0200, Florian Friesdorf wrote: > Further, for certain mails I sent (like this one ) I would like a > WAITING tag (or similar) in order to indicate that I am waiting for an > answer. Currently I set this manually. Could this be achieved through > some indicators via message mode or similar means? e.g.: I use a X-Wait header (like X-Wait: 2, meaning to wait for 2 days). If there is no activity in the thread within time, it receives additional tags "late" and "inbox". If an answer to a waiting mail arrives, it receives a tag "expected". Here's some python code that does the tagging (I haven't tested it): --=-=-= Content-Type: text/x-python Content-Disposition: inline; filename=tagging-wait.py Content-Description: python code import notmuch, re, time MY_ADDR = 'my email address' db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) def query(qstring): return db.create_query(qstring).search_messages() def query_threads(qstring): return db.create_query(qstring).search_threads() def timeout(msg): try: wait_days = msg.get_header('X-Wait') if wait_days: wait_days = int(wait_days) return time.time() > msg.get_date() + 24 * 60 * 60 * int(wait_days) except ValueError: return False def run(): new_thread_ids = set(t.get_thread_id() for t in query_threads('tag:new')) new_thread_clause = '(%s)' % " or ".join("thread:%s" % t for t in new_thread_ids) # checking all "wait" and "late" threads for msg in query('tag:wait'): thread_id = msg.get_thread_id() if thread_id in new_thread_ids: msg.remove_tag('wait') msg.remove_tag('late') for new_msg in query('thread:%s and tag:new' % thread_id): new_msg.add_tag('expected') else: if 'late' not in msg.get_tags() and timeout(msg): msg.add_tag('late') msg.add_tag('inbox') msg.remove_tag('wait') # handle sent messages for msg in query('tag:new and (tag:sent or from:%s)' % MY_ADDR): msg.add_tag('sent') if msg.get_header('X-Wait'): msg.add_tag('wait') --=-=-= Kind regards Michael Radziej --=-=-=--