annotate lisp/lpr.el @ 2230:6314334d7c2b

Add standard library headers.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Wed, 17 Mar 1993 15:58:09 +0000
parents b2a50ea75eea
children 10e417efb12a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
1 ;;; lpr.el --- print Emacs buffer on line printer.
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
2
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
3 ;; Copyright (C) 1985, 1988, 1992 Free Software Foundation, Inc.
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
5 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: unix
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
7
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
24 ;;; Code:
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
269
2ca8cdb96a9f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 262
diff changeset
26 ;;;###autoload
1671
b2a50ea75eea * lpr.el (lpr-switches, lpr-command): Make these defvars, not
Jim Blandy <jimb@redhat.com>
parents: 1615
diff changeset
27 (defvar lpr-switches nil
1615
21e2defc55c0 * lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents: 1463
diff changeset
28 "*List of strings to pass as extra switch args to lpr when it is invoked.")
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
1068
2fee5d1fe47e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 922
diff changeset
30 ;;;###autoload
1671
b2a50ea75eea * lpr.el (lpr-switches, lpr-command): Make these defvars, not
Jim Blandy <jimb@redhat.com>
parents: 1615
diff changeset
31 (defvar lpr-command
1615
21e2defc55c0 * lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents: 1463
diff changeset
32 (if (memq system-type '(usg-unix-v dgux-unix hpux silicon-graphics-unix))
21e2defc55c0 * lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents: 1463
diff changeset
33 "lp" "lpr")
21e2defc55c0 * lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents: 1463
diff changeset
34 "*Shell command for printing a file")
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (defvar print-region-function nil
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 "Function to call to print the region on a printer.
216
2c663336acaf *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 155
diff changeset
38 See definition of `print-region-1' for calling conventions.")
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
40 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (defun lpr-buffer ()
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 "Print buffer contents as with Unix command `lpr'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (interactive)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (print-region-1 (point-min) (point-max) lpr-switches nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
47 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (defun print-buffer ()
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 "Print buffer contents as with Unix command `lpr -p'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (interactive)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (print-region-1 (point-min) (point-max) lpr-switches t))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
54 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (defun lpr-region (start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 "Print region contents as with Unix command `lpr'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (interactive "r")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (print-region-1 start end lpr-switches nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
61 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (defun print-region (start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 "Print region contents as with Unix command `lpr -p'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (interactive "r")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (print-region-1 start end lpr-switches t))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defun print-region-1 (start end switches page-headers)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (let ((name (concat (buffer-name) " Emacs buffer"))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (width tab-width))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (save-excursion
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (message "Spooling...")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (if (/= tab-width 8)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (progn
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (print-region-new-buffer start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (setq tab-width width)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (untabify (point-min) (point-max))))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (if page-headers
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (if (eq system-type 'usg-unix-v)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (progn
922
52cd80cb5be1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
81 (print-region-new-buffer start end)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (call-process-region start end "pr" t t nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; On BSD, use an option to get page headers.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (setq switches (cons "-p" switches))))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (apply (or print-region-function 'call-process-region)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (nconc (list start end lpr-command
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 nil nil nil)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (nconc (and (eq system-type 'berkeley-unix)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (list "-J" name "-T" name))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 switches)))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (message "Spooling...done"))))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; This function copies the text between start and end
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; into a new buffer, makes that buffer current,
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; and sets start and end to the buffer bounds.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; start and end are used free.
922
52cd80cb5be1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
97 (defun print-region-new-buffer (start end)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (or (string= (buffer-name) " *spool temp*")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (let ((oldbuf (current-buffer)))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (set-buffer (get-buffer-create " *spool temp*"))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (widen) (erase-buffer)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (insert-buffer-substring oldbuf start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (setq start (point-min) end (point-max)))))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
104
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
105 ;;; lpr.el ends here