Hey, folks. Following up on this thread about better fcc handling, Jesse passed on a simple python script he wrote that uses the python "mailbox" module to deliver a message on stdin to a specified maildir directory. It's very a simple, elegant and general purpose script (attached).
I then put the following in my notmuch .emacs to use the new script in message-mode to fcc sent mail to my ~/.mail/sent directory: ;; fcc handler (defun maildir-deliver-region(destdir) (shell-command-on-region (point-min) (point-max) (concat "maildir-deliver.py -c -s -d " destdir))) (setq message-fcc-handler-function 'maildir-deliver-region) (defun my-message-header-setup () (message-add-header "Fcc: ~/.mail/sent")) (add-hook 'message-send-hook 'my-message-header-setup) Works like a charm. Thanks Jesse! I think we should look at packaging this in a set of notmuch helper scripts, hopefully including notmuchsync. jamie.
pgpS1ojP8FF63.pgp
Description: PGP signature
#!/usr/bin/env python
import mailbox
import sys
import optparse
def maildir_deliver(msg, maildir, mark_read=False, mark_cur=False):
if mark_read:
msg.set_flags("S")
if mark_cur:
msg.set_subdir('cur')
md = mailbox.Maildir(maildir)
key = md.add(msg)
md.close
if __name__ == '__main__':
parser = optparse.OptionParser()
parser.add_option("-d", "--destdir",
dest="maildir",
help="destination maildir")
parser.add_option("-s", "--seen",
action="store_true",
dest="mark_read",
default=False,
help="mark message as read")
parser.add_option("-c", "--cur",
action="store_true",
dest="mark_cur",
default=False,
help="deliver message to cur instead of new")
(options, args) = parser.parse_args()
msg = mailbox.MaildirMessage(sys.stdin)
maildir_deliver(msg, options.maildir, options.mark_read, options.mark_cur)
_______________________________________________ notmuch mailing list [email protected] http://notmuchmail.org/mailman/listinfo/notmuch
