X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/8678d9e413593b0abab296551a20589745c459da..ea0857a126fbd38e96fd499c7173341a3e8614b6:/lisp/lpr.el diff --git a/lisp/lpr.el b/lisp/lpr.el index 709f992b2b..b31d19b624 100644 --- a/lisp/lpr.el +++ b/lisp/lpr.el @@ -1,6 +1,6 @@ ;;; lpr.el --- print Emacs buffer on line printer -;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2011 +;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2012 ;; Free Software Foundation, Inc. ;; Maintainer: FSF @@ -31,11 +31,13 @@ ;;;###autoload (defvar lpr-windows-system - (memq system-type '(ms-dos windows-nt))) + (memq system-type '(ms-dos windows-nt)) + "Non-nil if running on MS-DOS or MS Windows.") ;;;###autoload (defvar lpr-lp-system - (memq system-type '(usg-unix-v hpux irix))) + (memq system-type '(usg-unix-v hpux irix)) + "Non-nil if running on a system type that uses the \"lp\" command.") (defgroup lpr nil @@ -258,21 +260,30 @@ for further customization of the printer command." lpr-page-header-switches))) (setq start (point-min) end (point-max)))) - (apply (or print-region-function 'call-process-region) - (nconc (list start end lpr-command - nil nil nil) - (and lpr-add-switches - (list "-J" name)) - ;; These belong in pr if we are using that. - (and lpr-add-switches lpr-headers-switches - (list "-T" title)) - (and (stringp printer-name) - (list (concat lpr-printer-switch - printer-name))) - nswitches)) - (if (markerp end) - (set-marker end nil)) - (message "Spooling%s...done" switch-string)))) + (let ((buf (current-buffer))) + (with-temp-buffer + (let ((tempbuf (current-buffer))) + (with-current-buffer buf + (apply (or print-region-function 'call-process-region) + (nconc (list start end lpr-command + nil tempbuf nil) + (and lpr-add-switches + (list "-J" name)) + ;; These belong in pr if we are using that. + (and lpr-add-switches lpr-headers-switches + (list "-T" title)) + (and (stringp printer-name) + (list (concat lpr-printer-switch + printer-name))) + nswitches)))) + (if (markerp end) + (set-marker end nil)) + (message "Spooling%s...done%s%s" switch-string + (pcase (count-lines (point-min) (point-max)) + (0 "") + (1 ": ") + (_ ":\n")) + (buffer-string))))))) ;; This function copies the text between start and end ;; into a new buffer, makes that buffer current.