annotate lisp/lpr.el @ 830:d7f1e2db9faf

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