- (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)))))))