X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-print.el;h=85fa1f218cfae1111cdb3e053c49cd4e05540b38;hb=afa45bd6b886838b760884a1870f274fc33b5f89;hp=f96ccbeb2428425169ea21d3fd80f44a67a1ab82;hpb=05f4904616b95a17332d7573e44a4aad2dc4033e;p=notmuch
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index f96ccbeb..85fa1f21 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -1,4 +1,4 @@
-;; notmuch-print.el --- printing messages from notmuch.
+;;; notmuch-print.el --- printing messages from notmuch -*- lexical-binding: t -*-
;;
;; Copyright © David Edmondson
;;
@@ -15,13 +15,21 @@
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
-;; along with Notmuch. If not, see .
+;; along with Notmuch. If not, see .
;;
;; Authors: David Edmondson
+;;; Code:
+
+(require 'notmuch-lib)
+
+(declare-function notmuch-show-get-prop "notmuch-show" (prop &optional props))
+
+;;; Options
+
(defcustom notmuch-print-mechanism 'notmuch-print-lpr
"How should printing be done?"
- :group 'notmuch
+ :group 'notmuch-show
:type '(choice
(function :tag "Use lpr" notmuch-print-lpr)
(function :tag "Use ps-print" notmuch-print-ps-print)
@@ -30,7 +38,7 @@
(function :tag "Use muttprint then evince" notmuch-print-muttprint/evince)
(function :tag "Using a custom function")))
-;; Utility functions:
+;;; Utility functions
(defun notmuch-print-run-evince (file)
"View FILE using 'evince'."
@@ -40,7 +48,7 @@
"Pass the contents of the current buffer to 'muttprint'.
Optional OUTPUT allows passing a list of flags to muttprint."
- (apply #'call-process-region (point-min) (point-max)
+ (apply #'notmuch--call-process-region (point-min) (point-max)
;; Reads from stdin.
"muttprint"
nil nil nil
@@ -48,38 +56,45 @@ Optional OUTPUT allows passing a list of flags to muttprint."
"--printed-headers" "Date_To_From_CC_Newsgroups_*Subject*_/Tags/"
output))
-;; User-visible functions:
+;;; User-visible functions
-(defun notmuch-print-lpr (msg)
+(defun notmuch-print-lpr (_msg)
"Print a message buffer using lpr."
(lpr-buffer))
(defun notmuch-print-ps-print (msg)
"Print a message buffer using the ps-print package."
- (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+ (let ((subject (notmuch-prettify-subject
+ (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
(rename-buffer subject t)
(ps-print-buffer)))
(defun notmuch-print-ps-print/evince (msg)
"Preview a message buffer using ps-print and evince."
- (let ((ps-file (make-temp-file "notmuch"))
- (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+ (let ((ps-file (make-temp-file "notmuch" nil ".ps"))
+ (subject (notmuch-prettify-subject
+ (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
(rename-buffer subject t)
(ps-print-buffer ps-file)
(notmuch-print-run-evince ps-file)))
-(defun notmuch-print-muttprint (msg)
+(defun notmuch-print-muttprint (_msg)
"Print a message using muttprint."
(notmuch-print-run-muttprint))
-(defun notmuch-print-muttprint/evince (msg)
+(defun notmuch-print-muttprint/evince (_msg)
"Preview a message buffer using muttprint and evince."
- (let ((ps-file (make-temp-file "notmuch")))
+ (let ((ps-file (make-temp-file "notmuch" nil ".ps")))
(notmuch-print-run-muttprint (list "--printer" (concat "TO_FILE:" ps-file)))
(notmuch-print-run-evince ps-file)))
(defun notmuch-print-message (msg)
"Print a message using the user-selected mechanism."
+ (set-buffer-modified-p nil)
(funcall notmuch-print-mechanism msg))
+;;; _
+
(provide 'notmuch-print)
+
+;;; notmuch-print.el ends here