|
|
1.1 root 1: ;; Print Emacs buffer on line printer.
2: ;; Copyright (C) 1985, 1988 Free Software Foundation, Inc.
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: (defvar lpr-command (if (eq system-type 'usg-unix-v)
26: "lp" "lpr")
27: "Shell command for printing a file")
28:
29: (defun lpr-buffer ()
30: "Print buffer contents as with Unix command `lpr'.
31: `lpr-switches' is a list of extra switches (strings) to pass to lpr."
32: (interactive)
33: (print-region-1 (point-min) (point-max) lpr-switches))
34:
35: (defun print-buffer ()
36: "Print buffer contents as with Unix command `lpr -p'.
37: `lpr-switches' is a list of extra switches (strings) to pass to lpr."
38: (interactive)
39: (print-region-1 (point-min) (point-max) (cons "-p" lpr-switches)))
40:
41: (defun lpr-region (start end)
42: "Print region contents as with Unix command `lpr'.
43: `lpr-switches' is a list of extra switches (strings) to pass to lpr."
44: (interactive "r")
45: (print-region-1 start end lpr-switches))
46:
47: (defun print-region (start end)
48: "Print region contents as with Unix command `lpr -p'.
49: `lpr-switches' is a list of extra switches (strings) to pass to lpr."
50: (interactive "r")
51: (print-region-1 start end (cons "-p" lpr-switches)))
52:
53: (defun print-region-1 (start end switches)
54: (let ((name (concat (buffer-name) " Emacs buffer"))
55: (width tab-width))
56: (save-excursion
57: (message "Spooling...")
58: (if (/= tab-width 8)
59: (let ((oldbuf (current-buffer)))
60: (set-buffer (get-buffer-create " *spool temp*"))
61: (widen) (erase-buffer)
62: (insert-buffer-substring oldbuf start end)
63: (setq tab-width width)
64: (untabify (point-min) (point-max))
65: (setq start (point-min) end (point-max))))
66: (apply 'call-process-region
67: (nconc (list start end lpr-command
68: nil nil nil)
69: (nconc (and (eq system-type 'berkeley-unix)
70: (list "-J" name "-T" name))
71: switches)))
72: (message "Spooling...done"))))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.