Mercurial > emacs
annotate lisp/lpr.el @ 8575:2d50d249caf4
Keybindings don't overshadown comint bindings.
author | Tom Tromey <tromey@redhat.com> |
---|---|
date | Sun, 21 Aug 1994 03:54:45 +0000 |
parents | ce5ba216927d |
children | d49cb56cce45 |
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 |
7300 | 3 ;; Copyright (C) 1985, 1988, 1992, 1994 Free Software Foundation, Inc. |
846
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 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
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 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
24 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
25 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
26 ;; Commands to send the region or a buffer your printer. Entry points |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
27 ;; are `lpr-buffer', `print-buffer', lpr-region', or `print-region'; option |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
28 ;; variables include `lpr-switches' and `lpr-command'. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
30 ;;; Code: |
155 | 31 |
269 | 32 ;;;###autoload |
1671
b2a50ea75eea
* lpr.el (lpr-switches, lpr-command): Make these defvars, not
Jim Blandy <jimb@redhat.com>
parents:
1615
diff
changeset
|
33 (defvar lpr-switches nil |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
34 "*List of strings to pass as extra switch args to `lpr' when it is invoked.") |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
35 |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
36 (defvar lpr-add-options (eq system-type 'berkeley-unix) |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
37 "*Non-nil means construct -T and -J options for the `lpr'.") |
155 | 38 |
1068 | 39 ;;;###autoload |
1671
b2a50ea75eea
* lpr.el (lpr-switches, lpr-command): Make these defvars, not
Jim Blandy <jimb@redhat.com>
parents:
1615
diff
changeset
|
40 (defvar lpr-command |
8566
ce5ba216927d
(lpr-command, lpr-headers-switches): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8562
diff
changeset
|
41 (if (memq system-type '(usg-unix-v dgux hpux irix)) |
1615
21e2defc55c0
* lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents:
1463
diff
changeset
|
42 "lp" "lpr") |
21e2defc55c0
* lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents:
1463
diff
changeset
|
43 "*Shell command for printing a file") |
155 | 44 |
5462
09820fbab8d1
(lpr-headers-switches): Set proper value on hpux and usg.
Richard M. Stallman <rms@gnu.org>
parents:
5391
diff
changeset
|
45 (defvar lpr-headers-switches |
8566
ce5ba216927d
(lpr-command, lpr-headers-switches): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8562
diff
changeset
|
46 (if (memq system-type '(usg-unix-v hpux)) nil "-p") |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
47 "*List of strings to use as options for `lpr' to request page headings.") |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
48 |
155 | 49 (defvar print-region-function nil |
50 "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
|
51 See definition of `print-region-1' for calling conventions.") |
155 | 52 |
256 | 53 ;;;###autoload |
155 | 54 (defun lpr-buffer () |
55 "Print buffer contents as with Unix command `lpr'. | |
56 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
57 (interactive) | |
58 (print-region-1 (point-min) (point-max) lpr-switches nil)) | |
59 | |
256 | 60 ;;;###autoload |
155 | 61 (defun print-buffer () |
62 "Print buffer contents as with Unix command `lpr -p'. | |
63 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
64 (interactive) | |
65 (print-region-1 (point-min) (point-max) lpr-switches t)) | |
66 | |
256 | 67 ;;;###autoload |
155 | 68 (defun lpr-region (start end) |
69 "Print region contents as with Unix command `lpr'. | |
70 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
71 (interactive "r") | |
72 (print-region-1 start end lpr-switches nil)) | |
73 | |
256 | 74 ;;;###autoload |
155 | 75 (defun print-region (start end) |
76 "Print region contents as with Unix command `lpr -p'. | |
77 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
78 (interactive "r") | |
79 (print-region-1 start end lpr-switches t)) | |
80 | |
81 (defun print-region-1 (start end switches page-headers) | |
8113
6a12a2845ccc
(print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8021
diff
changeset
|
82 ;; On some MIPS system, having a space in the job name |
6a12a2845ccc
(print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8021
diff
changeset
|
83 ;; crashes the printer demon. But using dashes looks ugly |
6a12a2845ccc
(print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8021
diff
changeset
|
84 ;; and it seems to annoying to do for that MIPS system. |
6a12a2845ccc
(print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
8021
diff
changeset
|
85 (let ((name (concat (buffer-name) " Emacs buffer")) |
8020
23deb92071c6
(print-region-1): Don't include a space in the job name.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
86 (title (concat (buffer-name) " Emacs buffer")) |
155 | 87 (width tab-width)) |
88 (save-excursion | |
89 (message "Spooling...") | |
90 (if (/= tab-width 8) | |
91 (progn | |
92 (print-region-new-buffer start end) | |
93 (setq tab-width width) | |
4446
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
94 (save-excursion |
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
95 (goto-char end) |
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
96 (setq end (point-marker))) |
155 | 97 (untabify (point-min) (point-max)))) |
98 (if page-headers | |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
99 (if lpr-headers-switches |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
100 ;; On BSD, use an option to get page headers. |
5391
0306cbfa87b7
(print-region-1): If lpr-headers-switches is string,
Richard M. Stallman <rms@gnu.org>
parents:
5267
diff
changeset
|
101 (setq switches (append (if (stringp lpr-headers-switches) |
0306cbfa87b7
(print-region-1): If lpr-headers-switches is string,
Richard M. Stallman <rms@gnu.org>
parents:
5267
diff
changeset
|
102 (list lpr-headers-switches) |
0306cbfa87b7
(print-region-1): If lpr-headers-switches is string,
Richard M. Stallman <rms@gnu.org>
parents:
5267
diff
changeset
|
103 lpr-headers-switches) |
0306cbfa87b7
(print-region-1): If lpr-headers-switches is string,
Richard M. Stallman <rms@gnu.org>
parents:
5267
diff
changeset
|
104 switches)) |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
105 (print-region-new-buffer start end) |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
106 (call-process-region start end "pr" t t nil) |
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
107 (setq start (point-min) end (point-max)))) |
155 | 108 (apply (or print-region-function 'call-process-region) |
109 (nconc (list start end lpr-command | |
110 nil nil nil) | |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
111 (nconc (and lpr-add-options |
8020
23deb92071c6
(print-region-1): Don't include a space in the job name.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
112 (list "-J" name "-T" title)) |
155 | 113 switches))) |
4446
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
114 (if (markerp end) |
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
115 (set-marker end nil)) |
155 | 116 (message "Spooling...done")))) |
117 | |
118 ;; This function copies the text between start and end | |
119 ;; into a new buffer, makes that buffer current, | |
120 ;; and sets start and end to the buffer bounds. | |
121 ;; start and end are used free. | |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
122 (defun print-region-new-buffer (ostart oend) |
155 | 123 (or (string= (buffer-name) " *spool temp*") |
124 (let ((oldbuf (current-buffer))) | |
125 (set-buffer (get-buffer-create " *spool temp*")) | |
126 (widen) (erase-buffer) | |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
127 (insert-buffer-substring oldbuf ostart oend) |
155 | 128 (setq start (point-min) end (point-max))))) |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
617
diff
changeset
|
129 |
2382
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
130 (defun printify-region (begin end) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
131 "Turn nonprinting characters (other than TAB, LF, SPC, RET, and FF) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
132 in the current buffer into printable representations as control or |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
133 hexadecimal escapes." |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
134 (interactive "r") |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
135 (save-excursion |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
136 (goto-char begin) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
137 (let (c) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
138 (while (re-search-forward "[\^@-\^h\^k\^n-\^_\177-\377]" end t) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
139 (setq c (preceding-char)) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
140 (delete-backward-char 1) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
141 (insert |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
142 (if (< c ?\ ) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
143 (format "\\^%c" (+ c ?@)) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
144 (format "\\%02x" c))))))) |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
145 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
617
diff
changeset
|
146 ;;; lpr.el ends here |