On Wed, Feb 20, 2013 at 05:27:50PM +0100, Matthias Apitz wrote:


Hi,

In mutt you can delete an entire thread, without reading it, by pressing
Ctrl-d

It would be nice if mutt, for example with Ctrl-Shift-d, remembers
this after a mutt session and does not present any mail of this thread
anymore. Comments about such a feature?

        matthias

PS: The actual thread would have been a candidate for me for pressing
Ctrl-Shift-d :-)

something like this should work. you can just pipe a message to the script and add a procmail receipe to do something with messages in your killfile:

#!/usr/bin/env python

import email
import argparse
import sys
import anydbm

parser = argparse.ArgumentParser(description='check or kill email threads')
parser.add_argument('-c', '--check', action='store_true', help='check if this 
message is part of a killed thread')
parser.add_argument('-k', '--kill', action='store_true', help='mark messages in 
this thread as killed')
parser.add_argument('-d', '--db', help='specify database to use to store 
message ids', required=True)
args = parser.parse_args()

db = anydbm.open(args.db, 'c')

msg = email.message_from_file(sys.stdin)
msgid = msg.get('message-id')

rv = 0

if args.check:
   refs = msg.get('references', '').split()
   if msgid in db or any((k in db for k in refs)):
       db[msgid] = None  # add current message in event references are trimmed
   else:
       rv = 1
elif args.kill:
   db[msgid] = None
else:
   print >>sys.stderr, 'Must specify either --check or --kill'
   rv = 1

db.close()
sys.exit(rv)

Reply via email to