Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5c / e86ccf34e0442bb1c1a3bed74d3a1bc94712d7
1 Return-Path: <jrollins@finestructure.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 39380431FBC\r
6         for <notmuch@notmuchmail.org>; Wed, 27 Jan 2010 06:44:47 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -3.511\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-3.511 tagged_above=-999 required=5 tests=[AWL=0.488,\r
12         BAYES_50=0.001, RCVD_IN_DNSWL_MED=-4] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id vQJyBPJEbLpL for <notmuch@notmuchmail.org>;\r
16         Wed, 27 Jan 2010 06:44:46 -0800 (PST)\r
17 Received: from serrano.cc.columbia.edu (serrano.cc.columbia.edu [128.59.29.6])\r
18         by olra.theworths.org (Postfix) with ESMTP id 76759431FAE\r
19         for <notmuch@notmuchmail.org>; Wed, 27 Jan 2010 06:44:46 -0800 (PST)\r
20 Received: from servo.finestructure.net (cpe-72-227-128-66.nyc.res.rr.com\r
21         [72.227.128.66])\r
22         (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0)\r
23         by serrano.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id o0REijpp017073\r
24         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
25         Wed, 27 Jan 2010 09:44:45 -0500 (EST)\r
26 Received: from jrollins by servo.finestructure.net with local (Exim 4.71)\r
27         (envelope-from <jrollins@finestructure.net>)\r
28         id 1Na98O-0002u5-T0; Wed, 27 Jan 2010 09:44:44 -0500\r
29 From: Jameson Rollins <jrollins@finestructure.net>\r
30 To: notmuch@notmuchmail.org\r
31 In-Reply-To: <873a1zs3t5.fsf@jhu.edu>\r
32 References: <873a1zs3t5.fsf@jhu.edu>\r
33 Date: Wed, 27 Jan 2010 09:44:41 -0500\r
34 Message-ID: <878wbj4nfq.fsf@servo.finestructure.net>\r
35 MIME-Version: 1.0\r
36 Content-Type: multipart/mixed; boundary="=-=-="\r
37 X-No-Spam-Score: Local\r
38 X-Scanned-By: MIMEDefang 2.68 on 128.59.29.6\r
39 Subject: Re: [notmuch] Fcc, Maildir, and Emacs message-mode -- a bit of code\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Wed, 27 Jan 2010 14:44:47 -0000\r
53 \r
54 --=-=-=\r
55 Content-Type: multipart/signed; boundary="==-=-=";\r
56         micalg=pgp-sha256; protocol="application/pgp-signature"\r
57 \r
58 --==-=-=\r
59 \r
60 Hey, folks.  Following up on this thread about better fcc handling,\r
61 Jesse passed on a simple python script he wrote that uses the python\r
62 "mailbox" module to deliver a message on stdin to a specified maildir\r
63 directory.  It's very a simple, elegant and general purpose script\r
64 (attached).\r
65 \r
66 I then put the following in my notmuch .emacs to use the new script in\r
67 message-mode to fcc sent mail to my ~/.mail/sent directory:\r
68 \r
69 ;; fcc handler\r
70 (defun maildir-deliver-region(destdir)\r
71   (shell-command-on-region\r
72    (point-min) (point-max)\r
73    (concat "maildir-deliver.py -c -s -d " destdir)))\r
74 (setq message-fcc-handler-function 'maildir-deliver-region)\r
75 (defun my-message-header-setup ()\r
76   (message-add-header "Fcc: ~/.mail/sent"))\r
77 (add-hook 'message-send-hook 'my-message-header-setup)\r
78 \r
79 Works like a charm.  Thanks Jesse!\r
80 \r
81 I think we should look at packaging this in a set of notmuch helper\r
82 scripts, hopefully including notmuchsync.\r
83 \r
84 jamie.\r
85 \r
86 \r
87 --==-=-=\r
88 Content-Type: application/pgp-signature\r
89 \r
90 -----BEGIN PGP SIGNATURE-----\r
91 Version: GnuPG v1.4.10 (GNU/Linux)\r
92 \r
93 iQIcBAEBCAAGBQJLYFFZAAoJEO00zqvie6q8zBQQAKeW9CS/VtexSaPfefPkETi8\r
94 li5cXLfKo//Ghd54Rkks5zhDQuUUPKwpS1KyyhJMUVedCTBO9f6yUqAqbzAsoc/U\r
95 ylKZrSD6jUerXvX4XZCmNoHBSSiql15XUeOHsbgNkErzEqg+gmUtARnbV4d7AQH2\r
96 76k7N+OxGiwGKR5zQt400iDZbGTP2ijhnXuoz2MX9BzcJVeQ/BtxBbOG47wJQ9nn\r
97 VsuhY4uUBHr8zbPleWgJg/ZjW7eB9d28WGzQIKePBNxz8hNKkXldzXD9IgIODS5H\r
98 noMG8GgpDC/Bst4zXiIaRqPTXLpQEFWOI3PGAvuCGWRHj/wMQOFD6Zr0apGeL7Do\r
99 AE4qn2W0LabsuCCdMpFs//P5rLXRLrX5xNENyvUgQo1H2Bmwz84vTzuMFbDZFSSb\r
100 xJPlm2clfzQy89xHti4nOeh+kA2/AQXA5Wh7J9el08vj4pQfZx4aRMoWdlqlA1i7\r
101 iuvQKUIanL/181hv2p0tdwr4Lfq8pDb3ps+3QW/TTt8Xm4bygwneqr0B3UvzV3sY\r
102 h26iLQEy10YMQQCk3QGUS7gMY6ttwD1bK0LEtCCDdFB0tmz19QQSMgcGbyacLiLj\r
103 59bvBru9JernwNo3uyRJHyCE0TLDQsj+0HcnXYgaKmDhHj27By5rBHqk7IpUFoE9\r
104 /QXniOulCEbwXhrKycc2\r
105 =8Xfg\r
106 -----END PGP SIGNATURE-----\r
107 --==-=-=--\r
108 \r
109 --=-=-=\r
110 Content-Type: text/x-python\r
111 Content-Disposition: Content-Disposition:attachment;\r
112  filename=maildir-deliver.py\r
113 Content-Description: python maildir delivery script\r
114 \r
115 #!/usr/bin/env python\r
116 \r
117 import mailbox\r
118 import sys\r
119 import optparse\r
120 \r
121 def maildir_deliver(msg, maildir, mark_read=False, mark_cur=False):\r
122     if mark_read:\r
123         msg.set_flags("S")\r
124     if mark_cur:\r
125         msg.set_subdir('cur')\r
126     md = mailbox.Maildir(maildir)\r
127     key = md.add(msg)\r
128     md.close\r
129 \r
130 if __name__ == '__main__':\r
131     parser = optparse.OptionParser()\r
132     parser.add_option("-d", "--destdir",\r
133                       dest="maildir", \r
134                       help="destination maildir")\r
135     parser.add_option("-s", "--seen",\r
136                       action="store_true", \r
137                       dest="mark_read",\r
138                       default=False,\r
139                       help="mark message as read")\r
140     parser.add_option("-c", "--cur",\r
141                       action="store_true", \r
142                       dest="mark_cur",\r
143                       default=False,\r
144                       help="deliver message to cur instead of new")\r
145     (options, args) = parser.parse_args()\r
146     msg = mailbox.MaildirMessage(sys.stdin)\r
147     maildir_deliver(msg, options.maildir, options.mark_read, options.mark_cur)\r
148 \r
149 --=-=-=--\r