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 39380431FBC for ; Wed, 27 Jan 2010 06:44:47 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -3.511 X-Spam-Level: X-Spam-Status: No, score=-3.511 tagged_above=-999 required=5 tests=[AWL=0.488, BAYES_50=0.001, RCVD_IN_DNSWL_MED=-4] autolearn=ham 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 vQJyBPJEbLpL for ; Wed, 27 Jan 2010 06:44:46 -0800 (PST) Received: from serrano.cc.columbia.edu (serrano.cc.columbia.edu [128.59.29.6]) by olra.theworths.org (Postfix) with ESMTP id 76759431FAE for ; Wed, 27 Jan 2010 06:44:46 -0800 (PST) Received: from servo.finestructure.net (cpe-72-227-128-66.nyc.res.rr.com [72.227.128.66]) (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0) by serrano.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id o0REijpp017073 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 27 Jan 2010 09:44:45 -0500 (EST) Received: from jrollins by servo.finestructure.net with local (Exim 4.71) (envelope-from ) id 1Na98O-0002u5-T0; Wed, 27 Jan 2010 09:44:44 -0500 From: Jameson Rollins To: notmuch@notmuchmail.org In-Reply-To: <873a1zs3t5.fsf@jhu.edu> References: <873a1zs3t5.fsf@jhu.edu> Date: Wed, 27 Jan 2010 09:44:41 -0500 Message-ID: <878wbj4nfq.fsf@servo.finestructure.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.68 on 128.59.29.6 Subject: Re: [notmuch] Fcc, Maildir, and Emacs message-mode -- a bit of code 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: Wed, 27 Jan 2010 14:44:47 -0000 --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --==-=-= 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. --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBCAAGBQJLYFFZAAoJEO00zqvie6q8zBQQAKeW9CS/VtexSaPfefPkETi8 li5cXLfKo//Ghd54Rkks5zhDQuUUPKwpS1KyyhJMUVedCTBO9f6yUqAqbzAsoc/U ylKZrSD6jUerXvX4XZCmNoHBSSiql15XUeOHsbgNkErzEqg+gmUtARnbV4d7AQH2 76k7N+OxGiwGKR5zQt400iDZbGTP2ijhnXuoz2MX9BzcJVeQ/BtxBbOG47wJQ9nn VsuhY4uUBHr8zbPleWgJg/ZjW7eB9d28WGzQIKePBNxz8hNKkXldzXD9IgIODS5H noMG8GgpDC/Bst4zXiIaRqPTXLpQEFWOI3PGAvuCGWRHj/wMQOFD6Zr0apGeL7Do AE4qn2W0LabsuCCdMpFs//P5rLXRLrX5xNENyvUgQo1H2Bmwz84vTzuMFbDZFSSb xJPlm2clfzQy89xHti4nOeh+kA2/AQXA5Wh7J9el08vj4pQfZx4aRMoWdlqlA1i7 iuvQKUIanL/181hv2p0tdwr4Lfq8pDb3ps+3QW/TTt8Xm4bygwneqr0B3UvzV3sY h26iLQEy10YMQQCk3QGUS7gMY6ttwD1bK0LEtCCDdFB0tmz19QQSMgcGbyacLiLj 59bvBru9JernwNo3uyRJHyCE0TLDQsj+0HcnXYgaKmDhHj27By5rBHqk7IpUFoE9 /QXniOulCEbwXhrKycc2 =8Xfg -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/x-python Content-Disposition: Content-Disposition:attachment; filename=maildir-deliver.py Content-Description: python maildir delivery script #!/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) --=-=-=--