Mercurial > emacs
annotate lisp/lpr.el @ 4181:d7cb993a93b1
(normal-top-level): Call abbreviate-file-name again after calling command-line.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 20 Jul 1993 05:46:10 +0000 |
parents | 030b76db285a |
children | ff1f9d7addd9 |
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 | 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 |
1615
21e2defc55c0
* lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents:
1463
diff
changeset
|
34 "*List of strings to pass as extra switch args to lpr when it is invoked.") |
155 | 35 |
1068 | 36 ;;;###autoload |
1671
b2a50ea75eea
* lpr.el (lpr-switches, lpr-command): Make these defvars, not
Jim Blandy <jimb@redhat.com>
parents:
1615
diff
changeset
|
37 (defvar lpr-command |
1615
21e2defc55c0
* lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents:
1463
diff
changeset
|
38 (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
|
39 "lp" "lpr") |
21e2defc55c0
* lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents:
1463
diff
changeset
|
40 "*Shell command for printing a file") |
155 | 41 |
42 (defvar print-region-function nil | |
43 "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
|
44 See definition of `print-region-1' for calling conventions.") |
155 | 45 |
256 | 46 ;;;###autoload |
155 | 47 (defun lpr-buffer () |
48 "Print buffer contents as with Unix command `lpr'. | |
49 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
50 (interactive) | |
51 (print-region-1 (point-min) (point-max) lpr-switches nil)) | |
52 | |
256 | 53 ;;;###autoload |
155 | 54 (defun print-buffer () |
55 "Print buffer contents as with Unix command `lpr -p'. | |
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 t)) | |
59 | |
256 | 60 ;;;###autoload |
155 | 61 (defun lpr-region (start end) |
62 "Print region contents as with Unix command `lpr'. | |
63 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
64 (interactive "r") | |
65 (print-region-1 start end lpr-switches nil)) | |
66 | |
256 | 67 ;;;###autoload |
155 | 68 (defun print-region (start end) |
69 "Print region contents as with Unix command `lpr -p'. | |
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 t)) | |
73 | |
74 (defun print-region-1 (start end switches page-headers) | |
75 (let ((name (concat (buffer-name) " Emacs buffer")) | |
76 (width tab-width)) | |
77 (save-excursion | |
78 (message "Spooling...") | |
79 (if (/= tab-width 8) | |
80 (progn | |
81 (print-region-new-buffer start end) | |
82 (setq tab-width width) | |
83 (untabify (point-min) (point-max)))) | |
84 (if page-headers | |
85 (if (eq system-type 'usg-unix-v) | |
86 (progn | |
922 | 87 (print-region-new-buffer start end) |
155 | 88 (call-process-region start end "pr" t t nil)) |
89 ;; On BSD, use an option to get page headers. | |
90 (setq switches (cons "-p" switches)))) | |
91 (apply (or print-region-function 'call-process-region) | |
92 (nconc (list start end lpr-command | |
93 nil nil nil) | |
94 (nconc (and (eq system-type 'berkeley-unix) | |
95 (list "-J" name "-T" name)) | |
96 switches))) | |
97 (message "Spooling...done")))) | |
98 | |
99 ;; This function copies the text between start and end | |
100 ;; into a new buffer, makes that buffer current, | |
101 ;; and sets start and end to the buffer bounds. | |
102 ;; start and end are used free. | |
922 | 103 (defun print-region-new-buffer (start end) |
155 | 104 (or (string= (buffer-name) " *spool temp*") |
105 (let ((oldbuf (current-buffer))) | |
106 (set-buffer (get-buffer-create " *spool temp*")) | |
107 (widen) (erase-buffer) | |
108 (insert-buffer-substring oldbuf start end) | |
109 (setq start (point-min) end (point-max))))) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
617
diff
changeset
|
110 |
2382
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
111 (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
|
112 "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
|
113 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
|
114 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
|
115 (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
|
116 (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
|
117 (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
|
118 (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
|
119 (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
|
120 (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
|
121 (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
|
122 (insert |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
123 (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
|
124 (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
|
125 (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
|
126 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
617
diff
changeset
|
127 ;;; lpr.el ends here |