A tool for printing from notmuch
authorJesse Rosenthal <jrosenthal@jhu.edu>
Fri, 28 Jan 2011 20:25:28 +0000 (15:25 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:48 +0000 (09:37 -0800)
5f/2725c38daa3937271926f872532cfa82adf125 [new file with mode: 0644]

diff --git a/5f/2725c38daa3937271926f872532cfa82adf125 b/5f/2725c38daa3937271926f872532cfa82adf125
new file mode 100644 (file)
index 0000000..1bfbbea
--- /dev/null
@@ -0,0 +1,109 @@
+Return-Path: <prvs=0024c1a73=jrosenthal@jhu.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0B995431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 28 Jan 2011 12:25:35 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 3ZZTxGc8hlIW for <notmuch@notmuchmail.org>;\r
+       Fri, 28 Jan 2011 12:25:34 -0800 (PST)\r
+Received: from ipex1.johnshopkins.edu (ipex1.johnshopkins.edu [162.129.8.141])\r
+       (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 4D20F431FB5\r
+       for <notmuch@notmuchmail.org>; Fri, 28 Jan 2011 12:25:34 -0800 (PST)\r
+X-IronPort-Anti-Spam-Filtered: true\r
+X-IronPort-Anti-Spam-Result: AvQEAJ+1Qk0KoSAO/2dsb2JhbACWZI8SsgyIaYVPBIUYhw8\r
+X-IronPort-AV: E=Sophos;i="4.60,394,1291611600"; d="scan'208";a="43230333"\r
+Received: from watt.hwcampus.jhu.edu ([10.161.32.14])\r
+       by ipex1.johnshopkins.edu with ESMTP/TLS/ADH-AES256-SHA;\r
+       28 Jan 2011 15:25:28 -0500\r
+Received: by watt.hwcampus.jhu.edu (Postfix, from userid 502)\r
+       id 6711F789974; Fri, 28 Jan 2011 15:25:28 -0500 (EST)\r
+From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: A tool for printing from notmuch\r
+User-Agent: Notmuch/0.5-56-g74cb76a (http://notmuchmail.org) Emacs/23.2.1\r
+       (x86_64-apple-darwin)\r
+Date: Fri, 28 Jan 2011 15:25:28 -0500\r
+Message-ID: <m162t87p3b.fsf@watt.hwcampus.jhu.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 28 Jan 2011 20:25:35 -0000\r
+\r
+Dear all,\r
+\r
+Printing from notmuch is a bit of a pain. Muttprint doesn't really help\r
+much, because it can't handle multiparts well, doesn't know what to do\r
+with html, and will print out pages of base64 if you have\r
+attachments. And more often than not, what I need to print is an HTML\r
+email (a bus ticket or something).\r
+\r
+A solution I've been working on for my own use is here:\r
+\r
+http://commonmeasure.org/~jkr/notmuchprint\r
+\r
+It's a python script that takes a message-id and sends printable html to\r
+your browser or stdout. Plain text is put in <pre> tags, html mails are,\r
+as much as possible, left alone, except for the headers at the top. You\r
+can configure (in ~/.notmuchprintrc) the font for plain text emails,\r
+what browser to use, whether to view automatically or output html, and\r
+whether or not to prefer plain text if both are available. (Since it's\r
+mainly html emails I need to print or view, I set the last one to no.)\r
+It also has a few command line options. Type "--help" to get the scoop.\r
+\r
+The only requirement outside of the stdlib is BeautifulSoup, to deal\r
+with email html.\r
+\r
+It's been working well for me. I have the following in my .emacs so I\r
+can use it from show mode by pressing "z":\r
+\r
+(define-key notmuch-show-mode-map "z" \r
+  '(lambda () (interactive)\r
+     (shell-command (concat "notmuchprint '"\r
+                           (notmuch-show-get-message-id) \r
+                           "'"))))\r
+\r
+The single-quotes are necessary for msg-ids with dollar-signs and\r
+whatnot in them.\r
+\r
+A couple of points:\r
+\r
+1. The HTML generation is intentionally pretty primitive. First, I\r
+didn't want to spend too much time on what is just a header box. Second,\r
+I didn't want to introduce any CSS that might screw with whatever\r
+godawful styles the email has. I'd welcome someone fixing this part up,\r
+but I still think a goal should be to make sure html emails remain\r
+unchanged.\r
+\r
+2. It uses json instead of the python bindings for two reasons. First,\r
+for my own personal use-case (remote) the bindings wouldn't have\r
+helped. Second, I'm guessing that the slowdown from getting json output\r
+is more than compensated for by having gmime do the parsing instead of\r
+python.\r
+\r
+Anyway, if people find this useful, or want to make changes, I'll make a\r
+git repo. For now, though, I just wanted to share it, since it's been\r
+making my life a bit easier.\r
+\r
+Best,\r
+Jesse\r