1 Return-Path: <dme@dme.org>
\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 AF1BB40DBE6
\r
6 for <notmuch@notmuchmail.org>; Thu, 11 Nov 2010 04:58:55 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] 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 a4xoXtYSAopk for <notmuch@notmuchmail.org>;
\r
16 Thu, 11 Nov 2010 04:58:44 -0800 (PST)
\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
18 [74.125.82.45]) by olra.theworths.org (Postfix) with ESMTP id 254DA40DBCD for
\r
19 <notmuch@notmuchmail.org>; Thu, 11 Nov 2010 04:58:44 -0800 (PST)
\r
20 Received: by wwb39 with SMTP id 39so202072wwb.2
\r
21 for <notmuch@notmuchmail.org>; Thu, 11 Nov 2010 04:58:41 -0800 (PST)
\r
22 Received: by 10.227.129.76 with SMTP id n12mr793727wbs.100.1289480321141;
\r
23 Thu, 11 Nov 2010 04:58:41 -0800 (PST)
\r
24 Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com
\r
26 by mx.google.com with ESMTPS id b30sm1678383wbb.4.2010.11.11.04.58.39
\r
27 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
28 Thu, 11 Nov 2010 04:58:39 -0800 (PST)
\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
30 id 5F23559405B; Thu, 11 Nov 2010 12:57:05 +0000 (GMT)
\r
31 To: Keith Packard <keithp@keithp.com>,
\r
32 Sebastian Spaeth <Sebastian@SSpaeth.de>, notmuch@notmuchmail.org
\r
33 Subject: Re: Printing mail
\r
34 In-Reply-To: <yunhbfpy66e.fsf@aiko.keithp.com>
\r
35 References: <yunbp5ysg7z.fsf@aiko.keithp.com> <87fwva4glr.fsf@SSpaeth.de>
\r
36 <yun8w12s7fo.fsf@aiko.keithp.com> <87eiattz0u.fsf@SSpaeth.de>
\r
37 <yunhbfpy66e.fsf@aiko.keithp.com>
\r
38 User-Agent: Notmuch/0.4-21-g3f7bc98 (http://notmuchmail.org) Emacs/23.2.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 From: David Edmondson <dme@dme.org>
\r
41 Date: Thu, 11 Nov 2010 12:57:05 +0000
\r
42 Message-ID: <87sjz8yq5a.fsf@ut.hh.sledj.net>
\r
44 Content-Type: multipart/mixed; boundary="=-=-="
\r
45 X-BeenThere: notmuch@notmuchmail.org
\r
46 X-Mailman-Version: 2.1.13
\r
48 List-Id: "Use and development of the notmuch mail system."
\r
49 <notmuch.notmuchmail.org>
\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
53 List-Post: <mailto:notmuch@notmuchmail.org>
\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
57 X-List-Received-Date: Thu, 11 Nov 2010 12:58:55 -0000
\r
60 Content-Type: text/plain
\r
62 On Tue, 09 Nov 2010 23:43:53 -0800, Keith Packard <keithp@keithp.com> wrote:
\r
63 > On Wed, 10 Nov 2010 08:32:01 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:
\r
65 > > which gives me nice menu entries for previewing my printouts (defaults
\r
66 > > to 'gv' but can easily be set to use 'evince') and which provides the
\r
67 > > M-x pr-ps-buffer-preview command to invoke the print preview directly
\r
68 > > (unfortunately it still asks about the n-up scaling of pages).
\r
70 > Oh, but that doesn't print a message, it prints a buffer which may contain
\r
71 > other stuff, and may have some elided lines.
\r
73 Which is swings and roundabouts, especially if the message in question
\r
74 has multiple parts - muttprint produces mostly horrid output for
\r
75 something with both text/plain and text/html parts.
\r
77 How about something like the attached?
\r
80 Content-Type: text/x-diff; charset=utf-8
\r
81 Content-Disposition: inline;
\r
82 filename=0001-emacs-Improved-printing-support.patch
\r
83 Content-Transfer-Encoding: quoted-printable
\r
85 >From 2fefbe83fd5d0abed4aa063f5d0d2a7b59873bd8 Mon Sep 17 00:00:00 2001
\r
86 From: David Edmondson <dme@dme.org>
\r
87 Date: Thu, 11 Nov 2010 12:33:19 +0000
\r
88 Subject: [PATCH] emacs: Improved printing support.
\r
91 emacs/Makefile.local | 3 +-
\r
92 emacs/notmuch-print.el | 67 ++++++++++++++++++++++++++++++++++++++++++++=
\r
94 emacs/notmuch-show.el | 38 +++++++++++++++++++++++++++
\r
95 3 files changed, 107 insertions(+), 1 deletions(-)
\r
96 create mode 100644 emacs/notmuch-print.el
\r
98 diff --git a/emacs/Makefile.local b/emacs/Makefile.local
\r
99 index c5280f1..df87427 100644
\r
100 --- a/emacs/Makefile.local
\r
101 +++ b/emacs/Makefile.local
\r
102 @@ -13,7 +13,8 @@ emacs_sources :=3D \
\r
103 $(dir)/notmuch-maildir-fcc.el \
\r
104 $(dir)/notmuch-message.el \
\r
106 - $(dir)/notmuch-lkml.el
\r
107 + $(dir)/notmuch-lkml.el \
\r
108 + $(dir)/notmuch-print.el
\r
110 emacs_images :=3D \
\r
111 $(dir)/notmuch-logo.png
\r
112 diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
\r
113 new file mode 100644
\r
114 index 0000000..2ad4b45
\r
116 +++ b/emacs/notmuch-print.el
\r
118 +;; notmuch-print.el --- printing messages from notmuch.
\r
120 +;; Copyright =C2=A9 David Edmondson
\r
122 +;; This file is part of Notmuch.
\r
124 +;; Notmuch is free software: you can redistribute it and/or modify it
\r
125 +;; under the terms of the GNU General Public License as published by
\r
126 +;; the Free Software Foundation, either version 3 of the License, or
\r
127 +;; (at your option) any later version.
\r
129 +;; Notmuch is distributed in the hope that it will be useful, but
\r
130 +;; WITHOUT ANY WARRANTY; without even the implied warranty of
\r
131 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
132 +;; General Public License for more details.
\r
134 +;; You should have received a copy of the GNU General Public License
\r
135 +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
\r
137 +;; Authors: David Edmondson <dme@dme.org>
\r
139 +(defcustom notmuch-print-mechanism 'lpr
\r
140 + "How should printing be done?"
\r
143 + (const :tag "Use lpr" lpr)
\r
144 + (const :tag "Use ps-print" ps-print)
\r
145 + (const :tag "Use muttprint" muttprint)
\r
146 + (function :tag "Using a custom function")))
\r
148 +(defvar notmuch-print-mechanism-map
\r
149 + '((lpr . notmuch-print-lpr)
\r
150 + (ps-print . notmuch-print-ps-print)
\r
151 + (muttprint . notmuch-print-muttprint)))
\r
153 +(defmacro notmuch-print-with-file (filename &rest body)
\r
154 + `(with-temp-buffer
\r
155 + (insert-file-contents ,filename)
\r
156 + (setq buffer-modified-p nil)
\r
159 +(defun notmuch-print-lpr (filename)
\r
160 + (notmuch-print-with-file filename
\r
163 +(defun notmuch-print-ps-print (filename)
\r
164 + (notmuch-print-with-file filename
\r
165 + (ps-print-buffer)))
\r
167 +(defun notmuch-print-muttprint (filename)
\r
169 + (concat "cat " (shell-quote-argument filename) " | muttprint")))
\r
171 +(defun notmuch-print-message (filename)
\r
174 + ((functionp 'notmuch-print-mechanism)
\r
175 + 'notmuch-print-mechanism)
\r
176 + ((assoc notmuch-print-mechanism notmuch-print-mechanism-map)
\r
177 + (cdr (assoc notmuch-print-mechanism notmuch-print-mechanism-map)))
\r
179 + (error "No printing mechanism found")))))
\r
180 + (funcall fn filename)))
\r
184 +(provide 'notmuch-print)
\r
185 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
186 index 5efdf84..3680faf 100644
\r
187 --- a/emacs/notmuch-show.el
\r
188 +++ b/emacs/notmuch-show.el
\r
190 (require 'notmuch-query)
\r
191 (require 'notmuch-wash)
\r
192 (require 'notmuch-mua)
\r
193 +(require 'notmuch-print)
\r
195 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
\r
196 (declare-function notmuch-fontify-headers "notmuch" nil)
\r
197 @@ -174,6 +175,38 @@ Set `notmuch-show-address-simplication' to:
\r
198 mm-handle (> (notmuch-count-attachments mm-handle) 1))))
\r
201 +(defun notmuch-show-with-message-as-text (fn)
\r
202 + "Apply function `fn' to a text representation of the current
\r
204 + (let* ((from (notmuch-show-clean-address
\r
205 + (mail-header-parse-address (notmuch-show-get-from))))
\r
206 + (subject (notmuch-show-get-subject))
\r
207 + (date (notmuch-show-get-date))
\r
209 + "Tags: " (mapconcat '(lambda (tag) tag)
\r
210 + (notmuch-show-get-tags) ", ")
\r
212 + "From: " from "\n"
\r
213 + "Date: " date "\n"))
\r
214 + (body (save-excursion
\r
215 + (goto-char (notmuch-show-message-top))
\r
217 + (buffer-substring (point) (notmuch-show-message-bottom))))
\r
218 + (depth (notmuch-show-get-depth))
\r
219 + (file (make-temp-file "notmuch")))
\r
220 + (with-temp-file file
\r
222 + (indent-rigidly (point-min) (point-max) (- depth))
\r
223 + (goto-char (point-min))
\r
225 + (funcall fn file)
\r
226 + (delete-file file)))
\r
228 +(defun notmuch-show-print-message ()
\r
229 + "Print the current message."
\r
231 + (notmuch-show-with-message-as-text 'notmuch-print-message))
\r
233 (defun notmuch-show-fontify-header ()
\r
235 ((looking-at "[Tt]o:")
\r
236 @@ -520,6 +553,8 @@ current buffer, if possible."
\r
237 (plist-put msg :message-invis-spec message-invis-spec)
\r
238 (overlay-put (make-overlay body-start body-end) 'invisible message-inv=
\r
241 + (plist-put msg :depth depth)
\r
243 ;; Save the properties for this message. Currently this saves the
\r
244 ;; entire message (augmented it with other stuff), which seems
\r
245 ;; like overkill. We might save a reduced subset (for example, not
\r
246 @@ -821,6 +856,9 @@ All currently available key bindings:
\r
247 (defun notmuch-show-get-to ()
\r
248 (notmuch-show-get-header :To))
\r
250 +(defun notmuch-show-get-depth ()
\r
251 + (notmuch-show-get-prop :depth))
\r
253 (defun notmuch-show-set-tags (tags)
\r
254 "Set the tags of the current message."
\r
255 (notmuch-show-set-prop :tags tags)
\r
261 Content-Type: text/plain
\r
266 David Edmondson, http://dme.org
\r