X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/362b9d483c714a8fd87966ddbd8686850f870e34..2b75be6704c3adf2f6ec9428dbcca90bf28043ef:/lisp/lpr.el diff --git a/lisp/lpr.el b/lisp/lpr.el index 561aa05f37..76c69f3308 100644 --- a/lisp/lpr.el +++ b/lisp/lpr.el @@ -1,7 +1,7 @@ ;;; lpr.el --- print Emacs buffer on line printer -;; Copyright (C) 1985, 1988, 1992, 1994, 2001, 2002, 2003, -;; 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2011 +;; Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: unix @@ -29,6 +29,8 @@ ;;; Code: +(eval-when-compile (require 'cl)) + ;;;###autoload (defvar lpr-windows-system (memq system-type '(ms-dos windows-nt))) @@ -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 + (case (count-lines (point-min) (point-max)) + (0 "") + (1 ": ") + (t ":\n")) + (buffer-string))))))) ;; This function copies the text between start and end ;; into a new buffer, makes that buffer current. @@ -337,5 +348,4 @@ The characters tab, linefeed, space, return and formfeed are not affected." (provide 'lpr) -;; arch-tag: 21c3f821-ebec-4ca9-ac67-a81e4b75c62a ;;; lpr.el ends here