--- /dev/null
+Return-Path: <dme@dme.org>\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 883ED40DDCF\r
+ for <notmuch@notmuchmail.org>; Fri, 12 Nov 2010 04:55:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+ tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\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 7Op59phRvHJB for <notmuch@notmuchmail.org>;\r
+ Fri, 12 Nov 2010 04:55:08 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45]) by olra.theworths.org (Postfix) with ESMTP id 8F8A24196F0 for\r
+ <notmuch@notmuchmail.org>; Fri, 12 Nov 2010 04:55:08 -0800 (PST)\r
+Received: by wwb39 with SMTP id 39so28016wwb.2\r
+ for <notmuch@notmuchmail.org>; Fri, 12 Nov 2010 04:55:07 -0800 (PST)\r
+Received: by 10.216.28.15 with SMTP id f15mr3816609wea.39.1289566496478;\r
+ Fri, 12 Nov 2010 04:54:56 -0800 (PST)\r
+Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com\r
+ [81.149.164.25])\r
+ by mx.google.com with ESMTPS id p4sm2116657wej.28.2010.11.12.04.54.53\r
+ (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+ Fri, 12 Nov 2010 04:54:54 -0800 (PST)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+ id 7EB1C59405B; Fri, 12 Nov 2010 12:53:09 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: =?UTF-8?q?=5BPATCH=5D=20emacs=3A=20Improved=20printing=20support=2E?=\r
+Date: Fri, 12 Nov 2010 12:53:08 +0000\r
+Message-Id: <1289566388-24300-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <87sjz8yq5a.fsf@ut.hh.sledj.net>\r
+References: <87sjz8yq5a.fsf@ut.hh.sledj.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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, 12 Nov 2010 12:55:20 -0000\r
+\r
+---\r
+\r
+More usable (I'm trying 'muttprint then evince').\r
+\r
+ emacs/Makefile.local | 3 +-\r
+ emacs/notmuch-print.el | 75 ++++++++++++++++++++++++++++++++++++++++++++++++\r
+ emacs/notmuch-show.el | 51 ++++++++++++++++++++++++++++++++\r
+ 3 files changed, 128 insertions(+), 1 deletions(-)\r
+ create mode 100644 emacs/notmuch-print.el\r
+\r
+diff --git a/emacs/Makefile.local b/emacs/Makefile.local\r
+index c5280f1..df87427 100644\r
+--- a/emacs/Makefile.local\r
++++ b/emacs/Makefile.local\r
+@@ -13,7 +13,8 @@ emacs_sources := \\r
+ $(dir)/notmuch-maildir-fcc.el \\r
+ $(dir)/notmuch-message.el \\r
+ $(dir)/coolj.el \\r
+- $(dir)/notmuch-lkml.el\r
++ $(dir)/notmuch-lkml.el \\r
++ $(dir)/notmuch-print.el\r
+ \r
+ emacs_images := \\r
+ $(dir)/notmuch-logo.png\r
+diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el\r
+new file mode 100644\r
+index 0000000..62e380c\r
+--- /dev/null\r
++++ b/emacs/notmuch-print.el\r
+@@ -0,0 +1,75 @@\r
++;; notmuch-print.el --- printing messages from notmuch.\r
++;;\r
++;; Copyright © David Edmondson\r
++;;\r
++;; This file is part of Notmuch.\r
++;;\r
++;; Notmuch is free software: you can redistribute it and/or modify it\r
++;; under the terms of the GNU General Public License as published by\r
++;; the Free Software Foundation, either version 3 of the License, or\r
++;; (at your option) any later version.\r
++;;\r
++;; Notmuch is distributed in the hope that it will be useful, but\r
++;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
++;; General Public License for more details.\r
++;;\r
++;; You should have received a copy of the GNU General Public License\r
++;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.\r
++;;\r
++;; Authors: David Edmondson <dme@dme.org>\r
++\r
++(defcustom notmuch-print-mechanism 'notmuch-print-lpr\r
++ "How should printing be done?"\r
++ :group 'notmuch\r
++ :type '(choice\r
++ (function :tag "Use lpr" notmuch-print-lpr)\r
++ (function :tag "Use ps-print" notmuch-print-ps-print)\r
++ (function :tag "Use ps-print then evince" notmuch-print-ps-print/evince)\r
++ (function :tag "Use muttprint" notmuch-print-muttprint)\r
++ (function :tag "Use muttprint then evince" notmuch-print-muttprint/evince)\r
++ (function :tag "Using a custom function")))\r
++\r
++(defmacro notmuch-print-with-file (filename &rest body)\r
++ `(with-temp-buffer\r
++ (insert-file-contents ,filename)\r
++ (setq buffer-modified-p nil)\r
++ ,@body))\r
++\r
++(defun notmuch-print-lpr (filename)\r
++ (notmuch-print-with-file filename\r
++ (lpr-buffer)))\r
++\r
++(defun notmuch-print-ps-print (filename)\r
++ (notmuch-print-with-file filename\r
++ (ps-print-buffer)))\r
++\r
++(defun notmuch-print-ps-print/evince (filename)\r
++ (let ((ps-file (make-temp-file "notmuch")))\r
++ (notmuch-print-with-file filename\r
++ (ps-print-buffer ps-file)\r
++ (async-shell-command (concat "evince " ps-file)))))\r
++\r
++(defun notmuch-print-muttprint (filename)\r
++ (shell-command\r
++ (concat "muttprint "\r
++ "--file " (shell-quote-argument filename) " "\r
++ ;; Show the tags.\r
++ "--printed-headers Date_To_From_CC_Newsgroups_*Subject*_/Tags/ ")))\r
++\r
++(defun notmuch-print-muttprint/evince (filename)\r
++ (let ((ps-file (make-temp-file "notmuch")))\r
++ (call-process-shell-command\r
++ (concat "muttprint "\r
++ "--file " (shell-quote-argument filename) " "\r
++ ;; Show the tags.\r
++ "--printed-headers Date_To_From_CC_Newsgroups_*Subject*_/Tags/ "\r
++ "--printer \"TO_FILE:" (shell-quote-argument ps-file) "\""))\r
++ (async-shell-command (concat "evince " ps-file))))\r
++\r
++(defun notmuch-print-message (filename)\r
++ (funcall notmuch-print-mechanism filename))\r
++\r
++;;\r
++\r
++(provide 'notmuch-print)\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index aa89cfd..002c2fd 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -32,6 +32,7 @@\r
+ (require 'notmuch-query)\r
+ (require 'notmuch-wash)\r
+ (require 'notmuch-mua)\r
++(require 'notmuch-print)\r
+ \r
+ (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))\r
+ (declare-function notmuch-fontify-headers "notmuch" nil)\r
+@@ -174,6 +175,51 @@ Set `notmuch-show-address-simplication' to:\r
+ mm-handle (> (notmuch-count-attachments mm-handle) 1))))\r
+ (message "Done"))\r
+ \r
++(defun notmuch-show-with-message-as-text (fn)\r
++ "Apply function `fn' to a text representation of the current\r
++message."\r
++\r
++ ;; Remake the header to ensure that all information is available.\r
++ (let* ((to (notmuch-show-get-to))\r
++ (cc (notmuch-show-get-cc))\r
++ (from (notmuch-show-get-from))\r
++ (subject (notmuch-show-get-subject))\r
++ (date (notmuch-show-get-date))\r
++ (tags (notmuch-show-get-tags))\r
++ (depth (notmuch-show-get-depth))\r
++\r
++ (header (concat\r
++ "Subject: " subject "\n"\r
++ "To: " to "\n"\r
++ (if (not (string= cc ""))\r
++ (concat "Cc: " cc "\n")\r
++ "")\r
++ "From: " from "\n"\r
++ "Date: " date "\n"\r
++ (if tags\r
++ (concat "Tags: "\r
++ (mapconcat '(lambda (tag) tag) tags ", ") "\n")\r
++ "")))\r
++ (all (buffer-substring (notmuch-show-message-top)\r
++ (notmuch-show-message-bottom)))\r
++\r
++ (file (make-temp-file "notmuch")))\r
++ (with-temp-file file\r
++ (insert all)\r
++ (indent-rigidly (point-min) (point-max) (- depth))\r
++ ;; Remove the original header.\r
++ (goto-char (point-min))\r
++ (re-search-forward "^$" (point-max) nil)\r
++ (delete-region (point-min) (point))\r
++ (insert header))\r
++ (funcall fn file)\r
++ (delete-file file)))\r
++\r
++(defun notmuch-show-print-message ()\r
++ "Print the current message."\r
++ (interactive)\r
++ (notmuch-show-with-message-as-text 'notmuch-print-message))\r
++\r
+ (defun notmuch-show-fontify-header ()\r
+ (let ((face (cond\r
+ ((looking-at "[Tt]o:")\r
+@@ -530,6 +576,8 @@ current buffer, if possible."\r
+ (plist-put msg :message-invis-spec message-invis-spec)\r
+ (overlay-put (make-overlay body-start body-end) 'invisible message-invis-spec)\r
+ \r
++ (plist-put msg :depth depth)\r
++\r
+ ;; Save the properties for this message. Currently this saves the\r
+ ;; entire message (augmented it with other stuff), which seems\r
+ ;; like overkill. We might save a reduced subset (for example, not\r
+@@ -831,6 +879,9 @@ All currently available key bindings:\r
+ (defun notmuch-show-get-to ()\r
+ (notmuch-show-get-header :To))\r
+ \r
++(defun notmuch-show-get-depth ()\r
++ (notmuch-show-get-prop :depth))\r
++\r
+ (defun notmuch-show-set-tags (tags)\r
+ "Set the tags of the current message."\r
+ (notmuch-show-set-prop :tags tags)\r
+-- \r
+1.7.2.3\r
+\r