annotate lisp/lpr.el @ 10670:f759e91a1654

(lpr-add-switches): Renamed from lpr-add-options. (print-region-1): If we run pr, give it the -h option instead of giving lpr the -T option.
author Richard M. Stallman <rms@gnu.org>
date Mon, 06 Feb 1995 03:30:19 +0000
parents 727636abd576
children f6f235bc26ba
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
7300
cc7cd83ccf3f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 5462
diff changeset
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
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
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
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
269
2ca8cdb96a9f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 262
diff changeset
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
10670
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
36 (defvar lpr-add-switches (eq system-type 'berkeley-unix)
5267
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
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
1068
2fee5d1fe47e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 922
diff changeset
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")
9187
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
43 "*Name of program for printing a file.")
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
10637
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
45 ;; Default is nil, because that enables us to use pr -f
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
46 ;; which is more reliable than pr with no args, which is what lpr -p does.
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
47 (defvar lpr-headers-switches nil
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
48 "*List of strings to use as options for `lpr' to request page headings.
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
49 If nil, we run `lpr-page-header-program' to make page headings
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
50 and print the result.")
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
51
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (defvar print-region-function nil
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 "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
54 See definition of `print-region-1' for calling conventions.")
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
9187
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
56 (defvar lpr-page-header-program "pr"
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
57 "*Name of program for adding page headers to a file.")
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
58
10054
cd3eda7518f0 (lpr-page-header-switches): Use -f by default.
Richard M. Stallman <rms@gnu.org>
parents: 9900
diff changeset
59 (defvar lpr-page-header-switches '("-f")
9187
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
60 "*List of strings to use as options for `lpr-page-header-program'.")
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
61
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
62 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defun lpr-buffer ()
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 "Print buffer contents as with Unix command `lpr'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 `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
66 (interactive)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (print-region-1 (point-min) (point-max) lpr-switches nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
69 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (defun print-buffer ()
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 "Print buffer contents as with Unix command `lpr -p'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 `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
73 (interactive)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (print-region-1 (point-min) (point-max) lpr-switches t))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
76 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (defun lpr-region (start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 "Print region contents as with Unix command `lpr'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 `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
80 (interactive "r")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (print-region-1 start end lpr-switches nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
83 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (defun print-region (start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 "Print region contents as with Unix command `lpr -p'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 `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
87 (interactive "r")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (print-region-1 start end lpr-switches t))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (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
91 ;; 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
92 ;; 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
93 ;; 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
94 (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
95 (title (concat (buffer-name) " Emacs buffer"))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (width tab-width))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (save-excursion
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (message "Spooling...")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (if (/= tab-width 8)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (progn
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (print-region-new-buffer start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (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
103 (save-excursion
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
104 (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
105 (setq end (point-marker)))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (untabify (point-min) (point-max))))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (if page-headers
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
108 (if lpr-headers-switches
10637
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
109 ;; It is possible to use an lpr option
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
110 ;; 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
111 (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
112 (list lpr-headers-switches)
0306cbfa87b7 (print-region-1): If lpr-headers-switches is string,
Richard M. Stallman <rms@gnu.org>
parents: 5267
diff changeset
113 lpr-headers-switches)
0306cbfa87b7 (print-region-1): If lpr-headers-switches is string,
Richard M. Stallman <rms@gnu.org>
parents: 5267
diff changeset
114 switches))
10637
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
115 ;; Run a separate program to get page headers.
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
116 (print-region-new-buffer start end)
10670
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
117 (apply 'call-process-region start end lpr-page-header-program
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
118 t t nil
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
119 (nconc (and lpr-add-switches
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
120 (list "-h" title))
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
121 lpr-page-header-switches))
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
122 (setq start (point-min) end (point-max))))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (apply (or print-region-function 'call-process-region)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (nconc (list start end lpr-command
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 nil nil nil)
10670
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
126 (nconc (and lpr-add-switches
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
127 (list "-J" name))
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
128 ;; These belong in pr if we are using that.
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
129 (and lpr-add-switches lpr-headers-switches
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
130 (list "-T" title))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 switches)))
4446
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
132 (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
133 (set-marker end nil))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (message "Spooling...done"))))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; This function copies the text between start and end
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; into a new buffer, makes that buffer current,
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; and sets start and end to the buffer bounds.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; 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
140 (defun print-region-new-buffer (ostart oend)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (or (string= (buffer-name) " *spool temp*")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (let ((oldbuf (current-buffer)))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (set-buffer (get-buffer-create " *spool temp*"))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (widen) (erase-buffer)
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
145 (insert-buffer-substring oldbuf ostart oend)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (setq start (point-min) end (point-max)))))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
147
2382
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
148 (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
149 "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
150 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
151 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
152 (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
153 (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
154 (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
155 (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
156 (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
157 (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
158 (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
159 (insert
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
160 (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
161 (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
162 (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
163
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
164 ;;; lpr.el ends here