Mercurial > emacs
annotate lisp/lpr.el @ 29538:c0c34d18e8a0
(update_charset_table): Update the table
bytes_by_char_head.
(init_charset_once): Initialize elements of bytes_by_char_head to
1 except for leading codes for private charases.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sat, 10 Jun 2000 00:12:46 +0000 |
parents | efd5a62ccce9 |
children | 178c89d24a0d |
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 | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
155 | 24 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
25 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
26 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
27 ;; 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
|
28 ;; are `lpr-buffer', `print-buffer', lpr-region', or `print-region'; option |
22679
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
29 ;; variables include `printer-name', `lpr-switches' and `lpr-command'. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1671
diff
changeset
|
30 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
31 ;;; Code: |
155 | 32 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
33 (defgroup lpr nil |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
34 "Print Emacs buffer on line printer" |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
35 :group 'wp) |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
36 |
22679
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
37 ;;;###autoload |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
38 (defcustom printer-name |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
39 (if (memq system-type '(ms-dos windows-nt)) "PRN") |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
40 "*The name of a local printer to which data is sent for printing. |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
41 \(Note that PostScript files are sent to `ps-printer-name', which see.\) |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
42 |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
43 On Unix-like systems, a string value should be a name understood by |
24091
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
44 lpr's -P option; otherwise the value should be nil. |
22679
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
45 |
24091
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
46 On MS-DOS and MS-Windows systems, a string value is taken as the name of |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
47 a printer device or port, provided `lpr-command' is set to \"\". |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
48 Typical non-default settings would be \"LPT1\" to \"LPT3\" for parallel |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
49 printers, or \"COM1\" to \"COM4\" or \"AUX\" for serial printers, or |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
50 \"//hostname/printer\" for a shared network printer. You can also set |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
51 it to the name of a file, in which case the output gets appended to that |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
52 file. If you want to discard the printed output, set this to \"NUL\"." |
23264
359e6eb97e11
(printer-name): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents:
22679
diff
changeset
|
53 :type '(choice ; could use string but then we lose completion for files. |
359e6eb97e11
(printer-name): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents:
22679
diff
changeset
|
54 (file :tag "Name") |
359e6eb97e11
(printer-name): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents:
22679
diff
changeset
|
55 (const :tag "Default" nil)) |
22679
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
56 :group 'lpr) |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
57 |
269 | 58 ;;;###autoload |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
59 (defcustom lpr-switches nil |
13803
e0bae9f528fe
(lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents:
11831
diff
changeset
|
60 "*List of strings to pass as extra options for the printer program. |
22679
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
61 It is recommended to set `printer-name' instead of including an explicit |
08902da4c832
(printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
21569
diff
changeset
|
62 switch on this list. |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
63 See `lpr-command'." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
64 :type '(repeat (string :tag "Argument")) |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
65 :group 'lpr) |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
66 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
67 (defcustom lpr-add-switches (eq system-type 'berkeley-unix) |
13803
e0bae9f528fe
(lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents:
11831
diff
changeset
|
68 "*Non-nil means construct -T and -J options for the printer program. |
e0bae9f528fe
(lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents:
11831
diff
changeset
|
69 These are made assuming that the program is `lpr'; |
e0bae9f528fe
(lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents:
11831
diff
changeset
|
70 if you are using some other incompatible printer program, |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
71 this variable should be nil." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
72 :type 'boolean |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
73 :group 'lpr) |
155 | 74 |
1068 | 75 ;;;###autoload |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
76 (defcustom lpr-command |
24091
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
77 (cond |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
78 ((memq system-type '(ms-dos windows-nt)) |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
79 "") |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
80 ((memq system-type '(usg-unix-v dgux hpux irix)) |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
81 "lp") |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
82 (t |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
83 "lpr")) |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
84 "*Name of program for printing a file. |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
85 |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
86 On MS-DOS and MS-Windows systems, if the value is an empty string then |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
87 Emacs will write directly to the printer port named by `printer-name'. |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
88 The programs `print' and `nprint' (the standard print programs on |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
89 Windows NT and Novell Netware respectively) are handled specially, using |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
90 `printer-name' as the destination for output; any other program is |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
91 treated like `lpr' except that an explicit filename is given as the last |
1874c3236349
(printer-name): Update docstring about usage on MS-DOS
Andrew Innes <andrewi@gnu.org>
parents:
23264
diff
changeset
|
92 argument." |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
93 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
94 :group 'lpr) |
155 | 95 |
10637
6e25c10f6fe8
(lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents:
10054
diff
changeset
|
96 ;; 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
|
97 ;; which is more reliable than pr with no args, which is what lpr -p does. |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
98 (defcustom lpr-headers-switches nil |
13894
eeee95f4d989
(lpr-page-header-switches, lpr-headers-switches): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
13803
diff
changeset
|
99 "*List of strings of options to request page headings in the printer program. |
10637
6e25c10f6fe8
(lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents:
10054
diff
changeset
|
100 If nil, we run `lpr-page-header-program' to make page headings |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
101 and print the result." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
102 :type '(repeat (string :tag "Argument")) |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
103 :group 'lpr) |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
104 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
105 (defcustom print-region-function nil |
155 | 106 "Function to call to print the region on a printer. |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
107 See definition of `print-region-1' for calling conventions." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
108 :type 'function |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
109 :group 'lpr) |
155 | 110 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
111 (defcustom lpr-page-header-program "pr" |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
112 "*Name of program for adding page headers to a file." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
113 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
114 :group 'lpr) |
9187
8cf9181c119e
(print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents:
8598
diff
changeset
|
115 |
17813
2e13bced7aff
(lpr-page-header-switches): Use -F, not -f.
Richard M. Stallman <rms@gnu.org>
parents:
17695
diff
changeset
|
116 ;; Berkeley systems support -F, and GNU pr supports both -f and -F, |
2e13bced7aff
(lpr-page-header-switches): Use -F, not -f.
Richard M. Stallman <rms@gnu.org>
parents:
17695
diff
changeset
|
117 ;; So it looks like -F is a better default. |
17865
bbcdcb97c227
(lpr-page-header-switches): Remove extra paren.
Richard M. Stallman <rms@gnu.org>
parents:
17813
diff
changeset
|
118 (defcustom lpr-page-header-switches '("-F") |
13894
eeee95f4d989
(lpr-page-header-switches, lpr-headers-switches): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
13803
diff
changeset
|
119 "*List of strings to use as options for the page-header-generating program. |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
120 The variable `lpr-page-header-program' specifies the program to use." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
121 :type '(repeat string) |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14188
diff
changeset
|
122 :group 'lpr) |
9187
8cf9181c119e
(print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents:
8598
diff
changeset
|
123 |
256 | 124 ;;;###autoload |
155 | 125 (defun lpr-buffer () |
27007
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
126 "Print buffer contents without pagination or page headers. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
127 See the variables `lpr-switches' and `lpr-command' |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
128 for customization of the printer command." |
155 | 129 (interactive) |
130 (print-region-1 (point-min) (point-max) lpr-switches nil)) | |
131 | |
256 | 132 ;;;###autoload |
155 | 133 (defun print-buffer () |
26219
af8d23cd7220
(print-buffer): Doc-string fix.
Gerd Moellmann <gerd@gnu.org>
parents:
24091
diff
changeset
|
134 "Paginate and print buffer contents. |
27007
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
135 |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
136 The variable `lpr-headers-switches' controls how to paginate. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
137 If it is nil (the default), we run the `pr' program (or whatever program |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
138 `lpr-page-header-program' specifies) to paginate. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
139 `lpr-page-header-switches' specifies the switches for that program. |
26219
af8d23cd7220
(print-buffer): Doc-string fix.
Gerd Moellmann <gerd@gnu.org>
parents:
24091
diff
changeset
|
140 |
27007
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
141 Otherwise, the switches in `lpr-headers-switches' are used |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
142 in the print command itself; we expect them to request pagination. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
143 |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
144 See the variables `lpr-switches' and `lpr-command' |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
145 for further customization of the printer command." |
155 | 146 (interactive) |
147 (print-region-1 (point-min) (point-max) lpr-switches t)) | |
148 | |
256 | 149 ;;;###autoload |
155 | 150 (defun lpr-region (start end) |
27007
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
151 "Print region contents without pagination or page headers. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
152 See the variables `lpr-switches' and `lpr-command' |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
153 for customization of the printer command." |
155 | 154 (interactive "r") |
155 (print-region-1 start end lpr-switches nil)) | |
156 | |
256 | 157 ;;;###autoload |
155 | 158 (defun print-region (start end) |
27007
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
159 "Paginate and print the region contents. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
160 |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
161 The variable `lpr-headers-switches' controls how to paginate. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
162 If it is nil (the default), we run the `pr' program (or whatever program |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
163 `lpr-page-header-program' specifies) to paginate. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
164 `lpr-page-header-switches' specifies the switches for that program. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
165 |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
166 Otherwise, the switches in `lpr-headers-switches' are used |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
167 in the print command itself; we expect them to request pagination. |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
168 |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
169 See the variables `lpr-switches' and `lpr-command' |
2d337fafb392
(lpr-buffer, print-buffer, lpr-region, print-region): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
26219
diff
changeset
|
170 for further customization of the printer command." |
155 | 171 (interactive "r") |
172 (print-region-1 start end lpr-switches t)) | |
173 | |
174 (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
|
175 ;; 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
|
176 ;; 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
|
177 ;; 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
|
178 (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
|
179 (title (concat (buffer-name) " Emacs buffer")) |
21569
c1f86e273a38
(print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents:
20278
diff
changeset
|
180 ;; Make pipes use the same coding system as |
c1f86e273a38
(print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents:
20278
diff
changeset
|
181 ;; writing the buffer to a file would. |
c1f86e273a38
(print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents:
20278
diff
changeset
|
182 (coding-system-for-write |
c1f86e273a38
(print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents:
20278
diff
changeset
|
183 (or coding-system-for-write buffer-file-coding-system)) |
c1f86e273a38
(print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents:
20278
diff
changeset
|
184 (coding-system-for-read |
c1f86e273a38
(print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents:
20278
diff
changeset
|
185 (or coding-system-for-read buffer-file-coding-system)) |
10708
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
186 (width tab-width) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
187 switch-string) |
155 | 188 (save-excursion |
10708
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
189 (if page-headers |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
190 (if lpr-headers-switches |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
191 ;; It is possible to use an lpr option |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
192 ;; to get page headers. |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
193 (setq switches (append (if (stringp lpr-headers-switches) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
194 (list lpr-headers-switches) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
195 lpr-headers-switches) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
196 switches)))) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
197 (setq switch-string |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
198 (if switches (concat " with options " |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
199 (mapconcat 'identity switches " ")) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
200 "")) |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
201 (message "Spooling%s..." switch-string) |
155 | 202 (if (/= tab-width 8) |
10700
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
203 (let ((new-coords (print-region-new-buffer start end))) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
204 (setq start (car new-coords) end (cdr new-coords)) |
155 | 205 (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
|
206 (save-excursion |
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
207 (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
|
208 (setq end (point-marker))) |
155 | 209 (untabify (point-min) (point-max)))) |
210 (if page-headers | |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
211 (if lpr-headers-switches |
10708
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
212 ;; We handled this above by modifying SWITCHES. |
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
213 nil |
10637
6e25c10f6fe8
(lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents:
10054
diff
changeset
|
214 ;; Run a separate program to get page headers. |
10700
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
215 (let ((new-coords (print-region-new-buffer start end))) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
216 (setq start (car new-coords) end (cdr new-coords))) |
10670
f759e91a1654
(lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents:
10643
diff
changeset
|
217 (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
|
218 t t nil |
20278
17c72edb5980
(print-region-1): When running pr, use -h always.
Karl Heuer <kwzh@gnu.org>
parents:
17865
diff
changeset
|
219 (nconc (list "-h" title) |
10670
f759e91a1654
(lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents:
10643
diff
changeset
|
220 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
|
221 (setq start (point-min) end (point-max)))) |
28442
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
222 (let ((printer-name-switch (if (memq system-type |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
223 '(usg-unix-v dgux hpux irix)) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
224 "-d" "-P"))) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
225 (apply (or print-region-function 'call-process-region) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
226 (nconc (list start end lpr-command |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
227 nil nil nil) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
228 (nconc (and lpr-add-switches |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
229 (list "-J" name)) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
230 ;; These belong in pr if we are using that. |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
231 (and lpr-add-switches lpr-headers-switches |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
232 (list "-T" title)) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
233 (and (stringp printer-name) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
234 (list (concat printer-name-switch |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
235 printer-name))) |
efd5a62ccce9
(print-region-1): Use -d to specify printer name for
Gerd Moellmann <gerd@gnu.org>
parents:
27007
diff
changeset
|
236 switches)))) |
4446
ff1f9d7addd9
(print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents:
2382
diff
changeset
|
237 (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
|
238 (set-marker end nil)) |
10708
8a15461d4f64
(print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents:
10700
diff
changeset
|
239 (message "Spooling%s...done" switch-string)))) |
155 | 240 |
241 ;; This function copies the text between start and end | |
10700
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
242 ;; into a new buffer, makes that buffer current. |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
243 ;; It returns the new range to print from the new current buffer |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
244 ;; as (START . END). |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
245 |
5267
f7ea27a729b8
(lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents:
5004
diff
changeset
|
246 (defun print-region-new-buffer (ostart oend) |
10700
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
247 (if (string= (buffer-name) " *spool temp*") |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
248 (cons ostart oend) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
249 (let ((oldbuf (current-buffer))) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
250 (set-buffer (get-buffer-create " *spool temp*")) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
251 (widen) (erase-buffer) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
252 (insert-buffer-substring oldbuf ostart oend) |
f6f235bc26ba
(print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents:
10670
diff
changeset
|
253 (cons (point-min) (point-max))))) |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
617
diff
changeset
|
254 |
2382
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
255 (defun printify-region (begin end) |
17695
5788aa5f0fd0
(printify-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17414
diff
changeset
|
256 "Replace nonprinting characters in region with printable representations. |
5788aa5f0fd0
(printify-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17414
diff
changeset
|
257 The printable representations use ^ (for ASCII control characters) or hex. |
5788aa5f0fd0
(printify-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17414
diff
changeset
|
258 The characters tab, linefeed, space, return and formfeed are not affected." |
2382
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
259 (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
|
260 (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
|
261 (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
|
262 (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
|
263 (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
|
264 (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
|
265 (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
|
266 (insert |
030b76db285a
(printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
267 (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
|
268 (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
|
269 (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
|
270 |
11831 | 271 (provide 'lpr) |
272 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
617
diff
changeset
|
273 ;;; lpr.el ends here |