From: Michael Radziej <mir@spieleck.de>
To: Florian Friesdorf <flo@chaoflow.net>, notmuch@notmuchmail.org
Subject: Re: (auto-)tagging sent messages
Date: Sun, 17 Apr 2011 00:44:06 +0200 [thread overview]
Message-ID: <87mxjphl55.fsf@spieleck.de> (raw)
In-Reply-To: <8739ll8dkv.fsf@eve.chaoflow.net>
[-- Attachment #1: Type: text/plain, Size: 674 bytes --]
Hi Florian!
On Thu, 14 Apr 2011 10:03:12 +0200, Florian Friesdorf <flo@chaoflow.net> 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):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: python code --]
[-- Type: text/x-python, Size: 1436 bytes --]
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')
[-- Attachment #3: Type: text/plain, Size: 32 bytes --]
Kind regards
Michael Radziej
next prev parent reply other threads:[~2011-04-16 22:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-14 8:03 (auto-)tagging sent messages Florian Friesdorf
2011-04-16 12:57 ` Pieter Praet
2011-04-16 19:23 ` Tom Prince
2011-04-17 17:53 ` Pieter Praet
2011-04-17 23:17 ` Tom Prince
2011-04-18 6:40 ` Pieter Praet
2011-04-17 18:23 ` Jameson Graef Rollins
2011-04-18 20:26 ` Austin Clements
2011-04-26 2:38 ` servilio
2011-04-16 22:44 ` Michael Radziej [this message]
2011-04-18 13:22 ` Xavier Maillard
2011-04-18 18:44 ` Michael Radziej
2011-04-18 19:29 ` Xavier Maillard
2011-04-19 10:18 ` Michael Radziej
2011-04-20 12:20 ` Xavier Maillard
2011-04-25 20:27 ` Carl Worth
2011-04-25 20:56 ` Tim Gray
2011-04-25 21:41 ` Carl Worth
2011-04-25 21:59 ` tracking non-mail files [was: Re: (auto-)tagging sent messages] Jameson Graef Rollins
2011-04-25 22:28 ` Carl Worth
2011-04-25 22:25 ` (auto-)tagging sent messages Xavier Maillard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mxjphl55.fsf@spieleck.de \
--to=mir@spieleck.de \
--cc=flo@chaoflow.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).