Function: print-region-1

print-region-1 is a byte-compiled function defined in lpr.el.gz.

Signature

(print-region-1 START END SWITCHES PAGE-HEADERS)

Source Code

;; Defined in /usr/src/emacs/lisp/lpr.el.gz
(defun print-region-1 (start end switches page-headers)
  (and page-headers lpr-headers-switches
       ;; It's possible to use an lpr option to get page headers.
       (setq switches (append (if (stringp lpr-headers-switches)
                                  (list lpr-headers-switches)
                                lpr-headers-switches)
                              switches)))
  ;; On some MIPS system, having a space in the job name
  ;; crashes the printer demon.  But using dashes looks ugly
  ;; and it seems to annoying to do for that MIPS system.
  (save-excursion
    (let ((name  (concat (buffer-name) " Emacs buffer"))
          ;; Make pipes use the same coding system as
          ;; writing the buffer to a file would.
          (coding-system-for-write (or coding-system-for-write
                                       buffer-file-coding-system))
          (coding-system-for-read  (or coding-system-for-read
                                       buffer-file-coding-system))
          (width tab-width))
      (if (/= tab-width 8)
	  (let ((new-coords (print-region-new-buffer start end)))
	    (setq start     (car new-coords)
		  end       (cdr new-coords)
		  tab-width width)
	    (save-excursion
	      (goto-char end)
	      (setq end (point-marker)))
	    (untabify (point-min) (point-max))))
      (if page-headers
	  (if lpr-headers-switches
	      ;; We handled this above by modifying SWITCHES.
	      nil
	    ;; Run a separate program to get page headers.
	    (let ((new-coords (print-region-new-buffer start end)))
              (apply #'call-process-region (car new-coords) (cdr new-coords)
		     lpr-page-header-program t t nil
		     (mapcar (lambda (e) (format e name))
			     lpr-page-header-switches)))
	    (setq start (point-min)
		  end   (point-max))))
      (lpr-print-region start end switches name))))