Commit | Line | Data |
---|---|---|
2c840b90 KS |
1 | ;;; printing.el --- printing utilities |
2 | ||
449cba44 | 3 | ;; Copyright (C) 2000, 2001, 2002, 2003, 2004 |
2c840b90 KS |
4 | ;; Free Software Foundation, Inc. |
5 | ||
45f17557 VJL |
6 | ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
7 | ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> | |
0117451d | 8 | ;; Time-stamp: <2004/07/12 21:10:35 vinicius> |
2c840b90 | 9 | ;; Keywords: wp, print, PostScript |
45f17557 | 10 | ;; Version: 6.8 |
2c840b90 KS |
11 | ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ |
12 | ||
45f17557 | 13 | (defconst pr-version "6.8" |
0117451d | 14 | "printing.el, v 6.8 <2004/07/12 vinicius> |
2c840b90 KS |
15 | |
16 | Please send all bug fixes and enhancements to | |
45f17557 | 17 | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
2c840b90 KS |
18 | ") |
19 | ||
20 | ;; This file is part of GNU Emacs. | |
21 | ||
22 | ;; GNU Emacs is free software; you can redistribute it and/or modify it under | |
23 | ;; the terms of the GNU General Public License as published by the Free | |
24 | ;; Software Foundation; either version 2, or (at your option) any later | |
25 | ;; version. | |
26 | ||
27 | ;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY | |
28 | ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
29 | ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
30 | ;; details. | |
31 | ||
32 | ;; You should have received a copy of the GNU General Public License along with | |
33 | ;; GNU Emacs; see the file COPYING. If not, write to the Free Software | |
34 | ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
35 | ||
36 | ;;; Commentary: | |
37 | ||
38 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
39 | ;; | |
40 | ;; Introduction | |
41 | ;; ------------ | |
42 | ;; | |
45f17557 VJL |
43 | ;; This package provides an user interface to some printing utilities that |
44 | ;; includes previewing/printing a PostScript file, printing a text file and | |
2c840b90 | 45 | ;; previewing/printing some major modes (like mh-folder-mode, |
45f17557 VJL |
46 | ;; rmail-summary-mode, gnus-summary-mode, etc). It also includes a |
47 | ;; PostScript/text printer database. | |
48 | ;; | |
49 | ;; Indeed, there are two user interfaces: | |
50 | ;; | |
0117451d | 51 | ;; * Menu interface: |
45f17557 VJL |
52 | ;; When `printing' is loaded, the menubar is modified to use `printing' |
53 | ;; menu instead of the print options in menubar. | |
54 | ;; This is the default user interface. | |
55 | ;; | |
0117451d | 56 | ;; * Buffer interface: |
45f17557 VJL |
57 | ;; It is an option of `printing' menu, but it can be binded into another |
58 | ;; key, so user can activate the buffer interface directly without using | |
59 | ;; a menu. See `pr-interface' command. | |
2c840b90 KS |
60 | ;; |
61 | ;; `printing' was inspired on: | |
62 | ;; | |
63 | ;; print-nt.el Frederic Corne <frederic.corne@erli.fr> | |
64 | ;; Special printing functions for Windows NT | |
65 | ;; | |
66 | ;; mh-e-init.el Tom Vogels <tov@ece.cmu.edu> | |
67 | ;; PS-print for mail messages | |
68 | ;; | |
69 | ;; win32-ps-print.el Matthew O. Persico <mpersico@erols.com> | |
70 | ;; PostScript printing with ghostscript | |
71 | ;; | |
72 | ;; ps-print-interface.el Volker Franz <volker.franz@tuebingen.mpg.de> | |
73 | ;; Graphical front end for ps-print and previewing | |
74 | ;; | |
75 | ;; `printing' is prepared to run on GNU, Unix and NT systems. | |
76 | ;; On GNU or Unix system, `printing' depends on gs and gv utilities. | |
77 | ;; On NT system, `printing' depends on gstools (gswin32.exe and gsview32.exe). | |
78 | ;; To obtain ghostscript, ghostview and GSview see the URL | |
79 | ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'. | |
80 | ;; | |
0117451d VJL |
81 | ;; `printing' depends on ps-print package to generate PostScript files, to |
82 | ;; spool and to despool PostScript buffer. So, `printing' provides an | |
83 | ;; interface to ps-print package and it also provides some extra stuff. | |
84 | ;; | |
2c840b90 KS |
85 | ;; To download the latest ps-print package see |
86 | ;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'. | |
87 | ;; Please, see README file for ps-print installation instructions. | |
88 | ;; | |
89 | ;; | |
0117451d VJL |
90 | ;; Log Messages |
91 | ;; ------------ | |
92 | ;; | |
93 | ;; The buffer *Printing Command Output* is where the `printing' log messages | |
94 | ;; are inserted. All program called by `printing' has a log entry in the | |
95 | ;; buffer *Printing Command Output*. A log entry has the following form: | |
96 | ;; | |
97 | ;; PROGRAM (ARG...) | |
98 | ;; MESSAGE | |
99 | ;; Exit status: CODE | |
100 | ;; | |
101 | ;; Where | |
102 | ;; PROGRAM is the program activated by `printing', | |
103 | ;; ARG is an argument passed to PROGRAM (it can have more than one argument), | |
104 | ;; MESSAGE is an error message returned by PROGRAM (it can have no message, if | |
105 | ;; PROGRAM is successful), | |
106 | ;; and CODE is a numeric exit status or a signal description string. | |
107 | ;; | |
108 | ;; For example, after previewing a PostScript file, *Printing Command Output* | |
109 | ;; will have the following entry: | |
110 | ;; | |
111 | ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps") | |
112 | ;; Exit status: 0 | |
113 | ;; | |
114 | ;; In the example above, the previewing was successful. If during previewing, | |
115 | ;; you quit gv execution (by typing C-g during Emacs session), the log entry | |
116 | ;; would be: | |
117 | ;; | |
118 | ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps") | |
119 | ;; Exit status: Quit | |
120 | ;; | |
121 | ;; So, if something goes wrong, a good place to take a look is the buffer | |
122 | ;; *Printing Command Output*. Don't forget to see also the buffer *Messages*, | |
123 | ;; it can help. | |
124 | ;; | |
125 | ;; | |
2c840b90 KS |
126 | ;; Novices (First Users) |
127 | ;; --------------------- | |
128 | ;; | |
129 | ;; First of all, take a glance of printing documentation only to have an idea | |
130 | ;; of what `printing' is capable. | |
131 | ;; | |
132 | ;; Then try to set the variables: `pr-ps-name', `pr-ps-printer-alist', | |
133 | ;; `pr-txt-name', `pr-txt-printer-alist' and `pr-path-alist'. These variables | |
134 | ;; are the main variables for printing processing. | |
135 | ;; | |
136 | ;; Now, please, see these variables documentation more in deep. You can do | |
137 | ;; this by typing C-h v pr-ps-name RET (for example) if you already loaded | |
138 | ;; printing package, or by browsing printing.el source file. | |
139 | ;; | |
140 | ;; If the documentation isn't clear or if you find a way to improve the | |
141 | ;; documentation, please, send an email to maintainer. All printing users | |
142 | ;; will thank you. | |
143 | ;; | |
144 | ;; One way to set variables is by calling `pr-customize', customize all | |
145 | ;; variables and save the customization by future sessions (see Options | |
146 | ;; section). Other way is by coding your settings on Emacs init file (that is, | |
147 | ;; .emacs file), see below for a first setting template that it should be | |
148 | ;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT | |
149 | ;; or MS-DOS): | |
150 | ;; | |
151 | ;; * Example of setting for Windows system: | |
152 | ;; | |
153 | ;; (require 'printing) ; load printing package | |
154 | ;; (setq pr-path-alist | |
155 | ;; '((windows "c:/applications/executables" PATH ghostview mpage) | |
156 | ;; (ghostview "c:/gs/gsview-dir") | |
157 | ;; (mpage "c:/mpage-dir") | |
158 | ;; )) | |
159 | ;; (setq pr-txt-name 'prt_06a) | |
160 | ;; (setq pr-txt-printer-alist | |
161 | ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a") | |
162 | ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c") | |
163 | ;; (PRN "" nil "PRN") | |
164 | ;; (standard "redpr.exe" nil "") | |
165 | ;; )) | |
166 | ;; (setq pr-ps-name 'lps_06b) | |
167 | ;; (setq pr-ps-printer-alist | |
168 | ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a") | |
169 | ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b") | |
170 | ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c") | |
171 | ;; (lps_08c nil nil nil "\\\\printers\\lps_08c") | |
172 | ;; (LPT1 "" nil "" "LPT1:") | |
173 | ;; (PRN "" nil "" "PRN") | |
174 | ;; (standard "redpr.exe" nil "" "") | |
175 | ;; )) | |
176 | ;; (pr-update-menus t) ; update now printer and utility menus | |
177 | ;; | |
178 | ;; * Example of setting for GNU or Unix system: | |
179 | ;; | |
180 | ;; (require 'printing) ; load printing package | |
181 | ;; (setq pr-path-alist | |
182 | ;; '((unix "." "~/bin" ghostview mpage PATH) | |
183 | ;; (ghostview "$HOME/bin/gsview-dir") | |
184 | ;; (mpage "$HOME/bin/mpage-dir") | |
185 | ;; )) | |
186 | ;; (setq pr-txt-name 'prt_06a) | |
187 | ;; (setq pr-txt-printer-alist | |
188 | ;; '((prt_06a "lpr" nil "prt_06a") | |
189 | ;; (prt_07c nil nil "prt_07c") | |
190 | ;; )) | |
191 | ;; (setq pr-ps-name 'lps_06b) | |
192 | ;; (setq pr-ps-printer-alist | |
193 | ;; '((lps_06b "lpr" nil "-P" "lps_06b") | |
194 | ;; (lps_07c "lpr" nil nil "lps_07c") | |
195 | ;; (lps_08c nil nil nil "lps_08c") | |
196 | ;; )) | |
197 | ;; (pr-update-menus t) ; update now printer and utility menus | |
198 | ;; | |
199 | ;; | |
200 | ;; NOTE 1: Don't forget to download and install ghostscript utilities (see | |
201 | ;; Utilities section). | |
202 | ;; | |
203 | ;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be | |
204 | ;; set, as they are implicit set by `pr-ps-printer-alist' and | |
205 | ;; `pr-txt-printer-alist'. | |
206 | ;; | |
207 | ;; NOTE 3: The duplex feature will only work on PostScript printers that | |
208 | ;; support this feature. | |
209 | ;; You can check if your PostScript printer supports duplex feature | |
210 | ;; by checking the printer manual. Or you can try these steps: | |
211 | ;; 1. Open a buffer (or use the *scratch* buffer). | |
212 | ;; 2. Type: | |
213 | ;; First line (on first page) | |
214 | ;; ^L | |
215 | ;; Second line (on second page) | |
216 | ;; 3. Print this buffer with duplex turned on. | |
217 | ;; If it's printed 2 (two) sheets of paper, then your PostScript | |
218 | ;; printer doesn't have duplex feature; otherwise, it's ok, your | |
219 | ;; printer does have duplex feature. | |
220 | ;; | |
739ce395 VJL |
221 | ;; NOTE 4: See Tips section. |
222 | ;; | |
223 | ;; | |
224 | ;; Tips | |
225 | ;; ---- | |
226 | ;; | |
45f17557 | 227 | ;; 1. If you have a local printer, that is, a printer which is connected |
739ce395 VJL |
228 | ;; directly to your computer, don't forget to connect the printer to your |
229 | ;; computer before printing. | |
230 | ;; | |
1f5a8e4a VJL |
231 | ;; 2. If you try to print a file and it seems that the file was printed, but |
232 | ;; there is no paper in the printer, then try to set `pr-delete-temp-file' | |
233 | ;; to nil. Probably `printing' is deleting the temporary file before your | |
234 | ;; local system can get it to send to the printer. | |
235 | ;; | |
236 | ;; 3. Don't try to print a dynamic buffer, that is, a buffer which is | |
237 | ;; modifying while `printing' tries to print. Eventually you got an error | |
238 | ;; message. Instead, save the dynamic buffer to a file or copy it in | |
239 | ;; another buffer and, then, print the file or the new static buffer. | |
240 | ;; An example of dynamic buffer is the *Messages* buffer. | |
241 | ;; | |
45f17557 VJL |
242 | ;; 4. When running Emacs on Windows (with or without cygwin), check if your |
243 | ;; printer is a text printer or not by typing in a DOS window: | |
244 | ;; | |
245 | ;; print /D:\\host\printer somefile.txt | |
246 | ;; | |
0117451d | 247 | ;; Where, `host' is the machine where the printer is directly connected, |
45f17557 | 248 | ;; `printer' is the printer name and `somefile.txt' is a text file. |
f88aa6e5 | 249 | ;; |
45f17557 VJL |
250 | ;; If the printer `\\host\printer' doesn't print the content of |
251 | ;; `somefile.txt' or, instead, it returns the following message: | |
f88aa6e5 | 252 | ;; |
45f17557 VJL |
253 | ;; PostScript Error Handler |
254 | ;; Offending Command = CCC | |
255 | ;; Stack = | |
256 | ;; | |
257 | ;; Where `CCC' is whatever is at the beginning of the text to be printed. | |
258 | ;; | |
259 | ;; Therefore, the printer `\\host\printer' is not a text printer, but a | |
260 | ;; PostScript printer. So, please, don't include this printer in | |
261 | ;; `pr-txt-printer-alist' (which see). | |
38253bba | 262 | ;; |
2c840b90 KS |
263 | ;; |
264 | ;; Using `printing' | |
265 | ;; ---------------- | |
266 | ;; | |
267 | ;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're | |
268 | ;; using Windows 9x/NT or MS-DOS): | |
269 | ;; | |
270 | ;; (require 'printing) | |
271 | ;; | |
272 | ;; When `printing' is loaded: | |
273 | ;; * On Emacs 20: | |
274 | ;; it replaces the Tools/Print menu by Tools/Printing menu. | |
275 | ;; * On Emacs 21: | |
276 | ;; it replaces the File/Print* menu entries by File/Print menu. | |
277 | ;; Please, see section Menu Layout below for menu explanation. | |
278 | ;; | |
279 | ;; To use `printing' utilities you can use the Printing menu options, type M-x | |
280 | ;; followed by one of the commands below, or type a key associated with the | |
281 | ;; command you want (if there is a key binding). | |
282 | ;; | |
283 | ;; `printing' has the following commands: | |
284 | ;; | |
285 | ;; pr-interface | |
286 | ;; pr-ps-directory-preview | |
287 | ;; pr-ps-directory-using-ghostscript | |
288 | ;; pr-ps-directory-print | |
289 | ;; pr-ps-directory-ps-print | |
290 | ;; pr-ps-buffer-preview | |
291 | ;; pr-ps-buffer-using-ghostscript | |
292 | ;; pr-ps-buffer-print | |
293 | ;; pr-ps-buffer-ps-print | |
294 | ;; pr-ps-region-preview | |
295 | ;; pr-ps-region-using-ghostscript | |
296 | ;; pr-ps-region-print | |
297 | ;; pr-ps-region-ps-print | |
298 | ;; pr-ps-mode-preview | |
299 | ;; pr-ps-mode-using-ghostscript | |
300 | ;; pr-ps-mode-print | |
301 | ;; pr-ps-mode-ps-print | |
302 | ;; pr-ps-file-preview | |
303 | ;; pr-ps-file-up-preview | |
304 | ;; pr-ps-file-using-ghostscript | |
305 | ;; pr-ps-file-print | |
306 | ;; pr-ps-file-ps-print | |
307 | ;; pr-ps-file-up-ps-print | |
308 | ;; pr-ps-fast-fire | |
309 | ;; pr-despool-preview | |
310 | ;; pr-despool-using-ghostscript | |
311 | ;; pr-despool-print | |
312 | ;; pr-despool-ps-print | |
313 | ;; pr-printify-directory | |
314 | ;; pr-printify-buffer | |
315 | ;; pr-printify-region | |
316 | ;; pr-txt-directory | |
317 | ;; pr-txt-buffer | |
318 | ;; pr-txt-region | |
319 | ;; pr-txt-mode | |
320 | ;; pr-txt-fast-fire | |
321 | ;; pr-toggle-file-duplex | |
322 | ;; pr-toggle-file-tumble | |
323 | ;; pr-toggle-file-landscape | |
324 | ;; pr-toggle-ghostscript | |
325 | ;; pr-toggle-faces | |
326 | ;; pr-toggle-spool | |
327 | ;; pr-toggle-duplex | |
328 | ;; pr-toggle-tumble | |
329 | ;; pr-toggle-landscape | |
330 | ;; pr-toggle-upside-down | |
331 | ;; pr-toggle-line | |
332 | ;; pr-toggle-zebra | |
333 | ;; pr-toggle-header | |
334 | ;; pr-toggle-lock | |
335 | ;; pr-toggle-region | |
336 | ;; pr-toggle-mode | |
337 | ;; pr-customize | |
338 | ;; lpr-customize | |
339 | ;; pr-help | |
340 | ;; pr-ps-name | |
341 | ;; pr-txt-name | |
342 | ;; pr-ps-utility | |
343 | ;; pr-show-ps-setup | |
344 | ;; pr-show-pr-setup | |
345 | ;; pr-show-lpr-setup | |
346 | ;; | |
347 | ;; The general meanings of above commands are: | |
348 | ;; | |
349 | ;; PREFIX: | |
350 | ;; `pr-interface' buffer interface for printing package. | |
351 | ;; `pr-help' help for printing package. | |
449cba44 VJL |
352 | ;; `pr-ps-name' interactively select a PostScript printer. |
353 | ;; `pr-txt-name' interactively select a text printer. | |
354 | ;; `pr-ps-utility' interactively select a PostScript utility. | |
2c840b90 KS |
355 | ;; `pr-show-*-setup' show current settings. |
356 | ;; `pr-ps-*' deal with PostScript code generation. | |
357 | ;; `pr-txt-*' deal with text generation. | |
358 | ;; `pr-toggle-*' toggle on/off some boolean variable. | |
359 | ;; `pr-despool-*' despool the PostScript spooling buffer. | |
360 | ;; `pr-printify-*' replace nonprintable ASCII by printable ASCII | |
361 | ;; representation. | |
362 | ;; | |
363 | ;; SUFFIX: | |
364 | ;; `*-customize' customization. | |
365 | ;; `*-preview' preview a PostScript file. | |
366 | ;; `*-using-ghostscript' use ghostscript to print. | |
367 | ;; `*-fast-fire' fast fire command (see it for documentation). | |
368 | ;; `*-print' send PostScript directly to printer. | |
369 | ;; `*-ps-print' send PostScript directly to printer or use | |
370 | ;; ghostscript to print. It depends on | |
371 | ;; `pr-print-using-ghostscript' option. | |
372 | ;; | |
373 | ;; INFIX/SUFFIX: | |
374 | ;; `*-directory*' process a directory. | |
375 | ;; `*-buffer*' process a buffer. | |
376 | ;; `*-region*' process a region. | |
377 | ;; `*-mode*' process a major mode (see explanation below). | |
378 | ;; `*-file-*' process a PostScript file. | |
379 | ;; `*-file-up-*' process a PostScript file using a filter utility. | |
380 | ;; | |
381 | ;; Here are some examples: | |
382 | ;; | |
383 | ;; `pr-ps-buffer-using-ghostscript' | |
384 | ;; Use ghostscript to print a buffer. | |
385 | ;; | |
386 | ;; `pr-ps-file-print' | |
387 | ;; Print a PostScript file. | |
388 | ;; | |
389 | ;; `pr-toggle-spool' | |
390 | ;; Toggle spooling buffer. | |
391 | ;; | |
392 | ;; So you can preview through ghostview, use ghostscript to print (if you don't | |
393 | ;; have a PostScript printer) or send directly to printer a PostScript code | |
394 | ;; generated by `ps-print' package. | |
395 | ;; | |
396 | ;; Besides operating one buffer or region each time, you also can postpone | |
397 | ;; previewing or printing by saving the PostScript code generated in a | |
398 | ;; temporary Emacs buffer. This way you can save banner pages between | |
399 | ;; successive printing. You can toggle on/off spooling by invoking | |
400 | ;; `pr-toggle-spool' interactively or through menu bar. | |
401 | ;; | |
402 | ;; If you type, for example: | |
403 | ;; | |
404 | ;; C-u M-x pr-ps-buffer-print RET | |
405 | ;; | |
406 | ;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and | |
407 | ;; a file name, and save the PostScript code generated to the file name instead | |
408 | ;; of sending to printer. | |
409 | ;; | |
410 | ;; This behavior is similar with the commands that deal with PostScript code | |
411 | ;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If | |
412 | ;; spooling is on, only `pr-despool-*' commands prompt for a file name and save | |
413 | ;; the PostScript code spooled in this file. | |
414 | ;; | |
415 | ;; Besides the behavior described above, the `*-directory*' commands also | |
416 | ;; prompt for a directory and a file name regexp. So, it's possible to process | |
417 | ;; all or certain files on a directory at once (see also documentation for | |
418 | ;; `pr-list-directory'). | |
419 | ;; | |
420 | ;; `printing' has also a special way to handle some major mode through | |
421 | ;; `*-mode*' commands. So it's possible to customize a major mode printing, | |
422 | ;; it's only needed to declare the customization in `pr-mode-alist' (see | |
423 | ;; section Options) and invoke some of `*-mode*' commands. An example for | |
424 | ;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and | |
425 | ;; you're in the *Summary* buffer, if you forget to switch to the *Article* | |
426 | ;; buffer before printing, you'll get a nicely formatted list of article | |
427 | ;; subjects shows up at the printer. With major mode printing you don't need | |
428 | ;; to switch from gnus *Summary* buffer first. | |
429 | ;; | |
430 | ;; Current global keyboard mapping for GNU Emacs is: | |
431 | ;; | |
432 | ;; (global-set-key [print] 'pr-ps-fast-fire) | |
433 | ;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript) | |
434 | ;; (global-set-key [C-print] 'pr-txt-fast-fire) | |
435 | ;; | |
436 | ;; And for XEmacs is: | |
437 | ;; | |
438 | ;; (global-set-key 'f22 'pr-ps-fast-fire) | |
439 | ;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript) | |
440 | ;; (global-set-key '(control f22) 'pr-txt-fast-fire) | |
441 | ;; | |
442 | ;; As a suggestion of global keyboard mapping for some `printing' commands: | |
443 | ;; | |
444 | ;; (global-set-key "\C-ci" 'pr-interface) | |
445 | ;; (global-set-key "\C-cbp" 'pr-ps-buffer-print) | |
446 | ;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview) | |
447 | ;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript) | |
448 | ;; (global-set-key "\C-crp" 'pr-ps-region-print) | |
449 | ;; (global-set-key "\C-crx" 'pr-ps-region-preview) | |
450 | ;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript) | |
451 | ;; | |
452 | ;; | |
453 | ;; Options | |
454 | ;; ------- | |
455 | ;; | |
456 | ;; Below it's shown a brief description of `printing' options, please, see the | |
457 | ;; options declaration in the code for a long documentation. | |
458 | ;; | |
459 | ;; `pr-path-style' Specify which path style to use for external | |
460 | ;; commands. | |
461 | ;; | |
462 | ;; `pr-path-alist' Specify an alist for command paths. | |
463 | ;; | |
464 | ;; `pr-txt-name' Specify a printer for printing a text file. | |
465 | ;; | |
466 | ;; `pr-txt-printer-alist' Specify an alist of all text printers. | |
467 | ;; | |
468 | ;; `pr-ps-name' Specify a printer for printing a PostScript | |
469 | ;; file. | |
470 | ;; | |
471 | ;; `pr-ps-printer-alist' Specify an alist for all PostScript printers. | |
472 | ;; | |
473 | ;; `pr-temp-dir' Specify a directory for temporary files during | |
474 | ;; printing. | |
475 | ;; | |
476 | ;; `pr-ps-temp-file' Specify PostScript temporary file name. | |
477 | ;; | |
449cba44 VJL |
478 | ;; `pr-gv-command' Specify path and name of the gsview/gv |
479 | ;; utility. | |
2c840b90 | 480 | ;; |
449cba44 VJL |
481 | ;; `pr-gs-command' Specify path and name of the ghostscript |
482 | ;; utility. | |
2c840b90 KS |
483 | ;; |
484 | ;; `pr-gs-switches' Specify ghostscript switches. | |
485 | ;; | |
486 | ;; `pr-gs-device' Specify ghostscript device switch value. | |
487 | ;; | |
488 | ;; `pr-gs-resolution' Specify ghostscript resolution switch value. | |
489 | ;; | |
490 | ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript. | |
491 | ;; | |
492 | ;; `pr-faces-p' Non-nil means print with face attributes. | |
493 | ;; | |
494 | ;; `pr-spool-p' Non-nil means spool printing in a buffer. | |
495 | ;; | |
496 | ;; `pr-file-landscape' Non-nil means print PostScript file in | |
497 | ;; landscape orientation. | |
498 | ;; | |
499 | ;; `pr-file-duplex' Non-nil means print PostScript file in duplex | |
500 | ;; mode. | |
501 | ;; | |
502 | ;; `pr-file-tumble' Non-nil means print PostScript file in tumble | |
503 | ;; mode. | |
504 | ;; | |
505 | ;; `pr-auto-region' Non-nil means region is automagically detected. | |
506 | ;; | |
449cba44 VJL |
507 | ;; `pr-auto-mode' Non-nil means major-mode specific printing is |
508 | ;; prefered over normal printing. | |
2c840b90 KS |
509 | ;; |
510 | ;; `pr-mode-alist' Specify an alist for a major-mode and printing | |
511 | ;; function. | |
512 | ;; | |
513 | ;; `pr-ps-utility' Specify PostScript utility processing. | |
514 | ;; | |
515 | ;; `pr-ps-utility-alist' Specify an alist for PostScript utility | |
516 | ;; processing. | |
517 | ;; | |
518 | ;; `pr-menu-lock' Non-nil means menu is locked while selecting | |
519 | ;; toggle options. | |
520 | ;; | |
521 | ;; `pr-menu-char-height' Specify menu char height in pixels. | |
522 | ;; | |
523 | ;; `pr-menu-char-width' Specify menu char width in pixels. | |
524 | ;; | |
525 | ;; `pr-setting-database' Specify an alist for settings in general. | |
526 | ;; | |
527 | ;; `pr-visible-entry-list' Specify a list of Printing menu visible | |
528 | ;; entries. | |
529 | ;; | |
530 | ;; `pr-delete-temp-file' Non-nil means delete temporary files. | |
531 | ;; | |
532 | ;; `pr-list-directory' Non-nil means list directory when processing a | |
533 | ;; directory. | |
534 | ;; | |
535 | ;; `pr-buffer-name' Specify the name of the buffer interface for | |
536 | ;; printing package. | |
537 | ;; | |
538 | ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be | |
539 | ;; ignored in interface buffer. | |
540 | ;; | |
541 | ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a | |
542 | ;; field in interface buffer. | |
543 | ;; | |
2c840b90 KS |
544 | ;; To set the above options you may: |
545 | ;; | |
546 | ;; a) insert the code in your ~/.emacs, like: | |
547 | ;; | |
548 | ;; (setq pr-faces-p t) | |
549 | ;; | |
550 | ;; This way always keep your default settings when you enter a new Emacs | |
551 | ;; session. | |
552 | ;; | |
553 | ;; b) or use `set-variable' in your Emacs session, like: | |
554 | ;; | |
555 | ;; M-x set-variable RET pr-faces-p RET t RET | |
556 | ;; | |
557 | ;; This way keep your settings only during the current Emacs session. | |
558 | ;; | |
559 | ;; c) or use customization, for example: | |
560 | ;; click on menu-bar *Help* option, | |
561 | ;; then click on *Customize*, | |
562 | ;; then click on *Browse Customization Groups*, | |
563 | ;; expand *PostScript* group, | |
564 | ;; expand *Printing* group | |
565 | ;; and then customize `printing' options. | |
566 | ;; Through this way, you may choose if the settings are kept or not when | |
567 | ;; you leave out the current Emacs session. | |
568 | ;; | |
569 | ;; d) or see the option value: | |
570 | ;; | |
571 | ;; C-h v pr-faces-p RET | |
572 | ;; | |
573 | ;; and click the *customize* hypertext button. | |
574 | ;; Through this way, you may choose if the settings are kept or not when | |
575 | ;; you leave out the current Emacs session. | |
576 | ;; | |
577 | ;; e) or invoke: | |
578 | ;; | |
579 | ;; M-x pr-customize RET | |
580 | ;; | |
581 | ;; and then customize `printing' options. | |
582 | ;; Through this way, you may choose if the settings are kept or not when | |
583 | ;; you leave out the current Emacs session. | |
584 | ;; | |
585 | ;; f) or use menu bar, for example: | |
586 | ;; click on menu-bar *File* option, | |
587 | ;; then click on *Printing*, | |
588 | ;; then click on *Customize*, | |
589 | ;; then click on *printing* | |
590 | ;; and then customize `printing' options. | |
591 | ;; Through this way, you may choose if the settings are kept or not when | |
592 | ;; you leave out the current Emacs session. | |
593 | ;; | |
594 | ;; | |
595 | ;; Menu Layout | |
596 | ;; ----------- | |
597 | ;; | |
598 | ;; The `printing' menu (Tools/Printing or File/Print) has the following layout: | |
599 | ;; | |
600 | ;; +-----------------------------+ | |
601 | ;; A 0 | Printing Interface | | |
602 | ;; +-----------------------------+ +-A---------+ +-B------+ | |
603 | ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up | | |
604 | ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up | | |
605 | ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up | | |
606 | ;; +-----------------------------+ |Mode >|-- B |Other...| | |
607 | ;; II 4 | Printify >|-----\ |File >|--\ +--------+ | |
608 | ;; 5 | Print >|---\ | |Despool... | | | |
609 | ;; 6 | Text Printer: name >|-\ | | +-----------+ | | |
610 | ;; +-----------------------------+ | | | +---------+ +------------+ | |
b8d955f4 | 611 | ;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia |
2c840b90 KS |
612 | ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib |
613 | ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C | |
614 | ;; 10 |[ ]Line Number | | | +---------+ +------------+ | |
615 | ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic | |
616 | ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... | | |
617 | ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... | | |
618 | ;; 14 |[ ]Upside-Down | | |Region | | Other... | | |
619 | ;; 15 | Print All Pages >|--\ | |Mode | +------------+ | |
620 | ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id | |
621 | ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie | |
449cba44 VJL |
622 | ;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If |
623 | ;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+ | |
2c840b90 KS |
624 | ;; +-----------------------------+ | |... | |
625 | ;; V 19 |[ ]Auto Region | | |(*)name | | |
626 | ;; 20 |[ ]Auto Mode | | |... | | |
627 | ;; 21 |[ ]Menu Lock | | +---------+ +--------------+ | |
628 | ;; +-----------------------------+ \------------------|(*)All Pages | | |
629 | ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages | | |
630 | ;; 23 | Show Settings >|-------|printing| |( )Odd Pages | | |
631 | ;; 24 | Help | |ps-print| |( )Even Sheets| | |
632 | ;; +-----------------------------+ |lpr | |( )Odd Sheets | | |
633 | ;; +--------+ +--------------+ | |
634 | ;; | |
635 | ;; See `pr-visible-entry-list' for hiding some parts of the menu. | |
636 | ;; | |
637 | ;; The menu has the following sections: | |
638 | ;; | |
639 | ;; A. Interface: | |
640 | ;; | |
641 | ;; 0. You can use a buffer interface instead of menus. It looks like the | |
642 | ;; customization buffer. Basically, it has the same options found in the | |
643 | ;; menu and some extra options, all this on a buffer. | |
644 | ;; | |
645 | ;; I. PostScript printing: | |
646 | ;; | |
647 | ;; 1. You can generate a PostScript file (if you type C-u before activating | |
648 | ;; menu) or PostScript temporary file for a directory, a buffer, a region | |
649 | ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing; | |
650 | ;; after file generation, ghostview is activated using the file generated | |
651 | ;; as argument. This option is disabled if spooling is on (option 16). | |
652 | ;; Also, if you already have a PostScript file you can preview it. | |
653 | ;; Instead of previewing each buffer, region or major mode at once, you | |
654 | ;; can save temporarily the PostScript code generated in a buffer and | |
655 | ;; preview it later. The option `Despool...' despools the PostScript | |
656 | ;; spooling buffer in a temporary file and uses ghostview to preview it. | |
657 | ;; If you type C-u before choosing this option, the PostScript code | |
658 | ;; generated is saved in a file instead of saving in a temporary file. | |
659 | ;; To spool the PostScript code generated you need to turn on the option | |
660 | ;; 16. The option `Despool...' is enabled if spooling is on (option | |
661 | ;; 16). | |
662 | ;; | |
663 | ;; NOTE 1: It's possible to customize a major mode printing, just declare | |
664 | ;; the customization in `pr-mode-alist' and invoke some of | |
665 | ;; `*-mode*' commands or select Mode option in Printing menu. An | |
666 | ;; example for major mode usage is when you're using gnus (or mh, | |
667 | ;; or rmail, etc.) and you're in the *Summary* buffer, if you | |
668 | ;; forget to switch to the *Article* buffer before printing, | |
669 | ;; you'll get a nicely formatted list of article subjects shows | |
670 | ;; up at the printer. With major mode printing you don't need to | |
671 | ;; switch from gnus *Summary* buffer first. | |
672 | ;; | |
673 | ;; NOTE 2: There are the following options for PostScript file | |
674 | ;; processing: | |
b8d955f4 VJL |
675 | ;; Ia. Print the file *No Preprocessing*, that is, send it |
676 | ;; directly to PostScript printer. | |
2c840b90 KS |
677 | ;; Ib. PostScript utility processing selection. |
678 | ;; See `pr-ps-utility-alist' and `pr-setting-database' for | |
679 | ;; documentation. | |
680 | ;; Ic. Do n-up processing before printing. | |
681 | ;; Id. Toggle on/off landscape for PostScript file processing. | |
682 | ;; Ie. Toggle on/off duplex for PostScript file processing. | |
683 | ;; If. Toggle on/off tumble for PostScript file processing. | |
684 | ;; | |
685 | ;; NOTE 3: Don't forget to download and install the utilities declared on | |
686 | ;; `pr-ps-utility-alist'. | |
687 | ;; | |
688 | ;; 2. Operate the same way as option 1, but it sends directly the PostScript | |
689 | ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to | |
690 | ;; print the PostScript file generated. It depends on option 18, if it's | |
691 | ;; turned on, it uses ghostscript; otherwise, it sends directly to | |
692 | ;; printer. If spooling is on (option 16), the PostScript code is saved | |
693 | ;; temporarily in a buffer instead of printing it or saving it in a file. | |
694 | ;; Also, if you already have a PostScript file you can print it. Instead | |
695 | ;; of printing each buffer, region or major mode at once, you can save | |
696 | ;; temporarily the PostScript code generated in a buffer and print it | |
697 | ;; later. The option `Despool...' despools the PostScript spooling | |
698 | ;; buffer directly on a printer. If you type C-u before choosing this | |
699 | ;; option, the PostScript code generated is saved in a file instead of | |
700 | ;; sending to printer. To spool the PostScript code generated you need | |
701 | ;; to turn on the option 16. This option is enabled if spooling is on | |
702 | ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1. | |
703 | ;; | |
704 | ;; 3. You can select a new PostScript printer to send PostScript code | |
705 | ;; generated. For selection it's used all PostScript printers defined | |
706 | ;; in `pr-ps-printer-alist' variable (see it for documentation). | |
707 | ;; See also `pr-setting-database'. | |
708 | ;; | |
709 | ;; II. Text printing: | |
710 | ;; | |
711 | ;; 4. If you have control characters (character code from \000 to \037) in a | |
712 | ;; buffer and you want to print them in a text printer, select this | |
713 | ;; option. All control characters in your buffer or region will be | |
714 | ;; replaced by a printable representation. The printable representations | |
715 | ;; use ^ (for ASCII control characters) or hex. The characters tab, | |
716 | ;; linefeed, space, return and formfeed are not affected. You don't need | |
717 | ;; to select this option if you use any option of section I, the | |
718 | ;; PostScript engine treats control characters properly. | |
719 | ;; | |
720 | ;; 5. If you want to print a directory, buffer, region or major mode in a | |
721 | ;; text printer, select this option. See also the NOTE 1 on option 1. | |
722 | ;; | |
723 | ;; 6. You can select a new text printer to send text generated. For | |
724 | ;; selection it's used all text printers defined in | |
725 | ;; `pr-txt-printer-alist' variable (see it for documentation). | |
726 | ;; See also `pr-setting-database'. | |
727 | ;; | |
728 | ;; III. PostScript page toggle options: | |
729 | ;; | |
730 | ;; 7. If you want a PostScript landscape printing, turn on this option. | |
731 | ;; | |
732 | ;; 8. If you want to have a header in each page in your PostScript code, | |
733 | ;; turn on this option. | |
734 | ;; | |
735 | ;; 9. If you want to draw a gaudy frame around the header, turn on this | |
736 | ;; option. This option is enabled if print header is on (option 8). | |
737 | ;; | |
738 | ;; 10. If you want that the line number is printed in your PostScript code, | |
739 | ;; turn on this option. | |
740 | ;; | |
741 | ;; 11. If you want background zebra stripes in your PostScript code, turn on | |
742 | ;; this option. | |
743 | ;; | |
744 | ;; 12. If you want a duplex printing and your PostScript printer has this | |
745 | ;; feature, turn on this option. | |
746 | ;; | |
747 | ;; 13. If you turned on duplex printing, you can choose if you want to have | |
748 | ;; a printing suitable for binding on the left or right (tumble off), or | |
749 | ;; to have a printing suitable for binding at top or bottom (tumble on). | |
750 | ;; This option is enabled if duplex is on (option 12). | |
751 | ;; | |
752 | ;; 14. If you want a PostScript upside-down printing, turn on this option. | |
753 | ;; | |
754 | ;; 15. With this option, you can choose if you want to print all pages, odd | |
755 | ;; pages, even pages, odd sheets or even sheets. | |
756 | ;; See also `ps-even-or-odd-pages'. | |
757 | ;; | |
758 | ;; IV. PostScript processing toggle options: | |
759 | ;; | |
760 | ;; 16. If you want to spool the PostScript code generated, turn on this | |
761 | ;; option. To spool the PostScript code generated use option 2. You | |
762 | ;; can despool later by choosing option 1 or 2, sub-option `Despool...'. | |
763 | ;; | |
764 | ;; 17. If you use colors in your buffers and want to see these colors on | |
765 | ;; your PostScript code generated, turn on this option. If you have a | |
766 | ;; black/white PostScript printer, these colors are displayed in gray | |
767 | ;; scale by PostScript printer interpreter. | |
768 | ;; | |
769 | ;; 18. If you don't have a PostScript printer to send PostScript files, turn | |
770 | ;; on this option. When this option is on, the ghostscript is used to | |
771 | ;; print PostScript files. In GNU or Unix system, if ghostscript is set | |
772 | ;; as a PostScript filter, you don't need to turn on this option. | |
773 | ;; | |
774 | ;; V. Printing customization: | |
775 | ;; | |
776 | ;; 19. If you want that region is automagically detected, turn on this | |
777 | ;; option. Note that this will only work if you're using transient mark | |
778 | ;; mode. When this option is on, the `*-buffer*' commands will behave | |
779 | ;; like `*-region*' commands, that is, `*-buffer*' commands will print | |
780 | ;; only the region marked instead of all buffer. | |
781 | ;; | |
782 | ;; 20. Turn this option on if you want that when current major-mode is | |
783 | ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands | |
784 | ;; behave like `*-mode*' commands. | |
785 | ;; | |
449cba44 | 786 | ;; 21. If you want that Printing menu stays open while you are setting |
2c840b90 KS |
787 | ;; toggle options, turn on this option. The variables |
788 | ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the | |
789 | ;; menu position, so don't forget to adjust these variables if menu | |
790 | ;; position is not ok. | |
791 | ;; | |
792 | ;; VI. Customization: | |
793 | ;; | |
794 | ;; 22. Besides all options in section III, IV and V, you can customize much | |
795 | ;; more PostScript options in `ps-print' option. Or you can customize | |
796 | ;; some `lpr' options for text printing. Or customize `printing' | |
797 | ;; options. | |
798 | ;; | |
799 | ;; 23. Show current settings for `printing', `ps-print' or `lpr'. | |
800 | ;; | |
801 | ;; 24. Quick help for printing menu layout. | |
802 | ;; | |
803 | ;; | |
804 | ;; Option Settings | |
805 | ;; --------------- | |
806 | ;; | |
807 | ;; Below it's shown only the main options that affect all `printing' package. | |
808 | ;; Check all the settings below *BEFORE* running `printing' commands. | |
809 | ;; | |
810 | ;; * Example of setting for GNU or Unix system: | |
811 | ;; | |
812 | ;; (require 'printing) | |
813 | ;; (setq pr-path-alist | |
814 | ;; '((unix "." "~/bin" ghostview mpage PATH) | |
815 | ;; (ghostview "$HOME/bin/gsview-dir") | |
816 | ;; (mpage "$HOME/bin/mpage-dir") | |
817 | ;; )) | |
818 | ;; (setq pr-txt-name 'prt_06a) | |
819 | ;; (setq pr-txt-printer-alist | |
820 | ;; '((prt_06a "lpr" nil "prt_06a") | |
821 | ;; (prt_07c nil nil "prt_07c") | |
822 | ;; )) | |
823 | ;; (setq pr-ps-name 'lps_06b) | |
824 | ;; (setq pr-ps-printer-alist | |
825 | ;; '((lps_06b "lpr" nil "-P" "lps_06b") | |
826 | ;; (lps_07c "lpr" nil nil "lps_07c") | |
827 | ;; (lps_08c nil nil nil "lps_08c") | |
828 | ;; )) | |
829 | ;; (setq pr-temp-dir "/tmp/") | |
830 | ;; (setq pr-gv-command "gv") | |
831 | ;; (setq pr-gs-command "gs") | |
832 | ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10")) | |
833 | ;; (setq pr-gs-device "uniprint") | |
834 | ;; (setq pr-gs-resolution 300) | |
835 | ;; (setq pr-ps-utility 'mpage) | |
836 | ;; (setq pr-ps-utility-alist | |
837 | ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil) | |
838 | ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil | |
839 | ;; (inherits-from: . no-duplex)) | |
840 | ;; )) | |
841 | ;; (setq pr-setting-database | |
842 | ;; '((no-duplex | |
843 | ;; nil nil nil | |
844 | ;; (pr-file-duplex . nil) | |
845 | ;; (pr-file-tumble . nil)) | |
846 | ;; )) | |
847 | ;; (pr-update-menus t) ; update now printer and utility menus | |
848 | ;; | |
849 | ;; * Example of setting for Windows system: | |
850 | ;; | |
851 | ;; (require 'printing) | |
852 | ;; (setq pr-path-alist | |
853 | ;; '((windows "c:/applications/executables" PATH ghostview mpage) | |
854 | ;; (ghostview "c:/gs/gsview-dir") | |
855 | ;; (mpage "c:/mpage-dir") | |
856 | ;; )) | |
857 | ;; (setq pr-txt-name 'prt_06a) | |
858 | ;; (setq pr-txt-printer-alist | |
859 | ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a") | |
860 | ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c") | |
861 | ;; (PRN "" nil "PRN") | |
862 | ;; (standard "redpr.exe" nil "") | |
863 | ;; )) | |
864 | ;; (setq pr-ps-name 'lps_06b) | |
865 | ;; (setq pr-ps-printer-alist | |
866 | ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a") | |
867 | ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b") | |
868 | ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c") | |
869 | ;; (lps_08c nil nil nil "\\\\printers\\lps_08c") | |
870 | ;; (LPT1 "" nil "" "LPT1:") | |
871 | ;; (PRN "" nil "" "PRN") | |
872 | ;; (standard "redpr.exe" nil "" "") | |
873 | ;; )) | |
874 | ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/") | |
875 | ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe") | |
876 | ;; (setq pr-gs-command "c:/gs/gswin32.exe") | |
877 | ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")) | |
878 | ;; (setq pr-gs-device "mswinpr2") | |
879 | ;; (setq pr-gs-resolution 300) | |
880 | ;; (setq pr-ps-utility 'psnup) | |
881 | ;; (setq pr-ps-utility-alist | |
882 | ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " | |
883 | ;; nil (inherits-from: . no-duplex)) | |
884 | ;; )) | |
885 | ;; (setq pr-setting-database | |
886 | ;; '((no-duplex | |
887 | ;; nil nil nil | |
888 | ;; (pr-file-duplex . nil) | |
889 | ;; (pr-file-tumble . nil)) | |
890 | ;; )) | |
891 | ;; (pr-update-menus t) ; update now printer and utility menus | |
892 | ;; | |
893 | ;; NOTE: Don't forget to download and install the utilities declared on | |
894 | ;; `pr-ps-utility-alist'. | |
895 | ;; | |
896 | ;; | |
897 | ;; Utilities | |
898 | ;; --------- | |
899 | ;; | |
900 | ;; `printing' package has the following utilities: | |
901 | ;; | |
902 | ;; `pr-setup' Return the current `printing' setup. | |
903 | ;; | |
904 | ;; `lpr-setup' Return the current `lpr' setup. | |
905 | ;; | |
906 | ;; `pr-update-menus' Update utility, PostScript and text printer menus. | |
907 | ;; | |
908 | ;; Below are some URL where you can find good utilities. | |
909 | ;; | |
910 | ;; * For `printing' package: | |
911 | ;; | |
912 | ;; printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz' | |
913 | ;; ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz' | |
914 | ;; | |
915 | ;; * For GNU or Unix system: | |
916 | ;; | |
917 | ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html' | |
918 | ;; enscript `http://people.ssh.fi/mtr/genscript/' | |
919 | ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html' | |
920 | ;; mpage `http://www.mesa.nl/pub/mpage/' | |
921 | ;; | |
922 | ;; * For Windows system: | |
923 | ;; | |
924 | ;; gswin32, gsview32 | |
925 | ;; `http://www.gnu.org/software/ghostscript/ghostscript.html' | |
926 | ;; enscript `http://people.ssh.fi/mtr/genscript/' | |
927 | ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html' | |
928 | ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/' | |
929 | ;; | |
930 | ;; | |
931 | ;; Acknowledgments | |
932 | ;; --------------- | |
933 | ;; | |
0117451d VJL |
934 | ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions: |
935 | ;; - directory processing. | |
936 | ;; - `pr-path-alist' variable. | |
937 | ;; - doc fix. | |
938 | ;; - a lot of tests on Windows. | |
2c840b90 KS |
939 | ;; |
940 | ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests. | |
941 | ;; | |
942 | ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging | |
943 | ;; and for suggestions: | |
944 | ;; - even/odd pages printing. | |
945 | ;; - ghostscript parameters for `pr-ps-printer-alist'. | |
946 | ;; - default printer name. | |
947 | ;; - completion functions. | |
948 | ;; - automagic region detection. | |
949 | ;; - menu entry hiding. | |
950 | ;; - fast fire PostScript printing command. | |
951 | ;; - `pr-path-style' variable. | |
952 | ;; | |
953 | ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions: | |
954 | ;; - PostScript Print and PostScript Print Preview merge. | |
955 | ;; - Tools/Printing menu. | |
956 | ;; - replace *-using-preview by *-using-ghostscript. | |
957 | ;; - printer selection. | |
958 | ;; - extra parameters for `pr-ps-printer-alist'. | |
959 | ;; | |
960 | ;; Thanks to: | |
961 | ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el | |
962 | ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el | |
963 | ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el | |
964 | ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el | |
965 | ;; And to all people who contributed with them. | |
966 | ;; | |
967 | ;; | |
968 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
969 | ||
970 | ;;; Code: | |
971 | ||
972 | ||
973 | (require 'lpr) | |
974 | (require 'ps-print) | |
975 | ||
976 | ||
45f17557 VJL |
977 | (and (string< ps-print-version "6.6.4") |
978 | (error "`printing' requires `ps-print' package version 6.6.4 or later.")) | |
2c840b90 KS |
979 | |
980 | ||
981 | (eval-and-compile | |
982 | (defconst pr-cygwin-system | |
983 | (and ps-windows-system (getenv "OSTYPE") | |
984 | (string-match "cygwin" (getenv "OSTYPE"))))) | |
985 | ||
986 | ||
987 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
988 | ;; To avoid compilation gripes | |
989 | ||
990 | ||
991 | (eval-and-compile | |
992 | ||
993 | (or (fboundp 'subst-char-in-string) | |
994 | (defun subst-char-in-string (fromchar tochar string &optional inplace) | |
995 | "Replace FROMCHAR with TOCHAR in STRING each time it occurs. | |
996 | Unless optional argument INPLACE is non-nil, return a new string." | |
997 | (let ((i (length string)) | |
998 | (newstr (if inplace string (copy-sequence string)))) | |
999 | (while (> (setq i (1- i)) 0) | |
1000 | (if (eq (aref newstr i) fromchar) | |
1001 | (aset newstr i tochar))) | |
1002 | newstr))) | |
1003 | ||
1004 | ;; GNU Emacs | |
1005 | (defalias 'pr-e-frame-char-height 'frame-char-height) | |
1006 | (defalias 'pr-e-frame-char-width 'frame-char-width) | |
1007 | (defalias 'pr-e-mouse-pixel-position 'mouse-pixel-position) | |
1008 | ;; XEmacs | |
1009 | (defalias 'pr-x-add-submenu 'add-submenu) | |
1010 | (defalias 'pr-x-event-function 'event-function) | |
1011 | (defalias 'pr-x-event-object 'event-object) | |
1012 | (defalias 'pr-x-find-menu-item 'find-menu-item) | |
1013 | (defalias 'pr-x-font-height 'font-height) | |
1014 | (defalias 'pr-x-font-width 'font-width) | |
1015 | (defalias 'pr-x-get-popup-menu-response 'get-popup-menu-response) | |
1016 | (defalias 'pr-x-make-event 'make-event) | |
1017 | (defalias 'pr-x-misc-user-event-p 'misc-user-event-p) | |
1018 | (defalias 'pr-x-relabel-menu-item 'relabel-menu-item) | |
1019 | (defalias 'pr-x-event-x-pixel 'event-x-pixel) | |
1020 | (defalias 'pr-x-event-y-pixel 'event-y-pixel) | |
1021 | ||
1022 | (cond | |
1023 | ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
1024 | (defvar deactivate-mark nil) | |
1025 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parent) | |
1026 | (defalias 'pr-f-set-keymap-name 'ignore) | |
1027 | (defalias 'pr-f-read-string 'read-string) | |
1028 | (defun pr-keep-region-active () | |
1029 | (setq deactivate-mark nil))) | |
1030 | ||
1031 | ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
1032 | (defvar current-menubar nil) | |
1033 | (defvar current-mouse-event nil) | |
1034 | (defvar zmacs-region-stays nil) | |
1035 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parents) | |
1036 | (defalias 'pr-f-set-keymap-name 'set-keymap-name) | |
1037 | (defun pr-f-read-string (prompt initial history default) | |
1038 | (let ((str (read-string prompt initial))) | |
1039 | (if (and str (not (string= str ""))) | |
1040 | str | |
1041 | default))) | |
1042 | (defun pr-keep-region-active () | |
1043 | (setq zmacs-region-stays t))))) | |
1044 | ||
1045 | ||
1046 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1047 | ;; Customization Functions | |
1048 | ||
1049 | ||
1050 | (defun pr-alist-custom-set (symbol value) | |
1051 | "Set the value of custom variables for printer & utility selection." | |
1052 | (set symbol value) | |
1053 | (and (featurep 'printing) ; update only after printing is loaded | |
1054 | (pr-update-menus t))) | |
1055 | ||
1056 | ||
1057 | (defun pr-ps-utility-custom-set (symbol value) | |
1058 | "Update utility menu entry." | |
1059 | (set symbol value) | |
1060 | (and (featurep 'printing) ; update only after printing is loaded | |
1061 | (pr-menu-set-utility-title value))) | |
1062 | ||
1063 | ||
1064 | (defun pr-ps-name-custom-set (symbol value) | |
1065 | "Update `PostScript Printer:' menu entry." | |
1066 | (set symbol value) | |
1067 | (and (featurep 'printing) ; update only after printing is loaded | |
1068 | (pr-menu-set-ps-title value))) | |
1069 | ||
1070 | ||
1071 | (defun pr-txt-name-custom-set (symbol value) | |
1072 | "Update `Text Printer:' menu entry." | |
1073 | (set symbol value) | |
1074 | (and (featurep 'printing) ; update only after printing is loaded | |
1075 | (pr-menu-set-txt-title value))) | |
1076 | ||
1077 | ||
1078 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1079 | ;; User Interface (I) | |
1080 | ||
1081 | ||
1082 | (defgroup printing nil | |
1083 | "Printing Utilities group" | |
1084 | :tag "Printing Utilities" | |
1085 | :link '(emacs-library-link :tag "Source Lisp File" "printing.el") | |
1086 | :prefix "pr-" | |
1087 | :group 'wp | |
1088 | :group 'postscript) | |
1089 | ||
1090 | ||
1091 | (defcustom pr-path-style | |
1092 | (if (and (not pr-cygwin-system) | |
1093 | ps-windows-system) | |
1094 | 'windows | |
1095 | 'unix) | |
1096 | "*Specify which path style to use for external commands. | |
1097 | ||
1098 | Valid values are: | |
1099 | ||
1100 | windows Windows 9x/NT style (\\) | |
1101 | ||
1102 | unix Unix style (/)" | |
1103 | :type '(choice :tag "Path style" | |
1104 | (const :tag "Windows 9x/NT Style (\\)" :value windows) | |
1105 | (const :tag "Unix Style (/)" :value unix)) | |
1106 | :group 'printing) | |
1107 | ||
1108 | ||
1109 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1110 | ;; Internal Functions (I) | |
1111 | ||
1112 | ||
0117451d | 1113 | (defun pr-dosify-file-name (path) |
2c840b90 KS |
1114 | "Replace unix-style directory separator character with dos/windows one." |
1115 | (interactive "sPath: ") | |
1116 | (if (eq pr-path-style 'windows) | |
1117 | (subst-char-in-string ?/ ?\\ path) | |
1118 | path)) | |
1119 | ||
1120 | ||
0117451d | 1121 | (defun pr-unixify-file-name (path) |
2c840b90 KS |
1122 | "Replace dos/windows-style directory separator character with unix one." |
1123 | (interactive "sPath: ") | |
1124 | (if (eq pr-path-style 'windows) | |
1125 | (subst-char-in-string ?\\ ?/ path) | |
1126 | path)) | |
1127 | ||
1128 | ||
0117451d | 1129 | (defun pr-standard-file-name (path) |
45f17557 VJL |
1130 | "Ensure the proper directory separator depending on the OS. |
1131 | That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory | |
1132 | separator; otherwise, ensure unix-style directory separator." | |
1133 | (if (or pr-cygwin-system ps-windows-system) | |
1134 | (subst-char-in-string ?/ ?\\ path) | |
1135 | (subst-char-in-string ?\\ ?/ path))) | |
1136 | ||
1137 | ||
2c840b90 KS |
1138 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1139 | ;; User Interface (II) | |
1140 | ||
1141 | ||
1142 | (defcustom pr-path-alist | |
1143 | '((unix PATH) | |
1144 | (cygwin PATH) | |
1145 | (windows PATH)) | |
1146 | "*Specify an alist for command paths. | |
1147 | ||
1148 | It's used to find commands used for printing package, like gv, gs, gsview.exe, | |
1149 | mpage, print.exe, etc. See also `pr-command' function. | |
1150 | ||
1151 | Each element has the form: | |
1152 | ||
1153 | (ENTRY DIRECTORY...) | |
1154 | ||
1155 | Where: | |
1156 | ||
1157 | ENTRY It's a symbol, used to identify this entry. | |
1158 | There must exist at least one of the following entries: | |
1159 | ||
1160 | unix this entry is used when Emacs is running on GNU or | |
1161 | Unix system. | |
1162 | ||
1163 | cygwin this entry is used when Emacs is running on Windows | |
1164 | 95/98/NT/2000 with Cygwin. | |
1165 | ||
1166 | windows this entry is used when Emacs is running on Windows | |
1167 | 95/98/NT/2000. | |
1168 | ||
1169 | DIRECTORY It should be a string or a symbol. If it's a symbol, it should | |
1170 | exist an equal entry in `pr-path-alist'. If it's a string, | |
1171 | it's considered a directory specification. | |
1172 | ||
1173 | The directory specification may contain: | |
1174 | $var environment variable expansion | |
1175 | ~/ tilde expansion | |
1176 | ./ current directory | |
1177 | ../ previous directory | |
1178 | ||
1179 | For example, let's say the home directory is /home/my and the | |
1180 | current directory is /home/my/dir, so: | |
1181 | ||
1182 | THE ENTRY IS EXPANDED TO | |
1183 | ~/entry /home/my/entry | |
1184 | ./entry /home/my/dir/entry | |
1185 | ../entry /home/my/entry | |
1186 | $HOME/entry /home/my/entry | |
1187 | $HOME/~/other/../my/entry /home/my/entry | |
1188 | ||
1189 | SPECIAL SYMBOL: If the symbol `PATH' is used in the directory | |
1190 | list and there isn't a `PATH' entry in `pr-path-alist' or the | |
1191 | `PATH' entry has a null directory list, the PATH environment | |
1192 | variable is used. | |
1193 | ||
1194 | Examples: | |
1195 | ||
1196 | * On GNU or Unix system: | |
1197 | ||
1198 | '((unix \".\" \"~/bin\" ghostview mpage PATH) | |
1199 | (ghostview \"$HOME/bin/gsview-dir\") | |
1200 | (mpage \"$HOME/bin/mpage-dir\") | |
1201 | ) | |
1202 | ||
1203 | * On Windows system: | |
1204 | ||
1205 | '((windows \"c:/applications/executables\" PATH ghostview mpage) | |
1206 | (ghostview \"c:/gs/gsview-dir\") | |
1207 | (mpage \"c:/mpage-dir\") | |
1208 | )" | |
1209 | :type '(repeat | |
1210 | (cons :tag "" | |
1211 | (symbol :tag "Identifier ") | |
1212 | (repeat :tag "Directory List" | |
1213 | (choice :menu-tag "Directory" | |
1214 | :tag "Directory" | |
1215 | (string :value "") | |
1216 | (symbol :value symbol))))) | |
1217 | :group 'printing) | |
1218 | ||
1219 | ||
1220 | (defcustom pr-txt-name 'default | |
1221 | "*Specify a printer for printing a text file. | |
1222 | ||
1223 | The printer name symbol should be defined on `pr-txt-printer-alist' (see it for | |
1224 | documentation). | |
1225 | ||
1226 | This variable should be modified by customization engine. If this variable is | |
1227 | modified by other means (for example, a lisp function), use `pr-update-menus' | |
1228 | function (see it for documentation) to update text printer menu." | |
1229 | :type 'symbol | |
1230 | :set 'pr-txt-name-custom-set | |
1231 | :group 'printing) | |
1232 | ||
1233 | ||
1234 | (defcustom pr-txt-printer-alist | |
1235 | (list (list 'default lpr-command nil | |
1236 | (cond ((boundp 'printer-name) printer-name) | |
1237 | (ps-windows-system "PRN") | |
1238 | (t nil) | |
1239 | ))) | |
1240 | ;; Examples: | |
1241 | ;; * On GNU or Unix system: | |
1242 | ;; '((prt_06a "lpr" nil "prt_06a") | |
1243 | ;; (prt_07c nil nil "prt_07c") | |
1244 | ;; ) | |
1245 | ;; * On Windows system: | |
1246 | ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a") | |
1247 | ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c") | |
1248 | ;; (PRN "" nil "PRN") | |
1249 | ;; (standard "redpr.exe" nil "") | |
1250 | ;; ) | |
1251 | "*Specify an alist of all text printers (text printer database). | |
1252 | ||
1253 | The alist element has the form: | |
1254 | ||
1255 | (SYMBOL COMMAND SWITCHES NAME) | |
1256 | ||
1257 | Where: | |
1258 | ||
1259 | SYMBOL It's a symbol to identify a text printer. It's for | |
1260 | `pr-txt-name' variable setting and for menu selection. | |
1261 | Examples: | |
1262 | 'prt_06a | |
1263 | 'my_printer | |
1264 | ||
449cba44 VJL |
1265 | COMMAND Name of the program for printing a text file. On MS-DOS and |
1266 | MS-Windows systems, if the value is an empty string, then Emacs | |
1267 | will write directly to the printer port given by NAME (see text | |
2c840b90 KS |
1268 | below), that is, the NAME should be something like \"PRN\" or |
1269 | \"LPT1:\". | |
1270 | If NAME is something like \"\\\\\\\\host\\\\share-name\" then | |
1271 | COMMAND shouldn't be an empty string. | |
1272 | The programs `print' and `nprint' (the standard print programs | |
1273 | on Windows NT and Novell Netware respectively) are handled | |
1274 | specially, using NAME as the destination for output; any other | |
1275 | program is treated like `lpr' except that an explicit filename | |
1276 | is given as the last argument. | |
1277 | If COMMAND is nil, it's used the default printing program: | |
1278 | `print' for Windows system, `lp' for lp system and `lpr' for | |
1279 | all other systems. See also `pr-path-alist'. | |
1280 | Examples: | |
1281 | \"print\" | |
1282 | \"lpr\" | |
1283 | \"lp\" | |
1284 | ||
1285 | SWITCHES List of sexp's to pass as extra options for text printer | |
1286 | program. It is recommended to set NAME (see text below) | |
1287 | instead of including an explicit switch on this list. | |
1288 | Example: | |
1289 | . for lpr | |
1290 | '(\"-#3\" \"-l\") | |
1291 | nil | |
1292 | ||
1293 | NAME A string that specifies a text printer name. | |
1294 | On Unix-like systems, a string value should be a name | |
1295 | understood by lpr's -P option (or lp's -d option). | |
1296 | On MS-DOS and MS-Windows systems, it is the name of a printer | |
1297 | device or port. Typical non-default settings would be \"LPT1:\" | |
1298 | to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or | |
1299 | \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\" | |
1300 | (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network | |
1301 | printer. You can also set it to a name of a file, in which | |
1302 | case the output gets appended to that file. If you want to | |
1303 | discard the printed output, set this to \"NUL\". | |
1304 | Examples: | |
1305 | . for print.exe | |
1306 | \"/D:\\\\\\\\host\\\\share-name\" | |
1307 | \"LPT1:\" | |
1308 | \"PRN\" | |
1309 | ||
1310 | . for lpr or lp | |
1311 | \"share-name\" | |
1312 | ||
1313 | This variable should be modified by customization engine. If this variable is | |
1314 | modified by other means (for example, a lisp function), use `pr-update-menus' | |
1315 | function (see it for documentation) to update text printer menu. | |
1316 | ||
1317 | Examples: | |
1318 | ||
1319 | * On GNU or Unix system: | |
1320 | ||
1321 | '((prt_06a \"lpr\" nil \"prt_06a\") | |
1322 | (prt_07c nil nil \"prt_07c\") | |
1323 | ) | |
1324 | ||
1325 | * On Windows system: | |
1326 | ||
1327 | '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\") | |
1328 | (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\") | |
1329 | (PRN \"\" nil \"PRN\") | |
1330 | (standard \"redpr.exe\" nil \"\") | |
1331 | )" | |
1332 | :type '(repeat | |
1333 | (list :tag "Text Printer" | |
1334 | (symbol :tag "Printer Symbol Name") | |
1335 | (string :tag "Printer Command") | |
1336 | (repeat :tag "Printer Switches" | |
1337 | (sexp :tag "Switch" :value "")) | |
1338 | (choice :menu-tag "Printer Name" | |
1339 | :tag "Printer Name" | |
1340 | (const :tag "None" nil) | |
1341 | string))) | |
1342 | :set 'pr-alist-custom-set | |
1343 | :group 'printing) | |
1344 | ||
1345 | ||
1346 | (defcustom pr-ps-name 'default | |
1347 | "*Specify a printer for printing a PostScript file. | |
1348 | ||
1349 | This printer name symbol should be defined on `pr-ps-printer-alist' (see it for | |
1350 | documentation). | |
1351 | ||
1352 | This variable should be modified by customization engine. If this variable is | |
1353 | modified by other means (for example, a lisp function), use `pr-update-menus' | |
1354 | function (see it for documentation) to update PostScript printer menu." | |
1355 | :type 'symbol | |
1356 | :set 'pr-ps-name-custom-set | |
1357 | :group 'printing) | |
1358 | ||
1359 | ||
1360 | (defcustom pr-ps-printer-alist | |
1361 | (list (list 'default lpr-command nil | |
1362 | (cond (ps-windows-system nil) | |
1363 | (ps-lp-system "-d") | |
1364 | (t "-P")) | |
1365 | (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name))) | |
1366 | ;; Examples: | |
1367 | ;; * On GNU or Unix system: | |
1368 | ;; '((lps_06b "lpr" nil "-P" "lps_06b") | |
1369 | ;; (lps_07c "lpr" nil nil "lps_07c") | |
1370 | ;; (lps_08c nil nil nil "lps_08c") | |
1371 | ;; ) | |
1372 | ;; * On Windows system: | |
1373 | ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a") | |
1374 | ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b") | |
1375 | ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c") | |
1376 | ;; (lps_08c nil nil nil "\\\\printers\\lps_08c") | |
1377 | ;; (LPT1 "" nil "" "LPT1:") | |
1378 | ;; (PRN "" nil "" "PRN") | |
1379 | ;; (standard "redpr.exe" nil "" "") | |
1380 | ;; ) | |
1381 | "*Specify an alist for all PostScript printers (PostScript printer database). | |
1382 | ||
1383 | The alist element has the form: | |
1384 | ||
1385 | (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...) | |
1386 | ||
1387 | Where: | |
1388 | ||
1389 | SYMBOL It's a symbol to identify a PostScript printer. It's for | |
1390 | `pr-ps-name' variable setting and for menu selection. | |
1391 | Examples: | |
1392 | 'prt_06a | |
1393 | 'my_printer | |
1394 | ||
449cba44 VJL |
1395 | COMMAND Name of the program for printing a PostScript file. On MS-DOS |
1396 | and MS-Windows systems, if the value is an empty string then | |
1397 | Emacs will write directly to the printer port given by NAME | |
1398 | (see text below), that is, the NAME should be something like | |
1399 | \"PRN\" or \"LPT1:\". | |
2c840b90 KS |
1400 | If NAME is something like \"\\\\\\\\host\\\\share-name\" then |
1401 | COMMAND shouldn't be an empty string. | |
1402 | The programs `print' and `nprint' (the standard print programs | |
1403 | on Windows NT and Novell Netware respectively) are handled | |
1404 | specially, using NAME as the destination for output; any other | |
1405 | program is treated like `lpr' except that an explicit filename | |
1406 | is given as the last argument. | |
1407 | If COMMAND is nil, it's used the default printing program: | |
1408 | `print' for Windows system, `lp' for lp system and `lpr' for | |
1409 | all other systems. See also `pr-path-alist'. | |
1410 | Examples: | |
1411 | \"print\" | |
1412 | \"lpr\" | |
1413 | \"lp\" | |
1414 | \"cp\" | |
1415 | ||
1416 | SWITCHES List of sexp's to pass as extra options for PostScript printer | |
1417 | program. It is recommended to set NAME (see text below) | |
1418 | instead of including an explicit switch on this list. | |
1419 | Example: | |
1420 | . for lpr | |
1421 | '(\"-#3\" \"-l\") | |
1422 | nil | |
1423 | ||
1424 | PRINTER-SWITCH A string that specifies PostScript printer name switch. If | |
1425 | it's necessary to have a space between PRINTER-SWITCH and NAME, | |
1426 | it should be inserted at the end of PRINTER-SWITCH string. | |
1427 | If PRINTER-SWITCH is nil, it's used the default printer name | |
1428 | switch: `/D:' for Windows system, `-d' for lp system and `-P' | |
1429 | for all other systems. | |
1430 | Examples: | |
1431 | . for lpr | |
1432 | \"-P \" | |
1433 | ||
1434 | . for lp | |
1435 | \"-d \" | |
1436 | ||
1437 | . for print.exe | |
1438 | \"/D:\" | |
1439 | ||
1440 | NAME A string that specifies a PostScript printer name. | |
1441 | On Unix-like systems, a string value should be a name | |
1442 | understood by lpr's -P option (or lp's -d option). | |
1443 | On MS-DOS and MS-Windows systems, it is the name of a printer | |
1444 | device or port. Typical non-default settings would be \"LPT1:\" | |
1445 | to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or | |
1446 | \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\" | |
1447 | (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network | |
1448 | printer. You can also set it to a name of a file, in which | |
1449 | case the output gets appended to that file. If you want to | |
1450 | discard the printed output, set this to \"NUL\". | |
1451 | Examples: | |
1452 | . for cp.exe | |
1453 | \"\\\\\\\\host\\\\share-name\" | |
1454 | ||
1455 | . for print.exe | |
1456 | \"/D:\\\\\\\\host\\\\share-name\" | |
1457 | \"\\\\\\\\host\\\\share-name\" | |
1458 | \"LPT1:\" | |
1459 | \"PRN\" | |
1460 | ||
1461 | . for lpr or lp | |
1462 | \"share-name\" | |
1463 | ||
1464 | DEFAULT It's a way to set default values when this entry is selected. | |
1465 | It's a cons like: | |
1466 | ||
1467 | (VARIABLE . VALUE) | |
1468 | ||
1469 | That associates VARIABLE with VALUE. when this entry is | |
1470 | selected, it's executed the following command: | |
1471 | ||
1472 | (set VARIABLE (eval VALUE)) | |
1473 | ||
1474 | Note that VALUE can be any valid lisp expression. So, don't | |
1475 | forget to quote symbols and constant lists. | |
1476 | If VARIABLE is the special keyword `inherits-from:', VALUE must | |
1477 | be a symbol name setting defined in `pr-setting-database' from | |
1478 | which the current setting inherits the context. Take care with | |
1479 | circular inheritance. | |
1480 | Examples: | |
1481 | '(ps-landscape-mode . nil) | |
1482 | '(ps-spool-duplex . t) | |
1483 | '(pr-gs-device . (my-gs-device t)) | |
1484 | ||
1485 | This variable should be modified by customization engine. If this variable is | |
1486 | modified by other means (for example, a lisp function), use `pr-update-menus' | |
1487 | function (see it for documentation) to update PostScript printer menu. | |
1488 | ||
1489 | Examples: | |
1490 | ||
1491 | * On GNU or Unix system: | |
1492 | ||
1493 | '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\") | |
1494 | (lps_07c \"lpr\" nil nil \"lps_07c\") | |
1495 | (lps_08c nil nil nil \"lps_08c\") | |
1496 | ) | |
1497 | ||
1498 | * On Windows system: | |
1499 | ||
1500 | '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\") | |
1501 | (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\") | |
1502 | (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\") | |
1503 | (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\") | |
1504 | (LPT1 \"\" nil \"\" \"LPT1:\") | |
1505 | (PRN \"\" nil \"\" \"PRN\") | |
1506 | (standard \"redpr.exe\" nil \"\" \"\") | |
1507 | )" | |
1508 | :type '(repeat | |
1509 | (list | |
1510 | :tag "PostScript Printer" | |
1511 | (symbol :tag "Printer Symbol Name") | |
1512 | (string :tag "Printer Command") | |
1513 | (repeat :tag "Printer Switches" | |
1514 | (sexp :tag "Switch" :value "")) | |
1515 | (choice :menu-tag "Printer Name Switch" | |
1516 | :tag "Printer Name Switch" | |
1517 | (const :tag "None" nil) | |
1518 | string) | |
1519 | (choice :menu-tag "Printer Name" | |
1520 | :tag "Printer Name" | |
1521 | (const :tag "None" nil) | |
1522 | string) | |
1523 | (repeat | |
1524 | :tag "Default Value List" | |
1525 | :inline t | |
1526 | (cons | |
1527 | :tag "" | |
1528 | (choice | |
1529 | :menu-tag "Variable" | |
1530 | :tag "Variable" | |
1531 | (const :tag "Landscape" ps-landscape-mode) | |
1532 | (const :tag "Print Header" ps-print-header) | |
1533 | (const :tag "Print Header Frame" ps-print-header-frame) | |
1534 | (const :tag "Line Number" ps-line-number) | |
1535 | (const :tag "Zebra Stripes" ps-zebra-stripes) | |
1536 | (const :tag "Duplex" ps-spool-duplex) | |
1537 | (const :tag "Tumble" ps-spool-tumble) | |
1538 | (const :tag "Upside-Down" ps-print-upside-down) | |
1539 | (const :tag "PS File Landscape" pr-file-landscape) | |
1540 | (const :tag "PS File Duplex" pr-file-duplex) | |
1541 | (const :tag "PS File Tumble" pr-file-tumble) | |
1542 | (const :tag "Auto Region" pr-auto-region) | |
1543 | (const :tag "Auto Mode" pr-auto-mode) | |
1544 | (const :tag "Ghostscript Device" pr-gs-device) | |
1545 | (const :tag "Ghostscript Resolution" pr-gs-resolution) | |
1546 | (const :tag "inherits-from:" inherits-from:) | |
1547 | (variable :tag "Other")) | |
1548 | (sexp :tag "Value"))) | |
1549 | )) | |
1550 | :set 'pr-alist-custom-set | |
1551 | :group 'printing) | |
1552 | ||
1553 | ||
1554 | (defcustom pr-temp-dir | |
0117451d | 1555 | (pr-dosify-file-name |
2c840b90 KS |
1556 | (if (boundp 'temporary-file-directory) |
1557 | (symbol-value 'temporary-file-directory) | |
1558 | ;; hacked from `temporary-file-directory' variable in files.el | |
1559 | (file-name-as-directory | |
1560 | (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") | |
1561 | (cond (ps-windows-system "c:/temp") | |
1562 | ((memq system-type '(vax-vms axp-vms)) "SYS$SCRATCH:") | |
1563 | (t "/tmp") | |
1564 | ))))) | |
1565 | "*Specify a directory for temporary files during printing." | |
1566 | :type '(directory :tag "Temporary Directory") | |
1567 | :group 'printing) | |
1568 | ||
1569 | ||
1570 | (defcustom pr-ps-temp-file "prspool.ps" | |
1571 | "*Specify PostScript temporary file name." | |
1572 | :type '(file :tag "PostScript Temporary File Name") | |
1573 | :group 'printing) | |
1574 | ||
1575 | ||
1576 | (defcustom pr-gv-command | |
1577 | (if ps-windows-system | |
1578 | "gsview32.exe" | |
1579 | "gv") | |
449cba44 | 1580 | "*Specify path and name of the gsview/gv utility. |
2c840b90 KS |
1581 | |
1582 | See also `pr-path-alist'." | |
449cba44 | 1583 | :type '(string :tag "Ghostview Utility") |
2c840b90 KS |
1584 | :group 'printing) |
1585 | ||
1586 | ||
1587 | (defcustom pr-gs-command | |
1588 | (if ps-windows-system | |
1589 | "gswin32.exe" | |
1590 | "gs") | |
449cba44 | 1591 | "*Specify path and name of the ghostscript utility. |
2c840b90 KS |
1592 | |
1593 | See also `pr-path-alist'." | |
449cba44 | 1594 | :type '(string :tag "Ghostscript Utility") |
2c840b90 KS |
1595 | :group 'printing) |
1596 | ||
1597 | ||
1598 | (defcustom pr-gs-switches | |
1599 | (if ps-windows-system | |
1600 | '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts") | |
1601 | '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10")) | |
1602 | "*Specify ghostscript switches. See the documentation on GS for more info. | |
1603 | ||
1604 | It's a list of strings, where each string is one or more ghostscript switches. | |
1605 | ||
1606 | A note on the gs switches: | |
1607 | ||
1608 | -q quiet | |
1609 | -dNOPAUSE don't wait for user intervention | |
1610 | -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs | |
1611 | -c quit it's added at the end to terminate gs | |
1612 | ||
1613 | To see ghostscript documentation for more information: | |
1614 | ||
1615 | * On GNU or Unix system: | |
1616 | - for full documentation, type: man gs | |
1617 | - for brief documentation, type: gs -h | |
1618 | ||
1619 | * On Windows system: | |
1620 | - for full documentation, see in a browser the file | |
1621 | c:/gstools/gs5.50/index.html, that is, the file index.html which is | |
1622 | located in the same directory as gswin32.exe. | |
1623 | - for brief documentation, type: gswin32.exe -h" | |
1624 | :type '(repeat (string :tag "Ghostscript Switch")) | |
1625 | :group 'printing) | |
1626 | ||
1627 | ||
1628 | (defcustom pr-gs-device | |
1629 | (if ps-windows-system | |
1630 | "mswinpr2" | |
1631 | "uniprint") | |
449cba44 | 1632 | "*Specify the ghostscript device switch value (-sDEVICE=). |
2c840b90 KS |
1633 | |
1634 | A note on the gs switches: | |
1635 | ||
1636 | -sDEVICE=djet500 the printer - works with HP DeskJet 540 | |
1637 | ||
1638 | See `pr-gs-switches' for documentation. | |
1639 | See also `pr-ps-printer-alist'." | |
1640 | :type '(string :tag "Ghostscript Device") | |
1641 | :group 'printing) | |
1642 | ||
1643 | ||
1644 | (defcustom pr-gs-resolution 300 | |
1645 | "*Specify ghostscript resolution switch value (-r). | |
1646 | ||
1647 | A note on the gs switches: | |
1648 | ||
1649 | -r300 resolution 300x300 | |
1650 | ||
1651 | See `pr-gs-switches' for documentation. | |
1652 | See also `pr-ps-printer-alist'." | |
1653 | :type '(integer :tag "Ghostscript Resolution") | |
1654 | :group 'printing) | |
1655 | ||
1656 | ||
1657 | (defcustom pr-print-using-ghostscript nil | |
1658 | "*Non-nil means print using ghostscript. | |
1659 | ||
1660 | This is useful if you don't have a PostScript printer, so you could use the | |
1661 | ghostscript to print a PostScript file. | |
1662 | ||
1663 | In GNU or Unix system, if ghostscript is set as a PostScript filter, this | |
1664 | variable should be nil." | |
1665 | :type 'boolean | |
1666 | :group 'printing) | |
1667 | ||
1668 | ||
1669 | (defcustom pr-faces-p nil | |
1670 | "*Non-nil means print with face attributes." | |
1671 | :type 'boolean | |
1672 | :group 'printing) | |
1673 | ||
1674 | ||
1675 | (defcustom pr-spool-p nil | |
1676 | "*Non-nil means spool printing in a buffer." | |
1677 | :type 'boolean | |
1678 | :group 'printing) | |
1679 | ||
1680 | ||
1681 | (defcustom pr-file-landscape nil | |
1682 | "*Non-nil means print PostScript file in landscape orientation." | |
1683 | :type 'boolean | |
1684 | :group 'printing) | |
1685 | ||
1686 | ||
1687 | (defcustom pr-file-duplex nil | |
1688 | "*Non-nil means print PostScript file in duplex mode." | |
1689 | :type 'boolean | |
1690 | :group 'printing) | |
1691 | ||
1692 | ||
1693 | (defcustom pr-file-tumble nil | |
1694 | "*Non-nil means print PostScript file in tumble mode. | |
1695 | ||
1696 | If tumble is off, produces a printing suitable for binding on the left or | |
1697 | right. | |
1698 | If tumble is on, produces a printing suitable for binding at the top or | |
1699 | bottom." | |
1700 | :type 'boolean | |
1701 | :group 'printing) | |
1702 | ||
1703 | ||
1704 | (defcustom pr-auto-region t | |
1705 | "*Non-nil means region is automagically detected. | |
1706 | ||
1707 | Note that this will only work if you're using transient mark mode. | |
1708 | ||
1709 | When this variable is non-nil, the `*-buffer*' commands will behave like | |
1710 | `*-region*' commands, that is, `*-buffer*' commands will print only the region | |
1711 | marked instead of all buffer." | |
1712 | :type 'boolean | |
1713 | :group 'printing) | |
1714 | ||
1715 | ||
1716 | (defcustom pr-auto-mode t | |
449cba44 | 1717 | "*Non-nil means major-mode specific printing is prefered over normal printing. |
2c840b90 KS |
1718 | |
1719 | That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*' | |
1720 | and `*-region*' commands will behave like `*-mode*' commands; otherwise, | |
1721 | `*-buffer*' commands will print the current buffer and `*-region*' commands | |
1722 | will print the current region." | |
1723 | :type 'boolean | |
1724 | :group 'printing) | |
1725 | ||
1726 | ||
1727 | (defcustom pr-mode-alist | |
1728 | '((mh-folder-mode ; mh summary buffer | |
1729 | pr-mh-lpr-1 pr-mh-print-1 | |
1730 | 2 | |
1731 | (ps-article-author ps-article-subject) | |
1732 | ("/pagenumberstring load" pr-article-date) | |
1733 | nil | |
1734 | ) | |
1735 | (mh-letter-mode ; mh letter buffer | |
1736 | pr-mh-lpr-2 pr-mh-print-2 | |
1737 | 2 | |
1738 | (ps-article-author ps-article-subject) | |
1739 | ("/pagenumberstring load" pr-article-date) | |
1740 | nil | |
1741 | ) | |
1742 | (rmail-summary-mode ; rmail summary buffer | |
1743 | pr-rmail-lpr pr-rmail-print | |
1744 | 3 | |
1745 | (ps-article-subject ps-article-author buffer-name) | |
1746 | nil | |
1747 | nil | |
1748 | ) | |
1749 | (rmail-mode ; rmail buffer | |
1750 | pr-rmail-lpr pr-rmail-print | |
1751 | 3 | |
1752 | (ps-article-subject ps-article-author buffer-name) | |
1753 | nil | |
1754 | nil | |
1755 | ) | |
1756 | (gnus-summary-mode ; gnus summary buffer | |
1757 | pr-gnus-lpr pr-gnus-print | |
1758 | 3 | |
1759 | (ps-article-subject ps-article-author gnus-newsgroup-name) | |
1760 | nil | |
1761 | nil | |
1762 | ) | |
1763 | (gnus-article-mode ; gnus article buffer | |
1764 | pr-gnus-lpr pr-gnus-print | |
1765 | 3 | |
1766 | (ps-article-subject ps-article-author gnus-newsgroup-name) | |
1767 | nil | |
1768 | nil | |
1769 | ) | |
1770 | (Info-mode ; Info buffer | |
1771 | pr-mode-lpr pr-mode-print | |
1772 | 2 | |
1773 | (ps-info-node ps-info-file) | |
1774 | nil | |
1775 | nil | |
1776 | ) | |
1777 | (vm-mode ; vm mode | |
1778 | pr-vm-lpr pr-vm-print | |
1779 | 3 | |
1780 | (ps-article-subject ps-article-author buffer-name) | |
1781 | nil | |
1782 | nil | |
1783 | ) | |
1784 | ) | |
1785 | "*Specify an alist for a major-mode and printing functions. | |
1786 | ||
1787 | To customize a major mode printing, just declare the customization in | |
1788 | `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major | |
1789 | mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the | |
1790 | *Summary* buffer, if you forget to switch to the *Article* buffer before | |
1791 | printing, you'll get a nicely formatted list of article subjects shows up at | |
1792 | the printer. With major mode printing you don't need to switch from gnus | |
1793 | *Summary* buffer first. | |
1794 | ||
1795 | The elements have the following form: | |
1796 | ||
1797 | (MAJOR-MODE | |
1798 | LPR-PRINT PS-PRINT | |
1799 | HEADER-LINES | |
1800 | LEFT-HEADER | |
1801 | RIGHT-HEADER | |
1802 | KILL-LOCAL-VARIABLE | |
1803 | DEFAULT...) | |
1804 | ||
1805 | Where: | |
1806 | ||
1807 | MAJOR-MODE It's the major mode symbol. | |
1808 | ||
1809 | LPR-PRINT It's a symbol function for text printing. It's invoked with | |
1810 | one argument: | |
1811 | (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...). | |
1812 | ||
1813 | Usually LPR-PRINT function prepares the environment or buffer | |
1814 | and then call the function `pr-mode-lpr' which it's used to | |
1815 | process the buffer and send it to text printer. | |
1816 | ||
1817 | The `pr-mode-lpr' definition is: | |
1818 | ||
1819 | (pr-mode-lpr HEADER-LIST &optional FROM TO) | |
1820 | ||
1821 | Where HEADER-LIST is like the argument passed to LPR-PRINT. | |
1822 | FROM and TO are the beginning and end markers, respectively, | |
1823 | for a region. If FROM is nil, it's used (point-min); if TO is | |
1824 | nil, it's used (point-max). | |
1825 | ||
1826 | PS-PRINT It's a symbol function for PostScript printing. It's invoked | |
1827 | with 3 arguments: n-up printing, file name and the list: | |
1828 | (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...). | |
1829 | ||
1830 | Usually PS-PRINT function prepares the environment or buffer | |
1831 | and then call the function `pr-mode-print' which it's used to | |
1832 | process the buffer and send it to PostScript printer. | |
1833 | ||
1834 | The `pr-mode-print' definition is: | |
1835 | ||
1836 | (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO) | |
1837 | ||
1838 | Where N-UP, FILENAME and HEADER-LIST are like the arguments | |
1839 | passed to PS-PRINT. FROM and TO are the beginning and end | |
1840 | markers, respectively, for a region. If TO is nil, it's used | |
1841 | (point-max). | |
1842 | ||
1843 | HEADER-LINES It's the number of header lines; if is nil, it uses | |
1844 | `ps-header-lines' value. | |
1845 | ||
1846 | LEFT-HEADER It's the left header part, it's a list of string, variable | |
1847 | symbol or function symbol (with no argument); if is nil, it | |
1848 | uses `ps-left-header' value. | |
1849 | ||
1850 | RIGHT-HEADER It's the right header part, it's a list of string, variable | |
1851 | symbol or function symbol (with no argument); if is nil, it | |
1852 | uses `ps-right-header' value. | |
1853 | ||
1854 | KILL-LOCAL-VARIABLE | |
1855 | Non-nil means to kill all buffer local variable declared in | |
1856 | DEFAULT (see below). | |
1857 | ||
1858 | DEFAULT It's a way to set default values when this entry is selected. | |
1859 | It's a cons like: | |
1860 | ||
1861 | (VARIABLE-SYM . VALUE) | |
1862 | ||
1863 | That associates VARIABLE-SYM with VALUE. when this entry is | |
1864 | selected, it's executed the following command: | |
1865 | ||
1866 | (set (make-local-variable VARIABLE-SYM) (eval VALUE)) | |
1867 | ||
1868 | Note that VALUE can be any valid lisp expression. So, don't | |
1869 | forget to quote symbols and constant lists. | |
1870 | If VARIABLE is the special keyword `inherits-from:', VALUE must | |
1871 | be a symbol name setting defined in `pr-setting-database' from | |
1872 | which the current setting inherits the context. Take care with | |
1873 | circular inheritance. | |
1874 | Examples: | |
1875 | '(ps-landscape-mode . nil) | |
1876 | '(ps-spool-duplex . t) | |
1877 | '(pr-gs-device . (my-gs-device t))" | |
1878 | :type '(repeat | |
1879 | (list | |
1880 | :tag "" | |
1881 | (symbol :tag "Major Mode") | |
1882 | (function :tag "Text Printing Function") | |
1883 | (function :tag "PS Printing Function") | |
1884 | (choice :menu-tag "Number of Header Lines" | |
1885 | :tag "Number of Header Lines" | |
1886 | (integer :tag "Number") | |
1887 | (const :tag "Default Number" nil)) | |
1888 | (repeat :tag "Left Header List" | |
1889 | (choice :menu-tag "Left Header" | |
1890 | :tag "Left Header" | |
1891 | string symbol)) | |
1892 | (repeat :tag "Right Header List" | |
1893 | (choice :menu-tag "Right Header" | |
1894 | :tag "Right Header" | |
1895 | string symbol)) | |
1896 | (boolean :tag "Kill Local Variable At End") | |
1897 | (repeat | |
1898 | :tag "Default Value List" | |
1899 | :inline t | |
1900 | (cons | |
1901 | :tag "" | |
1902 | (choice | |
1903 | :menu-tag "Variable" | |
1904 | :tag "Variable" | |
1905 | (const :tag "Landscape" ps-landscape-mode) | |
1906 | (const :tag "Print Header" ps-print-header) | |
1907 | (const :tag "Print Header Frame" ps-print-header-frame) | |
1908 | (const :tag "Line Number" ps-line-number) | |
1909 | (const :tag "Zebra Stripes" ps-zebra-stripes) | |
1910 | (const :tag "Duplex" ps-spool-duplex) | |
1911 | (const :tag "Tumble" ps-spool-tumble) | |
1912 | (const :tag "Upside-Down" ps-print-upside-down) | |
1913 | (const :tag "PS File Landscape" pr-file-landscape) | |
1914 | (const :tag "PS File Duplex" pr-file-duplex) | |
1915 | (const :tag "PS File Tumble" pr-file-tumble) | |
1916 | (const :tag "Auto Region" pr-auto-region) | |
1917 | (const :tag "Auto Mode" pr-auto-mode) | |
1918 | (const :tag "Ghostscript Device" pr-gs-device) | |
1919 | (const :tag "Ghostscript Resolution" pr-gs-resolution) | |
1920 | (const :tag "inherits-from:" inherits-from:) | |
1921 | (variable :tag "Other")) | |
1922 | (sexp :tag "Value"))) | |
1923 | )) | |
1924 | :group 'printing) | |
1925 | ||
1926 | ||
1927 | (defcustom pr-ps-utility 'mpage | |
1928 | "*Specify PostScript utility symbol. | |
1929 | ||
1930 | This utility symbol should be defined on `pr-ps-utility-alist' (see it for | |
1931 | documentation). | |
1932 | ||
1933 | This variable should be modified by customization engine. If this variable is | |
1934 | modified by other means (for example, a lisp function), use `pr-update-menus' | |
1935 | function (see it for documentation) to update PostScript utility menu. | |
1936 | ||
1937 | NOTE: Don't forget to download and install the utilities declared on | |
1938 | `pr-ps-utility-alist'." | |
1939 | :type '(symbol :tag "PS File Utility") | |
1940 | :set 'pr-ps-utility-custom-set | |
1941 | :group 'printing) | |
1942 | ||
1943 | ||
1944 | (defcustom pr-ps-utility-alist | |
1945 | '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil) | |
1946 | (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil | |
1947 | (inherits-from: . no-duplex)) | |
1948 | ) | |
1949 | ;; Examples: | |
1950 | ;; * On GNU or Unix system: | |
1951 | ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil) | |
1952 | ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil | |
1953 | ;; (pr-file-duplex . nil) (pr-file-tumble . nil)) | |
1954 | ;; ) | |
1955 | ;; * On Windows system: | |
1956 | ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil | |
1957 | ;; (pr-file-duplex . nil) (pr-file-tumble . nil)) | |
1958 | ;; ) | |
1959 | "*Specify an alist for PostScript utility processing (PS utility database). | |
1960 | ||
1961 | The alist element has the form: | |
1962 | ||
1963 | (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT | |
1964 | SWITCHES DEFAULT...) | |
1965 | ||
1966 | Where: | |
1967 | ||
1968 | SYMBOL It's a symbol to identify a PostScript utility. It's for | |
1969 | `pr-ps-utility' variable setting and for menu selection. | |
1970 | Examples: | |
1971 | 'mpage | |
1972 | 'psnup | |
1973 | ||
1974 | UTILITY Name of utility for processing a PostScript file. | |
1975 | See also `pr-path-alist'. | |
1976 | Examples: | |
1977 | . for GNU or Unix system: | |
1978 | \"mpage\" | |
1979 | \"psnup -q\" | |
1980 | ||
1981 | . for Windows system: | |
1982 | \"c:/psutils/psnup -q\" | |
1983 | ||
449cba44 | 1984 | MUST-SWITCHES List of sexp's to pass as options to the PostScript utility |
2c840b90 | 1985 | program. These options are necessary to process the utility |
449cba44 | 1986 | program and must be placed before any other switches. |
2c840b90 KS |
1987 | Example: |
1988 | . for psnup: | |
1989 | '(\"-q\") | |
1990 | ||
1991 | PAPERSIZE It's a format string to specify paper size switch. | |
1992 | Example: | |
1993 | . for mpage | |
1994 | \"-b%s\" | |
1995 | ||
1996 | N-UP It's a format string to specify n-up switch. | |
1997 | Example: | |
1998 | . for psnup | |
1999 | \"-%d\" | |
2000 | ||
2001 | LANDSCAPE It's a string to specify landscape switch. If the utility | |
2002 | doesn't have landscape switch, set to nil. | |
2003 | Example: | |
2004 | . for psnup | |
2005 | \"-l\" | |
2006 | ||
2007 | DUPLEX It's a string to specify duplex switch. If the utility doesn't | |
2008 | have duplex switch, set to nil. | |
2009 | Example: | |
2010 | . for psnup | |
2011 | nil | |
2012 | ||
2013 | TUMBLE It's a string to specify tumble switch. If the utility doesn't | |
2014 | have tumble switch, set to nil. | |
2015 | Example: | |
2016 | . for psnup | |
2017 | nil | |
2018 | ||
2019 | OUTPUT It's a string to specify how to generate an output file. Some | |
2020 | utilities accept an output file option, but some others need | |
2021 | output redirection or some other way to specify an output file. | |
2022 | Example: | |
2023 | . for psnup | |
2024 | \" \" ; psnup ... input output | |
2025 | ||
2026 | . for mpage | |
2027 | \">\" ; mpage ... input > output | |
2028 | ||
449cba44 | 2029 | SWITCHES List of sexp's to pass as extra options to the PostScript utility |
2c840b90 KS |
2030 | program. |
2031 | Example: | |
2032 | . for psnup | |
2033 | '(\"-q\") | |
2034 | nil | |
2035 | ||
2036 | DEFAULT It's a way to set default values when this entry is selected. | |
2037 | It's a cons like: | |
2038 | ||
2039 | (VARIABLE . VALUE) | |
2040 | ||
2041 | That associates VARIABLE with VALUE. when this entry is | |
2042 | selected, it's executed the following command: | |
2043 | ||
2044 | (set VARIABLE (eval VALUE)) | |
2045 | ||
2046 | Note that VALUE can be any valid lisp expression. So, don't | |
2047 | forget to quote symbols and constant lists. | |
2048 | If VARIABLE is the special keyword `inherits-from:', VALUE must | |
2049 | be a symbol name setting defined in `pr-setting-database' from | |
2050 | which the current setting inherits the context. Take care with | |
2051 | circular inheritance. | |
2052 | Examples: | |
2053 | '(pr-file-landscape . nil) | |
2054 | '(pr-file-duplex . t) | |
2055 | '(pr-gs-device . (my-gs-device t)) | |
2056 | ||
2057 | This variable should be modified by customization engine. If this variable is | |
2058 | modified by other means (for example, a lisp function), use `pr-update-menus' | |
2059 | function (see it for documentation) to update PostScript utility menu. | |
2060 | ||
2061 | NOTE: Don't forget to download and install the utilities declared on | |
2062 | `pr-ps-utility-alist'. | |
2063 | ||
2064 | Examples: | |
2065 | ||
2066 | * On GNU or Unix system: | |
2067 | ||
2068 | '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil) | |
2069 | (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil | |
2070 | (pr-file-duplex . nil) (pr-file-tumble . nil)) | |
2071 | ) | |
2072 | ||
2073 | * On Windows system: | |
2074 | ||
2075 | '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" | |
2076 | nil (pr-file-duplex . nil) (pr-file-tumble . nil)) | |
2077 | )" | |
2078 | :type '(repeat | |
2079 | (list :tag "PS File Utility" | |
2080 | (symbol :tag "Utility Symbol") | |
2081 | (string :tag "Utility Name") | |
2082 | (repeat :tag "Must Utility Switches" | |
2083 | (sexp :tag "Switch" :value "")) | |
2084 | (choice :menu-tag "Paper Size" | |
2085 | :tag "Paper Size" | |
2086 | (const :tag "No Paper Size" nil) | |
2087 | (string :tag "Paper Size Format")) | |
2088 | (choice :menu-tag "N-Up" | |
2089 | :tag "N-Up" | |
2090 | (const :tag "No N-Up" nil) | |
2091 | (string :tag "N-Up Format")) | |
2092 | (choice :menu-tag "Landscape" | |
2093 | :tag "Landscape" | |
2094 | (const :tag "No Landscape" nil) | |
2095 | (string :tag "Landscape Switch")) | |
2096 | (choice :menu-tag "Duplex" | |
2097 | :tag "Duplex" | |
2098 | (const :tag "No Duplex" nil) | |
2099 | (string :tag "Duplex Switch")) | |
2100 | (choice :menu-tag "Tumble" | |
2101 | :tag "Tumble" | |
2102 | (const :tag "No Tumble" nil) | |
2103 | (string :tag "Tumble Switch")) | |
2104 | (string :tag "Output Separator") | |
2105 | (repeat :tag "Utility Switches" | |
2106 | (sexp :tag "Switch" :value "")) | |
2107 | (repeat | |
2108 | :tag "Default Value List" | |
2109 | :inline t | |
2110 | (cons | |
2111 | :tag "" | |
2112 | (choice | |
2113 | :menu-tag "Variable" | |
2114 | :tag "Variable" | |
2115 | (const :tag "PS File Landscape" pr-file-landscape) | |
2116 | (const :tag "PS File Duplex" pr-file-duplex) | |
2117 | (const :tag "PS File Tumble" pr-file-tumble) | |
2118 | (const :tag "Ghostscript Device" pr-gs-device) | |
2119 | (const :tag "Ghostscript Resolution" pr-gs-resolution) | |
2120 | (const :tag "inherits-from:" inherits-from:) | |
2121 | (variable :tag "Other")) | |
2122 | (sexp :tag "Value"))) | |
2123 | )) | |
2124 | :set 'pr-alist-custom-set | |
2125 | :group 'printing) | |
2126 | ||
2127 | ||
2128 | (defcustom pr-menu-lock t | |
2129 | "*Non-nil means menu is locked while selecting toggle options. | |
2130 | ||
2131 | See also `pr-menu-char-height' and `pr-menu-char-width'." | |
2132 | :type 'boolean | |
2133 | :group 'printing) | |
2134 | ||
2135 | ||
2136 | (defcustom pr-menu-char-height | |
2137 | (cond ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
2138 | (pr-e-frame-char-height)) | |
2139 | ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
2140 | (pr-x-font-height (face-font 'default)))) | |
2141 | "*Specify menu char height in pixels. | |
2142 | ||
2143 | This variable is used to guess which vertical position should be locked the | |
2144 | menu, so don't forget to adjust it if menu position is not ok. | |
2145 | ||
2146 | See also `pr-menu-lock' and `pr-menu-char-width'." | |
2147 | :type 'integer | |
2148 | :group 'printing) | |
2149 | ||
2150 | ||
2151 | (defcustom pr-menu-char-width | |
2152 | (cond ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
2153 | (pr-e-frame-char-width)) | |
2154 | ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
2155 | (pr-x-font-width (face-font 'default)))) | |
2156 | "*Specify menu char width in pixels. | |
2157 | ||
2158 | This variable is used to guess which horizontal position should be locked the | |
2159 | menu, so don't forget to adjust it if menu position is not ok. | |
2160 | ||
2161 | See also `pr-menu-lock' and `pr-menu-char-height'." | |
2162 | :type 'integer | |
2163 | :group 'printing) | |
2164 | ||
2165 | ||
2166 | (defcustom pr-setting-database | |
2167 | '((no-duplex ; setting symbol name | |
2168 | nil nil nil ; inherits local kill-local | |
2169 | (pr-file-duplex . nil) ; settings | |
2170 | (pr-file-tumble . nil)) | |
2171 | ) | |
2172 | "*Specify an alist for settings in general. | |
2173 | ||
2174 | The elements have the following form: | |
2175 | ||
2176 | (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...) | |
2177 | ||
2178 | Where: | |
2179 | ||
2180 | SYMBOL It's a symbol to identify the setting group. | |
2181 | ||
2182 | INHERITS Specify the inheritance for SYMBOL group. It's a symbol name | |
2183 | setting from which the current setting inherits the context. | |
2184 | If INHERITS is nil, means that there is no inheritance. | |
2185 | This is a simple inheritance mechanism. | |
2186 | ||
2187 | Let's see an example to illustrate the inheritance mechanism: | |
2188 | ||
2189 | (setq pr-setting-database | |
2190 | '((no-duplex ; setting symbol name | |
2191 | nil ; inherits | |
2192 | nil nil ; local kill-local | |
2193 | (pr-file-duplex . nil) ; settings | |
2194 | (pr-file-tumble . nil) | |
2195 | ) | |
2196 | (no-duplex-and-landscape ; setting symbol name | |
2197 | no-duplex ; inherits | |
2198 | nil nil ; local kill-local | |
2199 | (pr-file-landscape . nil) ; settings | |
2200 | ))) | |
2201 | ||
2202 | The example above has two setting groups: no-duplex and | |
2203 | no-duplex-and-landscape. When setting no-duplex is activated | |
2204 | through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist' | |
2205 | and `pr-ps-printer-alist'), the variables pr-file-duplex and | |
2206 | pr-file-tumble are both set to nil. | |
2207 | ||
2208 | Now when setting no-duplex-and-landscape is activated through | |
2209 | `inherits-from:', the variable pr-file-landscape is set to nil | |
2210 | and also the settings for no-duplex are done, because | |
2211 | no-duplex-and-landscape inherits settings from no-duplex. | |
2212 | ||
2213 | Take care with circular inheritance. It's an error if circular | |
2214 | inheritance happens. | |
2215 | ||
2216 | LOCAL Non-nil means that all settings for SYMBOL group will be | |
2217 | declared local buffer. | |
2218 | ||
2219 | KILL-LOCAL Non-nil means that all settings for SYMBOL group will be | |
2220 | killed at end. It has effect only when LOCAL is non-nil. | |
2221 | ||
2222 | SETTING It's a cons like: | |
2223 | ||
2224 | (VARIABLE . VALUE) | |
2225 | ||
2226 | That associates VARIABLE with VALUE. when this entry is | |
2227 | selected, it's executed the following command: | |
2228 | ||
2229 | * If LOCAL is non-nil: | |
2230 | (set (make-local-variable VARIABLE) (eval VALUE)) | |
2231 | ||
2232 | * If LOCAL is nil: | |
2233 | (set VARIABLE (eval VALUE)) | |
2234 | ||
2235 | Note that VALUE can be any valid lisp expression. So, don't | |
2236 | forget to quote symbols and constant lists. | |
2237 | This setting is ignored if VARIABLE is equal to keyword | |
2238 | `inherits-from:'. | |
2239 | Examples: | |
2240 | '(ps-landscape-mode . nil) | |
2241 | '(ps-spool-duplex . t) | |
2242 | '(pr-gs-device . (my-gs-device t))" | |
2243 | :type '(repeat | |
2244 | (list | |
2245 | :tag "" | |
2246 | (symbol :tag "Setting Name") | |
2247 | (choice :menu-tag "Inheritance" | |
2248 | :tag "Inheritance" | |
2249 | (const :tag "No Inheritance" nil) | |
2250 | (symbol :tag "Inherits From")) | |
2251 | (boolean :tag "Local Buffer Setting") | |
2252 | (boolean :tag "Kill Local Variable At End") | |
2253 | (repeat | |
2254 | :tag "Setting List" | |
2255 | :inline t | |
2256 | (cons | |
2257 | :tag "" | |
2258 | (choice | |
2259 | :menu-tag "Variable" | |
2260 | :tag "Variable" | |
2261 | (const :tag "Landscape" ps-landscape-mode) | |
2262 | (const :tag "Print Header" ps-print-header) | |
2263 | (const :tag "Print Header Frame" ps-print-header-frame) | |
2264 | (const :tag "Line Number" ps-line-number) | |
2265 | (const :tag "Zebra Stripes" ps-zebra-stripes) | |
2266 | (const :tag "Duplex" ps-spool-duplex) | |
2267 | (const :tag "Tumble" ps-spool-tumble) | |
2268 | (const :tag "Upside-Down" ps-print-upside-down) | |
2269 | (const :tag "PS File Landscape" pr-file-landscape) | |
2270 | (const :tag "PS File Duplex" pr-file-duplex) | |
2271 | (const :tag "PS File Tumble" pr-file-tumble) | |
2272 | (const :tag "Auto Region" pr-auto-region) | |
2273 | (const :tag "Auto Mode" pr-auto-mode) | |
2274 | (const :tag "Ghostscript Device" pr-gs-device) | |
2275 | (const :tag "Ghostscript Resolution" pr-gs-resolution) | |
2276 | (variable :tag "Other")) | |
2277 | (sexp :tag "Value"))) | |
2278 | )) | |
2279 | :group 'printing) | |
2280 | ||
2281 | ||
2282 | (defcustom pr-visible-entry-list | |
2283 | '(postscript text postscript-options postscript-process printing help) | |
2284 | "*Specify a list of Printing menu visible entries. | |
2285 | ||
2286 | Valid values with the corresponding menu parts are: | |
2287 | ||
2288 | +------------------------------+ | |
2289 | | Printing Interface | | |
2290 | +------------------------------+ | |
2291 | `postscript' | PostScript Preview >| | |
2292 | | PostScript Print >| | |
2293 | | PostScript Printer: name >| | |
2294 | +------------------------------+ | |
2295 | `text' | Printify >| | |
2296 | | Print >| | |
2297 | | Text Printer: name >| | |
2298 | +------------------------------+ | |
2299 | `postscript-options' |[ ] Landscape | | |
2300 | |[ ] Print Header | | |
2301 | |[ ] Print Header Frame | | |
2302 | |[ ] Line Number | | |
2303 | |[ ] Zebra Stripes | | |
2304 | |[ ] Duplex | | |
2305 | |[ ] Tumble | | |
2306 | |[ ] Upside-Down | | |
2307 | | Print All Pages >| | |
2308 | +------------------------------+ | |
2309 | `postscript-process' |[ ] Spool Buffer | | |
449cba44 VJL |
2310 | |[ ] Print with faces | |
2311 | |[ ] Print via Ghostscript | | |
2c840b90 KS |
2312 | +------------------------------+ |
2313 | `printing' |[ ] Auto Region | | |
2314 | |[ ] Auto Mode | | |
2315 | |[ ] Menu Lock | | |
2316 | +------------------------------+ | |
2317 | `help' | Customize >| | |
2318 | | Show Settings >| | |
2319 | | Help | | |
2320 | +------------------------------+ | |
2321 | ||
2322 | Any other value is ignored." | |
2323 | :type '(repeat :tag "Menu Visible Part" | |
2324 | (choice :menu-tag "Menu Part" | |
2325 | :tag "Menu Part" | |
2326 | (const postscript) | |
2327 | (const text) | |
2328 | (const postscript-options) | |
2329 | (const postscript-process) | |
2330 | (const printing) | |
2331 | (const help))) | |
2332 | :group 'printing) | |
2333 | ||
2334 | ||
2335 | (defcustom pr-delete-temp-file t | |
2336 | "*Non-nil means delete temporary files. | |
2337 | ||
2338 | Set `pr-delete-temp-file' to nil, if the following message (or a similar) | |
2339 | happens when printing: | |
2340 | ||
2341 | Error: could not open \"c:\\temp\\prspool.ps\" for reading." | |
2342 | :type 'boolean | |
2343 | :group 'printing) | |
2344 | ||
2345 | ||
2346 | (defcustom pr-list-directory nil | |
2347 | "*Non-nil means list directory when processing a directory. | |
2348 | ||
2349 | That is, any subdirectories (and the superdirectory) of the directory (given as | |
2350 | argument of functions below) are also printed (as dired-mode listings). | |
2351 | ||
2352 | It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript', | |
2353 | `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory' | |
2354 | and `pr-txt-directory'." | |
2355 | :type 'boolean | |
2356 | :group 'printing) | |
2357 | ||
2358 | ||
2359 | (defcustom pr-buffer-name "*Printing Interface*" | |
2360 | "*Specify the name of the buffer interface for printing package. | |
2361 | ||
2362 | It's used by `pr-interface'." | |
2363 | :type 'string | |
2364 | :group 'printing) | |
2365 | ||
2366 | ||
2367 | (defcustom pr-buffer-name-ignore | |
2368 | (list (regexp-quote pr-buffer-name) ; ignore printing interface buffer | |
2369 | "^ .*$") ; ignore invisible buffers | |
2370 | "*Specify a regexp list for buffer names to be ignored in interface buffer. | |
2371 | ||
2372 | NOTE: Case is important for matching, that is, `case-fold-search' is always | |
2373 | nil. | |
2374 | ||
2375 | It's used by `pr-interface'." | |
2376 | :type '(repeat (regexp :tag "Buffer Name Regexp")) | |
2377 | :group 'printing) | |
2378 | ||
2379 | ||
2380 | (defcustom pr-buffer-verbose t | |
2381 | "*Non-nil means to be verbose when editing a field in interface buffer. | |
2382 | ||
2383 | It's used by `pr-interface'." | |
2384 | :type 'boolean | |
2385 | :group 'printing) | |
2386 | ||
2387 | ||
2c840b90 KS |
2388 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2389 | ;; Internal Variables | |
2390 | ||
2391 | ||
2392 | (defvar pr-txt-command nil | |
2393 | "Name of program for printing a text file. | |
2394 | See `pr-txt-printer-alist'.") | |
2395 | ||
2396 | ||
2397 | (defvar pr-txt-switches nil | |
449cba44 | 2398 | "List of sexp's to pass as extra options to the text printer program. |
2c840b90 KS |
2399 | See `pr-txt-printer-alist'.") |
2400 | ||
2401 | ||
2402 | (defvar pr-txt-printer nil | |
2403 | "Specify text printer name. | |
2404 | See `pr-txt-printer-alist'.") | |
2405 | ||
2406 | ||
2407 | (defvar pr-ps-command nil | |
2408 | "Name of program for printing a PostScript file. | |
2409 | See `pr-ps-printer-alist'.") | |
2410 | ||
2411 | ||
2412 | (defvar pr-ps-switches nil | |
449cba44 | 2413 | "List of sexp's to pass as extra options to the PostScript printer program. |
2c840b90 KS |
2414 | See `pr-ps-printer-alist'.") |
2415 | ||
2416 | ||
2417 | (defvar pr-ps-printer-switch nil | |
2418 | "Specify PostScript printer name switch. | |
2419 | See `pr-ps-printer-alist'.") | |
2420 | ||
2421 | ||
2422 | (defvar pr-ps-printer nil | |
2423 | "Specify PostScript printer name. | |
2424 | See `pr-ps-printer-alist'.") | |
2425 | ||
2426 | ||
2427 | (defvar pr-menu-bar nil | |
2428 | "Specify Printing menu-bar entry.") | |
2429 | ||
2430 | ||
2431 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2432 | ;; Keys & Menus | |
2433 | ||
2434 | ||
2435 | (defmacro pr-xemacs-global-menubar (&rest body) | |
2436 | `(save-excursion | |
2437 | (let ((temp (get-buffer-create (make-temp-name " *Temp")))) | |
2438 | ;; be sure to access global menubar | |
2439 | (set-buffer temp) | |
2440 | ,@body | |
2441 | (kill-buffer temp)))) | |
2442 | ||
2c840b90 KS |
2443 | |
2444 | (defsubst pr-visible-p (key) | |
2445 | (memq key pr-visible-entry-list)) | |
2446 | ||
2447 | ||
2448 | (defsubst pr-mode-alist-p () | |
2449 | (cdr (assq major-mode pr-mode-alist))) | |
2450 | ||
2451 | ||
2452 | (defsubst pr-auto-mode-p () | |
2453 | (and pr-auto-mode (pr-mode-alist-p))) | |
2454 | ||
2455 | ||
2456 | (defsubst pr-using-ghostscript-p () | |
2457 | (and pr-print-using-ghostscript (not pr-spool-p))) | |
2458 | ||
2459 | ||
2460 | (eval-and-compile | |
526335b4 VJL |
2461 | (defun pr-get-symbol (name) |
2462 | ;; Recent versions of easy-menu downcase names before interning them. | |
2463 | (and (fboundp 'easy-menu-name-match) | |
2464 | (setq name (downcase name))) | |
2465 | (or (intern-soft name) | |
2466 | (make-symbol name))) | |
2467 | ||
2c840b90 KS |
2468 | (cond |
2469 | ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
2470 | (defsubst pr-region-active-p () | |
2471 | (and pr-auto-region transient-mark-mode mark-active))) | |
2472 | ||
2473 | ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
45f17557 | 2474 | (defvar zmacs-region-stays nil) ; to avoid compilation gripes |
2c840b90 KS |
2475 | (defsubst pr-region-active-p () |
2476 | (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))))) | |
2477 | ||
2478 | ||
2479 | (defconst pr-menu-spec | |
2480 | (cond | |
2481 | ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
2482 | '( | |
2483 | ["Printing Interface" pr-interface | |
2484 | :help "Use buffer interface instead of menu interface"] | |
2485 | "--" | |
2486 | ("PostScript Preview" :visible (pr-visible-p 'postscript) | |
2487 | :help "Preview PostScript instead of sending to printer" | |
2488 | ("Directory" :active (not pr-spool-p) | |
2489 | ["1-up" (pr-ps-directory-preview 1 nil nil t) t] | |
2490 | ["2-up" (pr-ps-directory-preview 2 nil nil t) t] | |
2491 | ["4-up" (pr-ps-directory-preview 4 nil nil t) t] | |
2492 | ["Other..." (pr-ps-directory-preview nil nil nil t) | |
2493 | :keys "\\[pr-ps-buffer-preview]"]) | |
2494 | ("Buffer" :active (not pr-spool-p) | |
2495 | ["1-up" (pr-ps-buffer-preview 1 t) t] | |
2496 | ["2-up" (pr-ps-buffer-preview 2 t) t] | |
2497 | ["4-up" (pr-ps-buffer-preview 4 t) t] | |
2498 | ["Other..." (pr-ps-buffer-preview nil t) | |
2499 | :keys "\\[pr-ps-buffer-preview]"]) | |
2500 | ("Region" :active (and (not pr-spool-p) (ps-mark-active-p)) | |
2501 | ["1-up" (pr-ps-region-preview 1 t) t] | |
2502 | ["2-up" (pr-ps-region-preview 2 t) t] | |
2503 | ["4-up" (pr-ps-region-preview 4 t) t] | |
2504 | ["Other..." (pr-ps-region-preview nil t) | |
2505 | :keys "\\[pr-ps-region-preview]"]) | |
2506 | ("Mode" :active (and (not pr-spool-p) (pr-mode-alist-p)) | |
2507 | ["1-up" (pr-ps-mode-preview 1 t) t] | |
2508 | ["2-up" (pr-ps-mode-preview 2 t) t] | |
2509 | ["4-up" (pr-ps-mode-preview 4 t) t] | |
2510 | ["Other..." (pr-ps-mode-preview nil t) | |
2511 | :keys "\\[pr-ps-mode-preview]"]) | |
2512 | ("File" | |
b8d955f4 | 2513 | ["No Preprocessing..." (call-interactively 'pr-ps-file-preview) |
2c840b90 KS |
2514 | :keys "\\[pr-ps-file-preview]" |
2515 | :help "Preview PostScript file"] | |
2516 | "--" | |
2517 | ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist | |
2518 | :help "Select PostScript utility"] | |
2519 | "--" | |
2520 | ["1-up..." (pr-ps-file-up-preview 1 t t) pr-ps-utility-alist] | |
2521 | ["2-up..." (pr-ps-file-up-preview 2 t t) pr-ps-utility-alist] | |
2522 | ["4-up..." (pr-ps-file-up-preview 4 t t) pr-ps-utility-alist] | |
2523 | ["Other..." (pr-ps-file-up-preview nil t t) | |
2524 | :keys "\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist] | |
2525 | "--" | |
2526 | ["Landscape" pr-toggle-file-landscape | |
2527 | :style toggle :selected pr-file-landscape | |
2528 | :help "Toggle landscape for PostScript file" | |
2529 | :active pr-ps-utility-alist] | |
2530 | ["Duplex" pr-toggle-file-duplex | |
2531 | :style toggle :selected pr-file-duplex | |
2532 | :help "Toggle duplex for PostScript file" | |
2533 | :active pr-ps-utility-alist] | |
2534 | ["Tumble" pr-toggle-file-tumble | |
2535 | :style toggle :selected pr-file-tumble | |
2536 | :help "Toggle tumble for PostScript file" | |
2537 | :active (and pr-file-duplex pr-ps-utility-alist)]) | |
2538 | ["Despool..." (call-interactively 'pr-despool-preview) | |
2539 | :active pr-spool-p :keys "\\[pr-despool-preview]" | |
2540 | :help "Despool PostScript buffer to printer or file (C-u)"]) | |
2541 | ("PostScript Print" :visible (pr-visible-p 'postscript) | |
2542 | :help "Send PostScript to printer or file (C-u)" | |
2543 | ("Directory" | |
2544 | ["1-up" (pr-ps-directory-ps-print 1 nil nil t) t] | |
2545 | ["2-up" (pr-ps-directory-ps-print 2 nil nil t) t] | |
2546 | ["4-up" (pr-ps-directory-ps-print 4 nil nil t) t] | |
2547 | ["Other..." (pr-ps-directory-ps-print nil nil nil t) | |
2548 | :keys "\\[pr-ps-buffer-ps-print]"]) | |
2549 | ("Buffer" | |
2550 | ["1-up" (pr-ps-buffer-ps-print 1 t) t] | |
2551 | ["2-up" (pr-ps-buffer-ps-print 2 t) t] | |
2552 | ["4-up" (pr-ps-buffer-ps-print 4 t) t] | |
2553 | ["Other..." (pr-ps-buffer-ps-print nil t) | |
2554 | :keys "\\[pr-ps-buffer-ps-print]"]) | |
2555 | ("Region" :active (ps-mark-active-p) | |
2556 | ["1-up" (pr-ps-region-ps-print 1 t) t] | |
2557 | ["2-up" (pr-ps-region-ps-print 2 t) t] | |
2558 | ["4-up" (pr-ps-region-ps-print 4 t) t] | |
2559 | ["Other..." (pr-ps-region-ps-print nil t) | |
2560 | :keys "\\[pr-ps-region-ps-print]"]) | |
2561 | ("Mode" :active (pr-mode-alist-p) | |
2562 | ["1-up" (pr-ps-mode-ps-print 1 t) t] | |
2563 | ["2-up" (pr-ps-mode-ps-print 2 t) t] | |
2564 | ["4-up" (pr-ps-mode-ps-print 4 t) t] | |
2565 | ["Other..." (pr-ps-mode-ps-print nil t) | |
2566 | :keys "\\[pr-ps-mode-ps-print]"]) | |
2567 | ("File" | |
b8d955f4 | 2568 | ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print) |
2c840b90 KS |
2569 | :keys "\\[pr-ps-file-ps-print]" |
2570 | :help "Send PostScript file to printer"] | |
2571 | "--" | |
2572 | ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist | |
2573 | :help "Select PostScript utility"] | |
2574 | "--" | |
2575 | ["1-up..." (pr-ps-file-up-ps-print 1 t t) pr-ps-utility-alist] | |
2576 | ["2-up..." (pr-ps-file-up-ps-print 2 t t) pr-ps-utility-alist] | |
2577 | ["4-up..." (pr-ps-file-up-ps-print 4 t t) pr-ps-utility-alist] | |
2578 | ["Other..." (pr-ps-file-up-ps-print nil t t) | |
2579 | :keys "\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist] | |
2580 | "--" | |
2581 | ["Landscape" pr-toggle-file-landscape | |
2582 | :style toggle :selected pr-file-landscape | |
2583 | :help "Toggle landscape for PostScript file" | |
2584 | :active pr-ps-utility-alist] | |
2585 | ["Duplex" pr-toggle-file-duplex | |
2586 | :style toggle :selected pr-file-duplex | |
2587 | :help "Toggle duplex for PostScript file" | |
2588 | :active pr-ps-utility-alist] | |
2589 | ["Tumble" pr-toggle-file-tumble | |
2590 | :style toggle :selected pr-file-tumble | |
2591 | :help "Toggle tumble for PostScript file" | |
2592 | :active (and pr-file-duplex pr-ps-utility-alist)]) | |
2593 | ["Despool..." (call-interactively 'pr-despool-ps-print) | |
2594 | :active pr-spool-p :keys "\\[pr-despool-ps-print]" | |
2595 | :help "Despool PostScript buffer to printer or file (C-u)"]) | |
2596 | ["PostScript Printers" pr-update-menus | |
2597 | :active pr-ps-printer-alist :included (pr-visible-p 'postscript) | |
2598 | :help "Select PostScript printer"] | |
2599 | "--" | |
2600 | ("Printify" :visible (pr-visible-p 'text) | |
2601 | :help "Replace non-printing chars with printable representations." | |
2602 | ["Directory" pr-printify-directory t] | |
2603 | ["Buffer" pr-printify-buffer t] | |
2604 | ["Region" pr-printify-region (ps-mark-active-p)]) | |
2605 | ("Print" :visible (pr-visible-p 'text) | |
2606 | :help "Send text to printer" | |
2607 | ["Directory" pr-txt-directory t] | |
2608 | ["Buffer" pr-txt-buffer t] | |
2609 | ["Region" pr-txt-region (ps-mark-active-p)] | |
2610 | ["Mode" pr-txt-mode (pr-mode-alist-p)]) | |
2611 | ["Text Printers" pr-update-menus | |
2612 | :active pr-txt-printer-alist :included (pr-visible-p 'text) | |
2613 | :help "Select text printer"] | |
2614 | "--" | |
2615 | ["Landscape" pr-toggle-landscape | |
2616 | :style toggle :selected ps-landscape-mode | |
2617 | :included (pr-visible-p 'postscript-options)] | |
2618 | ["Print Header" pr-toggle-header | |
2619 | :style toggle :selected ps-print-header | |
2620 | :included (pr-visible-p 'postscript-options)] | |
2621 | ["Print Header Frame" pr-toggle-header-frame | |
2622 | :style toggle :selected ps-print-header-frame :active ps-print-header | |
2623 | :included (pr-visible-p 'postscript-options)] | |
2624 | ["Line Number" pr-toggle-line | |
2625 | :style toggle :selected ps-line-number | |
2626 | :included (pr-visible-p 'postscript-options)] | |
2627 | ["Zebra Stripes" pr-toggle-zebra | |
2628 | :style toggle :selected ps-zebra-stripes | |
2629 | :included (pr-visible-p 'postscript-options)] | |
2630 | ["Duplex" pr-toggle-duplex | |
2631 | :style toggle :selected ps-spool-duplex | |
2632 | :included (pr-visible-p 'postscript-options)] | |
2633 | ["Tumble" pr-toggle-tumble | |
2634 | :style toggle :selected ps-spool-tumble :active ps-spool-duplex | |
2635 | :included (pr-visible-p 'postscript-options)] | |
2636 | ["Upside-Down" pr-toggle-upside-down | |
2637 | :style toggle :selected ps-print-upside-down | |
2638 | :included (pr-visible-p 'postscript-options)] | |
2639 | ("Print All Pages" :visible (pr-visible-p 'postscript-options) | |
2640 | :help "Select odd/even pages/sheets to print" | |
2641 | ["All Pages" (pr-even-or-odd-pages nil) | |
2642 | :style radio :selected (eq ps-even-or-odd-pages nil)] | |
2643 | ["Even Pages" (pr-even-or-odd-pages 'even-page) | |
2644 | :style radio :selected (eq ps-even-or-odd-pages 'even-page)] | |
2645 | ["Odd Pages" (pr-even-or-odd-pages 'odd-page) | |
2646 | :style radio :selected (eq ps-even-or-odd-pages 'odd-page)] | |
2647 | ["Even Sheets" (pr-even-or-odd-pages 'even-sheet) | |
2648 | :style radio :selected (eq ps-even-or-odd-pages 'even-sheet)] | |
2649 | ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet) | |
2650 | :style radio :selected (eq ps-even-or-odd-pages 'odd-sheet)]) | |
2651 | "--" | |
2652 | ["Spool Buffer" pr-toggle-spool | |
2653 | :style toggle :selected pr-spool-p | |
2654 | :included (pr-visible-p 'postscript-process) | |
2655 | :help "Toggle PostScript spooling"] | |
449cba44 | 2656 | ["Print with faces" pr-toggle-faces |
2c840b90 KS |
2657 | :style toggle :selected pr-faces-p |
2658 | :included (pr-visible-p 'postscript-process) | |
2659 | :help "Toggle PostScript printing with faces"] | |
449cba44 | 2660 | ["Print via Ghostscript" pr-toggle-ghostscript |
2c840b90 KS |
2661 | :style toggle :selected pr-print-using-ghostscript |
2662 | :included (pr-visible-p 'postscript-process) | |
2663 | :help "Toggle PostScript generation using ghostscript"] | |
2664 | "--" | |
2665 | ["Auto Region" pr-toggle-region | |
2666 | :style toggle :selected pr-auto-region | |
2667 | :included (pr-visible-p 'printing)] | |
2668 | ["Auto Mode" pr-toggle-mode | |
2669 | :style toggle :selected pr-auto-mode | |
2670 | :included (pr-visible-p 'printing)] | |
2671 | ["Menu Lock" pr-toggle-lock | |
2672 | :style toggle :selected pr-menu-lock | |
2673 | :included (pr-visible-p 'printing)] | |
2674 | "--" | |
2675 | ("Customize" :visible (pr-visible-p 'help) | |
2676 | ["printing" pr-customize t] | |
2677 | ["ps-print" ps-print-customize t] | |
2678 | ["lpr" lpr-customize t]) | |
2679 | ("Show Settings" :visible (pr-visible-p 'help) | |
2680 | ["printing" pr-show-pr-setup t] | |
2681 | ["ps-print" pr-show-ps-setup t] | |
2682 | ["lpr" pr-show-lpr-setup t]) | |
2683 | ["Help" pr-help :active t :included (pr-visible-p 'help)] | |
2684 | )) | |
2685 | ||
2686 | ||
2687 | ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
2688 | ;; Menu mapping: | |
2689 | ;; unfortunately XEmacs doesn't support :active or :visible | |
2690 | ;; for submenus, only for items. | |
2691 | ;; It uses :included instead of :active or :visible. | |
2692 | ;; Also, XEmacs doesn't support :help tag. | |
2693 | '( | |
2694 | ["Printing Interface" pr-interface] | |
2695 | "--" | |
2696 | ("PostScript Preview" :included (pr-visible-p 'postscript) | |
2697 | ("Directory" :included (not pr-spool-p) | |
2698 | ["1-up" (pr-ps-directory-preview 1 nil nil t) t] | |
2699 | ["2-up" (pr-ps-directory-preview 2 nil nil t) t] | |
2700 | ["4-up" (pr-ps-directory-preview 4 nil nil t) t] | |
2701 | ["Other..." (pr-ps-directory-preview nil nil nil t) | |
2702 | :keys "\\[pr-ps-buffer-preview]"]) | |
2703 | ("Buffer" :included (not pr-spool-p) | |
2704 | ["1-up" (pr-ps-buffer-preview 1 t) t] | |
2705 | ["2-up" (pr-ps-buffer-preview 2 t) t] | |
2706 | ["4-up" (pr-ps-buffer-preview 4 t) t] | |
2707 | ["Other..." (pr-ps-buffer-preview nil t) | |
2708 | :keys "\\[pr-ps-buffer-preview]"]) | |
2709 | ("Region" :included (and (not pr-spool-p) (ps-mark-active-p)) | |
2710 | ["1-up" (pr-ps-region-preview 1 t) t] | |
2711 | ["2-up" (pr-ps-region-preview 2 t) t] | |
2712 | ["4-up" (pr-ps-region-preview 4 t) t] | |
2713 | ["Other..." (pr-ps-region-preview nil t) | |
2714 | :keys "\\[pr-ps-region-preview]"]) | |
2715 | ("Mode" :included (and (not pr-spool-p) (pr-mode-alist-p)) | |
2716 | ["1-up" (pr-ps-mode-preview 1 t) t] | |
2717 | ["2-up" (pr-ps-mode-preview 2 t) t] | |
2718 | ["4-up" (pr-ps-mode-preview 4 t) t] | |
2719 | ["Other..." (pr-ps-mode-preview nil t) | |
2720 | :keys "\\[pr-ps-mode-preview]"]) | |
2721 | ("File" | |
b8d955f4 | 2722 | ["No Preprocessing..." (call-interactively 'pr-ps-file-preview) |
2c840b90 KS |
2723 | :keys "\\[pr-ps-file-preview]"] |
2724 | "--" | |
2725 | ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist] | |
2726 | "--" | |
2727 | ["1-up..." (pr-ps-file-up-preview 1 t t) pr-ps-utility-alist] | |
2728 | ["2-up..." (pr-ps-file-up-preview 2 t t) pr-ps-utility-alist] | |
2729 | ["4-up..." (pr-ps-file-up-preview 4 t t) pr-ps-utility-alist] | |
2730 | ["Other..." (pr-ps-file-up-preview nil t t) | |
2731 | :keys "\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist] | |
2732 | "--" | |
2733 | ["Landscape" pr-toggle-file-landscape | |
2734 | :style toggle :selected pr-file-landscape | |
2735 | :active pr-ps-utility-alist] | |
2736 | ["Duplex" pr-toggle-file-duplex | |
2737 | :style toggle :selected pr-file-duplex | |
2738 | :active pr-ps-utility-alist] | |
2739 | ["Tumble" pr-toggle-file-tumble | |
2740 | :style toggle :selected pr-file-tumble | |
2741 | :active (and pr-file-duplex pr-ps-utility-alist)]) | |
2742 | ["Despool..." (call-interactively 'pr-despool-preview) | |
2743 | :active pr-spool-p :keys "\\[pr-despool-preview]"]) | |
2744 | ("PostScript Print" :included (pr-visible-p 'postscript) | |
2745 | ("Directory" | |
2746 | ["1-up" (pr-ps-directory-ps-print 1 nil nil t) t] | |
2747 | ["2-up" (pr-ps-directory-ps-print 2 nil nil t) t] | |
2748 | ["4-up" (pr-ps-directory-ps-print 4 nil nil t) t] | |
2749 | ["Other..." (pr-ps-directory-ps-print nil nil nil t) | |
2750 | :keys "\\[pr-ps-buffer-ps-print]"]) | |
2751 | ("Buffer" | |
2752 | ["1-up" (pr-ps-buffer-ps-print 1 t) t] | |
2753 | ["2-up" (pr-ps-buffer-ps-print 2 t) t] | |
2754 | ["4-up" (pr-ps-buffer-ps-print 4 t) t] | |
2755 | ["Other..." (pr-ps-buffer-ps-print nil t) | |
2756 | :keys "\\[pr-ps-buffer-ps-print]"]) | |
2757 | ("Region" :included (ps-mark-active-p) | |
2758 | ["1-up" (pr-ps-region-ps-print 1 t) t] | |
2759 | ["2-up" (pr-ps-region-ps-print 2 t) t] | |
2760 | ["4-up" (pr-ps-region-ps-print 4 t) t] | |
2761 | ["Other..." (pr-ps-region-ps-print nil t) | |
2762 | :keys "\\[pr-ps-region-ps-print]"]) | |
2763 | ("Mode" :included (pr-mode-alist-p) | |
2764 | ["1-up" (pr-ps-mode-ps-print 1 t) t] | |
2765 | ["2-up" (pr-ps-mode-ps-print 2 t) t] | |
2766 | ["4-up" (pr-ps-mode-ps-print 4 t) t] | |
2767 | ["Other..." (pr-ps-mode-ps-print nil t) | |
2768 | :keys "\\[pr-ps-mode-ps-print]"]) | |
2769 | ("File" | |
b8d955f4 | 2770 | ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print) |
2c840b90 KS |
2771 | :keys "\\[pr-ps-file-ps-print]"] |
2772 | "--" | |
2773 | ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist] | |
2774 | "--" | |
2775 | ["1-up..." (pr-ps-file-up-ps-print 1 t t) pr-ps-utility-alist] | |
2776 | ["2-up..." (pr-ps-file-up-ps-print 2 t t) pr-ps-utility-alist] | |
2777 | ["4-up..." (pr-ps-file-up-ps-print 4 t t) pr-ps-utility-alist] | |
2778 | ["Other..." (pr-ps-file-up-ps-print nil t t) | |
2779 | :keys "\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist] | |
2780 | "--" | |
2781 | ["Landscape" pr-toggle-file-landscape | |
2782 | :style toggle :selected pr-file-landscape | |
2783 | :active pr-ps-utility-alist] | |
2784 | ["Duplex" pr-toggle-file-duplex | |
2785 | :style toggle :selected pr-file-duplex | |
2786 | :active pr-ps-utility-alist] | |
2787 | ["Tumble" pr-toggle-file-tumble | |
2788 | :style toggle :selected pr-file-tumble | |
2789 | :active (and pr-file-duplex pr-ps-utility-alist)]) | |
2790 | ["Despool..." (call-interactively 'pr-despool-ps-print) | |
2791 | :active pr-spool-p :keys "\\[pr-despool-ps-print]"]) | |
2792 | ["PostScript Printers" pr-update-menus | |
2793 | :active pr-ps-printer-alist :included (pr-visible-p 'postscript)] | |
2794 | "--" | |
2795 | ("Printify" :included (pr-visible-p 'text) | |
2796 | ["Directory" pr-printify-directory t] | |
2797 | ["Buffer" pr-printify-buffer t] | |
2798 | ["Region" pr-printify-region (ps-mark-active-p)]) | |
2799 | ("Print" :included (pr-visible-p 'text) | |
2800 | ["Directory" pr-txt-directory t] | |
2801 | ["Buffer" pr-txt-buffer t] | |
2802 | ["Region" pr-txt-region (ps-mark-active-p)] | |
2803 | ["Mode" pr-txt-mode (pr-mode-alist-p)]) | |
2804 | ["Text Printers" pr-update-menus | |
2805 | :active pr-txt-printer-alist :included (pr-visible-p 'text)] | |
2806 | "--" | |
2807 | ["Landscape" pr-toggle-landscape | |
2808 | :style toggle :selected ps-landscape-mode | |
2809 | :included (pr-visible-p 'postscript-options)] | |
2810 | ["Print Header" pr-toggle-header | |
2811 | :style toggle :selected ps-print-header | |
2812 | :included (pr-visible-p 'postscript-options)] | |
2813 | ["Print Header Frame" pr-toggle-header-frame | |
2814 | :style toggle :selected ps-print-header-frame :active ps-print-header | |
2815 | :included (pr-visible-p 'postscript-options)] | |
2816 | ["Line Number" pr-toggle-line | |
2817 | :style toggle :selected ps-line-number | |
2818 | :included (pr-visible-p 'postscript-options)] | |
2819 | ["Zebra Stripes" pr-toggle-zebra | |
2820 | :style toggle :selected ps-zebra-stripes | |
2821 | :included (pr-visible-p 'postscript-options)] | |
2822 | ["Duplex" pr-toggle-duplex | |
2823 | :style toggle :selected ps-spool-duplex | |
2824 | :included (pr-visible-p 'postscript-options)] | |
2825 | ["Tumble" pr-toggle-tumble | |
2826 | :style toggle :selected ps-spool-tumble :active ps-spool-duplex | |
2827 | :included (pr-visible-p 'postscript-options)] | |
2828 | ["Upside-Down" pr-toggle-upside-down | |
2829 | :style toggle :selected ps-print-upside-down | |
2830 | :included (pr-visible-p 'postscript-options)] | |
2831 | ("Print All Pages" :included (pr-visible-p 'postscript-options) | |
2832 | ["All Pages" (pr-even-or-odd-pages nil) | |
2833 | :style radio :selected (eq ps-even-or-odd-pages nil)] | |
2834 | ["Even Pages" (pr-even-or-odd-pages 'even-page) | |
2835 | :style radio :selected (eq ps-even-or-odd-pages 'even-page)] | |
2836 | ["Odd Pages" (pr-even-or-odd-pages 'odd-page) | |
2837 | :style radio :selected (eq ps-even-or-odd-pages 'odd-page)] | |
2838 | ["Even Sheets" (pr-even-or-odd-pages 'even-sheet) | |
2839 | :style radio :selected (eq ps-even-or-odd-pages 'even-sheet)] | |
2840 | ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet) | |
2841 | :style radio :selected (eq ps-even-or-odd-pages 'odd-sheet)]) | |
2842 | "--" | |
2843 | ["Spool Buffer" pr-toggle-spool | |
2844 | :style toggle :selected pr-spool-p | |
2845 | :included (pr-visible-p 'postscript-process)] | |
449cba44 | 2846 | ["Print with faces" pr-toggle-faces |
2c840b90 KS |
2847 | :style toggle :selected pr-faces-p |
2848 | :included (pr-visible-p 'postscript-process)] | |
449cba44 | 2849 | ["Print via Ghostscript" pr-toggle-ghostscript |
2c840b90 KS |
2850 | :style toggle :selected pr-print-using-ghostscript |
2851 | :included (pr-visible-p 'postscript-process)] | |
2852 | "--" | |
2853 | ["Auto Region" pr-toggle-region | |
2854 | :style toggle :selected pr-auto-region | |
2855 | :included (pr-visible-p 'printing)] | |
2856 | ["Auto Mode" pr-toggle-mode | |
2857 | :style toggle :selected pr-auto-mode | |
2858 | :included (pr-visible-p 'printing)] | |
2859 | ["Menu Lock" pr-toggle-lock | |
2860 | :style toggle :selected pr-menu-lock | |
2861 | :included (pr-visible-p 'printing)] | |
2862 | "--" | |
2863 | ("Customize" :included (pr-visible-p 'help) | |
2864 | ["printing" pr-customize t] | |
2865 | ["ps-print" ps-print-customize t] | |
2866 | ["lpr" lpr-customize t]) | |
2867 | ("Show Settings" :included (pr-visible-p 'help) | |
2868 | ["printing" pr-show-pr-setup t] | |
2869 | ["ps-print" pr-show-ps-setup t] | |
2870 | ["lpr" pr-show-lpr-setup t]) | |
2871 | ["Help" pr-help :active t :included (pr-visible-p 'help)] | |
2872 | )) | |
2873 | )) | |
2874 | ||
2875 | ||
2876 | (cond | |
2877 | ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
2878 | ;; Menu binding | |
2879 | (require 'easymenu) | |
2880 | ;; Replace existing "print" item by "Printing" item. | |
2881 | ;; If you're changing this file, you'll load it a second, | |
2882 | ;; third... time, but "print" item exists only in the first load. | |
2883 | (defvar pr-menu-print-item "print") | |
2884 | (cond | |
2885 | ;; Emacs 20 | |
2886 | ((string< emacs-version "21.") | |
2887 | (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item) | |
2888 | (when pr-menu-print-item | |
2889 | (easy-menu-remove-item nil '("tools") pr-menu-print-item) | |
2890 | (setq pr-menu-print-item nil | |
2891 | pr-menu-bar (vector 'menu-bar 'tools | |
2892 | (pr-get-symbol "Printing"))))) | |
2893 | ;; Emacs 21 | |
2894 | (pr-menu-print-item | |
2895 | (easy-menu-change '("files") "Print" pr-menu-spec "print-buffer") | |
2896 | (let ((items '("print-buffer" "print-region" | |
2897 | "ps-print-buffer-faces" "ps-print-region-faces" | |
2898 | "ps-print-buffer" "ps-print-region"))) | |
2899 | (while items | |
2900 | (easy-menu-remove-item nil '("files") (car items)) | |
2901 | (setq items (cdr items))) | |
2902 | (setq pr-menu-print-item nil | |
2903 | pr-menu-bar (vector 'menu-bar 'files | |
2904 | (pr-get-symbol "Print"))))) | |
2905 | (t | |
2906 | (easy-menu-change '("files") "Print" pr-menu-spec))) | |
2907 | ||
2908 | ;; Key binding | |
2909 | (global-set-key [print] 'pr-ps-fast-fire) | |
2910 | (global-set-key [M-print] 'pr-ps-mode-using-ghostscript) | |
2911 | (global-set-key [C-print] 'pr-txt-fast-fire)) | |
2912 | ||
2913 | ||
2914 | ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
2915 | ;; Menu binding | |
2916 | (pr-xemacs-global-menubar | |
2917 | (pr-x-add-submenu nil (cons "Printing" pr-menu-spec) "Apps")) | |
2918 | ||
2919 | ;; Key binding | |
2920 | (global-set-key 'f22 'pr-ps-fast-fire) | |
2921 | (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript) | |
2922 | (global-set-key '(control f22) 'pr-txt-fast-fire)))) | |
2923 | ||
2924 | ||
2925 | ;;; You can also use something like: | |
2926 | ;;;(global-set-key "\C-ci" 'pr-interface) | |
2927 | ;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print) | |
2928 | ;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview) | |
2929 | ;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript) | |
2930 | ;;;(global-set-key "\C-crp" 'pr-ps-region-print) | |
2931 | ;;;(global-set-key "\C-crx" 'pr-ps-region-preview) | |
2932 | ;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript) | |
2933 | ||
2934 | ||
2935 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
2936 | ;; Help Message | |
2937 | ||
2938 | ||
2939 | (defconst pr-help-message | |
2940 | (concat "printing.el version " pr-version | |
2941 | " ps-print.el version " ps-print-version | |
2942 | "\n\n | |
2943 | Menu Layout | |
2944 | ----------- | |
2945 | ||
2946 | The `printing' menu (Tools/Printing or File/Print) has the following layout: | |
2947 | ||
2948 | +-----------------------------+ | |
2949 | A 0 | Printing Interface | | |
2950 | +-----------------------------+ +-A---------+ +-B------+ | |
2951 | I 1 | PostScript Preview >|-------|Directory >|-----|1-up | | |
2952 | 2 | PostScript Print >|---- A |Buffer >|-- B |2-up | | |
2953 | 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up | | |
2954 | +-----------------------------+ |Mode >|-- B |Other...| | |
2955 | II 4 | Printify >|-----\\ |File >|--\\ +--------+ | |
2956 | 5 | Print >|---\\ | |Despool... | | | |
2957 | 6 | Text Printer: name >|-\\ | | +-----------+ | | |
2958 | +-----------------------------+ | | | +---------+ +------------+ | |
b8d955f4 | 2959 | III 7 |[ ]Landscape | | | \\-|Directory| | No Prep... | Ia |
2c840b90 KS |
2960 | 8 |[ ]Print Header | | | |Buffer | +------------+ Ib |
2961 | 9 |[ ]Print Header Frame | | | |Region | | name >|- C | |
2962 | 10 |[ ]Line Number | | | +---------+ +------------+ | |
2963 | 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic | |
2964 | 12 |[ ]Duplex | | \\---|Directory| | 2-up... | | |
2965 | 13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... | | |
2966 | 14 |[ ]Upside-Down | | |Region | | Other... | | |
2967 | 15 | Print All Pages >|--\\ | |Mode | +------------+ | |
2968 | +-----------------------------+ | | +---------+ |[ ]Landscape| Id | |
2969 | IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie | |
449cba44 VJL |
2970 | 17 |[ ]Print with faces | | \\--|( )name A| |[ ]Tumble | If |
2971 | 18 |[ ]Print via Ghostscript | | |( )name B| +------------+ | |
2c840b90 KS |
2972 | +-----------------------------+ | |... | |
2973 | V 19 |[ ]Auto Region | | |(*)name | | |
2974 | 20 |[ ]Auto Mode | | |... | | |
2975 | 21 |[ ]Menu Lock | | +---------+ +--------------+ | |
2976 | +-----------------------------+ \\------------------|(*)All Pages | | |
2977 | VI 22 | Customize >|--- D +-D------+ |( )Even Pages | | |
2978 | 23 | Show Settings >|-------|printing| |( )Odd Pages | | |
2979 | 24 | Help | |ps-print| |( )Even Sheets| | |
2980 | +-----------------------------+ |lpr | |( )Odd Sheets | | |
2981 | +--------+ +--------------+ | |
2982 | ||
2983 | See `pr-visible-entry-list' for hiding some parts of the menu. | |
2984 | ||
2985 | The menu has the following sections: | |
2986 | ||
2987 | A. Interface: | |
2988 | ||
2989 | 0. You can use a buffer interface instead of menus. It looks like the | |
2990 | customization buffer. Basically, it has the same options found in the | |
2991 | menu and some extra options, all this on a buffer. | |
2992 | ||
2993 | I. PostScript printing: | |
2994 | ||
2995 | 1. You can generate a PostScript file (if you type C-u before activating | |
2996 | menu) or PostScript temporary file for a directory, a buffer, a region | |
2997 | or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing; | |
2998 | after file generation, ghostview is activated using the file generated | |
2999 | as argument. This option is disabled if spooling is on (option 16). | |
3000 | Also, if you already have a PostScript file you can preview it. | |
3001 | Instead of previewing each buffer, region or major mode at once, you | |
3002 | can save temporarily the PostScript code generated in a buffer and | |
3003 | preview it later. The option `Despool...' despools the PostScript | |
3004 | spooling buffer in a temporary file and uses ghostview to preview it. | |
3005 | If you type C-u before choosing this option, the PostScript code | |
3006 | generated is saved in a file instead of saving in a temporary file. To | |
3007 | spool the PostScript code generated you need to turn on the option 16. | |
3008 | The option `Despool...' is enabled if spooling is on (option 16). | |
3009 | ||
3010 | NOTE 1: It's possible to customize a major mode printing, just declare | |
3011 | the customization in `pr-mode-alist' and invoke some of | |
3012 | `*-mode*' commands or select Mode option in Printing menu. An | |
3013 | example for major mode usage is when you're using gnus (or mh, | |
3014 | or rmail, etc.) and you're in the *Summary* buffer, if you | |
3015 | forget to switch to the *Article* buffer before printing, | |
3016 | you'll get a nicely formatted list of article subjects shows | |
3017 | up at the printer. With major mode printing you don't need to | |
3018 | switch from gnus *Summary* buffer first. | |
3019 | ||
3020 | NOTE 2: There are the following options for PostScript file processing: | |
b8d955f4 VJL |
3021 | Ia. Print the file *No Preprocessing*, that is, send it |
3022 | directly to PostScript printer. | |
2c840b90 KS |
3023 | Ib. PostScript utility processing selection. |
3024 | See `pr-ps-utility-alist' and `pr-setting-database' for | |
3025 | documentation. | |
3026 | Ic. Do n-up processing before printing. | |
3027 | Id. Toggle on/off landscape for PostScript file processing. | |
3028 | Ie. Toggle on/off duplex for PostScript file processing. | |
3029 | If. Toggle on/off tumble for PostScript file processing. | |
3030 | ||
3031 | NOTE 3: Don't forget to download and install the utilities declared on | |
3032 | `pr-ps-utility-alist'. | |
3033 | ||
3034 | 2. Operate the same way as option 1, but it sends directly the PostScript | |
3035 | code (or put in a file, if you've typed C-u) or it uses ghostscript to | |
3036 | print the PostScript file generated. It depends on option 18, if it's | |
3037 | turned on, it uses ghostscript; otherwise, it sends directly to | |
3038 | printer. If spooling is on (option 16), the PostScript code is saved | |
3039 | temporarily in a buffer instead of printing it or saving it in a file. | |
3040 | Also, if you already have a PostScript file you can print it. | |
3041 | Instead of printing each buffer, region or major mode at once, you can | |
3042 | save temporarily the PostScript code generated in a buffer and print it | |
3043 | later. The option `Despool...' despools the PostScript spooling buffer | |
3044 | directly on a printer. If you type C-u before choosing this option, | |
449cba44 VJL |
3045 | the PostScript code generated is saved in a file instead of sending it to |
3046 | the printer. To spool the PostScript code generated you need to turn on | |
3047 | option 16. This option is enabled if spooling is on (option 16). | |
2c840b90 KS |
3048 | See also the NOTE 1, NOTE 2 and NOTE 3 on option 1. |
3049 | ||
3050 | 3. You can select a new PostScript printer to send PostScript code | |
3051 | generated. For selection it's used all PostScript printers defined | |
3052 | in `pr-ps-printer-alist' variable (see it for documentation). | |
3053 | See also `pr-setting-database'. | |
3054 | ||
3055 | II. Text printing: | |
3056 | ||
3057 | 4. If you have control characters (character code from \\000 to \\037) in a | |
3058 | buffer and you want to print them in a text printer, select this | |
3059 | option. All control characters in your buffer or region will be | |
3060 | replaced by a printable representation. The printable representations | |
3061 | use ^ (for ASCII control characters) or hex. The characters tab, | |
3062 | linefeed, space, return and formfeed are not affected. | |
3063 | You don't need to select this option if you use any option of section | |
3064 | I, the PostScript engine treats control characters properly. | |
3065 | ||
3066 | 5. If you want to print a directory, buffer, region or major mode in a | |
3067 | text printer, select this option. See also the NOTE 1 on option 1. | |
3068 | ||
3069 | 6. You can select a new text printer to send text generated. For | |
3070 | selection it's used all text printers defined in `pr-txt-printer-alist' | |
3071 | variable (see it for documentation). | |
3072 | See also `pr-setting-database'. | |
3073 | ||
3074 | III. PostScript page toggle options: | |
3075 | ||
3076 | 7. If you want a PostScript landscape printing, turn on this option. | |
3077 | ||
3078 | 8. If you want to have a header in each page in your PostScript code, | |
3079 | turn on this option. | |
3080 | ||
3081 | 9. If you want to draw a gaudy frame around the header, turn on this | |
3082 | option. This option is enabled if print header is on (option 8). | |
3083 | ||
3084 | 10. If you want that the line number is printed in your PostScript code, | |
3085 | turn on this option. | |
3086 | ||
3087 | 11. If you want background zebra stripes in your PostScript code, turn on | |
3088 | this option. | |
3089 | ||
3090 | 12. If you want a duplex printing and your PostScript printer has this | |
3091 | feature, turn on this option. | |
3092 | ||
3093 | 13. If you turned on duplex printing, you can choose if you want to have a | |
3094 | printing suitable for binding on the left or right (tumble off), or to | |
3095 | have a printing suitable for binding at top or bottom (tumble on). | |
3096 | This option is enabled if duplex is on (option 12). | |
3097 | ||
3098 | 14. If you want a PostScript upside-down printing, turn on this option. | |
3099 | ||
3100 | 15. With this option, you can choose if you want to print all pages, odd | |
3101 | pages, even pages, odd sheets or even sheets. | |
3102 | See also `ps-even-or-odd-pages'. | |
3103 | ||
3104 | IV. PostScript processing toggle options: | |
3105 | ||
3106 | 16. If you want to spool the PostScript code generated, turn on this | |
3107 | option. To spool the PostScript code generated use option 2. You can | |
3108 | despool later by choosing option 1 or 2, sub-option `Despool...'. | |
3109 | ||
3110 | 17. If you use colors in your buffers and want to see these colors on your | |
3111 | PostScript code generated, turn on this option. If you have a | |
3112 | black/white PostScript printer, these colors are displayed in gray | |
3113 | scale by PostScript printer interpreter. | |
3114 | ||
3115 | 18. If you don't have a PostScript printer to send PostScript files, turn | |
3116 | on this option. When this option is on, the ghostscript is used to | |
3117 | print PostScript files. In GNU or Unix system, if ghostscript is set | |
3118 | as a PostScript filter, you don't need to turn on this option. | |
3119 | ||
3120 | V. Printing customization: | |
3121 | ||
3122 | 19. If you want that region is automagically detected, turn on this | |
3123 | option. Note that this will only work if you're using transient mark | |
3124 | mode. When this option is on, the `*-buffer*' commands will behave | |
3125 | like `*-region*' commands, that is, `*-buffer*' commands will print | |
3126 | only the region marked instead of all buffer. | |
3127 | ||
3128 | 20. Turn this option on if you want that when current major-mode is | |
3129 | declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands | |
3130 | behave like `*-mode*' commands. | |
3131 | ||
449cba44 | 3132 | 21. If you want that Printing menu stays open while you are setting |
2c840b90 KS |
3133 | toggle options, turn on this option. The variables |
3134 | `pr-menu-char-height' and `pr-menu-char-width' are used to guess the | |
3135 | menu position, so don't forget to adjust these variables if menu | |
3136 | position is not ok. | |
3137 | ||
3138 | VI. Customization: | |
3139 | ||
3140 | 22. Besides all options in section III, IV and V, you can customize much | |
3141 | more PostScript options in `ps-print' option. Or you can customize | |
3142 | some `lpr' options for text printing. Or customize `printing' | |
3143 | options. | |
3144 | ||
3145 | 23. Show current settings for `printing', `ps-print' or `lpr'. | |
3146 | ||
3147 | 24. Quick help for printing menu layout. | |
3148 | ") | |
3149 | "Printing help message.") | |
3150 | ||
3151 | ||
3152 | (defconst pr-interface-help-message | |
3153 | (concat "printing.el version " pr-version | |
3154 | " ps-print.el version " ps-print-version | |
3155 | "\n\n | |
3156 | The printing interface buffer has the same functionality as the printing menu. | |
3157 | The major difference is that the states (like sending PostScript generated to a | |
3158 | file, n-up printing, etc.) are set and saved between priting buffer | |
3159 | activation. Also, the landscape, duplex and tumble values are the same for | |
3160 | PostScript file and directory/buffer/region/mode processing; using menu, there | |
3161 | are different value sets for PostScript file and directory/buffer/region/mode | |
3162 | processing. | |
3163 | ||
3164 | The printing interface buffer has the following sections: | |
3165 | ||
3166 | 1. Print: | |
3167 | ||
3168 | Here you can choose to print/preview a buffer, a directory or a PostScript | |
3169 | file: | |
3170 | ||
3171 | 1a. Buffer: | |
3172 | ||
3173 | * Buffer List: | |
3174 | Select a buffer from the current buffer list. | |
3175 | ||
3176 | * Region: | |
3177 | If it's on, this means that the selected buffer has an active region, | |
3178 | so you can turn on/off, as you wish. | |
3179 | If it's off when a buffer is selected, this means that the selected | |
3180 | buffer has no active region, so it'll not be possible to turn it on. | |
3181 | If you want to process the region, let this option on. | |
3182 | If you want to process the whole buffer, let this option off. | |
3183 | ||
3184 | * Mode: | |
3185 | If it's on, this means that the selected buffer major mode is declared | |
3186 | for major mode processing, so you can turn on/off, as you wish. | |
3187 | If it's off when a buffer is selected, this means that the selected | |
3188 | buffer major mode isn't declared for major mode processing, so it'll | |
3189 | not be possible to turn it on. | |
3190 | If you want the major mode processing, let this option on. | |
3191 | If you don't want the major mode processing, let this option off. | |
3192 | ||
3193 | NOTE 1: It's possible to customize a major mode printing, just declare | |
3194 | the customization in `pr-mode-alist' and invoke some of | |
3195 | `*-mode*' commands or select Mode option in Printing menu. An | |
3196 | example for major mode usage is when you're using gnus (or mh, | |
3197 | or rmail, etc.) and you're in the *Summary* buffer, if you | |
3198 | forget to switch to the *Article* buffer before printing, | |
3199 | you'll get a nicely formatted list of article subjects shows | |
3200 | up at the printer. With major mode printing you don't need to | |
3201 | switch from gnus *Summary* buffer first. | |
3202 | ||
3203 | 1b. Directory: | |
3204 | ||
3205 | * Directory: | |
3206 | Specify a valid directory path. | |
3207 | ||
3208 | * File Regexp: | |
3209 | Specify a file name regexp. All file names in the directory that | |
3210 | match with regexp will be printed/previewed. An empty file name | |
3211 | regexp means to print/preview all files in the directory. | |
3212 | ||
3213 | * List Directory Entry: | |
3214 | If it's turned on, list directory entries besides file entries. | |
3215 | ||
3216 | 1c. PostScript file: | |
3217 | ||
3218 | * PostScript File: | |
3219 | Specify an existent PostScript file to print/preview. | |
3220 | ||
3221 | * PostScript Utility: | |
3222 | Select a PostScript utility. | |
3223 | See `pr-ps-utility-alist' and `pr-setting-database' for documentation. | |
3224 | ||
3225 | NOTE 2: Don't forget to download and install the utilities declared on | |
3226 | `pr-ps-utility-alist'. | |
3227 | ||
b8d955f4 | 3228 | * No Preprocessing: |
2c840b90 KS |
3229 | If it's turned on, don't use the PostScript utility to preprocess the |
3230 | PostScript file before printing/previewing. | |
3231 | ||
3232 | 2. PostScript printer: | |
3233 | ||
3234 | * PostScript Printer: | |
3235 | You can select a new PostScript printer to send PostScript code | |
3236 | generated. For selection it's used all PostScript printers defined | |
3237 | in `pr-ps-printer-alist' variable (see it for documentation). | |
3238 | See also `pr-setting-database'. | |
3239 | ||
3240 | * Despool: | |
3241 | If spooling is on, you can turn it on/off, as you wish. | |
3242 | If spooling is off, it'll not be possible to turn it on. | |
3243 | If it's turned on, specify to despools the PostScript spooling buffer in | |
3244 | a temporary file or in the selected PostScript file when | |
3245 | printing/previewing. | |
3246 | ||
3247 | * Preview: | |
3248 | Preview the PostScript generated. | |
3249 | ||
3250 | * Print: | |
3251 | Print the PostScript generated. | |
3252 | ||
3253 | * Quit: | |
3254 | Quit from printing interface buffer. | |
3255 | ||
3256 | * Send to Printer/Temporary File: | |
3257 | If it's turned on, the PostScript generated is sent directly to | |
3258 | PostScript printer or, for previewing, to a temporary file. | |
3259 | ||
3260 | * Send to File: | |
3261 | Specify a file name to send the PostScript generated. | |
3262 | ||
3263 | * N-Up: | |
3264 | Specify n-up printing. | |
3265 | ||
3266 | 3. Text printer: | |
3267 | ||
3268 | * Text Printer: | |
3269 | Select a new text printer to send text generated. For selection it's used | |
3270 | all text printers defined in `pr-txt-printer-alist' variable (see it for | |
3271 | documentation). See also `pr-setting-database'. | |
3272 | ||
3273 | * Printify: | |
3274 | If you have control characters (character code from \\000 to \\037) in a | |
3275 | buffer and you want to print them in a text printer, select this | |
3276 | option. All control characters in your buffer or region will be | |
3277 | replaced by a printable representation. The printable representations | |
3278 | use ^ (for ASCII control characters) or hex. The characters tab, | |
3279 | linefeed, space, return and formfeed are not affected. | |
3280 | You don't need to select this option if you use any option of section | |
3281 | I, the PostScript engine treats control characters properly. | |
3282 | ||
3283 | * Print: | |
3284 | To print a directory, buffer, region or major mode in a | |
3285 | text printer, select this option. See also the NOTE 1 on section 1. | |
3286 | ||
3287 | * Quit: | |
3288 | Quit from printing interface buffer. | |
3289 | ||
3290 | 4. Settings: | |
3291 | ||
3292 | There are 3 setting columns: | |
3293 | ||
3294 | 4a. First column (left column): | |
3295 | ||
3296 | * Landscape: | |
3297 | PostScript landscape printing. | |
3298 | ||
3299 | * Print Header: | |
3300 | To have a header in each page in your PostScript code. | |
3301 | ||
3302 | * Print Header Frame: | |
3303 | To draw a gaudy frame around the header. | |
3304 | ||
3305 | * Line Number: | |
3306 | The line number is printed in your PostScript code. | |
3307 | ||
3308 | * Zebra Stripes: | |
3309 | Background zebra stripes in your PostScript code. | |
3310 | ||
3311 | * Duplex: | |
3312 | Duplex printing (if your PostScript printer has this feature). | |
3313 | ||
3314 | * Tumble: | |
3315 | If duplex printing is on, you can choose if you want to have a | |
3316 | printing suitable for binding on the left or right (tumble off), or to | |
3317 | have a printing suitable for binding at top or bottom (tumble on). | |
3318 | ||
3319 | * Upside-Down: | |
3320 | PostScript upside-down printing. | |
3321 | ||
3322 | 4b. Second column (middle column): | |
3323 | ||
3324 | * Auto Region: | |
3325 | If you want that region is automagically detected, turn on this | |
3326 | option. Note that this will only work if you're using transient mark | |
3327 | mode. When this option is on, the `*-buffer*' commands will behave | |
3328 | like `*-region*' commands, that is, `*-buffer*' commands will print | |
3329 | only the region marked instead of all buffer. | |
3330 | ||
3331 | * Auto Mode: | |
3332 | Turn this option on if you want that when current major-mode is | |
3333 | declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands | |
3334 | behave like `*-mode*' commands. | |
3335 | ||
3336 | * Menu Lock: | |
449cba44 | 3337 | If you want that Printing menu stays open while you are setting |
2c840b90 KS |
3338 | toggle options, turn on this option. The variables |
3339 | `pr-menu-char-height' and `pr-menu-char-width' are used to guess the | |
3340 | menu position, so don't forget to adjust these variables if menu | |
3341 | position is not ok. | |
3342 | ||
3343 | * Spool Buffer: | |
3344 | To spool the PostScript code generated. You can despool later by | |
3345 | setting Despool option on PostScript printer section. | |
3346 | ||
449cba44 | 3347 | * Print with faces: |
2c840b90 KS |
3348 | If you use colors in your buffers and want to see these colors on your |
3349 | PostScript code generated, turn on this option. If you have a | |
3350 | black/white PostScript printer, these colors are displayed in gray | |
3351 | scale by PostScript printer interpreter. | |
3352 | ||
449cba44 | 3353 | * Print via Ghostscript: |
2c840b90 KS |
3354 | If you don't have a PostScript printer to send PostScript files, turn |
3355 | on this option. When this option is on, the ghostscript is used to | |
3356 | print PostScript files. In GNU or Unix system, if ghostscript is set | |
3357 | as a PostScript filter, you don't need to turn on this option. | |
3358 | ||
3359 | * Parity Page Menu: | |
3360 | To print all pages, odd pages, even pages, odd sheets or even sheets. | |
3361 | See also `ps-even-or-odd-pages'. | |
3362 | ||
3363 | 4c. Third column (right column): | |
3364 | ||
3365 | * Verbose: | |
3366 | That is, to be verbose when editing a field in interface buffer. | |
3367 | ||
3368 | 5. Customize: | |
3369 | ||
3370 | Besides all options in section 4, you can customize much more PostScript | |
3371 | options in `ps-print' option. Or you can customize some `lpr' options for | |
3372 | text printing. Or customize `printing' options. | |
3373 | ||
3374 | 6. Show settings: | |
3375 | ||
3376 | Show current settings for `printing', `ps-print' or `lpr'. | |
3377 | ||
3378 | 7. Help: | |
3379 | ||
3380 | Quick help for printing interface buffer and printing menu layout. You can | |
3381 | also quit the printing interface buffer or kill all printing help buffer. | |
3382 | ") | |
3383 | "Printing buffer interface help message.") | |
3384 | ||
3385 | ||
3386 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3387 | ;; Commands | |
3388 | ||
3389 | ||
3390 | ;;;###autoload | |
3391 | (defun pr-interface (&optional buffer) | |
3392 | "Activate the printing interface buffer. | |
3393 | ||
449cba44 | 3394 | If BUFFER is nil, the current buffer is used for printing. |
2c840b90 | 3395 | |
449cba44 | 3396 | For more information, type \\[pr-interface-help]." |
2c840b90 KS |
3397 | (interactive) |
3398 | (save-excursion | |
3399 | (set-buffer (or buffer (current-buffer))) | |
3400 | (pr-create-interface))) | |
3401 | ||
3402 | ||
3403 | ;;;###autoload | |
3404 | (defun pr-ps-directory-preview (n-up dir file-regexp &optional filename) | |
3405 | "Preview directory using ghostview. | |
3406 | ||
3407 | Interactively, the command prompts for N-UP printing number, a directory, a | |
3408 | file name regexp for matching and, when you use a prefix argument (C-u), the | |
3409 | command prompts the user for a file name, and saves the PostScript image in | |
3410 | that file instead of saving it in a temporary file. | |
3411 | ||
3412 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is | |
3413 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for | |
3414 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, | |
3415 | save the image in a temporary file. If FILENAME is a string, save the | |
3416 | PostScript image in a file with that name. If FILENAME is t, prompts for a | |
3417 | file name. | |
3418 | ||
3419 | See also documentation for `pr-list-directory'." | |
3420 | (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir"))) | |
3421 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename | |
3422 | (pr-prompt "PS preview dir")) | |
3423 | (setq filename (pr-ps-file filename)) | |
3424 | (pr-ps-file-list n-up dir file-regexp filename) | |
3425 | (or pr-spool-p | |
3426 | (pr-ps-file-preview filename))) | |
3427 | ||
3428 | ||
3429 | ;;;###autoload | |
3430 | (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp &optional filename) | |
3431 | "Print directory using PostScript through ghostscript. | |
3432 | ||
3433 | Interactively, the command prompts for N-UP printing number, a directory, a | |
3434 | file name regexp for matching and, when you use a prefix argument (C-u), the | |
3435 | command prompts the user for a file name, and saves the PostScript image in | |
3436 | that file instead of saving it in a temporary file. | |
3437 | ||
3438 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is | |
3439 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for | |
3440 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, | |
3441 | save the image in a temporary file. If FILENAME is a string, save the | |
3442 | PostScript image in a file with that name. If FILENAME is t, prompts for a | |
3443 | file name. | |
3444 | ||
3445 | See also documentation for `pr-list-directory'." | |
3446 | (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS"))) | |
3447 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename | |
3448 | (pr-prompt "PS print dir GS")) | |
3449 | (let ((file (pr-ps-file filename))) | |
3450 | (pr-ps-file-list n-up dir file-regexp file) | |
3451 | (pr-ps-file-using-ghostscript file) | |
3452 | (or filename (pr-delete-file file)))) | |
3453 | ||
3454 | ||
3455 | ;;;###autoload | |
3456 | (defun pr-ps-directory-print (n-up dir file-regexp &optional filename) | |
3457 | "Print directory using PostScript printer. | |
3458 | ||
3459 | Interactively, the command prompts for N-UP printing number, a directory, a | |
3460 | file name regexp for matching and, when you use a prefix argument (C-u), the | |
3461 | command prompts the user for a file name, and saves the PostScript image in | |
3462 | that file instead of saving it in a temporary file. | |
3463 | ||
3464 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is | |
3465 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for | |
3466 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, | |
3467 | save the image in a temporary file. If FILENAME is a string, save the | |
3468 | PostScript image in a file with that name. If FILENAME is t, prompts for a | |
3469 | file name. | |
3470 | ||
3471 | See also documentation for `pr-list-directory'." | |
3472 | (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir"))) | |
3473 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename | |
3474 | (pr-prompt "PS print dir")) | |
3475 | (let ((file (pr-ps-file filename))) | |
3476 | (pr-ps-file-list n-up dir file-regexp file) | |
3477 | (pr-ps-file-print file) | |
3478 | (or filename (pr-delete-file file)))) | |
3479 | ||
3480 | ||
3481 | ;;;###autoload | |
3482 | (defun pr-ps-directory-ps-print (n-up dir file-regexp &optional filename) | |
3483 | "Print directory using PostScript printer or through ghostscript. | |
3484 | ||
3485 | It depends on `pr-print-using-ghostscript'. | |
3486 | ||
3487 | Interactively, the command prompts for N-UP printing number, a directory, a | |
3488 | file name regexp for matching and, when you use a prefix argument (C-u), the | |
3489 | command prompts the user for a file name, and saves the PostScript image in | |
3490 | that file instead of saving it in a temporary file. | |
3491 | ||
3492 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is | |
3493 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for | |
3494 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, | |
3495 | save the image in a temporary file. If FILENAME is a string, save the | |
3496 | PostScript image in a file with that name. If FILENAME is t, prompts for a | |
3497 | file name. | |
3498 | ||
3499 | See also documentation for `pr-list-directory'." | |
3500 | (interactive (pr-interactive-ps-dir-args | |
3501 | (pr-prompt (pr-prompt-gs "PS print dir")))) | |
3502 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename | |
3503 | (pr-prompt (pr-prompt-gs "PS print dir"))) | |
3504 | (if (pr-using-ghostscript-p) | |
3505 | (pr-ps-directory-using-ghostscript n-up dir file-regexp filename) | |
3506 | (pr-ps-directory-print n-up dir file-regexp filename))) | |
3507 | ||
3508 | ||
3509 | ;;;###autoload | |
3510 | (defun pr-ps-buffer-preview (n-up &optional filename) | |
3511 | "Preview buffer using ghostview. | |
3512 | ||
3513 | Interactively, the command prompts for N-UP printing number and, when you use a | |
3514 | prefix argument (C-u), the command prompts the user for a file name, and saves | |
3515 | the PostScript image in that file instead of saving it in a temporary file. | |
3516 | ||
3517 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The | |
3518 | argument FILENAME is treated as follows: if it's nil, save the image in a | |
3519 | temporary file. If FILENAME is a string, save the PostScript image in a file | |
3520 | with that name. If FILENAME is t, prompts for a file name." | |
3521 | (interactive (pr-interactive-n-up-file (pr-prompt "PS preview"))) | |
3522 | (if (pr-auto-mode-p) | |
3523 | (pr-ps-mode-preview n-up filename) | |
3524 | (pr-ps-preview (pr-region-active-symbol) n-up filename | |
3525 | (pr-region-active-string "PS preview")))) | |
3526 | ||
3527 | ||
3528 | ;;;###autoload | |
3529 | (defun pr-ps-buffer-using-ghostscript (n-up &optional filename) | |
3530 | "Print buffer using PostScript through ghostscript. | |
3531 | ||
3532 | Interactively, the command prompts for N-UP printing number and, when you use a | |
3533 | prefix argument (C-u), the command prompts the user for a file name, and saves | |
3534 | the PostScript image in that file instead of sending it to the printer. | |
3535 | ||
3536 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The | |
3537 | argument FILENAME is treated as follows: if it's nil, send the image to the | |
3538 | printer. If FILENAME is a string, save the PostScript image in a file with | |
3539 | that name. If FILENAME is t, prompts for a file name." | |
3540 | (interactive (pr-interactive-n-up-file (pr-prompt "PS print GS"))) | |
3541 | (if (pr-auto-mode-p) | |
3542 | (pr-ps-mode-using-ghostscript n-up filename) | |
3543 | (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename | |
3544 | (pr-region-active-string "PS print GS")))) | |
3545 | ||
3546 | ||
3547 | ;;;###autoload | |
3548 | (defun pr-ps-buffer-print (n-up &optional filename) | |
3549 | "Print buffer using PostScript printer. | |
3550 | ||
3551 | Interactively, the command prompts for N-UP printing number and, when you use a | |
3552 | prefix argument (C-u), the command prompts the user for a file name, and saves | |
3553 | the PostScript image in that file instead of sending it to the printer. | |
3554 | ||
3555 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The | |
3556 | argument FILENAME is treated as follows: if it's nil, send the image to the | |
3557 | printer. If FILENAME is a string, save the PostScript image in a file with | |
3558 | that name. If FILENAME is t, prompts for a file name." | |
3559 | (interactive (pr-interactive-n-up-file (pr-prompt "PS print"))) | |
3560 | (if (pr-auto-mode-p) | |
3561 | (pr-ps-mode-print n-up filename) | |
3562 | (pr-ps-print (pr-region-active-symbol) n-up filename | |
3563 | (pr-region-active-string "PS print")))) | |
3564 | ||
3565 | ||
3566 | ;;;###autoload | |
3567 | (defun pr-ps-buffer-ps-print (n-up &optional filename) | |
3568 | "Print buffer using PostScript printer or through ghostscript. | |
3569 | ||
3570 | It depends on `pr-print-using-ghostscript'. | |
3571 | ||
3572 | Interactively, the command prompts for N-UP printing number and, when you use a | |
3573 | prefix argument (C-u), the command prompts the user for a file name, and saves | |
3574 | the PostScript image in that file instead of sending it to the printer. | |
3575 | ||
3576 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The | |
3577 | argument FILENAME is treated as follows: if it's nil, send the image to the | |
3578 | printer. If FILENAME is a string, save the PostScript image in a file with | |
3579 | that name. If FILENAME is t, prompts for a file name." | |
3580 | (interactive (pr-interactive-n-up-file | |
3581 | (pr-prompt (pr-prompt-gs "PS print")))) | |
3582 | (cond ((pr-auto-mode-p) | |
3583 | (pr-ps-mode-ps-print n-up filename)) | |
3584 | ((pr-using-ghostscript-p) | |
3585 | (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename | |
3586 | (pr-region-active-string "PS print GS"))) | |
3587 | (t | |
3588 | (pr-ps-print (pr-region-active-symbol) n-up filename | |
3589 | (pr-region-active-string "PS print"))))) | |
3590 | ||
3591 | ||
3592 | ;;;###autoload | |
3593 | (defun pr-ps-region-preview (n-up &optional filename) | |
3594 | "Preview region using ghostview. | |
3595 | ||
3596 | See also `pr-ps-buffer-preview'." | |
3597 | (interactive (pr-interactive-n-up-file (pr-prompt-region "PS preview"))) | |
3598 | (if (pr-auto-mode-p) | |
3599 | (let ((pr-auto-region t)) | |
3600 | (pr-ps-mode-preview n-up filename)) | |
3601 | (pr-ps-preview 'region n-up filename "PS preview region"))) | |
3602 | ||
3603 | ||
3604 | ;;;###autoload | |
3605 | (defun pr-ps-region-using-ghostscript (n-up &optional filename) | |
3606 | "Print region using PostScript through ghostscript. | |
3607 | ||
3608 | See also `pr-ps-buffer-using-ghostscript'." | |
3609 | (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print GS"))) | |
3610 | (if (pr-auto-mode-p) | |
3611 | (let ((pr-auto-region t)) | |
3612 | (pr-ps-mode-using-ghostscript n-up filename)) | |
3613 | (pr-ps-using-ghostscript 'region n-up filename "PS print GS region"))) | |
3614 | ||
3615 | ||
3616 | ;;;###autoload | |
3617 | (defun pr-ps-region-print (n-up &optional filename) | |
3618 | "Print region using PostScript printer. | |
3619 | ||
3620 | See also `pr-ps-buffer-print'." | |
3621 | (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print"))) | |
3622 | (if (pr-auto-mode-p) | |
3623 | (let ((pr-auto-region t)) | |
3624 | (pr-ps-mode-print n-up filename)) | |
3625 | (pr-ps-print 'region n-up filename "PS print region"))) | |
3626 | ||
3627 | ||
3628 | ;;;###autoload | |
3629 | (defun pr-ps-region-ps-print (n-up &optional filename) | |
3630 | "Print region using PostScript printer or through ghostscript. | |
3631 | ||
3632 | See also `pr-ps-buffer-ps-print'." | |
3633 | (interactive (pr-interactive-n-up-file | |
3634 | (pr-prompt-region (pr-prompt-gs "PS print")))) | |
3635 | (cond ((pr-auto-mode-p) | |
3636 | (let ((pr-auto-region t)) | |
3637 | (pr-ps-mode-ps-print n-up filename))) | |
3638 | ((pr-using-ghostscript-p) | |
3639 | (pr-ps-using-ghostscript 'region n-up filename "PS print GS region")) | |
3640 | (t | |
3641 | (pr-ps-print 'region n-up filename "PS print region")))) | |
3642 | ||
3643 | ||
3644 | ;;;###autoload | |
3645 | (defun pr-ps-mode-preview (n-up &optional filename) | |
3646 | "Preview major mode using ghostview. | |
3647 | ||
3648 | See also `pr-ps-buffer-preview'." | |
3649 | (interactive (pr-interactive-n-up-file "PS preview mode")) | |
3650 | (pr-set-n-up-and-filename 'n-up 'filename "PS preview mode") | |
3651 | (let ((file (pr-ps-file filename))) | |
3652 | (and (pr-ps-mode n-up file) | |
3653 | (not pr-spool-p) | |
3654 | (pr-ps-file-preview file)))) | |
3655 | ||
3656 | ||
3657 | ;;;###autoload | |
3658 | (defun pr-ps-mode-using-ghostscript (n-up &optional filename) | |
3659 | "Print major mode using PostScript through ghostscript. | |
3660 | ||
3661 | See also `pr-ps-buffer-using-ghostscript'." | |
3662 | (interactive (pr-interactive-n-up-file "PS print GS mode")) | |
3663 | (pr-set-n-up-and-filename 'n-up 'filename "PS print GS mode") | |
3664 | (let ((file (pr-ps-file filename))) | |
3665 | (when (and (pr-ps-mode n-up file) | |
3666 | (not pr-spool-p)) | |
3667 | (pr-ps-file-using-ghostscript file) | |
3668 | (or filename (pr-delete-file file))))) | |
3669 | ||
3670 | ||
3671 | ;;;###autoload | |
3672 | (defun pr-ps-mode-print (n-up &optional filename) | |
3673 | "Print major mode using PostScript printer. | |
3674 | ||
3675 | See also `pr-ps-buffer-print'." | |
3676 | (interactive (pr-interactive-n-up-file "PS print mode")) | |
3677 | (pr-set-n-up-and-filename 'n-up 'filename "PS print mode") | |
3678 | (pr-ps-mode n-up filename)) | |
3679 | ||
3680 | ||
3681 | ;;;###autoload | |
3682 | (defun pr-ps-mode-ps-print (n-up &optional filename) | |
3683 | "Print major mode using PostScript or through ghostscript. | |
3684 | ||
3685 | See also `pr-ps-buffer-ps-print'." | |
3686 | (interactive (pr-interactive-n-up-file (pr-prompt-gs "PS print mode"))) | |
3687 | (if (pr-using-ghostscript-p) | |
3688 | (pr-ps-mode-using-ghostscript n-up filename) | |
3689 | (pr-ps-mode-print n-up filename))) | |
3690 | ||
3691 | ||
3692 | ;;;###autoload | |
3693 | (defun pr-printify-directory (&optional dir file-regexp) | |
3694 | "Replace nonprinting characters in directory with printable representations. | |
3695 | The printable representations use ^ (for ASCII control characters) or hex. | |
3696 | The characters tab, linefeed, space, return and formfeed are not affected. | |
3697 | ||
3698 | Interactively, the command prompts for a directory and a file name regexp for | |
3699 | matching. | |
3700 | ||
3701 | Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil, | |
3702 | prompts for FILE(name)-REGEXP. | |
3703 | ||
3704 | See also documentation for `pr-list-directory'." | |
3705 | (interactive (pr-interactive-dir-args "Printify dir")) | |
3706 | (pr-set-dir-args 'dir 'file-regexp "Printify dir") | |
3707 | (pr-file-list dir file-regexp 'pr-printify-buffer)) | |
3708 | ||
3709 | ||
3710 | ;;;###autoload | |
3711 | (defun pr-printify-buffer () | |
3712 | "Replace nonprinting characters in buffer with printable representations. | |
3713 | The printable representations use ^ (for ASCII control characters) or hex. | |
3714 | The characters tab, linefeed, space, return and formfeed are not affected." | |
3715 | (interactive "*") | |
3716 | (if (pr-region-active-p) | |
3717 | (pr-printify-region) | |
3718 | (printify-region (point-min) (point-max)))) | |
3719 | ||
3720 | ||
3721 | ;;;###autoload | |
3722 | (defun pr-printify-region () | |
3723 | "Replace nonprinting characters in region with printable representations. | |
3724 | The printable representations use ^ (for ASCII control characters) or hex. | |
3725 | The characters tab, linefeed, space, return and formfeed are not affected." | |
3726 | (interactive "*") | |
3727 | (printify-region (point) (mark))) | |
3728 | ||
3729 | ||
3730 | ;;;###autoload | |
3731 | (defun pr-txt-directory (&optional dir file-regexp) | |
3732 | "Print directory using text printer. | |
3733 | ||
3734 | Interactively, the command prompts for a directory and a file name regexp for | |
3735 | matching. | |
3736 | ||
3737 | Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil, | |
3738 | prompts for FILE(name)-REGEXP. | |
3739 | ||
3740 | See also documentation for `pr-list-directory'." | |
3741 | (interactive (pr-interactive-dir-args "Print dir")) | |
3742 | (pr-set-dir-args 'dir 'file-regexp "Print dir") | |
3743 | (pr-file-list dir file-regexp 'pr-txt-buffer)) | |
3744 | ||
3745 | ||
3746 | ;;;###autoload | |
3747 | (defun pr-txt-buffer () | |
3748 | "Print buffer using text printer." | |
3749 | (interactive) | |
3750 | (cond ((pr-auto-mode-p) | |
3751 | (pr-txt-mode)) | |
3752 | ((pr-region-active-p) | |
3753 | (pr-txt-region)) | |
3754 | (t | |
3755 | (pr-txt-print (point-min) (point-max))))) | |
3756 | ||
3757 | ||
3758 | ;;;###autoload | |
3759 | (defun pr-txt-region () | |
3760 | "Print region using text printer." | |
3761 | (interactive) | |
3762 | (if (pr-auto-mode-p) | |
3763 | (let ((pr-auto-region t)) | |
3764 | (pr-txt-mode)) | |
3765 | (pr-txt-print (point) (mark)))) | |
3766 | ||
3767 | ||
3768 | ;;;###autoload | |
3769 | (defun pr-txt-mode () | |
3770 | "Print major mode using text printer." | |
3771 | (interactive) | |
3772 | (let ((args (pr-mode-alist-p))) | |
3773 | (if args | |
3774 | (funcall (car args) (nthcdr 2 args)) | |
3775 | (ding) | |
3776 | (message "`%s' major mode not declared." major-mode)))) | |
3777 | ||
3778 | ||
3779 | ;;;###autoload | |
3780 | (defun pr-despool-preview (&optional filename) | |
3781 | "Preview spooled PostScript. | |
3782 | ||
3783 | Interactively, when you use a prefix argument (C-u), the command prompts the | |
3784 | user for a file name, and saves the spooled PostScript image in that file | |
3785 | instead of saving it in a temporary file. | |
3786 | ||
3787 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, | |
3788 | save the image in a temporary file. If FILENAME is a string, save the | |
3789 | PostScript image in a file with that name." | |
3790 | (interactive (list (ps-print-preprint current-prefix-arg))) | |
3791 | (let ((file (pr-ps-file filename))) | |
3792 | (when (stringp file) | |
3793 | (pr-despool-print file) | |
3794 | (pr-ps-file-preview file)))) | |
3795 | ||
3796 | ||
3797 | ;;;###autoload | |
3798 | (defun pr-despool-using-ghostscript (&optional filename) | |
3799 | "Print spooled PostScript using ghostscript. | |
3800 | ||
3801 | Interactively, when you use a prefix argument (C-u), the command prompts the | |
3802 | user for a file name, and saves the spooled PostScript image in that file | |
3803 | instead of sending it to the printer. | |
3804 | ||
3805 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, | |
3806 | send the image to the printer. If FILENAME is a string, save the PostScript | |
3807 | image in a file with that name." | |
3808 | (interactive (list (ps-print-preprint current-prefix-arg))) | |
3809 | (let ((file (pr-ps-file filename))) | |
3810 | (when (stringp file) | |
3811 | (pr-despool-print file) | |
3812 | (pr-ps-file-using-ghostscript file) | |
3813 | (or filename (pr-delete-file file))))) | |
3814 | ||
3815 | ||
3816 | ;;;###autoload | |
3817 | (defun pr-despool-print (&optional filename) | |
3818 | "Send the spooled PostScript to the printer. | |
3819 | ||
3820 | Interactively, when you use a prefix argument (C-u), the command prompts the | |
3821 | user for a file name, and saves the spooled PostScript image in that file | |
3822 | instead of sending it to the printer. | |
3823 | ||
3824 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, | |
3825 | send the image to the printer. If FILENAME is a string, save the PostScript | |
3826 | image in a file with that name." | |
3827 | (interactive (list (ps-print-preprint current-prefix-arg))) | |
3828 | (let ((ps-lpr-command (pr-command pr-ps-command)) | |
3829 | (ps-lpr-switches pr-ps-switches) | |
3830 | (ps-printer-name-option pr-ps-printer-switch) | |
3831 | (ps-printer-name pr-ps-printer)) | |
3832 | (ps-despool filename))) | |
3833 | ||
3834 | ||
3835 | ;;;###autoload | |
3836 | (defun pr-despool-ps-print (&optional filename) | |
3837 | "Send the spooled PostScript to the printer or use ghostscript to print it. | |
3838 | ||
3839 | Interactively, when you use a prefix argument (C-u), the command prompts the | |
3840 | user for a file name, and saves the spooled PostScript image in that file | |
3841 | instead of sending it to the printer. | |
3842 | ||
3843 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, | |
3844 | send the image to the printer. If FILENAME is a string, save the PostScript | |
3845 | image in a file with that name." | |
3846 | (interactive (list (ps-print-preprint current-prefix-arg))) | |
3847 | (if pr-print-using-ghostscript | |
3848 | (pr-despool-using-ghostscript filename) | |
3849 | (pr-despool-print filename))) | |
3850 | ||
3851 | ||
3852 | ;;;###autoload | |
3853 | (defun pr-ps-file-preview (filename) | |
3854 | "Preview PostScript file FILENAME." | |
3855 | (interactive (list (pr-ps-infile-preprint "Preview "))) | |
3856 | (and (stringp filename) (file-exists-p filename) | |
45f17557 | 3857 | (pr-call-process pr-gv-command filename))) |
2c840b90 KS |
3858 | |
3859 | ||
3860 | ;;;###autoload | |
3861 | (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename) | |
3862 | "Preview PostScript file FILENAME." | |
3863 | (interactive (pr-interactive-n-up-inout "PS preview")) | |
3864 | (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename | |
3865 | "PS preview "))) | |
3866 | (pr-ps-utility-process n-up ifilename outfile) | |
3867 | (pr-ps-file-preview outfile))) | |
3868 | ||
3869 | ||
3870 | ;;;###autoload | |
3871 | (defun pr-ps-file-using-ghostscript (filename) | |
3872 | "Print PostScript file FILENAME using ghostscript." | |
3873 | (interactive (list (pr-ps-infile-preprint "Print preview "))) | |
3874 | (and (stringp filename) (file-exists-p filename) | |
3875 | (let* ((file (pr-expand-file-name filename)) | |
0117451d | 3876 | (tempfile (pr-dosify-file-name (make-temp-name file)))) |
2c840b90 | 3877 | ;; gs use |
45f17557 VJL |
3878 | (pr-call-process pr-gs-command |
3879 | (format "-sDEVICE=%s" pr-gs-device) | |
3880 | (format "-r%d" pr-gs-resolution) | |
3881 | (pr-switches-string pr-gs-switches "pr-gs-switches") | |
3882 | (format "-sOutputFile=\"%s\"" tempfile) | |
3883 | file | |
3884 | "-c quit") | |
2c840b90 KS |
3885 | ;; printing |
3886 | (pr-ps-file-print tempfile) | |
3887 | ;; deleting | |
3888 | (pr-delete-file tempfile)))) | |
3889 | ||
3890 | ||
3891 | ;;;###autoload | |
3892 | (defun pr-ps-file-print (filename) | |
3893 | "Print PostScript file FILENAME." | |
3894 | (interactive (list (pr-ps-infile-preprint "Print "))) | |
3895 | (and (stringp filename) (file-exists-p filename) | |
3896 | ;; printing | |
3897 | (let ((file (pr-expand-file-name filename))) | |
449cba44 | 3898 | (if (string= pr-ps-command "") |
2c840b90 KS |
3899 | (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name))) |
3900 | (save-excursion | |
3901 | (set-buffer ps-spool-buffer) | |
3902 | (erase-buffer) | |
3903 | (insert-file-contents-literally file)) | |
3904 | (pr-despool-print)) | |
45f17557 VJL |
3905 | (apply 'pr-call-process |
3906 | pr-ps-command | |
3907 | (pr-switches-string pr-ps-switches "pr-gs-switches") | |
3908 | (if (string-match "cp" pr-ps-command) | |
3909 | ;; for "cp" (cmd in out) | |
3910 | (list file | |
3911 | (concat pr-ps-printer-switch pr-ps-printer)) | |
3912 | ;; else, for others (cmd out in) | |
3913 | (list (concat pr-ps-printer-switch pr-ps-printer) | |
3914 | file))))))) | |
2c840b90 KS |
3915 | |
3916 | ||
3917 | ;;;###autoload | |
3918 | (defun pr-ps-file-ps-print (filename) | |
3919 | "Send PostScript file FILENAME to printer or use ghostscript to print it." | |
3920 | (interactive (list (pr-ps-infile-preprint | |
3921 | (if pr-print-using-ghostscript | |
3922 | "Print preview " | |
3923 | "Print ")))) | |
3924 | (if pr-print-using-ghostscript | |
3925 | (pr-ps-file-using-ghostscript filename) | |
3926 | (pr-ps-file-print filename))) | |
3927 | ||
3928 | ||
3929 | ;;;###autoload | |
3930 | (defun pr-ps-file-up-ps-print (n-up ifilename &optional ofilename) | |
3931 | "Process a PostScript file IFILENAME and send it to printer. | |
3932 | ||
3933 | Interactively, the command prompts for N-UP printing number, for an input | |
3934 | PostScript file IFILENAME and, when you use a prefix argument (C-u), the | |
3935 | command prompts the user for an output PostScript file name OFILENAME, and | |
3936 | saves the PostScript image in that file instead of sending it to the printer. | |
3937 | ||
3938 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The | |
3939 | argument IFILENAME is treated as follows: if it's t, prompts for an input | |
3940 | PostScript file name; otherwise, it *must* be a string that it's an input | |
3941 | PostScript file name. The argument OFILENAME is treated as follows: if it's | |
3942 | nil, send the image to the printer. If OFILENAME is a string, save the | |
3943 | PostScript image in a file with that name. If OFILENAME is t, prompts for a | |
3944 | file name." | |
3945 | (interactive (pr-interactive-n-up-inout | |
3946 | (if pr-print-using-ghostscript | |
3947 | "PS print GS" | |
3948 | "PS print"))) | |
3949 | (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename | |
3950 | (if pr-print-using-ghostscript | |
3951 | "PS print GS " | |
3952 | "PS print ")))) | |
3953 | (pr-ps-utility-process n-up ifilename outfile) | |
3954 | (unless ofilename | |
3955 | (pr-ps-file-ps-print outfile) | |
3956 | (pr-delete-file outfile)))) | |
3957 | ||
3958 | ||
3959 | ;;;###autoload | |
3960 | (defun pr-toggle-file-duplex () | |
3961 | "Toggle duplex for PostScript file." | |
3962 | (interactive) | |
3963 | (pr-toggle 'pr-file-duplex "PS file duplex" nil 7 5 nil | |
3964 | '("PostScript Print" "File"))) | |
3965 | ||
3966 | ||
3967 | ;;;###autoload | |
3968 | (defun pr-toggle-file-tumble () | |
3969 | "Toggle tumble for PostScript file. | |
3970 | ||
3971 | If tumble is off, produces a printing suitable for binding on the left or | |
3972 | right. | |
3973 | If tumble is on, produces a printing suitable for binding at the top or | |
3974 | bottom." | |
3975 | (interactive) | |
3976 | (pr-toggle 'pr-file-tumble "PS file tumble" nil 8 5 nil | |
3977 | '("PostScript Print" "File"))) | |
3978 | ||
3979 | ||
3980 | ;;;###autoload | |
3981 | (defun pr-toggle-file-landscape () | |
3982 | "Toggle landscape for PostScript file." | |
3983 | (interactive) | |
3984 | (pr-toggle 'pr-file-landscape "PS file landscape" nil 6 5 nil | |
3985 | '("PostScript Print" "File"))) | |
3986 | ||
3987 | ||
3988 | ;;;###autoload | |
3989 | (defun pr-toggle-ghostscript () | |
3990 | "Toggle printing using ghostscript." | |
3991 | (interactive) | |
3992 | (pr-toggle 'pr-print-using-ghostscript "Printing using ghostscript" | |
3993 | 'postscript-process 2 12 'toggle)) | |
3994 | ||
3995 | ||
3996 | ;;;###autoload | |
3997 | (defun pr-toggle-faces () | |
3998 | "Toggle printing with faces." | |
3999 | (interactive) | |
449cba44 | 4000 | (pr-toggle 'pr-faces-p "Printing with faces" |
2c840b90 KS |
4001 | 'postscript-process 1 12 'toggle)) |
4002 | ||
4003 | ||
4004 | ;;;###autoload | |
4005 | (defun pr-toggle-spool () | |
4006 | "Toggle spooling." | |
4007 | (interactive) | |
4008 | (pr-toggle 'pr-spool-p "Spooling printing" | |
4009 | 'postscript-process 0 12 'toggle)) | |
4010 | ||
4011 | ||
4012 | ;;;###autoload | |
4013 | (defun pr-toggle-duplex () | |
4014 | "Toggle duplex." | |
4015 | (interactive) | |
4016 | (pr-toggle 'ps-spool-duplex "Printing duplex" | |
4017 | 'postcsript-options 5 12 'toggle)) | |
4018 | ||
4019 | ||
4020 | ;;;###autoload | |
4021 | (defun pr-toggle-tumble () | |
4022 | "Toggle tumble. | |
4023 | ||
4024 | If tumble is off, produces a printing suitable for binding on the left or | |
4025 | right. | |
4026 | If tumble is on, produces a printing suitable for binding at the top or | |
4027 | bottom." | |
4028 | (interactive) | |
4029 | (pr-toggle 'ps-spool-tumble "Tumble" | |
4030 | 'postscript-options 6 12 'toggle)) | |
4031 | ||
4032 | ||
4033 | ;;;###autoload | |
4034 | (defun pr-toggle-landscape () | |
4035 | "Toggle landscape." | |
4036 | (interactive) | |
4037 | (pr-toggle 'ps-landscape-mode "Landscape" | |
4038 | 'postscript-options 0 12 'toggle)) | |
4039 | ||
4040 | ||
4041 | ;;;###autoload | |
4042 | (defun pr-toggle-upside-down () | |
4043 | "Toggle upside-down." | |
4044 | (interactive) | |
4045 | (pr-toggle 'ps-print-upside-down "Upside-Down" | |
4046 | 'postscript-options 7 12 'toggle)) | |
4047 | ||
4048 | ||
4049 | ;;;###autoload | |
4050 | (defun pr-toggle-line () | |
4051 | "Toggle line number." | |
4052 | (interactive) | |
4053 | (pr-toggle 'ps-line-number "Line number" | |
4054 | 'postscript-options 3 12 'toggle)) | |
4055 | ||
4056 | ||
4057 | ;;;###autoload | |
4058 | (defun pr-toggle-zebra () | |
4059 | "Toggle zebra stripes." | |
4060 | (interactive) | |
4061 | (pr-toggle 'ps-zebra-stripes "Zebra stripe" | |
4062 | 'postscript-options 4 12 'toggle)) | |
4063 | ||
4064 | ||
4065 | ;;;###autoload | |
4066 | (defun pr-toggle-header () | |
4067 | "Toggle printing header." | |
4068 | (interactive) | |
4069 | (pr-toggle 'ps-print-header "Print header" | |
4070 | 'postscript-options 1 12 'toggle)) | |
4071 | ||
4072 | ||
4073 | ;;;###autoload | |
4074 | (defun pr-toggle-header-frame () | |
4075 | "Toggle printing header frame." | |
4076 | (interactive) | |
4077 | (pr-toggle 'ps-print-header-frame "Print header frame" | |
4078 | 'postscript-options 2 12 'toggle)) | |
4079 | ||
4080 | ||
4081 | ;;;###autoload | |
4082 | (defun pr-toggle-lock () | |
4083 | "Toggle menu lock." | |
4084 | (interactive) | |
4085 | (pr-toggle 'pr-menu-lock "Menu lock" | |
4086 | 'printing 2 12 'toggle)) | |
4087 | ||
4088 | ||
4089 | ;;;###autoload | |
4090 | (defun pr-toggle-region () | |
4091 | "Toggle auto region." | |
4092 | (interactive) | |
4093 | (pr-toggle 'pr-auto-region "Auto region" | |
4094 | 'printing 0 12 'toggle)) | |
4095 | ||
4096 | ||
4097 | ;;;###autoload | |
4098 | (defun pr-toggle-mode () | |
4099 | "Toggle auto mode." | |
4100 | (interactive) | |
4101 | (pr-toggle 'pr-auto-mode "Auto mode" | |
4102 | 'printing 1 12 'toggle)) | |
4103 | ||
4104 | ||
4105 | ;;;###autoload | |
4106 | (defun pr-customize (&rest ignore) | |
449cba44 | 4107 | "Customization of the `printing' group." |
2c840b90 KS |
4108 | (interactive) |
4109 | (customize-group 'printing)) | |
4110 | ||
4111 | ||
4112 | ;;;###autoload | |
4113 | (defun lpr-customize (&rest ignore) | |
449cba44 | 4114 | "Customization of the `lpr' group." |
2c840b90 KS |
4115 | (interactive) |
4116 | (customize-group 'lpr)) | |
4117 | ||
4118 | ||
4119 | ;;;###autoload | |
4120 | (defun pr-help (&rest ignore) | |
449cba44 | 4121 | "Help for the printing package." |
2c840b90 KS |
4122 | (interactive) |
4123 | (pr-show-setup pr-help-message "*Printing Help*")) | |
4124 | ||
4125 | ||
4126 | ;;;###autoload | |
4127 | (defun pr-ps-name () | |
449cba44 | 4128 | "Interactively select a PostScript printer." |
2c840b90 KS |
4129 | (interactive) |
4130 | (pr-menu-set-ps-title | |
4131 | (pr-complete-alist "PostScript printer" pr-ps-printer-alist pr-ps-name))) | |
4132 | ||
4133 | ||
4134 | ;;;###autoload | |
4135 | (defun pr-txt-name () | |
449cba44 | 4136 | "Interactively select a text printer." |
2c840b90 KS |
4137 | (interactive) |
4138 | (pr-menu-set-txt-title | |
4139 | (pr-complete-alist "Text printer" pr-txt-printer-alist pr-txt-name))) | |
4140 | ||
4141 | ||
4142 | ;;;###autoload | |
4143 | (defun pr-ps-utility () | |
449cba44 | 4144 | "Interactively select a PostScript utility." |
2c840b90 KS |
4145 | (interactive) |
4146 | (pr-menu-set-utility-title | |
4147 | (pr-complete-alist "Postscript utility" pr-ps-utility-alist pr-ps-utility))) | |
4148 | ||
4149 | ||
4150 | ;;;###autoload | |
4151 | (defun pr-show-ps-setup (&rest ignore) | |
4152 | "Show current ps-print settings." | |
4153 | (interactive) | |
4154 | (pr-show-setup (ps-setup) "*PS Setup*")) | |
4155 | ||
4156 | ||
4157 | ;;;###autoload | |
4158 | (defun pr-show-pr-setup (&rest ignore) | |
4159 | "Show current printing settings." | |
4160 | (interactive) | |
4161 | (pr-show-setup (pr-setup) "*PR Setup*")) | |
4162 | ||
4163 | ||
4164 | ;;;###autoload | |
4165 | (defun pr-show-lpr-setup (&rest ignore) | |
4166 | "Show current lpr settings." | |
4167 | (interactive) | |
4168 | (pr-show-setup (lpr-setup) "*LPR Setup*")) | |
4169 | ||
4170 | ||
4171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4172 | ;; Fast Commands | |
4173 | ||
4174 | ||
4175 | ;;;###autoload | |
4176 | (defun pr-ps-fast-fire (n-up &optional select) | |
4177 | "Fast fire function for PostScript printing. | |
4178 | ||
4179 | If a region is active, the region will be printed instead of the whole buffer. | |
4180 | Also if the current major-mode is defined in `pr-mode-alist', the settings in | |
4181 | `pr-mode-alist' will be used, that is, the current buffer or region will be | |
4182 | printed using `pr-ps-mode-ps-print'. | |
4183 | ||
4184 | ||
4185 | Interactively, you have the following situations: | |
4186 | ||
4187 | M-x pr-ps-fast-fire RET | |
4188 | The command prompts the user for a N-UP value and printing will | |
4189 | immediatelly be done using the current active printer. | |
4190 | ||
4191 | C-u M-x pr-ps-fast-fire RET | |
4192 | C-u 0 M-x pr-ps-fast-fire RET | |
4193 | The command prompts the user for a N-UP value and also for a current | |
4194 | PostScript printer, then printing will immediatelly be done using the new | |
4195 | current active printer. | |
4196 | ||
4197 | C-u 1 M-x pr-ps-fast-fire RET | |
4198 | The command prompts the user for a N-UP value and also for a file name, | |
4199 | and saves the PostScript image in that file instead of sending it to the | |
4200 | printer. | |
4201 | ||
4202 | C-u 2 M-x pr-ps-fast-fire RET | |
4203 | The command prompts the user for a N-UP value, then for a current | |
4204 | PostScript printer and, finally, for a file name. Then change the active | |
4205 | printer to that choosen by user and saves the PostScript image in | |
4206 | that file instead of sending it to the printer. | |
4207 | ||
4208 | ||
4209 | Noninteractively, the argument N-UP should be a positive integer greater than | |
4210 | zero and the argument SELECT is treated as follows: | |
4211 | ||
4212 | If it's nil, send the image to the printer. | |
4213 | ||
4214 | If it's a list or an integer lesser or equal to zero, the command prompts | |
4215 | the user for a current PostScript printer, then printing will immediatelly | |
4216 | be done using the new current active printer. | |
4217 | ||
4218 | If it's an integer equal to 1, the command prompts the user for a file name | |
4219 | and saves the PostScript image in that file instead of sending it to the | |
4220 | printer. | |
4221 | ||
4222 | If it's an integer greater or equal to 2, the command prompts the user for a | |
4223 | current PostScript printer and for a file name. Then change the active | |
4224 | printer to that choosen by user and saves the PostScript image in that file | |
4225 | instead of sending it to the printer. | |
4226 | ||
4227 | If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new | |
4228 | active printer and printing will immediatelly be done using the new active | |
4229 | printer. | |
4230 | ||
4231 | Otherwise, send the image to the printer. | |
4232 | ||
4233 | ||
4234 | Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode' | |
4235 | are both set to t." | |
4236 | (interactive (list (pr-interactive-n-up (pr-prompt-gs "PS print fast")) | |
4237 | current-prefix-arg)) | |
4238 | (let ((pr-auto-region t) | |
4239 | (pr-auto-mode t) | |
4240 | filename) | |
4241 | (cond ((null select)) | |
4242 | ((listp select) | |
4243 | (pr-ps-name)) | |
4244 | ((and (symbolp select) | |
4245 | (assq select pr-ps-printer-alist)) | |
4246 | (pr-menu-set-ps-title select)) | |
4247 | ((integerp select) | |
4248 | (and (/= select 1) | |
4249 | (pr-ps-name)) | |
4250 | (and (>= select 1) (not pr-spool-p) | |
4251 | (setq filename (pr-ps-outfile-preprint | |
4252 | (if pr-print-using-ghostscript | |
4253 | "Fast GS " | |
4254 | "Fast ")))))) | |
4255 | (pr-ps-buffer-ps-print | |
4256 | (if (integerp n-up) | |
4257 | (min (max n-up 1) 100) | |
4258 | (error "n-up must be an integer greater than zero.")) | |
4259 | filename))) | |
4260 | ||
4261 | ||
4262 | ;;;###autoload | |
4263 | (defun pr-txt-fast-fire (&optional select-printer) | |
4264 | "Fast fire function for text printing. | |
4265 | ||
4266 | If a region is active, the region will be printed instead of the whole buffer. | |
4267 | Also if the current major-mode is defined in `pr-mode-alist', the settings in | |
4268 | `pr-mode-alist' will be used, that is, the current buffer or region will be | |
4269 | printed using `pr-txt-mode'. | |
4270 | ||
4271 | Interactively, when you use a prefix argument (C-u), the command prompts the | |
4272 | user for a new active text printer. | |
4273 | ||
4274 | Noninteractively, the argument SELECT-PRINTER is treated as follows: | |
4275 | ||
4276 | If it's nil, the printing is sent to the current active text printer. | |
4277 | ||
4278 | If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new | |
4279 | active printer and printing will immediatelly be done using the new active | |
4280 | printer. | |
4281 | ||
4282 | If it's non-nil, the command prompts the user for a new active text printer. | |
4283 | ||
4284 | Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode' | |
4285 | are both set to t." | |
4286 | (interactive (list current-prefix-arg)) | |
4287 | (cond ((null select-printer)) | |
4288 | ((and (symbolp select-printer) | |
4289 | (assq select-printer pr-txt-printer-alist)) | |
4290 | (pr-menu-set-txt-title select-printer)) | |
4291 | (t | |
4292 | (pr-txt-name))) | |
4293 | (let ((pr-auto-region t) | |
4294 | (pr-auto-mode t)) | |
4295 | (pr-txt-buffer))) | |
4296 | ||
4297 | ||
4298 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4299 | ;; Utilities | |
4300 | ||
4301 | ||
4302 | (defun pr-setup () | |
4303 | "Return the current `printing' setup. | |
4304 | ||
4305 | This is *not* an interactive command. | |
4306 | One way to see `printing' setup is to switch to a *Scratch* buffer and type: | |
4307 | ||
4308 | M-: (insert (pr-setup)) RET | |
4309 | ||
4310 | Or choose the menu option Printing/Show Settings/printing." | |
4311 | (let (ps-prefix-quote) | |
4312 | (mapconcat | |
4313 | #'ps-print-quote | |
4314 | (list | |
4315 | (concat "\n;;; printing.el version " pr-version "\n") | |
45f17557 VJL |
4316 | ";; internal vars" |
4317 | (ps-comment-string "pr-txt-command " pr-txt-command) | |
4318 | (ps-comment-string "pr-txt-switches " | |
4319 | (pr-switches-string pr-txt-switches "pr-txt-switches")) | |
4320 | (ps-comment-string "pr-txt-printer " pr-txt-printer) | |
4321 | (ps-comment-string "pr-ps-command " pr-ps-command) | |
4322 | (ps-comment-string "pr-ps-switches " | |
4323 | (pr-switches-string pr-ps-switches "pr-ps-switches")) | |
4324 | (ps-comment-string "pr-ps-printer-switch" pr-ps-printer-switch) | |
4325 | (ps-comment-string "pr-ps-printer " pr-ps-printer) | |
4326 | (ps-comment-string "pr-cygwin-system " pr-cygwin-system) | |
4327 | (ps-comment-string "ps-windows-system " ps-windows-system) | |
4328 | (ps-comment-string "ps-lp-system " ps-lp-system) | |
4329 | nil | |
4330 | '(14 . pr-path-style) | |
4331 | '(14 . pr-path-alist) | |
2c840b90 KS |
4332 | nil |
4333 | '(21 . pr-txt-name) | |
4334 | '(21 . pr-txt-printer-alist) | |
4335 | nil | |
4336 | '(20 . pr-ps-name) | |
4337 | '(20 . pr-ps-printer-alist) | |
4338 | nil | |
4339 | '(20 . pr-temp-dir) | |
4340 | '(20 . pr-ps-temp-file) | |
4341 | '(20 . pr-delete-temp-file) | |
4342 | '(20 . pr-list-directory) | |
4343 | nil | |
4344 | '(17 . pr-gv-command) | |
4345 | '(17 . pr-gs-command) | |
4346 | '(17 . pr-gs-switches) | |
4347 | '(17 . pr-gs-device) | |
4348 | '(17 . pr-gs-resolution) | |
4349 | nil | |
4350 | '(27 . pr-print-using-ghostscript) | |
4351 | '(27 . pr-faces-p) | |
4352 | '(27 . pr-spool-p) | |
4353 | '(27 . pr-file-landscape) | |
4354 | '(27 . pr-file-duplex) | |
4355 | '(27 . pr-file-tumble) | |
4356 | '(27 . pr-auto-region) | |
4357 | '(27 . pr-auto-mode) | |
4358 | nil | |
4359 | '(20 . pr-ps-utility) | |
4360 | '(20 . pr-ps-utility-alist) | |
4361 | nil | |
4362 | '(14 . pr-mode-alist) | |
4363 | nil | |
4364 | '(20 . pr-menu-lock) | |
4365 | '(20 . pr-menu-char-height) | |
4366 | '(20 . pr-menu-char-width) | |
4367 | nil | |
4368 | '(20 . pr-setting-database) | |
4369 | nil | |
4370 | '(22 . pr-visible-entry-list) | |
4371 | nil | |
4372 | '(22 . pr-buffer-verbose) | |
4373 | '(22 . pr-buffer-name) | |
4374 | '(22 . pr-buffer-name-ignore) | |
4375 | ")\n\n;;; printing.el - end of settings\n") | |
4376 | "\n"))) | |
4377 | ||
4378 | ||
4379 | (defun lpr-setup () | |
4380 | "Return the current `lpr' setup. | |
4381 | ||
4382 | This is *not* an interactive command. | |
4383 | One way to see `lpr' setup is to switch to a *Scratch* buffer and type: | |
4384 | ||
4385 | M-: (insert (lpr-setup)) RET | |
4386 | ||
4387 | Or choose the menu option Printing/Show Settings/lpr." | |
4388 | (let (ps-prefix-quote) | |
4389 | (mapconcat | |
4390 | #'ps-print-quote | |
4391 | '("\n;;; lpr.el settings\n" | |
4392 | (25 . printer-name) | |
4393 | (25 . lpr-switches) | |
4394 | (25 . lpr-add-switches) | |
4395 | (25 . lpr-command) | |
4396 | (25 . lpr-headers-switches) | |
4397 | (25 . print-region-function) | |
4398 | (25 . lpr-page-header-program) | |
4399 | (25 . lpr-page-header-switches) | |
4400 | ")\n\n;;; lpr.el - end of settings\n") | |
4401 | "\n"))) | |
4402 | ||
4403 | ||
4404 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4405 | ;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>) | |
4406 | ||
4407 | ||
4408 | (defalias 'pr-mh-get-msg-num 'mh-get-msg-num) | |
4409 | (defalias 'pr-mh-show 'mh-show) | |
4410 | (defalias 'pr-mh-start-of-uncleaned-message 'mh-start-of-uncleaned-message) | |
4411 | (defvar mh-show-buffer nil) | |
4412 | ||
4413 | ||
4414 | (defun pr-article-date () | |
4415 | "Find the date of an article or mail message in current buffer. | |
4416 | Return only the dayname, if present, weekday, month, and year." | |
4417 | (save-excursion | |
4418 | (goto-char (point-min)) | |
4419 | (if (re-search-forward | |
4420 | "^Date:[ \t]+\\(\\([A-Za-z]+, \\)?[0-9]+ [A-Za-z]+ [0-9]+\\)" nil t) | |
4421 | (buffer-substring (match-beginning 1) (match-end 1)) | |
4422 | (format-time-string "%Y/%m/%d")))) | |
4423 | ||
4424 | ||
4425 | (defun pr-mh-current-message () | |
4426 | "Go to mh-inbox current message." | |
4427 | (let ((msg (or (pr-mh-get-msg-num nil) 0))) | |
4428 | (pr-mh-show) | |
4429 | (set-buffer mh-show-buffer) | |
4430 | (goto-char (point-min)) | |
4431 | (pr-mh-start-of-uncleaned-message) | |
4432 | (message "Printing message %d" msg))) | |
4433 | ||
4434 | ||
4435 | (defun pr-mh-print-1 (n-up filename header-list) | |
4436 | "Print mh-inbox current message in PostScript." | |
4437 | (save-excursion | |
4438 | (save-window-excursion | |
4439 | (pr-mh-current-message) | |
4440 | (pr-mode-print n-up filename header-list (point))))) | |
4441 | ||
4442 | ||
4443 | (defun pr-mh-lpr-1 (header-list) | |
4444 | "Print mh-inbox current message in text printer." | |
4445 | (save-excursion | |
4446 | (save-window-excursion | |
4447 | (pr-mh-current-message) | |
4448 | (pr-mode-lpr header-list (point))))) | |
4449 | ||
4450 | ||
4451 | (defalias 'pr-mh-print-2 'pr-mode-print) | |
4452 | ||
4453 | ||
4454 | (defalias 'pr-mh-lpr-2 'pr-mode-lpr) | |
4455 | ||
4456 | ||
4457 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4458 | ;; rmail (hacked from ps-print.el) | |
4459 | ||
4460 | ||
4461 | (defun pr-rmail-lpr (header-list) | |
4462 | "Print RMAIL current message in text printer." | |
4463 | (pr-lpr-message-from-summary header-list | |
4464 | 'rmail-buffer 'rmail-summary-buffer)) | |
4465 | ||
4466 | ||
4467 | (defun pr-rmail-print (n-up filename header-list) | |
4468 | "Print RMAIL current message in PostScript." | |
4469 | (pr-ps-message-from-summary n-up filename header-list | |
4470 | 'rmail-buffer 'rmail-summary-buffer)) | |
4471 | ||
4472 | ||
4473 | (defun pr-ps-message-from-summary (n-up filename header-list | |
4474 | summary-buffer summary-default) | |
4475 | "Print current message in PostScript." | |
4476 | (let ((buf (or (and (boundp summary-buffer) | |
4477 | (symbol-value summary-buffer)) | |
4478 | (symbol-value summary-default)))) | |
4479 | (and (get-buffer buf) | |
4480 | (save-excursion | |
4481 | (set-buffer buf) | |
4482 | (pr-mode-print n-up filename header-list))))) | |
4483 | ||
4484 | ||
4485 | (defun pr-lpr-message-from-summary (header-list summary-buffer summary-default) | |
4486 | "Print current message in text printer." | |
4487 | (let ((buf (or (and (boundp summary-buffer) | |
4488 | (symbol-value summary-buffer)) | |
4489 | (symbol-value summary-default)))) | |
4490 | (and (get-buffer buf) | |
4491 | (save-excursion | |
4492 | (set-buffer buf) | |
4493 | (pr-mode-lpr header-list))))) | |
4494 | ||
4495 | ||
4496 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4497 | ;; gnus (hacked from ps-print.el) | |
4498 | ||
4499 | ||
4500 | (defvar pr-gnus-article "*Article*") | |
4501 | ||
4502 | ||
4503 | (defun pr-gnus-print (n-up filename header-list) | |
4504 | "Print *Article* current message in PostScript." | |
4505 | (pr-ps-message-from-summary n-up filename header-list | |
4506 | 'gnus-article-buffer 'pr-gnus-article)) | |
4507 | ||
4508 | ||
4509 | (defun pr-gnus-lpr (header-list) | |
4510 | "Print *Article* current message in text printer." | |
4511 | (pr-lpr-message-from-summary header-list | |
4512 | 'gnus-article-buffer 'pr-gnus-article)) | |
4513 | ||
4514 | ||
4515 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4516 | ;; vm (hacked from ps-print.el) | |
4517 | ||
4518 | ||
4519 | (defvar pr-vm-summary "") | |
4520 | ||
4521 | ||
4522 | (defun pr-vm-print (n-up filename header-list) | |
4523 | "Print current vm message in PostScript." | |
4524 | (pr-ps-message-from-summary n-up filename header-list | |
4525 | 'vm-mail-buffer 'pr-vm-summary)) | |
4526 | ||
4527 | ||
4528 | (defun pr-vm-lpr (header-list) | |
4529 | "Print current vm message in text printer." | |
4530 | (pr-lpr-message-from-summary header-list | |
4531 | 'vm-mail-buffer 'pr-vm-summary)) | |
4532 | ||
4533 | ||
4534 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4535 | ;; Mode Functions | |
4536 | ||
4537 | ||
4538 | (defun pr-ps-mode (n-up filename) | |
4539 | "If current major mode is declared, print it in PostScript." | |
4540 | (let ((args (pr-mode-alist-p))) | |
4541 | (if args | |
4542 | (let ((fun (cdr args))) | |
4543 | (funcall (car fun) n-up filename (cdr fun)) | |
4544 | t) | |
4545 | (ding) | |
4546 | (message "`%s' major mode not declared." major-mode) | |
4547 | nil))) | |
4548 | ||
4549 | ||
4550 | (defmacro pr-local-variable (header-list &rest body) | |
4551 | `(save-excursion | |
4552 | (let ((ps-header-lines (or (nth 0 ,header-list) ps-header-lines)) | |
4553 | (ps-left-header (or (nth 1 ,header-list) ps-left-header)) | |
4554 | (ps-right-header (or (nth 2 ,header-list) ps-right-header)) | |
4555 | ps-razzle-dazzle) | |
4556 | (let ((local-var-list (pr-eval-local-alist (nthcdr 4 ,header-list)))) | |
4557 | ,@body | |
4558 | (and (nth 3 ,header-list) | |
4559 | (pr-kill-local-variable local-var-list)))))) | |
4560 | ||
4561 | ||
4562 | (defun pr-mode-print (n-up filename header-list &optional from to) | |
4563 | "Print current major mode in PostScript." | |
4564 | (pr-local-variable | |
4565 | header-list | |
4566 | (let ((file (pr-ps-file filename)) | |
4567 | (start (cond (from) | |
4568 | ((pr-region-active-p) (region-beginning)) | |
4569 | (t nil) | |
4570 | ))) | |
4571 | (pr-text2ps (pr-region-active-symbol start) n-up file start | |
4572 | (cond (to) | |
4573 | ((pr-region-active-p) (region-end)) | |
4574 | (from (point-max)) | |
4575 | )) | |
4576 | (unless (or pr-spool-p filename) | |
4577 | (pr-ps-file-print file) | |
4578 | (pr-delete-file file))))) | |
4579 | ||
4580 | ||
4581 | (defun pr-mode-lpr (header-list &optional from to) | |
4582 | "Print current major mode in text printer." | |
4583 | (pr-local-variable | |
4584 | header-list | |
4585 | (pr-txt-print (cond (from) | |
4586 | ((pr-region-active-p) (region-beginning)) | |
4587 | (t (point-min))) | |
4588 | (cond (to) | |
4589 | ((pr-region-active-p) (region-end)) | |
4590 | (t (point-max)))))) | |
4591 | ||
4592 | ||
4593 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4594 | ;; Menu Lock | |
4595 | ||
4596 | ||
4597 | (defconst pr-menu-entry-alist | |
4598 | '((postscript . 3) | |
4599 | (text . 3) | |
4600 | (postscript-options . 9) | |
4601 | (postscript-process . 3) | |
4602 | (printing . 3) | |
4603 | (help . 3) | |
4604 | ) | |
4605 | "Alist that associates menu part with number of items per part. | |
4606 | ||
4607 | It's used by `pr-menu-index'. | |
4608 | ||
4609 | Each element has the form: | |
4610 | ||
4611 | (MENU-PART . NUMBER-OF-ITEMS) | |
4612 | ||
4613 | See `pr-visible-entry-alist'.") | |
4614 | ||
4615 | ||
4616 | (defun pr-menu-index (entry index) | |
4617 | (let ((base-list | |
4618 | (cond ((eq entry 'text) | |
4619 | '(postscript)) | |
4620 | ((eq entry 'postscript-options) | |
4621 | '(postscript text)) | |
4622 | ((eq entry 'postscript-process) | |
4623 | '(postscript text postscript-options)) | |
4624 | ((eq entry 'printing) | |
4625 | '(postscript text postscript-options postscript-process)) | |
4626 | (t | |
4627 | nil) | |
4628 | )) | |
4629 | key) | |
4630 | (while base-list | |
4631 | (setq key (car base-list) | |
4632 | base-list (cdr base-list)) | |
4633 | (and (pr-visible-p key) | |
4634 | (setq index (+ index | |
4635 | (cdr (assq key pr-menu-entry-alist))))))) | |
4636 | (+ index 2)) | |
4637 | ||
4638 | ||
449cba44 VJL |
4639 | (defvar pr-menu-position nil) |
4640 | (defvar pr-menu-state nil) | |
4641 | ||
4642 | ||
2c840b90 KS |
4643 | (eval-and-compile |
4644 | (cond | |
4645 | ((eq ps-print-emacs-type 'xemacs) | |
4646 | ;; XEmacs | |
45f17557 | 4647 | (defvar current-mouse-event nil) ; to avoid compilation gripes |
2c840b90 KS |
4648 | (defun pr-menu-position (entry index horizontal) |
4649 | (pr-x-make-event | |
4650 | 'button-release | |
4651 | (list 'button 1 | |
4652 | 'x (- (pr-x-event-x-pixel current-mouse-event) ; X | |
4653 | (* horizontal pr-menu-char-width)) | |
4654 | 'y (- (pr-x-event-y-pixel current-mouse-event) ; Y | |
4655 | (* (pr-menu-index entry index) pr-menu-char-height))))) | |
4656 | ) | |
4657 | (ps-windows-system | |
4658 | ;; GNU Emacs for Windows 9x/NT | |
4659 | (defun pr-menu-position (entry index horizontal) | |
4660 | (let ((pos (cdr (pr-e-mouse-pixel-position)))) | |
4661 | (list | |
034cb096 VJL |
4662 | (list (or (car pos) 0) ; X |
4663 | (- (or (cdr pos) 0) ; Y | |
2c840b90 KS |
4664 | (* (pr-menu-index entry index) pr-menu-char-height))) |
4665 | (selected-frame)))) ; frame | |
4666 | ) | |
4667 | (t | |
4668 | ;; GNU Emacs | |
4669 | (defun pr-menu-position (entry index horizontal) | |
4670 | (let ((pos (cdr (pr-e-mouse-pixel-position)))) | |
4671 | (list | |
034cb096 | 4672 | (list (- (or (car pos) 0) ; X |
2c840b90 | 4673 | (* horizontal pr-menu-char-width)) |
034cb096 | 4674 | (- (or (cdr pos) 0) ; Y |
2c840b90 KS |
4675 | (* (pr-menu-index entry index) pr-menu-char-height))) |
4676 | (selected-frame)))) ; frame | |
449cba44 | 4677 | )) |
2c840b90 | 4678 | |
449cba44 VJL |
4679 | (cond |
4680 | ((eq ps-print-emacs-type 'emacs) | |
4681 | ;; GNU Emacs | |
4682 | (defun pr-menu-lookup (path) | |
4683 | (let ((ipath pr-menu-bar)) | |
4684 | (lookup-key global-map | |
4685 | (if path | |
4686 | (vconcat ipath | |
4687 | (mapcar 'pr-get-symbol | |
4688 | (if (listp path) | |
4689 | path | |
4690 | (list path)))) | |
4691 | ipath)))) | |
2c840b90 | 4692 | |
449cba44 VJL |
4693 | ;; GNU Emacs |
4694 | (defun pr-menu-lock (entry index horizontal state path) | |
4695 | (when (and (not (interactive-p)) pr-menu-lock) | |
4696 | (or (and pr-menu-position (eq state pr-menu-state)) | |
4697 | (setq pr-menu-position (pr-menu-position entry index horizontal) | |
4698 | pr-menu-state state)) | |
4699 | (let* ((menu (pr-menu-lookup path)) | |
4700 | (result (x-popup-menu pr-menu-position menu))) | |
4701 | (and result | |
4702 | (let ((command (lookup-key menu (vconcat result)))) | |
4703 | (if (fboundp command) | |
4704 | (funcall command) | |
4705 | (eval command))))) | |
4706 | (setq pr-menu-position nil)))) | |
2c840b90 | 4707 | |
2c840b90 | 4708 | |
449cba44 VJL |
4709 | ((eq ps-print-emacs-type 'xemacs) |
4710 | ;; XEmacs | |
45f17557 | 4711 | (defvar current-menubar nil) ; to avoid compilation gripes |
449cba44 VJL |
4712 | (defun pr-menu-lookup (path) |
4713 | (car (pr-x-find-menu-item current-menubar (cons "Printing" path)))) | |
2c840b90 | 4714 | |
449cba44 VJL |
4715 | ;; XEmacs |
4716 | (defun pr-menu-lock (entry index horizontal state path) | |
4717 | (when (and (not (interactive-p)) pr-menu-lock) | |
4718 | (or (and pr-menu-position (eq state pr-menu-state)) | |
4719 | (setq pr-menu-position (pr-menu-position entry index horizontal) | |
4720 | pr-menu-state state)) | |
4721 | (let* ((menu (pr-menu-lookup path)) | |
4722 | (result (pr-x-get-popup-menu-response menu pr-menu-position))) | |
4723 | (and (pr-x-misc-user-event-p result) | |
4724 | (funcall (pr-x-event-function result) | |
4725 | (pr-x-event-object result)))) | |
4726 | (setq pr-menu-position nil)))))) | |
2c840b90 KS |
4727 | |
4728 | ||
4729 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4730 | ;; Printer & Utility Selection | |
4731 | ||
4732 | ||
4733 | (defun pr-update-var (var-sym alist) | |
4734 | (or (assq (symbol-value var-sym) alist) | |
4735 | (set var-sym (car (car alist))))) | |
4736 | ||
4737 | ||
4738 | (defun pr-update-menus (&optional force) | |
4739 | "Update utility, PostScript and text printer menus. | |
4740 | ||
4741 | If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist', | |
4742 | `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not; | |
4743 | otherwise, update PostScript printer menu iff `pr-ps-printer-menu-modified' is | |
4744 | non-nil, update text printer menu iff `pr-txt-printer-menu-modified' is | |
4745 | non-nil, and update PostScript File menus iff `pr-ps-utility-menu-modified' is | |
4746 | non-nil." | |
757caf1c | 4747 | (interactive "P") |
2c840b90 KS |
4748 | (pr-update-var 'pr-ps-name pr-ps-printer-alist) |
4749 | (pr-update-var 'pr-txt-name pr-txt-printer-alist) | |
4750 | (pr-update-var 'pr-ps-utility pr-ps-utility-alist) | |
4751 | (pr-do-update-menus force)) | |
4752 | ||
4753 | ||
4754 | (defvar pr-ps-printer-menu-modified t | |
449cba44 | 4755 | "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.") |
2c840b90 | 4756 | (defvar pr-txt-printer-menu-modified t |
449cba44 | 4757 | "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.") |
2c840b90 | 4758 | (defvar pr-ps-utility-menu-modified t |
449cba44 | 4759 | "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.") |
2c840b90 KS |
4760 | |
4761 | ||
4762 | (defconst pr-even-or-odd-alist | |
449cba44 VJL |
4763 | '((nil . "Print All Pages") |
4764 | (even-page . "Print Even Pages") | |
4765 | (odd-page . "Print Odd Pages") | |
2c840b90 | 4766 | (even-sheet . "Print Even Sheets") |
449cba44 | 4767 | (odd-sheet . "Print Odd Sheets"))) |
2c840b90 KS |
4768 | |
4769 | ||
4770 | (defun pr-menu-create (name alist var-sym fun entry index) | |
4771 | (cons name | |
4772 | (mapcar | |
4773 | #'(lambda (elt) | |
4774 | (let ((sym (car elt))) | |
4775 | (vector | |
4776 | (symbol-name sym) | |
4777 | (list fun (list 'quote sym) nil (list 'quote entry) index) | |
4778 | :style 'radio | |
4779 | :selected (list 'eq var-sym (list 'quote sym))))) | |
4780 | alist))) | |
4781 | ||
4782 | ||
4783 | (eval-and-compile | |
4784 | (cond | |
4785 | ((eq ps-print-emacs-type 'emacs) | |
4786 | ;; GNU Emacs | |
4787 | (defalias 'pr-update-mode-line 'force-mode-line-update) | |
4788 | ||
4789 | ;; GNU Emacs | |
4790 | (defun pr-do-update-menus (&optional force) | |
4791 | (pr-menu-alist pr-ps-printer-alist | |
4792 | 'pr-ps-name | |
4793 | 'pr-menu-set-ps-title | |
4794 | "PostScript Printers" | |
4795 | 'pr-ps-printer-menu-modified | |
4796 | force | |
4797 | "PostScript Printers" | |
4798 | 'postscript 2) | |
4799 | (pr-menu-alist pr-txt-printer-alist | |
4800 | 'pr-txt-name | |
4801 | 'pr-menu-set-txt-title | |
4802 | "Text Printers" | |
4803 | 'pr-txt-printer-menu-modified | |
4804 | force | |
4805 | "Text Printers" | |
4806 | 'text 2) | |
4807 | (let ((save-var pr-ps-utility-menu-modified)) | |
4808 | (pr-menu-alist pr-ps-utility-alist | |
4809 | 'pr-ps-utility | |
4810 | 'pr-menu-set-utility-title | |
4811 | '("PostScript Print" "File" "PostScript Utility") | |
4812 | 'save-var | |
4813 | force | |
4814 | "PostScript Utility" | |
4815 | nil 1)) | |
4816 | (pr-menu-alist pr-ps-utility-alist | |
4817 | 'pr-ps-utility | |
4818 | 'pr-menu-set-utility-title | |
4819 | '("PostScript Preview" "File" "PostScript Utility") | |
4820 | 'pr-ps-utility-menu-modified | |
4821 | force | |
4822 | "PostScript Utility" | |
4823 | nil 1) | |
4824 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) | |
4825 | ||
4826 | ;; GNU Emacs | |
4827 | (defvar pr-temp-menu nil) | |
4828 | ||
4829 | ;; GNU Emacs | |
4830 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name | |
4831 | entry index) | |
4832 | (when (and alist (or force (symbol-value modified-sym))) | |
4833 | (easy-menu-define pr-temp-menu nil "" | |
4834 | (pr-menu-create name alist var-sym fun entry index)) | |
4835 | (let ((item (pr-menu-get-item menu-path))) | |
4836 | (and item | |
4837 | (let* ((binding (nthcdr 3 item)) | |
4838 | (key-binding (cdr binding))) | |
4839 | (setcar binding pr-temp-menu) | |
4840 | (and key-binding (listp (car key-binding)) | |
4841 | (setcdr binding (cdr key-binding))) ; skip KEY-BINDING | |
4842 | (funcall fun (symbol-value var-sym) item)))) | |
4843 | (set modified-sym nil))) | |
4844 | ||
4845 | ;; GNU Emacs | |
4846 | (defun pr-menu-set-ps-title (value &optional item entry index) | |
4847 | (pr-menu-set-item-name (or item | |
4848 | (pr-menu-get-item "PostScript Printers")) | |
4849 | (format "PostScript Printer: %s" value)) | |
4850 | (pr-ps-set-printer value) | |
4851 | (and index | |
4852 | (pr-menu-lock entry index 12 'toggle nil))) | |
4853 | ||
4854 | ;; GNU Emacs | |
4855 | (defun pr-menu-set-txt-title (value &optional item entry index) | |
4856 | (pr-menu-set-item-name (or item | |
4857 | (pr-menu-get-item "Text Printers")) | |
4858 | (format "Text Printer: %s" value)) | |
4859 | (pr-txt-set-printer value) | |
4860 | (and index | |
4861 | (pr-menu-lock entry index 12 'toggle nil))) | |
4862 | ||
4863 | ;; GNU Emacs | |
4864 | (defun pr-menu-set-utility-title (value &optional item entry index) | |
4865 | (let ((name (symbol-name value))) | |
4866 | (if item | |
4867 | (pr-menu-set-item-name item name) | |
4868 | (pr-menu-set-item-name | |
4869 | (pr-menu-get-item | |
4870 | '("PostScript Print" "File" "PostScript Utility")) | |
4871 | name) | |
4872 | (pr-menu-set-item-name | |
4873 | (pr-menu-get-item | |
4874 | '("PostScript Preview" "File" "PostScript Utility")) | |
4875 | name))) | |
4876 | (pr-ps-set-utility value) | |
4877 | (and index | |
4878 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) | |
4879 | ||
4880 | ;; GNU Emacs | |
4881 | (defun pr-even-or-odd-pages (value &optional no-lock) | |
4882 | (pr-menu-set-item-name (pr-menu-get-item "Print All Pages") | |
4883 | (cdr (assq value pr-even-or-odd-alist))) | |
4884 | (setq ps-even-or-odd-pages value) | |
4885 | (or no-lock | |
4886 | (pr-menu-lock 'postscript-options 8 12 'toggle nil)))) | |
4887 | ||
4888 | ||
4889 | ((eq ps-print-emacs-type 'xemacs) | |
4890 | ;; XEmacs | |
4891 | (defalias 'pr-update-mode-line 'set-menubar-dirty-flag) | |
4892 | ||
4893 | ;; XEmacs | |
4894 | (defvar pr-ps-name-old "PostScript Printers") | |
4895 | (defvar pr-txt-name-old "Text Printers") | |
4896 | (defvar pr-ps-utility-old "PostScript Utility") | |
4897 | (defvar pr-even-or-odd-old "Print All Pages") | |
4898 | ||
4899 | ;; XEmacs | |
4900 | (defun pr-do-update-menus (&optional force) | |
4901 | (pr-menu-alist pr-ps-printer-alist | |
4902 | 'pr-ps-name | |
4903 | 'pr-menu-set-ps-title | |
4904 | '("Printing") | |
4905 | 'pr-ps-printer-menu-modified | |
4906 | force | |
4907 | pr-ps-name-old | |
4908 | 'postscript 2) | |
4909 | (pr-menu-alist pr-txt-printer-alist | |
4910 | 'pr-txt-name | |
4911 | 'pr-menu-set-txt-title | |
4912 | '("Printing") | |
4913 | 'pr-txt-printer-menu-modified | |
4914 | force | |
4915 | pr-txt-name-old | |
4916 | 'text 2) | |
4917 | (let ((save-var pr-ps-utility-menu-modified)) | |
4918 | (pr-menu-alist pr-ps-utility-alist | |
4919 | 'pr-ps-utility | |
4920 | 'pr-menu-set-utility-title | |
4921 | '("Printing" "PostScript Print" "File") | |
4922 | 'save-var | |
4923 | force | |
4924 | pr-ps-utility-old | |
4925 | nil 1)) | |
4926 | (pr-menu-alist pr-ps-utility-alist | |
4927 | 'pr-ps-utility | |
4928 | 'pr-menu-set-utility-title | |
4929 | '("Printing" "PostScript Preview" "File") | |
4930 | 'pr-ps-utility-menu-modified | |
4931 | force | |
4932 | pr-ps-utility-old | |
4933 | nil 1) | |
4934 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) | |
4935 | ||
4936 | ;; XEmacs | |
4937 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name | |
4938 | entry index) | |
4939 | (when (and alist (or force (symbol-value modified-sym))) | |
4940 | (pr-xemacs-global-menubar | |
4941 | (pr-x-add-submenu menu-path | |
4942 | (pr-menu-create name alist var-sym | |
4943 | fun entry index))) | |
4944 | (funcall fun (symbol-value var-sym)) | |
4945 | (set modified-sym nil))) | |
4946 | ||
4947 | ;; XEmacs | |
4948 | (defun pr-menu-set-ps-title (value &optional item entry index) | |
4949 | (pr-relabel-menu-item (format "PostScript Printer: %s" value) | |
4950 | 'pr-ps-name-old) | |
4951 | (pr-ps-set-printer value) | |
4952 | (and index | |
4953 | (pr-menu-lock entry index 12 'toggle nil))) | |
4954 | ||
4955 | ;; XEmacs | |
4956 | (defun pr-menu-set-txt-title (value &optional item entry index) | |
4957 | (pr-relabel-menu-item (format "Text Printer: %s" value) | |
4958 | 'pr-txt-name-old) | |
4959 | (pr-txt-set-printer value) | |
4960 | (and index | |
4961 | (pr-menu-lock entry index 12 'toggle nil))) | |
4962 | ||
4963 | ;; XEmacs | |
4964 | (defun pr-menu-set-utility-title (value &optional item entry index) | |
4965 | (pr-xemacs-global-menubar | |
4966 | (let ((newname (format "%s" value))) | |
4967 | (pr-x-relabel-menu-item | |
4968 | (list "Printing" "PostScript Print" "File" pr-ps-utility-old) | |
4969 | newname) | |
4970 | (pr-x-relabel-menu-item | |
4971 | (list "Printing" "PostScript Preview" "File" pr-ps-utility-old) | |
4972 | newname) | |
4973 | (setq pr-ps-utility-old newname))) | |
4974 | (pr-ps-set-utility value) | |
4975 | (and index | |
4976 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) | |
4977 | ||
4978 | ;; XEmacs | |
4979 | (defun pr-even-or-odd-pages (value &optional no-lock) | |
4980 | (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist)) | |
4981 | 'pr-even-or-odd-old) | |
4982 | (setq ps-even-or-odd-pages value) | |
4983 | (or no-lock | |
4984 | (pr-menu-lock 'postscript-options 8 12 'toggle nil)))))) | |
4985 | ||
4986 | ;; XEmacs | |
4987 | (defun pr-relabel-menu-item (newname var-sym) | |
4988 | (pr-xemacs-global-menubar | |
4989 | (pr-x-relabel-menu-item | |
4990 | (list "Printing" (symbol-value var-sym)) | |
4991 | newname) | |
4992 | (set var-sym newname))) | |
4993 | ||
449cba44 | 4994 | ;; GNU Emacs |
2c840b90 KS |
4995 | (defun pr-menu-set-item-name (item name) |
4996 | (and item | |
4997 | (setcar (nthcdr 2 item) name))) ; ITEM-NAME | |
4998 | ||
449cba44 | 4999 | ;; GNU Emacs |
2c840b90 KS |
5000 | (defun pr-menu-get-item (name-list) |
5001 | ;; NAME-LIST is a string or a list of strings. | |
5002 | (let ((ipath pr-menu-bar) | |
5003 | (len (and (listp name-list) (length name-list)))) | |
5004 | (and len (= len 1) | |
5005 | (setq name-list (car name-list))) | |
5006 | (cond | |
5007 | ((null name-list) | |
5008 | ;; nil | |
5009 | nil) | |
5010 | ((listp name-list) | |
5011 | ;; list and (length list) > 1 | |
5012 | (let* ((copy (copy-sequence name-list)) | |
5013 | (name (pr-get-symbol (nth (1- len) copy))) | |
5014 | (path (progn | |
5015 | (setcdr (nthcdr (- len 2) copy) nil) | |
5016 | copy)) | |
5017 | (menu (lookup-key | |
5018 | global-map | |
5019 | (if path | |
5020 | (vconcat ipath | |
5021 | (mapcar 'pr-get-symbol path)) | |
5022 | ipath)))) | |
5023 | (assq name (nthcdr 2 menu)))) | |
5024 | (t | |
5025 | ;; string | |
5026 | (let ((name (pr-get-symbol name-list)) | |
5027 | (menu (lookup-key global-map ipath))) | |
5028 | (assq name (nthcdr 2 menu))))))) | |
5029 | ||
5030 | ||
5031 | (defun pr-ps-set-utility (value) | |
5032 | (let ((item (cdr (assq value pr-ps-utility-alist)))) | |
5033 | (or item | |
5034 | (error | |
5035 | "Invalid PostScript utility name `%s' for variable `pr-ps-utility'." | |
5036 | value)) | |
5037 | (setq pr-ps-utility value) | |
5038 | (pr-eval-alist (nthcdr 9 item))) | |
5039 | (pr-update-mode-line)) | |
5040 | ||
5041 | ||
5042 | (defun pr-ps-set-printer (value) | |
5043 | (let ((ps (cdr (assq value pr-ps-printer-alist)))) | |
5044 | (or ps | |
5045 | (error | |
5046 | "Invalid PostScript printer name `%s' for variable `pr-ps-name'." | |
5047 | value)) | |
5048 | (setq pr-ps-name value | |
0117451d | 5049 | pr-ps-command (pr-dosify-file-name (nth 0 ps)) |
2c840b90 KS |
5050 | pr-ps-switches (nth 1 ps) |
5051 | pr-ps-printer-switch (nth 2 ps) | |
45f17557 | 5052 | pr-ps-printer (nth 3 ps)) |
2c840b90 KS |
5053 | (or (stringp pr-ps-command) |
5054 | (setq pr-ps-command | |
5055 | (cond (ps-windows-system "print") | |
5056 | (ps-lp-system "lp") | |
5057 | (t "lpr") | |
5058 | ))) | |
5059 | (or (stringp pr-ps-printer-switch) | |
5060 | (setq pr-ps-printer-switch | |
5061 | (cond (ps-windows-system "/D:") | |
5062 | (ps-lp-system "-d") | |
5063 | (t "-P") | |
5064 | ))) | |
5065 | (pr-eval-alist (nthcdr 4 ps))) | |
5066 | (pr-update-mode-line)) | |
5067 | ||
5068 | ||
5069 | (defun pr-txt-set-printer (value) | |
5070 | (let ((txt (cdr (assq value pr-txt-printer-alist)))) | |
5071 | (or txt | |
5072 | (error "Invalid text printer name `%s' for variable `pr-txt-name'." | |
5073 | value)) | |
5074 | (setq pr-txt-name value | |
0117451d | 5075 | pr-txt-command (pr-dosify-file-name (nth 0 txt)) |
2c840b90 | 5076 | pr-txt-switches (nth 1 txt) |
45f17557 | 5077 | pr-txt-printer (nth 2 txt))) |
2c840b90 KS |
5078 | (or (stringp pr-txt-command) |
5079 | (setq pr-txt-command | |
5080 | (cond (ps-windows-system "print") | |
5081 | (ps-lp-system "lp") | |
5082 | (t "lpr") | |
5083 | ))) | |
5084 | (pr-update-mode-line)) | |
5085 | ||
5086 | ||
5087 | (defun pr-eval-alist (alist) | |
5088 | (mapcar #'(lambda (option) | |
5089 | (let ((var-sym (car option)) | |
5090 | (value (cdr option))) | |
5091 | (if (eq var-sym 'inherits-from:) | |
5092 | (pr-eval-setting-alist value 'global) | |
5093 | (set var-sym (eval value))))) | |
5094 | alist)) | |
5095 | ||
5096 | ||
5097 | (defun pr-eval-local-alist (alist) | |
5098 | (let (local-list) | |
5099 | (mapcar #'(lambda (option) | |
5100 | (let ((var-sym (car option)) | |
5101 | (value (cdr option))) | |
5102 | (setq local-list | |
5103 | (if (eq var-sym 'inherits-from:) | |
5104 | (nconc (pr-eval-setting-alist value) local-list) | |
5105 | (set (make-local-variable var-sym) (eval value)) | |
5106 | (cons var-sym local-list))))) | |
5107 | alist) | |
5108 | local-list)) | |
5109 | ||
5110 | ||
5111 | (defun pr-eval-setting-alist (key &optional global old) | |
5112 | (let ((setting (cdr (assq key pr-setting-database)))) | |
5113 | (and setting | |
5114 | (let ((inherits (nth 0 setting)) | |
5115 | (local (nth 1 setting)) | |
5116 | (kill (nth 2 setting)) | |
5117 | local-list) | |
5118 | (and local global | |
5119 | (progn | |
5120 | (ding) | |
5121 | (message "There are local buffer settings for `%S'." key) | |
5122 | (setq global nil))) | |
5123 | (and inherits | |
5124 | (if (memq inherits old) | |
5125 | (error "Circular inheritance for `%S'." inherits) | |
5126 | (setq local-list | |
5127 | (pr-eval-setting-alist inherits global | |
5128 | (cons inherits old))))) | |
5129 | (mapcar | |
5130 | (cond ((not local) ; global settings | |
5131 | #'(lambda (option) | |
5132 | (let ((var-sym (car option))) | |
5133 | (or (eq var-sym 'inherits-from:) | |
5134 | (set var-sym (eval (cdr option))))))) | |
5135 | (kill ; local settings with killing | |
5136 | #'(lambda (option) | |
5137 | (let ((var-sym (car option))) | |
5138 | (unless (eq var-sym 'inherits-from:) | |
5139 | (setq local-list (cons var-sym local-list)) | |
5140 | (set (make-local-variable var-sym) | |
5141 | (eval (cdr option))))))) | |
5142 | (t ; local settings without killing | |
5143 | #'(lambda (option) | |
5144 | (let ((var-sym (car option))) | |
5145 | (or (eq var-sym 'inherits-from:) | |
5146 | (set (make-local-variable var-sym) | |
5147 | (eval (cdr option)))))))) | |
5148 | (nthcdr 3 setting)) | |
5149 | local-list)))) | |
5150 | ||
5151 | ||
5152 | (defun pr-kill-local-variable (local-var-list) | |
5153 | (mapcar 'kill-local-variable local-var-list)) | |
5154 | ||
5155 | ||
5156 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
5157 | ;; Internal Functions (II) | |
5158 | ||
5159 | ||
5160 | (defun pr-prompt (str) | |
5161 | (if (pr-auto-mode-p) | |
5162 | (concat str " mode") | |
5163 | (pr-region-active-string str))) | |
5164 | ||
5165 | ||
5166 | (defun pr-prompt-region (str) | |
5167 | (concat str (if (pr-auto-mode-p) | |
5168 | " mode" | |
5169 | " region"))) | |
5170 | ||
5171 | ||
5172 | (defun pr-prompt-gs (str) | |
5173 | (if (pr-using-ghostscript-p) | |
5174 | (concat str " GS") | |
5175 | str)) | |
5176 | ||
5177 | ||
5178 | (defun pr-region-active-symbol (&optional region-p) | |
5179 | (if (or region-p (pr-region-active-p)) | |
5180 | 'region | |
5181 | 'buffer)) | |
5182 | ||
5183 | ||
5184 | (defun pr-region-active-string (prefix) | |
5185 | (concat prefix | |
5186 | (if (pr-region-active-p) | |
5187 | " region" | |
5188 | " buffer"))) | |
5189 | ||
5190 | ||
5191 | (defun pr-show-setup (settings buffer-name) | |
5192 | (with-output-to-temp-buffer buffer-name | |
5193 | (princ settings) | |
5194 | (print-help-return-message))) | |
5195 | ||
5196 | ||
5197 | (defun pr-complete-alist (prompt alist default) | |
5198 | (let ((collection (mapcar #'(lambda (elt) | |
5199 | (setq elt (car elt)) | |
5200 | (cons (symbol-name elt) elt)) | |
5201 | alist))) | |
5202 | (cdr (assoc (completing-read (concat prompt ": ") | |
5203 | collection nil t | |
5204 | (symbol-name default) nil | |
5205 | (symbol-name default)) | |
5206 | collection)))) | |
5207 | ||
5208 | ||
5209 | (defun pr-delete-file (file) | |
5210 | (and pr-delete-temp-file (delete-file file))) | |
5211 | ||
5212 | ||
5213 | (defun pr-expand-file-name (filename) | |
0117451d | 5214 | (pr-dosify-file-name (expand-file-name filename))) |
2c840b90 KS |
5215 | |
5216 | ||
5217 | (defun pr-ps-outfile-preprint (&optional mess) | |
5218 | (let* ((prompt (format "%soutput PostScript file name: " (or mess ""))) | |
5219 | (res (read-file-name prompt default-directory "" nil))) | |
5220 | (while (cond ((not (file-writable-p res)) | |
5221 | (ding) | |
5222 | (setq prompt "is unwritable")) | |
5223 | ((file-directory-p res) | |
5224 | (ding) | |
5225 | (setq prompt "is a directory")) | |
5226 | ((file-exists-p res) | |
5227 | (ding) | |
5228 | (setq prompt "exists") | |
5229 | (not (y-or-n-p (format "File `%s' exists; overwrite? " | |
5230 | res)))) | |
5231 | (t nil)) | |
5232 | (setq res (read-file-name | |
5233 | (format "File %s; PostScript file: " prompt) | |
5234 | (file-name-directory res) nil nil | |
5235 | (file-name-nondirectory res)))) | |
5236 | (pr-expand-file-name res))) | |
5237 | ||
5238 | ||
5239 | (defun pr-ps-infile-preprint (&optional mess) | |
5240 | (let* ((prompt (format "%sinput PostScript file name: " (or mess ""))) | |
5241 | (res (read-file-name prompt default-directory "" nil))) | |
5242 | (while (cond ((not (file-exists-p res)) | |
5243 | (ding) | |
5244 | (setq prompt "doesn't exist")) | |
5245 | ((not (file-readable-p res)) | |
5246 | (ding) | |
5247 | (setq prompt "is unreadable")) | |
5248 | ((file-directory-p res) | |
5249 | (ding) | |
5250 | (setq prompt "is a directory")) | |
5251 | (t nil)) | |
5252 | (setq res (read-file-name | |
5253 | (format "File %s; PostScript file: " prompt) | |
5254 | (file-name-directory res) nil nil | |
5255 | (file-name-nondirectory res)))) | |
5256 | (pr-expand-file-name res))) | |
5257 | ||
5258 | ||
5259 | (defun pr-toggle (var-sym mess entry index horizontal state &optional path) | |
5260 | (set var-sym (not (symbol-value var-sym))) | |
5261 | (message "%s is %s" mess (if (symbol-value var-sym) "on" "off")) | |
5262 | (pr-menu-lock entry index horizontal state path)) | |
5263 | ||
5264 | ||
5265 | (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt) | |
5266 | ;; n-up | |
5267 | (or (symbol-value n-up-sym) | |
5268 | (set n-up-sym (pr-interactive-n-up prompt))) | |
5269 | (and (eq (symbol-value infile-sym) t) | |
5270 | (set infile-sym (and (not (interactive-p)) | |
5271 | (pr-ps-infile-preprint prompt)))) | |
5272 | ;; input file | |
5273 | (or (symbol-value infile-sym) | |
5274 | (error "%s: input PostScript file name is missing" prompt)) | |
0117451d | 5275 | (set infile-sym (pr-dosify-file-name (symbol-value infile-sym))) |
2c840b90 KS |
5276 | ;; output file |
5277 | (and (eq (symbol-value outfile-sym) t) | |
5278 | (set outfile-sym (and (not (interactive-p)) | |
5279 | current-prefix-arg | |
5280 | (pr-ps-outfile-preprint prompt)))) | |
5281 | (and (symbol-value outfile-sym) | |
0117451d | 5282 | (set outfile-sym (pr-dosify-file-name (symbol-value outfile-sym)))) |
2c840b90 KS |
5283 | (pr-ps-file (symbol-value outfile-sym))) |
5284 | ||
5285 | ||
5286 | (defun pr-ps-utility-process (n-up infile outfile) | |
5287 | (let (item) | |
5288 | (and (stringp infile) (file-exists-p infile) | |
5289 | (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist))) | |
45f17557 VJL |
5290 | (pr-call-process (nth 0 item) |
5291 | (pr-switches-string (nth 1 item) | |
5292 | "pr-ps-utility-alist entry") | |
5293 | (pr-switches-string (nth 8 item) | |
5294 | "pr-ps-utility-alist entry") | |
5295 | (and (nth 2 item) | |
5296 | (format (nth 2 item) ps-paper-type)) | |
5297 | (format (nth 3 item) n-up) | |
5298 | (and pr-file-landscape (nth 4 item)) | |
5299 | (and pr-file-duplex (nth 5 item)) | |
5300 | (and pr-file-tumble (nth 6 item)) | |
5301 | (pr-expand-file-name infile) | |
5302 | (nth 7 item) | |
5303 | (pr-expand-file-name outfile))))) | |
5304 | ||
5305 | ||
5306 | (defun pr-remove-nil-from-list (lst) | |
5307 | (while (and lst (null (car lst))) | |
5308 | (setq lst (cdr lst))) | |
5309 | (let ((b lst) | |
5310 | (l (cdr lst))) | |
5311 | (while l | |
5312 | (if (car l) | |
5313 | (setq b l | |
5314 | l (cdr l)) | |
5315 | (setq l (cdr l)) | |
5316 | (setcdr b l)))) | |
5317 | lst) | |
5318 | ||
5319 | ||
5320 | (defun pr-call-process (command &rest args) | |
5321 | (let ((buffer (get-buffer-create "*Printing Command Output*")) | |
5322 | (cmd (pr-command command)) | |
5323 | status) | |
5324 | (setq args (pr-remove-nil-from-list args)) | |
5325 | (save-excursion | |
5326 | (set-buffer buffer) | |
5327 | (goto-char (point-max)) | |
5328 | (insert (format "%s %S\n" cmd args))) | |
0117451d VJL |
5329 | (setq status |
5330 | (condition-case data | |
5331 | (apply 'call-process cmd nil buffer nil args) | |
5332 | ((quit error) | |
5333 | (error-message-string data)))) | |
45f17557 VJL |
5334 | (save-excursion |
5335 | (set-buffer buffer) | |
5336 | (goto-char (point-max)) | |
5337 | (insert (format "Exit status: %s\n" status))))) | |
2c840b90 KS |
5338 | |
5339 | ||
5340 | (defun pr-txt-print (from to) | |
0117451d | 5341 | (let ((lpr-command (pr-standard-file-name (pr-command pr-txt-command))) |
2c840b90 KS |
5342 | (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches")) |
5343 | (printer-name pr-txt-printer)) | |
5344 | (lpr-region from to))) | |
5345 | ||
5346 | ||
5347 | (defun pr-switches-string (switches mess) | |
5348 | (mapconcat 'identity (pr-switches switches mess) " ")) | |
5349 | ||
5350 | ||
5351 | (defun pr-switches (switches mess) | |
5352 | (or (listp switches) | |
5353 | (error "%S should have a list of strings." mess)) | |
5354 | (ps-flatten-list ; dynamic evaluation | |
5355 | (mapcar 'ps-eval-switch switches))) | |
5356 | ||
5357 | ||
5358 | (defun pr-ps-preview (kind n-up filename mess) | |
5359 | (pr-set-n-up-and-filename 'n-up 'filename mess) | |
5360 | (let ((file (pr-ps-file filename))) | |
5361 | (pr-text2ps kind n-up file) | |
5362 | (or pr-spool-p (pr-ps-file-preview file)))) | |
5363 | ||
5364 | ||
5365 | (defun pr-ps-using-ghostscript (kind n-up filename mess) | |
5366 | (pr-set-n-up-and-filename 'n-up 'filename mess) | |
5367 | (let ((file (pr-ps-file filename))) | |
5368 | (pr-text2ps kind n-up file) | |
5369 | (unless (or pr-spool-p filename) | |
5370 | (pr-ps-file-using-ghostscript file) | |
5371 | (pr-delete-file file)))) | |
5372 | ||
5373 | ||
5374 | (defun pr-ps-print (kind n-up filename mess) | |
5375 | (pr-set-n-up-and-filename 'n-up 'filename mess) | |
5376 | (let ((file (pr-ps-file filename))) | |
5377 | (pr-text2ps kind n-up file) | |
5378 | (unless (or pr-spool-p filename) | |
5379 | (pr-ps-file-print file) | |
5380 | (pr-delete-file file)))) | |
5381 | ||
5382 | ||
5383 | (defun pr-ps-file (&optional filename) | |
0117451d VJL |
5384 | (pr-dosify-file-name (or filename |
5385 | (convert-standard-filename | |
5386 | (expand-file-name pr-ps-temp-file pr-temp-dir))))) | |
2c840b90 KS |
5387 | |
5388 | ||
5389 | (defun pr-interactive-n-up (mess) | |
5390 | (or (stringp mess) (setq mess "*")) | |
5391 | (save-match-data | |
5392 | (let* ((fmt-prompt "%s[%s] N-up printing: (default 1) ") | |
5393 | (prompt "") | |
5394 | (str (pr-f-read-string (format fmt-prompt prompt mess) "1" nil "1")) | |
5395 | int) | |
5396 | (while (if (string-match "^\\s *[0-9]+$" str) | |
5397 | (setq int (string-to-int str) | |
5398 | prompt (cond ((< int 1) "Integer below 1; ") | |
5399 | ((> int 100) "Integer above 100; ") | |
5400 | (t nil))) | |
5401 | (setq prompt "Invalid integer syntax; ")) | |
5402 | (ding) | |
5403 | (setq str | |
5404 | (pr-f-read-string (format fmt-prompt prompt mess) str nil "1"))) | |
5405 | int))) | |
5406 | ||
5407 | ||
5408 | (defun pr-interactive-dir (mess) | |
5409 | (let* ((dir-name (file-name-directory (or (buffer-file-name) | |
5410 | default-directory))) | |
5411 | (fmt-prompt (concat "%s[" mess "] Directory to print: ")) | |
5412 | (dir (read-file-name (format fmt-prompt "") | |
5413 | "" dir-name nil dir-name)) | |
5414 | prompt) | |
5415 | (while (cond ((not (file-directory-p dir)) | |
5416 | (ding) | |
5417 | (setq prompt "It's not a directory! ")) | |
5418 | ((not (file-readable-p dir)) | |
5419 | (ding) | |
5420 | (setq prompt "Directory is unreadable! ")) | |
5421 | (t nil)) | |
5422 | (setq dir-name (file-name-directory dir) | |
5423 | dir (read-file-name (format fmt-prompt prompt) | |
5424 | "" dir-name nil dir-name))) | |
5425 | (file-name-as-directory dir))) | |
5426 | ||
5427 | ||
5428 | (defun pr-interactive-regexp (mess) | |
5429 | (pr-f-read-string (format "[%s] File regexp to print: " mess) "" nil "")) | |
5430 | ||
5431 | ||
5432 | (defun pr-interactive-dir-args (mess) | |
5433 | (list | |
5434 | ;; get directory argument | |
5435 | (pr-interactive-dir mess) | |
5436 | ;; get file name regexp | |
5437 | (pr-interactive-regexp mess))) | |
5438 | ||
5439 | ||
5440 | (defun pr-interactive-ps-dir-args (mess) | |
5441 | (list | |
5442 | ;; get n-up argument | |
5443 | (pr-interactive-n-up mess) | |
5444 | ;; get directory argument | |
5445 | (pr-interactive-dir mess) | |
5446 | ;; get file name regexp | |
5447 | (pr-interactive-regexp mess) | |
5448 | ;; get output file name | |
5449 | (and (not pr-spool-p) | |
5450 | (ps-print-preprint current-prefix-arg)))) | |
5451 | ||
5452 | ||
5453 | (defun pr-interactive-n-up-file (mess) | |
5454 | (list | |
5455 | ;; get n-up argument | |
5456 | (pr-interactive-n-up mess) | |
5457 | ;; get output file name | |
5458 | (and (not pr-spool-p) | |
5459 | (ps-print-preprint current-prefix-arg)))) | |
5460 | ||
5461 | ||
5462 | (defun pr-interactive-n-up-inout (mess) | |
5463 | (list | |
5464 | ;; get n-up argument | |
5465 | (pr-interactive-n-up mess) | |
5466 | ;; get input file name | |
5467 | (pr-ps-infile-preprint (concat mess " ")) | |
5468 | ;; get output file name | |
5469 | (ps-print-preprint current-prefix-arg))) | |
5470 | ||
5471 | ||
5472 | (defun pr-set-outfilename (filename-sym) | |
5473 | (and (not pr-spool-p) | |
5474 | (eq (symbol-value filename-sym) t) | |
5475 | (set filename-sym (and (not (interactive-p)) | |
5476 | current-prefix-arg | |
5477 | (ps-print-preprint current-prefix-arg)))) | |
5478 | (and (symbol-value filename-sym) | |
0117451d | 5479 | (set filename-sym (pr-dosify-file-name (symbol-value filename-sym))))) |
2c840b90 KS |
5480 | |
5481 | ||
5482 | (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess) | |
5483 | ;; n-up | |
5484 | (or (symbol-value n-up-sym) | |
5485 | (set n-up-sym (pr-interactive-n-up mess))) | |
5486 | ;; output file | |
5487 | (pr-set-outfilename filename-sym)) | |
5488 | ||
5489 | ||
5490 | (defun pr-set-dir-args (dir-sym regexp-sym mess) | |
5491 | ;; directory | |
5492 | (or (symbol-value dir-sym) | |
5493 | (set dir-sym (pr-interactive-dir mess))) | |
5494 | ;; file name regexp | |
5495 | (or (symbol-value regexp-sym) | |
5496 | (set regexp-sym (pr-interactive-regexp mess)))) | |
5497 | ||
5498 | ||
5499 | (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess) | |
5500 | ;; n-up | |
5501 | (or (symbol-value n-up-sym) | |
5502 | (set n-up-sym (pr-interactive-n-up mess))) | |
5503 | ;; directory & file name regexp | |
5504 | (pr-set-dir-args dir-sym regexp-sym mess) | |
5505 | ;; output file | |
5506 | (pr-set-outfilename filename-sym)) | |
5507 | ||
5508 | ||
5509 | (defun pr-find-buffer-visiting (file) | |
5510 | (if (not (file-directory-p file)) | |
5511 | (find-buffer-visiting (if ps-windows-system | |
5512 | (downcase file) | |
5513 | file)) | |
5514 | (let ((truename (file-truename file)) | |
5515 | (blist (buffer-list)) | |
5516 | found) | |
5517 | (while (and (not found) blist) | |
5518 | (save-excursion | |
5519 | (set-buffer (car blist)) | |
5520 | (and (eq major-mode 'dired-mode) | |
5521 | (save-excursion | |
5522 | (goto-char (point-min)) | |
5523 | (string= (buffer-substring-no-properties | |
5524 | (+ (point-min) 2) | |
5525 | (progn | |
5526 | (end-of-line) | |
5527 | (1- (point)))) | |
5528 | truename)) | |
5529 | (setq found (car blist)))) | |
5530 | (setq blist (cdr blist))) | |
5531 | found))) | |
5532 | ||
5533 | ||
5534 | (defun pr-file-list (dir file-regexp fun) | |
5535 | (mapcar #'(lambda (file) | |
5536 | (and (or pr-list-directory | |
5537 | (not (file-directory-p file))) | |
5538 | (let ((buffer (pr-find-buffer-visiting file)) | |
5539 | pop-up-windows | |
5540 | pop-up-frames) | |
5541 | (and (or buffer | |
5542 | (file-readable-p file)) | |
5543 | (save-excursion | |
5544 | (set-buffer (or buffer | |
5545 | (find-file-noselect file))) | |
5546 | (funcall fun) | |
5547 | (or buffer | |
5548 | (kill-buffer (current-buffer)))))))) | |
5549 | (directory-files dir t file-regexp))) | |
5550 | ||
5551 | ||
5552 | (defun pr-delete-file-if-exists (filename) | |
5553 | (and (not pr-spool-p) (stringp filename) (file-exists-p filename) | |
5554 | (delete-file filename))) | |
5555 | ||
5556 | ||
5557 | (defun pr-ps-file-list (n-up dir file-regexp filename) | |
5558 | (pr-delete-file-if-exists (setq filename (pr-expand-file-name filename))) | |
5559 | (let ((pr-spool-p t)) | |
5560 | (pr-file-list dir file-regexp | |
5561 | #'(lambda () | |
5562 | (if (pr-auto-mode-p) | |
5563 | (pr-ps-mode n-up filename) | |
5564 | (pr-text2ps 'buffer n-up filename))))) | |
5565 | (or pr-spool-p | |
5566 | (pr-despool-print filename))) | |
5567 | ||
5568 | ||
5569 | (defun pr-text2ps (kind n-up filename &optional from to) | |
5570 | (let ((ps-n-up-printing n-up) | |
5571 | (ps-spool-config (and (eq ps-spool-config 'setpagedevice) | |
5572 | 'setpagedevice))) | |
5573 | (pr-delete-file-if-exists filename) | |
5574 | (cond (pr-faces-p | |
5575 | (cond (pr-spool-p | |
5576 | ;; pr-faces-p and pr-spool-p | |
5577 | ;; here FILENAME arg is ignored | |
5578 | (cond ((eq kind 'buffer) | |
5579 | (ps-spool-buffer-with-faces)) | |
5580 | ((eq kind 'region) | |
5581 | (ps-spool-region-with-faces (or from (point)) | |
5582 | (or to (mark)))) | |
5583 | )) | |
5584 | ;; pr-faces-p and not pr-spool-p | |
5585 | ((eq kind 'buffer) | |
5586 | (ps-print-buffer-with-faces filename)) | |
5587 | ((eq kind 'region) | |
5588 | (ps-print-region-with-faces (or from (point)) | |
5589 | (or to (mark)) filename)) | |
5590 | )) | |
5591 | (pr-spool-p | |
5592 | ;; not pr-faces-p and pr-spool-p | |
5593 | ;; here FILENAME arg is ignored | |
5594 | (cond ((eq kind 'buffer) | |
5595 | (ps-spool-buffer)) | |
5596 | ((eq kind 'region) | |
5597 | (ps-spool-region (or from (point)) (or to (mark)))) | |
5598 | )) | |
5599 | ;; not pr-faces-p and not pr-spool-p | |
5600 | ((eq kind 'buffer) | |
5601 | (ps-print-buffer filename)) | |
5602 | ((eq kind 'region) | |
5603 | (ps-print-region (or from (point)) (or to (mark)) filename)) | |
5604 | ))) | |
5605 | ||
5606 | ||
5607 | (defun pr-command (command) | |
5608 | "Return absolute file name specification for COMMAND. | |
5609 | ||
449cba44 VJL |
5610 | If COMMAND is an empty string, return it. |
5611 | ||
2c840b90 KS |
5612 | If COMMAND is already an absolute file name specification, return it. |
5613 | Else it uses `pr-path-alist' to find COMMAND, if find it then return it; | |
5614 | otherwise, gives an error. | |
5615 | ||
5616 | When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and | |
5617 | `unix' are used (see `pr-path-alist' for documentation). | |
5618 | ||
5619 | If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND, | |
5620 | COMMAND.exe, COMMAND.bat and COMMAND.com in this order." | |
449cba44 VJL |
5621 | (if (string= command "") |
5622 | command | |
0117451d | 5623 | (pr-dosify-file-name |
449cba44 VJL |
5624 | (or (pr-find-command command) |
5625 | (pr-path-command (cond (pr-cygwin-system 'cygwin) | |
5626 | (ps-windows-system 'windows) | |
5627 | (t 'unix)) | |
5628 | (file-name-nondirectory command) | |
5629 | nil) | |
5630 | (error "Command not found: %s" | |
5631 | (file-name-nondirectory command)))))) | |
2c840b90 KS |
5632 | |
5633 | ||
5634 | (defun pr-path-command (symbol command sym-list) | |
5635 | (let ((lpath (cdr (assq symbol pr-path-alist))) | |
5636 | cmd) | |
5637 | ;; PATH expansion | |
5638 | (and (eq symbol 'PATH) (null lpath) | |
5639 | (setq lpath (parse-colon-path (getenv "PATH")))) | |
5640 | (while (and lpath | |
5641 | (not | |
5642 | (setq cmd | |
5643 | (let ((path (car lpath))) | |
5644 | (cond | |
5645 | ;; symbol expansion | |
5646 | ((symbolp path) | |
5647 | (and (not (memq path sym-list)) | |
5648 | (pr-path-command path command | |
5649 | (cons path sym-list)))) | |
5650 | ;; normal path | |
5651 | ((stringp path) | |
5652 | (pr-find-command | |
5653 | (expand-file-name | |
5654 | (substitute-in-file-name | |
5655 | (concat (file-name-as-directory path) | |
5656 | command))))) | |
5657 | ))))) | |
5658 | (setq lpath (cdr lpath))) | |
5659 | cmd)) | |
5660 | ||
5661 | ||
5662 | (defun pr-find-command (cmd) | |
5663 | (if ps-windows-system | |
5664 | ;; windows system | |
5665 | (let ((ext (cons (file-name-extension cmd t) | |
5666 | (list ".exe" ".bat" ".com"))) | |
5667 | found) | |
5668 | (setq cmd (file-name-sans-extension cmd)) | |
5669 | (while (and ext | |
5670 | (setq found (concat cmd (car ext))) | |
5671 | (not (and (file-regular-p found) | |
5672 | (file-executable-p found)))) | |
5673 | (setq ext (cdr ext) | |
5674 | found nil)) | |
5675 | found) | |
5676 | ;; non-windows systems | |
5677 | (and (file-regular-p cmd) | |
5678 | (file-executable-p cmd) | |
5679 | cmd))) | |
5680 | ||
5681 | ||
5682 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
5683 | ;; Printing Interface (inspired on ps-print-interface.el) | |
5684 | ||
5685 | ||
5686 | (require 'widget) | |
5687 | (require 'wid-edit) | |
5688 | (require 'cus-edit) | |
5689 | ||
5690 | ||
5691 | (defvar pr-i-window-configuration nil) | |
5692 | ||
5693 | (defvar pr-i-buffer nil) | |
5694 | (defvar pr-i-region nil) | |
5695 | (defvar pr-i-mode nil) | |
5696 | (defvar pr-i-despool nil) | |
5697 | (defvar pr-i-ps-as-is t) | |
5698 | (defvar pr-i-n-up 1) | |
5699 | (defvar pr-i-directory "./") | |
5700 | (defvar pr-i-regexp "") | |
5701 | (defvar pr-i-ps-file "") | |
5702 | (defvar pr-i-out-file "") | |
5703 | (defvar pr-i-answer-yes nil) | |
5704 | (defvar pr-i-process 'buffer) | |
5705 | (defvar pr-i-ps-send 'printer) | |
5706 | ||
5707 | ||
5708 | (defvar pr-interface-map nil | |
5709 | "Keymap for pr-interface.") | |
5710 | ||
5711 | (if pr-interface-map | |
5712 | nil | |
5713 | (setq pr-interface-map (make-sparse-keymap)) | |
5714 | (cond ((eq ps-print-emacs-type 'xemacs) ; XEmacs | |
5715 | (pr-f-set-keymap-parents pr-interface-map (list widget-keymap)) | |
5716 | (pr-f-set-keymap-name pr-interface-map 'pr-interface-map)) | |
5717 | ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | |
5718 | (pr-f-set-keymap-parents pr-interface-map widget-keymap))) | |
5719 | (define-key pr-interface-map "q" 'pr-interface-quit) | |
5720 | (define-key pr-interface-map "?" 'pr-interface-help)) | |
5721 | ||
5722 | ||
5723 | (defmacro pr-interface-save (&rest body) | |
5724 | `(save-excursion | |
5725 | (set-buffer pr-i-buffer) | |
5726 | ,@body)) | |
5727 | ||
5728 | ||
5729 | (defun pr-create-interface () | |
5730 | "Create the front end for printing package." | |
5731 | (setq pr-i-buffer (buffer-name (current-buffer)) | |
5732 | pr-i-region (ps-mark-active-p) | |
5733 | pr-i-mode (pr-mode-alist-p) | |
5734 | pr-i-window-configuration (current-window-configuration)) | |
5735 | ||
5736 | (put 'pr-i-process 'pr-widget-list nil) | |
5737 | (put 'pr-i-ps-send 'pr-widget-list nil) | |
5738 | ||
5739 | (delete-other-windows) | |
5740 | (kill-buffer (get-buffer-create pr-buffer-name)) | |
5741 | (switch-to-buffer (get-buffer-create pr-buffer-name)) | |
5742 | ||
5743 | ;; header | |
5744 | (let ((versions (concat "printing v" pr-version | |
5745 | " ps-print v" ps-print-version))) | |
5746 | (widget-insert (make-string (- 79 (length versions)) ?\ ) versions)) | |
5747 | (pr-insert-italic "\nCurrent Directory : " 1) | |
5748 | (pr-insert-italic default-directory) | |
5749 | ||
5750 | (pr-insert-section-1) ; 1. Print | |
5751 | (pr-insert-section-2) ; 2. PostScript Printer | |
5752 | (pr-insert-section-3) ; 3. Text Printer | |
5753 | ||
5754 | ;; separator | |
5755 | (widget-insert "\n\n " (make-string 77 ?-)) | |
5756 | ||
5757 | (pr-insert-section-4) ; 4. Settings | |
5758 | (pr-insert-section-5) ; 5. Customize | |
5759 | (pr-insert-section-6) ; 6. Show Settings | |
5760 | (pr-insert-section-7) ; 7. Help | |
5761 | ||
5762 | (use-local-map pr-interface-map) | |
5763 | (widget-setup) | |
5764 | (goto-char (point-min)) | |
5765 | ||
5766 | (and pr-i-region ; let region activated | |
5767 | (pr-keep-region-active))) | |
5768 | ||
5769 | ||
5770 | (defun pr-insert-section-1 () | |
5771 | ;; 1. Print: | |
5772 | (pr-insert-italic "\nPrint :" 1) | |
5773 | ||
5774 | ;; 1a. Buffer: | |
5775 | ;; 1a. Buffer: Buffer List | |
5776 | (pr-insert-radio-button 'pr-i-process 'buffer) | |
5777 | (pr-insert-menu "Buffer List" 'pr-i-buffer | |
5778 | (let ((blist (buffer-list)) | |
5779 | case-fold-search choices) | |
5780 | (while blist | |
5781 | (let ((name (buffer-name (car blist))) | |
5782 | (ignore pr-buffer-name-ignore) | |
5783 | found) | |
5784 | (setq blist (cdr blist)) | |
5785 | (while (and ignore (not found)) | |
5786 | (setq found (string-match (car ignore) name) | |
5787 | ignore (cdr ignore))) | |
5788 | (or found | |
5789 | (setq choices | |
5790 | (cons (list 'quote | |
5791 | (list 'choice-item | |
5792 | :format "%[%t%]" | |
5793 | name)) | |
5794 | choices))))) | |
5795 | (nreverse choices)) | |
5796 | " Buffer : " nil | |
5797 | '(progn | |
5798 | (pr-interface-save | |
5799 | (setq pr-i-region (ps-mark-active-p) | |
5800 | pr-i-mode (pr-mode-alist-p))) | |
5801 | (pr-update-checkbox 'pr-i-region) | |
5802 | (pr-update-checkbox 'pr-i-mode))) | |
5803 | ;; 1a. Buffer: Region | |
5804 | (put 'pr-i-region 'pr-widget | |
5805 | (pr-insert-checkbox | |
5806 | "\n " | |
5807 | 'pr-i-region | |
5808 | #'(lambda (widget &rest ignore) | |
5809 | (let ((region-p (pr-interface-save | |
5810 | (ps-mark-active-p)))) | |
5811 | (cond ((null (widget-value widget)) ; widget is nil | |
5812 | (setq pr-i-region nil)) | |
5813 | (region-p ; widget is true and there is a region | |
5814 | (setq pr-i-region t) | |
5815 | (widget-value-set widget t) | |
5816 | (widget-setup)) ; MUST be called after widget-value-set | |
5817 | (t ; widget is true and there is no region | |
5818 | (ding) | |
5819 | (message "There is no region active") | |
5820 | (setq pr-i-region nil) | |
5821 | (widget-value-set widget nil) | |
5822 | (widget-setup))))) ; MUST be called after widget-value-set | |
5823 | " Region")) | |
5824 | ;; 1a. Buffer: Mode | |
5825 | (put 'pr-i-mode 'pr-widget | |
5826 | (pr-insert-checkbox | |
5827 | " " | |
5828 | 'pr-i-mode | |
5829 | #'(lambda (widget &rest ignore) | |
5830 | (let ((mode-p (pr-interface-save | |
5831 | (pr-mode-alist-p)))) | |
5832 | (cond | |
5833 | ((null (widget-value widget)) ; widget is nil | |
5834 | (setq pr-i-mode nil)) | |
5835 | (mode-p ; widget is true and there is a `mode' | |
5836 | (setq pr-i-mode t) | |
5837 | (widget-value-set widget t) | |
5838 | (widget-setup)) ; MUST be called after widget-value-set | |
5839 | (t ; widget is true and there is no `mode' | |
5840 | (ding) | |
5841 | (message | |
5842 | "This buffer isn't in a mode that printing treats specially.") | |
5843 | (setq pr-i-mode nil) | |
5844 | (widget-value-set widget nil) | |
5845 | (widget-setup))))) ; MUST be called after widget-value-set | |
5846 | " Mode\n")) | |
5847 | ||
5848 | ;; 1b. Directory: | |
5849 | (pr-insert-radio-button 'pr-i-process 'directory) | |
5850 | (widget-create | |
5851 | 'directory | |
5852 | :size 58 | |
5853 | :format " Directory : %v" | |
5854 | :notify 'pr-interface-directory | |
5855 | :action (lambda (widget &optional event) | |
5856 | (if (pr-interface-directory widget) | |
5857 | (pr-widget-field-action widget event) | |
5858 | (ding) | |
449cba44 | 5859 | (message "Please specify a readable directory"))) |
2c840b90 KS |
5860 | pr-i-directory) |
5861 | ;; 1b. Directory: File Regexp | |
5862 | (widget-create 'regexp | |
5863 | :size 58 | |
5864 | :format "\n File Regexp : %v\n" | |
5865 | :notify (lambda (widget &rest ignore) | |
5866 | (setq pr-i-regexp (widget-value widget))) | |
5867 | pr-i-regexp) | |
5868 | ;; 1b. Directory: List Directory Entry | |
5869 | (widget-insert " ") | |
5870 | (pr-insert-toggle 'pr-list-directory " List Directory Entry\n") | |
5871 | ||
5872 | ;; 1c. PostScript File: | |
5873 | (pr-insert-radio-button 'pr-i-process 'file) | |
5874 | (widget-create | |
5875 | 'file | |
5876 | :size 51 | |
5877 | :format " PostScript File : %v" | |
5878 | :notify 'pr-interface-infile | |
5879 | :action (lambda (widget &rest event) | |
5880 | (if (pr-interface-infile widget) | |
5881 | (pr-widget-field-action widget event) | |
5882 | (ding) | |
449cba44 | 5883 | (message "Please specify a readable PostScript file"))) |
2c840b90 KS |
5884 | pr-i-ps-file) |
5885 | ;; 1c. PostScript File: PostScript Utility | |
5886 | (pr-insert-menu "PostScript Utility" 'pr-ps-utility | |
5887 | (pr-choice-alist pr-ps-utility-alist) | |
5888 | "\n PostScript Utility : " | |
5889 | " ") | |
b8d955f4 VJL |
5890 | ;; 1c. PostScript File: No Preprocessing |
5891 | (pr-insert-toggle 'pr-i-ps-as-is " No Preprocessing")) | |
2c840b90 KS |
5892 | |
5893 | ||
5894 | (defun pr-insert-section-2 () | |
5895 | ;; 2. PostScript Printer: | |
5896 | ;; 2. PostScript Printer: PostScript Printer List | |
5897 | (pr-insert-italic "\n\nPostScript Printer : " 2 20) | |
5898 | (pr-insert-menu "PostScript Printer" 'pr-ps-name | |
5899 | (pr-choice-alist pr-ps-printer-alist)) | |
5900 | ;; 2. PostScript Printer: Despool | |
5901 | (put 'pr-i-despool 'pr-widget | |
5902 | (pr-insert-checkbox | |
5903 | " " | |
5904 | 'pr-i-despool | |
5905 | #'(lambda (widget &rest ignore) | |
5906 | (if pr-spool-p | |
5907 | (setq pr-i-despool (not pr-i-despool)) | |
5908 | (ding) | |
449cba44 | 5909 | (message "Can despool only when spooling is actually selected") |
2c840b90 KS |
5910 | (setq pr-i-despool nil)) |
5911 | (widget-value-set widget pr-i-despool) | |
5912 | (widget-setup)) ; MUST be called after widget-value-set | |
5913 | " Despool ")) | |
5914 | ;; 2. PostScript Printer: Preview Print Quit | |
5915 | (pr-insert-button 'pr-interface-preview "Preview" " ") | |
5916 | (pr-insert-button 'pr-interface-ps-print "Print" " ") | |
5917 | (pr-insert-button 'pr-interface-quit "Quit") | |
5918 | ;; 2. PostScript Printer: Send to Printer/Temporary File | |
5919 | (pr-insert-radio-button 'pr-i-ps-send 'printer) | |
5920 | (widget-insert " Send to Printer/Temporary File") | |
5921 | ;; 2. PostScript Printer: Send to File | |
5922 | (pr-insert-radio-button 'pr-i-ps-send 'file) | |
5923 | (widget-create | |
5924 | 'file | |
5925 | :size 57 | |
5926 | :format " Send to File : %v" | |
5927 | :notify 'pr-interface-outfile | |
5928 | :action (lambda (widget &rest event) | |
5929 | (if (and (pr-interface-outfile widget) | |
5930 | (or (not (file-exists-p pr-i-out-file)) | |
5931 | (setq pr-i-answer-yes | |
5932 | (y-or-n-p "File exists; overwrite? ")))) | |
5933 | (pr-widget-field-action widget event) | |
5934 | (ding) | |
449cba44 | 5935 | (message "Please specify a writable PostScript file"))) |
2c840b90 KS |
5936 | pr-i-out-file) |
5937 | ;; 2. PostScript Printer: N-Up | |
5938 | (widget-create | |
5939 | 'integer | |
5940 | :size 3 | |
5941 | :format "\n N-Up : %v" | |
5942 | :notify (lambda (widget &rest ignore) | |
5943 | (let ((value (if (string= (widget-apply widget :value-get) "") | |
5944 | 0 | |
5945 | (widget-value widget)))) | |
5946 | (if (and (integerp value) | |
5947 | (<= 1 value) (<= value 100)) | |
5948 | (progn | |
5949 | (message " ") | |
5950 | (setq pr-i-n-up value)) | |
5951 | (ding) | |
449cba44 | 5952 | (message "Please specify an integer between 1 and 100")))) |
2c840b90 KS |
5953 | pr-i-n-up)) |
5954 | ||
5955 | ||
5956 | (defun pr-insert-section-3 () | |
5957 | ;; 3. Text Printer: | |
5958 | (pr-insert-italic "\n\nText Printer : " 2 14) | |
5959 | (pr-insert-menu "Text Printer" 'pr-txt-name | |
5960 | (pr-choice-alist pr-txt-printer-alist) | |
5961 | nil " ") | |
5962 | (pr-insert-button 'pr-interface-printify "Printify" " ") | |
5963 | (pr-insert-button 'pr-interface-txt-print "Print" " ") | |
5964 | (pr-insert-button 'pr-interface-quit "Quit")) | |
5965 | ||
5966 | ||
5967 | (defun pr-insert-section-4 () | |
5968 | ;; 4. Settings: | |
5969 | ;; 4. Settings: Landscape Auto Region Verbose | |
5970 | (pr-insert-checkbox "\n\n " 'ps-landscape-mode | |
5971 | #'(lambda (&rest ignore) | |
5972 | (setq ps-landscape-mode (not ps-landscape-mode) | |
5973 | pr-file-landscape ps-landscape-mode)) | |
5974 | " Landscape ") | |
5975 | (pr-insert-toggle 'pr-auto-region " Auto Region ") | |
5976 | (pr-insert-toggle 'pr-buffer-verbose " Verbose\n ") | |
5977 | ||
5978 | ;; 4. Settings: Print Header Auto Mode | |
5979 | (pr-insert-toggle 'ps-print-header " Print Header ") | |
5980 | (pr-insert-toggle 'pr-auto-mode " Auto Mode\n ") | |
5981 | ||
5982 | ;; 4. Settings: Print Header Frame Menu Lock | |
5983 | (pr-insert-toggle 'ps-print-header-frame " Print Header Frame ") | |
5984 | (pr-insert-toggle 'pr-menu-lock " Menu Lock\n ") | |
5985 | ||
5986 | ;; 4. Settings: Line Number | |
5987 | (pr-insert-toggle 'ps-line-number " Line Number\n ") | |
5988 | ||
5989 | ;; 4. Settings: Zebra Stripes Spool Buffer | |
5990 | (pr-insert-toggle 'ps-zebra-stripes " Zebra Stripes") | |
5991 | (pr-insert-checkbox " " | |
5992 | 'pr-spool-p | |
5993 | #'(lambda (&rest ignore) | |
5994 | (setq pr-spool-p (not pr-spool-p)) | |
5995 | (unless pr-spool-p | |
5996 | (setq pr-i-despool nil) | |
5997 | (pr-update-checkbox 'pr-i-despool))) | |
5998 | " Spool Buffer") | |
5999 | ||
449cba44 | 6000 | ;; 4. Settings: Duplex Print with faces |
2c840b90 KS |
6001 | (pr-insert-checkbox "\n " |
6002 | 'ps-spool-duplex | |
6003 | #'(lambda (&rest ignore) | |
6004 | (setq ps-spool-duplex (not ps-spool-duplex) | |
6005 | pr-file-duplex ps-spool-duplex)) | |
6006 | " Duplex ") | |
449cba44 | 6007 | (pr-insert-toggle 'pr-faces-p " Print with faces") |
2c840b90 | 6008 | |
449cba44 | 6009 | ;; 4. Settings: Tumble Print via Ghostscript |
2c840b90 KS |
6010 | (pr-insert-checkbox "\n " |
6011 | 'ps-spool-tumble | |
6012 | #'(lambda (&rest ignore) | |
6013 | (setq ps-spool-tumble (not ps-spool-tumble) | |
6014 | pr-file-tumble ps-spool-tumble)) | |
6015 | " Tumble ") | |
449cba44 | 6016 | (pr-insert-toggle 'pr-print-using-ghostscript " Print via Ghostscript\n ") |
2c840b90 KS |
6017 | |
6018 | ;; 4. Settings: Upside-Down Page Parity | |
acc037ba VJL |
6019 | (pr-insert-toggle 'ps-print-upside-down " Upside-Down") |
6020 | (pr-insert-italic "\n\nSelect Pages : " 2 14) | |
2c840b90 KS |
6021 | (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages |
6022 | (mapcar #'(lambda (alist) | |
6023 | (list 'quote | |
6024 | (list 'choice-item | |
6025 | :format "%[%t%]" | |
6026 | :tag (cdr alist) | |
6027 | :value (car alist)))) | |
6028 | pr-even-or-odd-alist))) | |
6029 | ||
6030 | ||
6031 | (defun pr-insert-section-5 () | |
6032 | ;; 5. Customize: | |
6033 | (pr-insert-italic "\n\nCustomize : " 2 11) | |
6034 | (pr-insert-button 'pr-customize "printing" " ") | |
6035 | (pr-insert-button #'(lambda (&rest ignore) (ps-print-customize)) | |
6036 | "ps-print" " ") | |
6037 | (pr-insert-button 'lpr-customize "lpr")) | |
6038 | ||
6039 | ||
6040 | (defun pr-insert-section-6 () | |
6041 | ;; 6. Show Settings: | |
6042 | (pr-insert-italic "\nShow Settings : " 1 14) | |
6043 | (pr-insert-button 'pr-show-pr-setup "printing" " ") | |
6044 | (pr-insert-button 'pr-show-ps-setup "ps-print" " ") | |
6045 | (pr-insert-button 'pr-show-lpr-setup "lpr")) | |
6046 | ||
6047 | ||
6048 | (defun pr-insert-section-7 () | |
6049 | ;; 7. Help: | |
6050 | (pr-insert-italic "\nHelp : " 1 5) | |
6051 | (pr-insert-button 'pr-interface-help "Interface Help" " ") | |
6052 | (pr-insert-button 'pr-help "Menu Help" " ") | |
6053 | (pr-insert-button 'pr-interface-quit "Quit" "\n ") | |
6054 | (pr-insert-button 'pr-kill-help "Kill All Printing Help Buffer")) | |
6055 | ||
6056 | ||
6057 | (defun pr-kill-help (&rest ignore) | |
6058 | "Kill all printing help buffer." | |
6059 | (interactive) | |
6060 | (let ((help '("*Printing Interface Help*" "*Printing Help*" | |
6061 | "*LPR Setup*" "*PR Setup*" "*PS Setup*"))) | |
6062 | (while help | |
6063 | (let ((buffer (get-buffer (car help)))) | |
6064 | (setq help (cdr help)) | |
6065 | (when buffer | |
6066 | (delete-windows-on buffer) | |
6067 | (kill-buffer buffer))))) | |
6068 | (recenter (- (window-height) 2))) | |
6069 | ||
6070 | ||
6071 | (defun pr-interface-quit (&rest ignore) | |
6072 | "Kill the printing buffer interface and quit." | |
6073 | (interactive) | |
6074 | (kill-buffer pr-buffer-name) | |
6075 | (set-window-configuration pr-i-window-configuration)) | |
6076 | ||
6077 | ||
6078 | (defun pr-interface-help (&rest ignore) | |
6079 | "printing buffer interface help." | |
6080 | (interactive) | |
6081 | (pr-show-setup pr-interface-help-message "*Printing Interface Help*")) | |
6082 | ||
6083 | ||
6084 | (defun pr-interface-txt-print (&rest ignore) | |
6085 | "Print using lpr package." | |
6086 | (interactive) | |
6087 | (condition-case data | |
6088 | (cond | |
6089 | ((eq pr-i-process 'directory) | |
6090 | (pr-i-directory) | |
6091 | (pr-interface-save | |
6092 | (pr-txt-directory pr-i-directory pr-i-regexp))) | |
6093 | ((eq pr-i-process 'buffer) | |
6094 | (pr-interface-save | |
6095 | (cond (pr-i-region | |
6096 | (let ((pr-auto-mode pr-i-mode)) | |
6097 | (pr-txt-region))) | |
6098 | (pr-i-mode | |
6099 | (let (pr-auto-region) | |
6100 | (pr-txt-mode))) | |
6101 | (t | |
6102 | (let (pr-auto-mode pr-auto-region) | |
6103 | (pr-txt-buffer))) | |
6104 | ))) | |
6105 | ((eq pr-i-process 'file) | |
449cba44 | 6106 | (error "Please specify a text file")) |
2c840b90 KS |
6107 | (t |
6108 | (error "Internal error: `pr-i-process' = %S" pr-i-process)) | |
6109 | ) | |
6110 | ;; handlers | |
6111 | ((quit error) | |
6112 | (ding) | |
6113 | (message (error-message-string data))))) | |
6114 | ||
6115 | ||
6116 | (defun pr-interface-printify (&rest ignore) | |
6117 | "Printify a buffer." | |
6118 | (interactive) | |
6119 | (condition-case data | |
6120 | (cond | |
6121 | ((eq pr-i-process 'directory) | |
6122 | (pr-i-directory) | |
6123 | (pr-interface-save | |
6124 | (pr-printify-directory pr-i-directory pr-i-regexp))) | |
6125 | ((eq pr-i-process 'buffer) | |
6126 | (pr-interface-save | |
6127 | (if pr-i-region | |
6128 | (pr-printify-region) | |
6129 | (pr-printify-buffer)))) | |
6130 | ((eq pr-i-process 'file) | |
449cba44 | 6131 | (error "Cannot printify a PostScript file")) |
2c840b90 KS |
6132 | (t |
6133 | (error "Internal error: `pr-i-process' = %S" pr-i-process)) | |
6134 | ) | |
6135 | ;; handlers | |
6136 | ((quit error) | |
6137 | (ding) | |
6138 | (message (error-message-string data))))) | |
6139 | ||
6140 | ||
6141 | (defun pr-interface-ps-print (&rest ignore) | |
6142 | "Print using ps-print package." | |
6143 | (interactive) | |
6144 | (pr-interface-ps 'pr-despool-ps-print 'pr-ps-directory-ps-print | |
6145 | 'pr-ps-file-ps-print 'pr-ps-file-up-ps-print | |
6146 | 'pr-ps-region-ps-print 'pr-ps-mode-ps-print | |
6147 | 'pr-ps-buffer-ps-print)) | |
6148 | ||
6149 | ||
6150 | (defun pr-interface-preview (&rest ignore) | |
6151 | "Preview a PostScript file." | |
6152 | (interactive) | |
6153 | (pr-interface-ps 'pr-despool-preview 'pr-ps-directory-preview | |
6154 | 'pr-ps-file-preview 'pr-ps-file-up-preview | |
6155 | 'pr-ps-region-preview 'pr-ps-mode-preview | |
6156 | 'pr-ps-buffer-preview)) | |
6157 | ||
6158 | ||
6159 | (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region | |
6160 | ps-mode ps-buffer) | |
6161 | (condition-case data | |
6162 | (let ((outfile (or (and (eq pr-i-process 'file) pr-i-ps-as-is) | |
6163 | (pr-i-ps-send)))) | |
6164 | (cond | |
6165 | ((and pr-i-despool pr-spool-p) | |
6166 | (pr-interface-save | |
6167 | (funcall ps-despool outfile)) | |
6168 | (setq pr-i-despool nil) | |
6169 | (pr-update-checkbox 'pr-i-despool)) | |
6170 | ((eq pr-i-process 'directory) | |
6171 | (pr-i-directory) | |
6172 | (pr-interface-save | |
6173 | (funcall ps-directory | |
6174 | pr-i-n-up pr-i-directory pr-i-regexp outfile))) | |
6175 | ((eq pr-i-process 'file) | |
6176 | (cond ((or (file-directory-p pr-i-ps-file) | |
6177 | (not (file-readable-p pr-i-ps-file))) | |
449cba44 | 6178 | (error "Please specify a readable PostScript file")) |
2c840b90 KS |
6179 | (pr-i-ps-as-is |
6180 | (pr-interface-save | |
6181 | (funcall ps-file pr-i-ps-file))) | |
6182 | (t | |
6183 | (pr-interface-save | |
6184 | (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile))) | |
6185 | )) | |
6186 | ((eq pr-i-process 'buffer) | |
6187 | (pr-interface-save | |
6188 | (cond (pr-i-region | |
6189 | (let ((pr-auto-mode pr-i-mode)) | |
6190 | (funcall ps-region pr-i-n-up outfile))) | |
6191 | (pr-i-mode | |
6192 | (let (pr-auto-region) | |
6193 | (funcall ps-mode pr-i-n-up outfile))) | |
6194 | (t | |
6195 | (let (pr-auto-mode pr-auto-region) | |
6196 | (funcall ps-buffer pr-i-n-up outfile))) | |
6197 | ))) | |
6198 | (t | |
6199 | (error "Internal error: `pr-i-process' = %S" pr-i-process)) | |
6200 | )) | |
6201 | ;; handlers | |
6202 | ((quit error) | |
6203 | (ding) | |
6204 | (message (error-message-string data))))) | |
6205 | ||
6206 | ||
6207 | (defun pr-i-ps-send () | |
6208 | (cond ((eq pr-i-ps-send 'printer) | |
6209 | nil) | |
6210 | ((not (eq pr-i-ps-send 'file)) | |
6211 | (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send)) | |
6212 | ((or (file-directory-p pr-i-out-file) | |
6213 | (not (file-writable-p pr-i-out-file))) | |
449cba44 | 6214 | (error "Please specify a writable PostScript file")) |
2c840b90 KS |
6215 | ((or (not (file-exists-p pr-i-out-file)) |
6216 | pr-i-answer-yes | |
6217 | (setq pr-i-answer-yes | |
6218 | (y-or-n-p (format "File `%s' exists; overwrite? " | |
6219 | pr-i-out-file)))) | |
6220 | pr-i-out-file) | |
6221 | (t | |
6222 | (error "File already exists")))) | |
6223 | ||
6224 | ||
6225 | (defun pr-i-directory () | |
6226 | (or (and (file-directory-p pr-i-directory) | |
6227 | (file-readable-p pr-i-directory)) | |
449cba44 | 6228 | (error "Please specify be a readable directory"))) |
2c840b90 KS |
6229 | |
6230 | ||
6231 | (defun pr-interface-directory (widget &rest ignore) | |
6232 | (and pr-buffer-verbose | |
449cba44 | 6233 | (message "You can use M-TAB or ESC TAB for file completion")) |
2c840b90 KS |
6234 | (let ((dir (widget-value widget))) |
6235 | (and (file-directory-p dir) | |
6236 | (file-readable-p dir) | |
6237 | (setq pr-i-directory dir)))) | |
6238 | ||
6239 | ||
6240 | (defun pr-interface-infile (widget &rest ignore) | |
6241 | (and pr-buffer-verbose | |
449cba44 | 6242 | (message "You can use M-TAB or ESC TAB for file completion")) |
2c840b90 KS |
6243 | (let ((file (widget-value widget))) |
6244 | (and (not (file-directory-p file)) | |
6245 | (file-readable-p file) | |
6246 | (setq pr-i-ps-file file)))) | |
6247 | ||
6248 | ||
6249 | (defun pr-interface-outfile (widget &rest ignore) | |
6250 | (setq pr-i-answer-yes nil) | |
6251 | (and pr-buffer-verbose | |
449cba44 | 6252 | (message "You can use M-TAB or ESC TAB for file completion")) |
2c840b90 KS |
6253 | (let ((file (widget-value widget))) |
6254 | (and (not (file-directory-p file)) | |
6255 | (file-writable-p file) | |
6256 | (setq pr-i-out-file file)))) | |
6257 | ||
6258 | ||
6259 | (defun pr-widget-field-action (widget event) | |
6260 | (and (get-buffer "*Completions*") ; clean frame window | |
6261 | (delete-windows-on "*Completions*")) | |
6262 | (message " ") ; clean echo area | |
6263 | (widget-field-action widget event)) | |
6264 | ||
6265 | ||
6266 | (defun pr-insert-italic (str &optional from to) | |
6267 | (let ((len (length str))) | |
6268 | (put-text-property (if from (max from 0) 0) | |
6269 | (if to (max to len) len) | |
6270 | 'face 'italic str) | |
6271 | (widget-insert str))) | |
6272 | ||
6273 | ||
6274 | (defun pr-insert-checkbox (before var-sym fun label) | |
6275 | (widget-insert before) | |
6276 | (prog1 | |
6277 | (widget-create 'checkbox | |
6278 | :notify fun | |
6279 | (symbol-value var-sym)) | |
6280 | (widget-insert label))) | |
6281 | ||
6282 | ||
6283 | (defun pr-insert-toggle (var-sym label) | |
6284 | (widget-create 'checkbox | |
6285 | :notify `(lambda (&rest ignore) | |
6286 | (setq ,var-sym (not ,var-sym))) | |
6287 | (symbol-value var-sym)) | |
6288 | (widget-insert label)) | |
6289 | ||
6290 | ||
6291 | (defun pr-insert-button (fun label &optional separator) | |
6292 | (widget-create 'push-button | |
6293 | :notify fun | |
6294 | label) | |
6295 | (and separator | |
6296 | (widget-insert separator))) | |
6297 | ||
6298 | ||
6299 | (defun pr-insert-menu (tag var-sym choices &optional before after &rest body) | |
6300 | (and before (widget-insert before)) | |
6301 | (eval `(widget-create 'menu-choice | |
6302 | :tag ,tag | |
6303 | :format "%v" | |
6304 | :inline t | |
6305 | :value ,var-sym | |
6306 | :notify (lambda (widget &rest ignore) | |
6307 | (setq ,var-sym (widget-value widget)) | |
6308 | ,@body) | |
6309 | :void '(choice-item :format "%[%t%]" | |
6310 | :tag "Can not display value!") | |
6311 | ,@choices)) | |
6312 | (and after (widget-insert after))) | |
6313 | ||
6314 | ||
6315 | (defun pr-insert-radio-button (var-sym sym) | |
6316 | (widget-insert "\n") | |
6317 | (let ((wid-list (get var-sym 'pr-widget-list)) | |
6318 | (wid (eval `(widget-create | |
6319 | 'radio-button | |
6320 | :format " %[%v%]" | |
6321 | :value (eq ,var-sym (quote ,sym)) | |
6322 | :notify (lambda (&rest ignore) | |
6323 | (setq ,var-sym (quote ,sym)) | |
6324 | (pr-update-radio-button (quote ,var-sym))))))) | |
6325 | (put var-sym 'pr-widget-list (cons (cons wid sym) wid-list)))) | |
6326 | ||
6327 | ||
6328 | (defun pr-update-radio-button (var-sym) | |
6329 | (let ((wid-list (get var-sym 'pr-widget-list))) | |
6330 | (while wid-list | |
6331 | (let ((wid (car (car wid-list))) | |
6332 | (value (cdr (car wid-list)))) | |
6333 | (setq wid-list (cdr wid-list)) | |
6334 | (widget-value-set wid (eq (symbol-value var-sym) value)))) | |
6335 | (widget-setup))) | |
6336 | ||
6337 | ||
6338 | (defun pr-update-checkbox (var-sym) | |
6339 | (let ((wid (get var-sym 'pr-widget))) | |
6340 | (when wid | |
6341 | (widget-value-set wid (symbol-value var-sym)) | |
6342 | (widget-setup)))) | |
6343 | ||
6344 | ||
6345 | (defun pr-choice-alist (alist) | |
6346 | (let ((max (apply 'max (mapcar #'(lambda (alist) | |
6347 | (length (symbol-name (car alist)))) | |
6348 | alist)))) | |
6349 | (mapcar #'(lambda (alist) | |
6350 | (let* ((sym (car alist)) | |
6351 | (name (symbol-name sym))) | |
6352 | (list | |
6353 | 'quote | |
6354 | (list | |
6355 | 'choice-item | |
6356 | :format "%[%t%]" | |
6357 | :tag (concat name | |
6358 | (make-string (- max (length name)) ?_)) | |
6359 | :value sym)))) | |
6360 | alist))) | |
6361 | ||
6362 | ||
6363 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
6364 | ||
6365 | ||
6366 | (pr-update-menus t) | |
6367 | ||
6368 | ||
6369 | (provide 'printing) | |
6370 | ||
6371 | ||
ab5796a9 | 6372 | ;;; arch-tag: 9ce9ac3f-0f60-4370-900b-1943215d9d18 |
2c840b90 | 6373 | ;;; printing.el ends here |