|
|
1.1 ! root 1: ;; Print Emacs buffer on line printer. ! 2: ;; Copyright (C) 1985 Richard M. Stallman. ! 3: ! 4: ;; This file is part of GNU Emacs. ! 5: ! 6: ;; GNU Emacs is distributed in the hope that it will be useful, ! 7: ;; but WITHOUT ANY WARRANTY. No author or distributor ! 8: ;; accepts responsibility to anyone for the consequences of using it ! 9: ;; or for whether it serves any particular purpose or works at all, ! 10: ;; unless he says so in writing. Refer to the GNU Emacs General Public ! 11: ;; License for full details. ! 12: ! 13: ;; Everyone is granted permission to copy, modify and redistribute ! 14: ;; GNU Emacs, but only under the conditions described in the ! 15: ;; GNU Emacs General Public License. A copy of this license is ! 16: ;; supposed to have been given to you along with GNU Emacs so you ! 17: ;; can know your rights and responsibilities. It should be in a ! 18: ;; file named COPYING. Among other things, the copyright notice ! 19: ;; and this notice must be preserved on all copies. ! 20: ! 21: ! 22: ;(defconst lpr-switches nil ! 23: ; "*List of strings to pass as extra switch args to lpr when it is invoked.") ! 24: ! 25: (defun lpr-buffer () ! 26: "Print buffer contents as with Unix command `lpr'. ! 27: `lpr-switches' is a list of extra switches (strings) to pass to lpr." ! 28: (interactive) ! 29: (print-region-1 (point-min) (point-max) lpr-switches)) ! 30: ! 31: (defun print-buffer () ! 32: "Print buffer contents as with Unix command `lpr -p'. ! 33: `lpr-switches' is a list of extra switches (strings) to pass to lpr." ! 34: (interactive) ! 35: (print-region-1 (point-min) (point-max) (cons "-p" lpr-switches))) ! 36: ! 37: (defun lpr-region (start end) ! 38: "Print region contents as with Unix command `lpr'. ! 39: `lpr-switches' is a list of extra switches (strings) to pass to lpr." ! 40: (interactive "r") ! 41: (print-region-1 start end lpr-switches)) ! 42: ! 43: (defun print-region (start end) ! 44: "Print region contents as with Unix command `lpr -p'. ! 45: `lpr-switches' is a list of extra switches (strings) to pass to lpr." ! 46: (interactive "r") ! 47: (print-region-1 start end (cons "-p" lpr-switches))) ! 48: ! 49: (defun print-region-1 (start end switches) ! 50: (save-excursion ! 51: (message "Spooling...") ! 52: (if (/= tab-width 8) ! 53: (let ((oldbuf (current-buffer))) ! 54: (set-buffer (get-buffer-create " *spool temp*")) ! 55: (widen) (erase-buffer) ! 56: (insert-buffer-substring oldbuf) ! 57: (call-process-region start end "expand" ! 58: t t nil ! 59: (format "-%d" tab-width)))) ! 60: (apply 'call-process-region ! 61: (nconc (list start end "lpr" ! 62: nil nil nil ! 63: "-J" (concat (buffer-name) " Emacs buffer") ! 64: "-T" (concat (buffer-name) " Emacs buffer")) ! 65: switches)) ! 66: (message "Spooling...done")))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.