1 ;;; printing.el --- printing utilities
3 ;; Copyright (C) 2000, 2001, 2002
4 ;; Free Software Foundation, Inc.
6 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
7 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
8 ;; Keywords: wp, print, PostScript
9 ;; Time-stamp: <2002/09/11 16:59:00 vinicius>
11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
13 (defconst pr-version
"6.7.1"
14 "printing.el, v 6.7.1 <2002/09/11 vinicius>
16 Please send all bug fixes and enhancements to
17 Vinicius Jose Latorre <vinicius@cpqd.com.br>
20 ;; This file is part of GNU Emacs.
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
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
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.
38 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
43 ;; This package provides some printing utilities that includes
44 ;; previewing/printing a PostScript file, printing a text file and
45 ;; previewing/printing some major modes (like mh-folder-mode,
46 ;; rmail-summary-mode, gnus-summary-mode, etc).
48 ;; `printing' was inspired on:
50 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr>
51 ;; Special printing functions for Windows NT
53 ;; mh-e-init.el Tom Vogels <tov@ece.cmu.edu>
54 ;; PS-print for mail messages
56 ;; win32-ps-print.el Matthew O. Persico <mpersico@erols.com>
57 ;; PostScript printing with ghostscript
59 ;; ps-print-interface.el Volker Franz <volker.franz@tuebingen.mpg.de>
60 ;; Graphical front end for ps-print and previewing
62 ;; `printing' is prepared to run on GNU, Unix and NT systems.
63 ;; On GNU or Unix system, `printing' depends on gs and gv utilities.
64 ;; On NT system, `printing' depends on gstools (gswin32.exe and gsview32.exe).
65 ;; To obtain ghostscript, ghostview and GSview see the URL
66 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'.
68 ;; `printing' also depends on ps-print and lpr GNU Emacs packages.
69 ;; To download the latest ps-print package see
70 ;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'.
71 ;; Please, see README file for ps-print installation instructions.
74 ;; Novices (First Users)
75 ;; ---------------------
77 ;; First of all, take a glance of printing documentation only to have an idea
78 ;; of what `printing' is capable.
80 ;; Then try to set the variables: `pr-ps-name', `pr-ps-printer-alist',
81 ;; `pr-txt-name', `pr-txt-printer-alist' and `pr-path-alist'. These variables
82 ;; are the main variables for printing processing.
84 ;; Now, please, see these variables documentation more in deep. You can do
85 ;; this by typing C-h v pr-ps-name RET (for example) if you already loaded
86 ;; printing package, or by browsing printing.el source file.
88 ;; If the documentation isn't clear or if you find a way to improve the
89 ;; documentation, please, send an email to maintainer. All printing users
92 ;; One way to set variables is by calling `pr-customize', customize all
93 ;; variables and save the customization by future sessions (see Options
94 ;; section). Other way is by coding your settings on Emacs init file (that is,
95 ;; .emacs file), see below for a first setting template that it should be
96 ;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT
99 ;; * Example of setting for Windows system:
101 ;; (require 'printing) ; load printing package
102 ;; (setq pr-path-alist
103 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
104 ;; (ghostview "c:/gs/gsview-dir")
105 ;; (mpage "c:/mpage-dir")
107 ;; (setq pr-txt-name 'prt_06a)
108 ;; (setq pr-txt-printer-alist
109 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
110 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
111 ;; (PRN "" nil "PRN")
112 ;; (standard "redpr.exe" nil "")
114 ;; (setq pr-ps-name 'lps_06b)
115 ;; (setq pr-ps-printer-alist
116 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
117 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
118 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
119 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
120 ;; (LPT1 "" nil "" "LPT1:")
121 ;; (PRN "" nil "" "PRN")
122 ;; (standard "redpr.exe" nil "" "")
124 ;; (pr-update-menus t) ; update now printer and utility menus
126 ;; * Example of setting for GNU or Unix system:
128 ;; (require 'printing) ; load printing package
129 ;; (setq pr-path-alist
130 ;; '((unix "." "~/bin" ghostview mpage PATH)
131 ;; (ghostview "$HOME/bin/gsview-dir")
132 ;; (mpage "$HOME/bin/mpage-dir")
134 ;; (setq pr-txt-name 'prt_06a)
135 ;; (setq pr-txt-printer-alist
136 ;; '((prt_06a "lpr" nil "prt_06a")
137 ;; (prt_07c nil nil "prt_07c")
139 ;; (setq pr-ps-name 'lps_06b)
140 ;; (setq pr-ps-printer-alist
141 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
142 ;; (lps_07c "lpr" nil nil "lps_07c")
143 ;; (lps_08c nil nil nil "lps_08c")
145 ;; (pr-update-menus t) ; update now printer and utility menus
148 ;; NOTE 1: Don't forget to download and install ghostscript utilities (see
149 ;; Utilities section).
151 ;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be
152 ;; set, as they are implicit set by `pr-ps-printer-alist' and
153 ;; `pr-txt-printer-alist'.
155 ;; NOTE 3: The duplex feature will only work on PostScript printers that
156 ;; support this feature.
157 ;; You can check if your PostScript printer supports duplex feature
158 ;; by checking the printer manual. Or you can try these steps:
159 ;; 1. Open a buffer (or use the *scratch* buffer).
161 ;; First line (on first page)
163 ;; Second line (on second page)
164 ;; 3. Print this buffer with duplex turned on.
165 ;; If it's printed 2 (two) sheets of paper, then your PostScript
166 ;; printer doesn't have duplex feature; otherwise, it's ok, your
167 ;; printer does have duplex feature.
173 ;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're
174 ;; using Windows 9x/NT or MS-DOS):
176 ;; (require 'printing)
178 ;; When `printing' is loaded:
180 ;; it replaces the Tools/Print menu by Tools/Printing menu.
182 ;; it replaces the File/Print* menu entries by File/Print menu.
183 ;; Please, see section Menu Layout below for menu explanation.
185 ;; To use `printing' utilities you can use the Printing menu options, type M-x
186 ;; followed by one of the commands below, or type a key associated with the
187 ;; command you want (if there is a key binding).
189 ;; `printing' has the following commands:
192 ;; pr-ps-directory-preview
193 ;; pr-ps-directory-using-ghostscript
194 ;; pr-ps-directory-print
195 ;; pr-ps-directory-ps-print
196 ;; pr-ps-buffer-preview
197 ;; pr-ps-buffer-using-ghostscript
198 ;; pr-ps-buffer-print
199 ;; pr-ps-buffer-ps-print
200 ;; pr-ps-region-preview
201 ;; pr-ps-region-using-ghostscript
202 ;; pr-ps-region-print
203 ;; pr-ps-region-ps-print
204 ;; pr-ps-mode-preview
205 ;; pr-ps-mode-using-ghostscript
207 ;; pr-ps-mode-ps-print
208 ;; pr-ps-file-preview
209 ;; pr-ps-file-up-preview
210 ;; pr-ps-file-using-ghostscript
212 ;; pr-ps-file-ps-print
213 ;; pr-ps-file-up-ps-print
215 ;; pr-despool-preview
216 ;; pr-despool-using-ghostscript
218 ;; pr-despool-ps-print
219 ;; pr-printify-directory
220 ;; pr-printify-buffer
221 ;; pr-printify-region
227 ;; pr-toggle-file-duplex
228 ;; pr-toggle-file-tumble
229 ;; pr-toggle-file-landscape
230 ;; pr-toggle-ghostscript
235 ;; pr-toggle-landscape
236 ;; pr-toggle-upside-down
253 ;; The general meanings of above commands are:
256 ;; `pr-interface' buffer interface for printing package.
257 ;; `pr-help' help for printing package.
258 ;; `pr-ps-name' select interactively a PostScript printer.
259 ;; `pr-txt-name' select interactively a text printer.
260 ;; `pr-ps-utility' select interactively a PostScript utility.
261 ;; `pr-show-*-setup' show current settings.
262 ;; `pr-ps-*' deal with PostScript code generation.
263 ;; `pr-txt-*' deal with text generation.
264 ;; `pr-toggle-*' toggle on/off some boolean variable.
265 ;; `pr-despool-*' despool the PostScript spooling buffer.
266 ;; `pr-printify-*' replace nonprintable ASCII by printable ASCII
270 ;; `*-customize' customization.
271 ;; `*-preview' preview a PostScript file.
272 ;; `*-using-ghostscript' use ghostscript to print.
273 ;; `*-fast-fire' fast fire command (see it for documentation).
274 ;; `*-print' send PostScript directly to printer.
275 ;; `*-ps-print' send PostScript directly to printer or use
276 ;; ghostscript to print. It depends on
277 ;; `pr-print-using-ghostscript' option.
280 ;; `*-directory*' process a directory.
281 ;; `*-buffer*' process a buffer.
282 ;; `*-region*' process a region.
283 ;; `*-mode*' process a major mode (see explanation below).
284 ;; `*-file-*' process a PostScript file.
285 ;; `*-file-up-*' process a PostScript file using a filter utility.
287 ;; Here are some examples:
289 ;; `pr-ps-buffer-using-ghostscript'
290 ;; Use ghostscript to print a buffer.
292 ;; `pr-ps-file-print'
293 ;; Print a PostScript file.
296 ;; Toggle spooling buffer.
298 ;; So you can preview through ghostview, use ghostscript to print (if you don't
299 ;; have a PostScript printer) or send directly to printer a PostScript code
300 ;; generated by `ps-print' package.
302 ;; Besides operating one buffer or region each time, you also can postpone
303 ;; previewing or printing by saving the PostScript code generated in a
304 ;; temporary Emacs buffer. This way you can save banner pages between
305 ;; successive printing. You can toggle on/off spooling by invoking
306 ;; `pr-toggle-spool' interactively or through menu bar.
308 ;; If you type, for example:
310 ;; C-u M-x pr-ps-buffer-print RET
312 ;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and
313 ;; a file name, and save the PostScript code generated to the file name instead
314 ;; of sending to printer.
316 ;; This behavior is similar with the commands that deal with PostScript code
317 ;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If
318 ;; spooling is on, only `pr-despool-*' commands prompt for a file name and save
319 ;; the PostScript code spooled in this file.
321 ;; Besides the behavior described above, the `*-directory*' commands also
322 ;; prompt for a directory and a file name regexp. So, it's possible to process
323 ;; all or certain files on a directory at once (see also documentation for
324 ;; `pr-list-directory').
326 ;; `printing' has also a special way to handle some major mode through
327 ;; `*-mode*' commands. So it's possible to customize a major mode printing,
328 ;; it's only needed to declare the customization in `pr-mode-alist' (see
329 ;; section Options) and invoke some of `*-mode*' commands. An example for
330 ;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and
331 ;; you're in the *Summary* buffer, if you forget to switch to the *Article*
332 ;; buffer before printing, you'll get a nicely formatted list of article
333 ;; subjects shows up at the printer. With major mode printing you don't need
334 ;; to switch from gnus *Summary* buffer first.
336 ;; Current global keyboard mapping for GNU Emacs is:
338 ;; (global-set-key [print] 'pr-ps-fast-fire)
339 ;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
340 ;; (global-set-key [C-print] 'pr-txt-fast-fire)
342 ;; And for XEmacs is:
344 ;; (global-set-key 'f22 'pr-ps-fast-fire)
345 ;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
346 ;; (global-set-key '(control f22) 'pr-txt-fast-fire)
348 ;; As a suggestion of global keyboard mapping for some `printing' commands:
350 ;; (global-set-key "\C-ci" 'pr-interface)
351 ;; (global-set-key "\C-cbp" 'pr-ps-buffer-print)
352 ;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview)
353 ;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
354 ;; (global-set-key "\C-crp" 'pr-ps-region-print)
355 ;; (global-set-key "\C-crx" 'pr-ps-region-preview)
356 ;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
362 ;; Below it's shown a brief description of `printing' options, please, see the
363 ;; options declaration in the code for a long documentation.
365 ;; `pr-path-style' Specify which path style to use for external
368 ;; `pr-path-alist' Specify an alist for command paths.
370 ;; `pr-txt-name' Specify a printer for printing a text file.
372 ;; `pr-txt-printer-alist' Specify an alist of all text printers.
374 ;; `pr-ps-name' Specify a printer for printing a PostScript
377 ;; `pr-ps-printer-alist' Specify an alist for all PostScript printers.
379 ;; `pr-temp-dir' Specify a directory for temporary files during
382 ;; `pr-ps-temp-file' Specify PostScript temporary file name.
384 ;; `pr-gv-command' Specify path and name of gsview program.
386 ;; `pr-gs-command' Specify path and name of ghostscript program.
388 ;; `pr-gs-switches' Specify ghostscript switches.
390 ;; `pr-gs-device' Specify ghostscript device switch value.
392 ;; `pr-gs-resolution' Specify ghostscript resolution switch value.
394 ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript.
396 ;; `pr-faces-p' Non-nil means print with face attributes.
398 ;; `pr-spool-p' Non-nil means spool printing in a buffer.
400 ;; `pr-file-landscape' Non-nil means print PostScript file in
401 ;; landscape orientation.
403 ;; `pr-file-duplex' Non-nil means print PostScript file in duplex
406 ;; `pr-file-tumble' Non-nil means print PostScript file in tumble
409 ;; `pr-auto-region' Non-nil means region is automagically detected.
411 ;; `pr-auto-mode' Non-nil means major-mode printing is prefered
412 ;; over normal printing.
414 ;; `pr-mode-alist' Specify an alist for a major-mode and printing
417 ;; `pr-ps-utility' Specify PostScript utility processing.
419 ;; `pr-ps-utility-alist' Specify an alist for PostScript utility
422 ;; `pr-menu-lock' Non-nil means menu is locked while selecting
425 ;; `pr-menu-char-height' Specify menu char height in pixels.
427 ;; `pr-menu-char-width' Specify menu char width in pixels.
429 ;; `pr-setting-database' Specify an alist for settings in general.
431 ;; `pr-visible-entry-list' Specify a list of Printing menu visible
434 ;; `pr-delete-temp-file' Non-nil means delete temporary files.
436 ;; `pr-list-directory' Non-nil means list directory when processing a
439 ;; `pr-buffer-name' Specify the name of the buffer interface for
442 ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be
443 ;; ignored in interface buffer.
445 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a
446 ;; field in interface buffer.
448 ;; `pr-shell-file-name' Specify file name to load inferior shells
451 ;; To set the above options you may:
453 ;; a) insert the code in your ~/.emacs, like:
455 ;; (setq pr-faces-p t)
457 ;; This way always keep your default settings when you enter a new Emacs
460 ;; b) or use `set-variable' in your Emacs session, like:
462 ;; M-x set-variable RET pr-faces-p RET t RET
464 ;; This way keep your settings only during the current Emacs session.
466 ;; c) or use customization, for example:
467 ;; click on menu-bar *Help* option,
468 ;; then click on *Customize*,
469 ;; then click on *Browse Customization Groups*,
470 ;; expand *PostScript* group,
471 ;; expand *Printing* group
472 ;; and then customize `printing' options.
473 ;; Through this way, you may choose if the settings are kept or not when
474 ;; you leave out the current Emacs session.
476 ;; d) or see the option value:
478 ;; C-h v pr-faces-p RET
480 ;; and click the *customize* hypertext button.
481 ;; Through this way, you may choose if the settings are kept or not when
482 ;; you leave out the current Emacs session.
486 ;; M-x pr-customize RET
488 ;; and then customize `printing' options.
489 ;; Through this way, you may choose if the settings are kept or not when
490 ;; you leave out the current Emacs session.
492 ;; f) or use menu bar, for example:
493 ;; click on menu-bar *File* option,
494 ;; then click on *Printing*,
495 ;; then click on *Customize*,
496 ;; then click on *printing*
497 ;; and then customize `printing' options.
498 ;; Through this way, you may choose if the settings are kept or not when
499 ;; you leave out the current Emacs session.
505 ;; The `printing' menu (Tools/Printing or File/Print) has the following layout:
507 ;; +-----------------------------+
508 ;; A 0 | Printing Interface |
509 ;; +-----------------------------+ +-A---------+ +-B------+
510 ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
511 ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
512 ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
513 ;; +-----------------------------+ |Mode >|-- B |Other...|
514 ;; II 4 | Printify >|-----\ |File >|--\ +--------+
515 ;; 5 | Print >|---\ | |Despool... | |
516 ;; 6 | Text Printer: name >|-\ | | +-----------+ |
517 ;; +-----------------------------+ | | | +---------+ +------------+
518 ;; III 7 |[ ]Landscape | | | \-|Directory| | As Is... | Ia
519 ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
520 ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C
521 ;; 10 |[ ]Line Number | | | +---------+ +------------+
522 ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
523 ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... |
524 ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... |
525 ;; 14 |[ ]Upside-Down | | |Region | | Other... |
526 ;; 15 | Print All Pages >|--\ | |Mode | +------------+
527 ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id
528 ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
529 ;; 17 |[ ]Print with-faces | | \--|( )name A| |[ ]Tumble | If
530 ;; 18 |[ ]Print Using Ghostscript | | |( )name B| +------------+
531 ;; +-----------------------------+ | |... |
532 ;; V 19 |[ ]Auto Region | | |(*)name |
533 ;; 20 |[ ]Auto Mode | | |... |
534 ;; 21 |[ ]Menu Lock | | +---------+ +--------------+
535 ;; +-----------------------------+ \------------------|(*)All Pages |
536 ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
537 ;; 23 | Show Settings >|-------|printing| |( )Odd Pages |
538 ;; 24 | Help | |ps-print| |( )Even Sheets|
539 ;; +-----------------------------+ |lpr | |( )Odd Sheets |
540 ;; +--------+ +--------------+
542 ;; See `pr-visible-entry-list' for hiding some parts of the menu.
544 ;; The menu has the following sections:
548 ;; 0. You can use a buffer interface instead of menus. It looks like the
549 ;; customization buffer. Basically, it has the same options found in the
550 ;; menu and some extra options, all this on a buffer.
552 ;; I. PostScript printing:
554 ;; 1. You can generate a PostScript file (if you type C-u before activating
555 ;; menu) or PostScript temporary file for a directory, a buffer, a region
556 ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
557 ;; after file generation, ghostview is activated using the file generated
558 ;; as argument. This option is disabled if spooling is on (option 16).
559 ;; Also, if you already have a PostScript file you can preview it.
560 ;; Instead of previewing each buffer, region or major mode at once, you
561 ;; can save temporarily the PostScript code generated in a buffer and
562 ;; preview it later. The option `Despool...' despools the PostScript
563 ;; spooling buffer in a temporary file and uses ghostview to preview it.
564 ;; If you type C-u before choosing this option, the PostScript code
565 ;; generated is saved in a file instead of saving in a temporary file.
566 ;; To spool the PostScript code generated you need to turn on the option
567 ;; 16. The option `Despool...' is enabled if spooling is on (option
570 ;; NOTE 1: It's possible to customize a major mode printing, just declare
571 ;; the customization in `pr-mode-alist' and invoke some of
572 ;; `*-mode*' commands or select Mode option in Printing menu. An
573 ;; example for major mode usage is when you're using gnus (or mh,
574 ;; or rmail, etc.) and you're in the *Summary* buffer, if you
575 ;; forget to switch to the *Article* buffer before printing,
576 ;; you'll get a nicely formatted list of article subjects shows
577 ;; up at the printer. With major mode printing you don't need to
578 ;; switch from gnus *Summary* buffer first.
580 ;; NOTE 2: There are the following options for PostScript file
582 ;; Ia. Print the file *as is*, that is, send it directly to
583 ;; PostScript printer.
584 ;; Ib. PostScript utility processing selection.
585 ;; See `pr-ps-utility-alist' and `pr-setting-database' for
587 ;; Ic. Do n-up processing before printing.
588 ;; Id. Toggle on/off landscape for PostScript file processing.
589 ;; Ie. Toggle on/off duplex for PostScript file processing.
590 ;; If. Toggle on/off tumble for PostScript file processing.
592 ;; NOTE 3: Don't forget to download and install the utilities declared on
593 ;; `pr-ps-utility-alist'.
595 ;; 2. Operate the same way as option 1, but it sends directly the PostScript
596 ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to
597 ;; print the PostScript file generated. It depends on option 18, if it's
598 ;; turned on, it uses ghostscript; otherwise, it sends directly to
599 ;; printer. If spooling is on (option 16), the PostScript code is saved
600 ;; temporarily in a buffer instead of printing it or saving it in a file.
601 ;; Also, if you already have a PostScript file you can print it. Instead
602 ;; of printing each buffer, region or major mode at once, you can save
603 ;; temporarily the PostScript code generated in a buffer and print it
604 ;; later. The option `Despool...' despools the PostScript spooling
605 ;; buffer directly on a printer. If you type C-u before choosing this
606 ;; option, the PostScript code generated is saved in a file instead of
607 ;; sending to printer. To spool the PostScript code generated you need
608 ;; to turn on the option 16. This option is enabled if spooling is on
609 ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
611 ;; 3. You can select a new PostScript printer to send PostScript code
612 ;; generated. For selection it's used all PostScript printers defined
613 ;; in `pr-ps-printer-alist' variable (see it for documentation).
614 ;; See also `pr-setting-database'.
616 ;; II. Text printing:
618 ;; 4. If you have control characters (character code from \000 to \037) in a
619 ;; buffer and you want to print them in a text printer, select this
620 ;; option. All control characters in your buffer or region will be
621 ;; replaced by a printable representation. The printable representations
622 ;; use ^ (for ASCII control characters) or hex. The characters tab,
623 ;; linefeed, space, return and formfeed are not affected. You don't need
624 ;; to select this option if you use any option of section I, the
625 ;; PostScript engine treats control characters properly.
627 ;; 5. If you want to print a directory, buffer, region or major mode in a
628 ;; text printer, select this option. See also the NOTE 1 on option 1.
630 ;; 6. You can select a new text printer to send text generated. For
631 ;; selection it's used all text printers defined in
632 ;; `pr-txt-printer-alist' variable (see it for documentation).
633 ;; See also `pr-setting-database'.
635 ;; III. PostScript page toggle options:
637 ;; 7. If you want a PostScript landscape printing, turn on this option.
639 ;; 8. If you want to have a header in each page in your PostScript code,
640 ;; turn on this option.
642 ;; 9. If you want to draw a gaudy frame around the header, turn on this
643 ;; option. This option is enabled if print header is on (option 8).
645 ;; 10. If you want that the line number is printed in your PostScript code,
646 ;; turn on this option.
648 ;; 11. If you want background zebra stripes in your PostScript code, turn on
651 ;; 12. If you want a duplex printing and your PostScript printer has this
652 ;; feature, turn on this option.
654 ;; 13. If you turned on duplex printing, you can choose if you want to have
655 ;; a printing suitable for binding on the left or right (tumble off), or
656 ;; to have a printing suitable for binding at top or bottom (tumble on).
657 ;; This option is enabled if duplex is on (option 12).
659 ;; 14. If you want a PostScript upside-down printing, turn on this option.
661 ;; 15. With this option, you can choose if you want to print all pages, odd
662 ;; pages, even pages, odd sheets or even sheets.
663 ;; See also `ps-even-or-odd-pages'.
665 ;; IV. PostScript processing toggle options:
667 ;; 16. If you want to spool the PostScript code generated, turn on this
668 ;; option. To spool the PostScript code generated use option 2. You
669 ;; can despool later by choosing option 1 or 2, sub-option `Despool...'.
671 ;; 17. If you use colors in your buffers and want to see these colors on
672 ;; your PostScript code generated, turn on this option. If you have a
673 ;; black/white PostScript printer, these colors are displayed in gray
674 ;; scale by PostScript printer interpreter.
676 ;; 18. If you don't have a PostScript printer to send PostScript files, turn
677 ;; on this option. When this option is on, the ghostscript is used to
678 ;; print PostScript files. In GNU or Unix system, if ghostscript is set
679 ;; as a PostScript filter, you don't need to turn on this option.
681 ;; V. Printing customization:
683 ;; 19. If you want that region is automagically detected, turn on this
684 ;; option. Note that this will only work if you're using transient mark
685 ;; mode. When this option is on, the `*-buffer*' commands will behave
686 ;; like `*-region*' commands, that is, `*-buffer*' commands will print
687 ;; only the region marked instead of all buffer.
689 ;; 20. Turn this option on if you want that when current major-mode is
690 ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
691 ;; behave like `*-mode*' commands.
693 ;; 21. If you want that Printing menu stays poped up while you are setting
694 ;; toggle options, turn on this option. The variables
695 ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
696 ;; menu position, so don't forget to adjust these variables if menu
697 ;; position is not ok.
699 ;; VI. Customization:
701 ;; 22. Besides all options in section III, IV and V, you can customize much
702 ;; more PostScript options in `ps-print' option. Or you can customize
703 ;; some `lpr' options for text printing. Or customize `printing'
706 ;; 23. Show current settings for `printing', `ps-print' or `lpr'.
708 ;; 24. Quick help for printing menu layout.
714 ;; Below it's shown only the main options that affect all `printing' package.
715 ;; Check all the settings below *BEFORE* running `printing' commands.
717 ;; * Example of setting for GNU or Unix system:
719 ;; (require 'printing)
720 ;; (setq pr-path-alist
721 ;; '((unix "." "~/bin" ghostview mpage PATH)
722 ;; (ghostview "$HOME/bin/gsview-dir")
723 ;; (mpage "$HOME/bin/mpage-dir")
725 ;; (setq pr-txt-name 'prt_06a)
726 ;; (setq pr-txt-printer-alist
727 ;; '((prt_06a "lpr" nil "prt_06a")
728 ;; (prt_07c nil nil "prt_07c")
730 ;; (setq pr-ps-name 'lps_06b)
731 ;; (setq pr-ps-printer-alist
732 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
733 ;; (lps_07c "lpr" nil nil "lps_07c")
734 ;; (lps_08c nil nil nil "lps_08c")
736 ;; (setq pr-temp-dir "/tmp/")
737 ;; (setq pr-gv-command "gv")
738 ;; (setq pr-gs-command "gs")
739 ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
740 ;; (setq pr-gs-device "uniprint")
741 ;; (setq pr-gs-resolution 300)
742 ;; (setq pr-ps-utility 'mpage)
743 ;; (setq pr-ps-utility-alist
744 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
745 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
746 ;; (inherits-from: . no-duplex))
748 ;; (setq pr-setting-database
751 ;; (pr-file-duplex . nil)
752 ;; (pr-file-tumble . nil))
754 ;; (pr-update-menus t) ; update now printer and utility menus
756 ;; * Example of setting for Windows system:
758 ;; (require 'printing)
759 ;; (setq pr-path-alist
760 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
761 ;; (ghostview "c:/gs/gsview-dir")
762 ;; (mpage "c:/mpage-dir")
764 ;; (setq pr-txt-name 'prt_06a)
765 ;; (setq pr-txt-printer-alist
766 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
767 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
768 ;; (PRN "" nil "PRN")
769 ;; (standard "redpr.exe" nil "")
771 ;; (setq pr-ps-name 'lps_06b)
772 ;; (setq pr-ps-printer-alist
773 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
774 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
775 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
776 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
777 ;; (LPT1 "" nil "" "LPT1:")
778 ;; (PRN "" nil "" "PRN")
779 ;; (standard "redpr.exe" nil "" "")
781 ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/")
782 ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe")
783 ;; (setq pr-gs-command "c:/gs/gswin32.exe")
784 ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts"))
785 ;; (setq pr-gs-device "mswinpr2")
786 ;; (setq pr-gs-resolution 300)
787 ;; (setq pr-ps-utility 'psnup)
788 ;; (setq pr-ps-utility-alist
789 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " "
790 ;; nil (inherits-from: . no-duplex))
792 ;; (setq pr-setting-database
795 ;; (pr-file-duplex . nil)
796 ;; (pr-file-tumble . nil))
798 ;; (pr-update-menus t) ; update now printer and utility menus
800 ;; NOTE: Don't forget to download and install the utilities declared on
801 ;; `pr-ps-utility-alist'.
807 ;; `printing' package has the following utilities:
809 ;; `pr-setup' Return the current `printing' setup.
811 ;; `lpr-setup' Return the current `lpr' setup.
813 ;; `pr-update-menus' Update utility, PostScript and text printer menus.
815 ;; Below are some URL where you can find good utilities.
817 ;; * For `printing' package:
819 ;; printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz'
820 ;; ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'
822 ;; * For GNU or Unix system:
824 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
825 ;; enscript `http://people.ssh.fi/mtr/genscript/'
826 ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html'
827 ;; mpage `http://www.mesa.nl/pub/mpage/'
829 ;; * For Windows system:
832 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'
833 ;; enscript `http://people.ssh.fi/mtr/genscript/'
834 ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html'
835 ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/'
841 ;; Thanks to Drew Adams <?@?> for directory processing and `pr-path-alist'
844 ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests.
846 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging
847 ;; and for suggestions:
848 ;; - even/odd pages printing.
849 ;; - ghostscript parameters for `pr-ps-printer-alist'.
850 ;; - default printer name.
851 ;; - completion functions.
852 ;; - automagic region detection.
853 ;; - menu entry hiding.
854 ;; - fast fire PostScript printing command.
855 ;; - `pr-path-style' variable.
857 ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions:
858 ;; - PostScript Print and PostScript Print Preview merge.
859 ;; - Tools/Printing menu.
860 ;; - replace *-using-preview by *-using-ghostscript.
861 ;; - printer selection.
862 ;; - extra parameters for `pr-ps-printer-alist'.
865 ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el
866 ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el
867 ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el
868 ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el
869 ;; And to all people who contributed with them.
872 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
881 (and (string< ps-print-version
"6.5.7")
882 (error "`printing' requires `ps-print' package version 6.5.7 or later."))
886 (defconst pr-cygwin-system
887 (and ps-windows-system
(getenv "OSTYPE")
888 (string-match "cygwin" (getenv "OSTYPE")))))
891 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
892 ;; To avoid compilation gripes
897 (or (fboundp 'subst-char-in-string
)
898 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
899 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
900 Unless optional argument INPLACE is non-nil, return a new string."
901 (let ((i (length string
))
902 (newstr (if inplace string
(copy-sequence string
))))
903 (while (> (setq i
(1- i
)) 0)
904 (if (eq (aref newstr i
) fromchar
)
905 (aset newstr i tochar
)))
909 (defalias 'pr-e-frame-char-height
'frame-char-height
)
910 (defalias 'pr-e-frame-char-width
'frame-char-width
)
911 (defalias 'pr-e-mouse-pixel-position
'mouse-pixel-position
)
913 (defalias 'pr-x-add-submenu
'add-submenu
)
914 (defalias 'pr-x-event-function
'event-function
)
915 (defalias 'pr-x-event-object
'event-object
)
916 (defalias 'pr-x-find-menu-item
'find-menu-item
)
917 (defalias 'pr-x-font-height
'font-height
)
918 (defalias 'pr-x-font-width
'font-width
)
919 (defalias 'pr-x-get-popup-menu-response
'get-popup-menu-response
)
920 (defalias 'pr-x-make-event
'make-event
)
921 (defalias 'pr-x-misc-user-event-p
'misc-user-event-p
)
922 (defalias 'pr-x-relabel-menu-item
'relabel-menu-item
)
923 (defalias 'pr-x-event-x-pixel
'event-x-pixel
)
924 (defalias 'pr-x-event-y-pixel
'event-y-pixel
)
927 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
928 (defvar deactivate-mark nil
)
929 (defalias 'pr-f-set-keymap-parents
'set-keymap-parent
)
930 (defalias 'pr-f-set-keymap-name
'ignore
)
931 (defalias 'pr-f-read-string
'read-string
)
932 (defun pr-keep-region-active ()
933 (setq deactivate-mark nil
)))
935 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
936 (defvar current-menubar nil
)
937 (defvar current-mouse-event nil
)
938 (defvar zmacs-region-stays nil
)
939 (defalias 'pr-f-set-keymap-parents
'set-keymap-parents
)
940 (defalias 'pr-f-set-keymap-name
'set-keymap-name
)
941 (defun pr-f-read-string (prompt initial history default
)
942 (let ((str (read-string prompt initial
)))
943 (if (and str
(not (string= str
"")))
946 (defun pr-keep-region-active ()
947 (setq zmacs-region-stays t
)))))
950 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
951 ;; Customization Functions
954 (defun pr-alist-custom-set (symbol value
)
955 "Set the value of custom variables for printer & utility selection."
957 (and (featurep 'printing
) ; update only after printing is loaded
958 (pr-update-menus t
)))
961 (defun pr-ps-utility-custom-set (symbol value
)
962 "Update utility menu entry."
964 (and (featurep 'printing
) ; update only after printing is loaded
965 (pr-menu-set-utility-title value
)))
968 (defun pr-ps-name-custom-set (symbol value
)
969 "Update `PostScript Printer:' menu entry."
971 (and (featurep 'printing
) ; update only after printing is loaded
972 (pr-menu-set-ps-title value
)))
975 (defun pr-txt-name-custom-set (symbol value
)
976 "Update `Text Printer:' menu entry."
978 (and (featurep 'printing
) ; update only after printing is loaded
979 (pr-menu-set-txt-title value
)))
982 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
983 ;; User Interface (I)
986 (defgroup printing nil
987 "Printing Utilities group"
988 :tag
"Printing Utilities"
989 :link
'(emacs-library-link :tag
"Source Lisp File" "printing.el")
995 (defcustom pr-path-style
996 (if (and (not pr-cygwin-system
)
1000 "*Specify which path style to use for external commands.
1004 windows Windows 9x/NT style (\\)
1006 unix Unix style (/)"
1007 :type
'(choice :tag
"Path style"
1008 (const :tag
"Windows 9x/NT Style (\\)" :value windows
)
1009 (const :tag
"Unix Style (/)" :value unix
))
1013 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1014 ;; Internal Functions (I)
1017 (defun pr-dosify-path (path)
1018 "Replace unix-style directory separator character with dos/windows one."
1019 (interactive "sPath: ")
1020 (if (eq pr-path-style
'windows
)
1021 (subst-char-in-string ?
/ ?
\\ path
)
1025 (defun pr-unixify-path (path)
1026 "Replace dos/windows-style directory separator character with unix one."
1027 (interactive "sPath: ")
1028 (if (eq pr-path-style
'windows
)
1029 (subst-char-in-string ?
\\ ?
/ path
)
1033 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1034 ;; User Interface (II)
1037 (defcustom pr-path-alist
1041 "*Specify an alist for command paths.
1043 It's used to find commands used for printing package, like gv, gs, gsview.exe,
1044 mpage, print.exe, etc. See also `pr-command' function.
1046 Each element has the form:
1048 (ENTRY DIRECTORY...)
1052 ENTRY It's a symbol, used to identify this entry.
1053 There must exist at least one of the following entries:
1055 unix this entry is used when Emacs is running on GNU or
1058 cygwin this entry is used when Emacs is running on Windows
1059 95/98/NT/2000 with Cygwin.
1061 windows this entry is used when Emacs is running on Windows
1064 DIRECTORY It should be a string or a symbol. If it's a symbol, it should
1065 exist an equal entry in `pr-path-alist'. If it's a string,
1066 it's considered a directory specification.
1068 The directory specification may contain:
1069 $var environment variable expansion
1071 ./ current directory
1072 ../ previous directory
1074 For example, let's say the home directory is /home/my and the
1075 current directory is /home/my/dir, so:
1077 THE ENTRY IS EXPANDED TO
1078 ~/entry /home/my/entry
1079 ./entry /home/my/dir/entry
1080 ../entry /home/my/entry
1081 $HOME/entry /home/my/entry
1082 $HOME/~/other/../my/entry /home/my/entry
1084 SPECIAL SYMBOL: If the symbol `PATH' is used in the directory
1085 list and there isn't a `PATH' entry in `pr-path-alist' or the
1086 `PATH' entry has a null directory list, the PATH environment
1091 * On GNU or Unix system:
1093 '((unix \".\" \"~/bin\" ghostview mpage PATH)
1094 (ghostview \"$HOME/bin/gsview-dir\")
1095 (mpage \"$HOME/bin/mpage-dir\")
1098 * On Windows system:
1100 '((windows \"c:/applications/executables\" PATH ghostview mpage)
1101 (ghostview \"c:/gs/gsview-dir\")
1102 (mpage \"c:/mpage-dir\")
1106 (symbol :tag
"Identifier ")
1107 (repeat :tag
"Directory List"
1108 (choice :menu-tag
"Directory"
1111 (symbol :value symbol
)))))
1115 (defcustom pr-txt-name
'default
1116 "*Specify a printer for printing a text file.
1118 The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
1121 This variable should be modified by customization engine. If this variable is
1122 modified by other means (for example, a lisp function), use `pr-update-menus'
1123 function (see it for documentation) to update text printer menu."
1125 :set
'pr-txt-name-custom-set
1129 (defcustom pr-txt-printer-alist
1130 (list (list 'default lpr-command nil
1131 (cond ((boundp 'printer-name
) printer-name
)
1132 (ps-windows-system "PRN")
1136 ;; * On GNU or Unix system:
1137 ;; '((prt_06a "lpr" nil "prt_06a")
1138 ;; (prt_07c nil nil "prt_07c")
1140 ;; * On Windows system:
1141 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
1142 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
1143 ;; (PRN "" nil "PRN")
1144 ;; (standard "redpr.exe" nil "")
1146 "*Specify an alist of all text printers (text printer database).
1148 The alist element has the form:
1150 (SYMBOL COMMAND SWITCHES NAME)
1154 SYMBOL It's a symbol to identify a text printer. It's for
1155 `pr-txt-name' variable setting and for menu selection.
1160 COMMAND Name of program for printing a text file. On MS-DOS and
1161 MS-Windows systems, if the value is an empty string then Emacs
1162 will write directly to the printer port named by NAME (see text
1163 below), that is, the NAME should be something like \"PRN\" or
1165 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1166 COMMAND shouldn't be an empty string.
1167 The programs `print' and `nprint' (the standard print programs
1168 on Windows NT and Novell Netware respectively) are handled
1169 specially, using NAME as the destination for output; any other
1170 program is treated like `lpr' except that an explicit filename
1171 is given as the last argument.
1172 If COMMAND is nil, it's used the default printing program:
1173 `print' for Windows system, `lp' for lp system and `lpr' for
1174 all other systems. See also `pr-path-alist'.
1180 SWITCHES List of sexp's to pass as extra options for text printer
1181 program. It is recommended to set NAME (see text below)
1182 instead of including an explicit switch on this list.
1188 NAME A string that specifies a text printer name.
1189 On Unix-like systems, a string value should be a name
1190 understood by lpr's -P option (or lp's -d option).
1191 On MS-DOS and MS-Windows systems, it is the name of a printer
1192 device or port. Typical non-default settings would be \"LPT1:\"
1193 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1194 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1195 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1196 printer. You can also set it to a name of a file, in which
1197 case the output gets appended to that file. If you want to
1198 discard the printed output, set this to \"NUL\".
1201 \"/D:\\\\\\\\host\\\\share-name\"
1208 This variable should be modified by customization engine. If this variable is
1209 modified by other means (for example, a lisp function), use `pr-update-menus'
1210 function (see it for documentation) to update text printer menu.
1214 * On GNU or Unix system:
1216 '((prt_06a \"lpr\" nil \"prt_06a\")
1217 (prt_07c nil nil \"prt_07c\")
1220 * On Windows system:
1222 '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\")
1223 (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\")
1224 (PRN \"\" nil \"PRN\")
1225 (standard \"redpr.exe\" nil \"\")
1228 (list :tag
"Text Printer"
1229 (symbol :tag
"Printer Symbol Name")
1230 (string :tag
"Printer Command")
1231 (repeat :tag
"Printer Switches"
1232 (sexp :tag
"Switch" :value
""))
1233 (choice :menu-tag
"Printer Name"
1235 (const :tag
"None" nil
)
1237 :set
'pr-alist-custom-set
1241 (defcustom pr-ps-name
'default
1242 "*Specify a printer for printing a PostScript file.
1244 This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
1247 This variable should be modified by customization engine. If this variable is
1248 modified by other means (for example, a lisp function), use `pr-update-menus'
1249 function (see it for documentation) to update PostScript printer menu."
1251 :set
'pr-ps-name-custom-set
1255 (defcustom pr-ps-printer-alist
1256 (list (list 'default lpr-command nil
1257 (cond (ps-windows-system nil
)
1260 (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name
)))
1262 ;; * On GNU or Unix system:
1263 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
1264 ;; (lps_07c "lpr" nil nil "lps_07c")
1265 ;; (lps_08c nil nil nil "lps_08c")
1267 ;; * On Windows system:
1268 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
1269 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
1270 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
1271 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
1272 ;; (LPT1 "" nil "" "LPT1:")
1273 ;; (PRN "" nil "" "PRN")
1274 ;; (standard "redpr.exe" nil "" "")
1276 "*Specify an alist for all PostScript printers (PostScript printer database).
1278 The alist element has the form:
1280 (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...)
1284 SYMBOL It's a symbol to identify a PostScript printer. It's for
1285 `pr-ps-name' variable setting and for menu selection.
1290 COMMAND Name of program for printing a PostScript file. On MS-DOS and
1291 MS-Windows systems, if the value is an empty string then Emacs
1292 will write directly to the printer port named by NAME (see text
1293 below), that is, the NAME should be something like \"PRN\" or
1295 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1296 COMMAND shouldn't be an empty string.
1297 The programs `print' and `nprint' (the standard print programs
1298 on Windows NT and Novell Netware respectively) are handled
1299 specially, using NAME as the destination for output; any other
1300 program is treated like `lpr' except that an explicit filename
1301 is given as the last argument.
1302 If COMMAND is nil, it's used the default printing program:
1303 `print' for Windows system, `lp' for lp system and `lpr' for
1304 all other systems. See also `pr-path-alist'.
1311 SWITCHES List of sexp's to pass as extra options for PostScript printer
1312 program. It is recommended to set NAME (see text below)
1313 instead of including an explicit switch on this list.
1319 PRINTER-SWITCH A string that specifies PostScript printer name switch. If
1320 it's necessary to have a space between PRINTER-SWITCH and NAME,
1321 it should be inserted at the end of PRINTER-SWITCH string.
1322 If PRINTER-SWITCH is nil, it's used the default printer name
1323 switch: `/D:' for Windows system, `-d' for lp system and `-P'
1324 for all other systems.
1335 NAME A string that specifies a PostScript printer name.
1336 On Unix-like systems, a string value should be a name
1337 understood by lpr's -P option (or lp's -d option).
1338 On MS-DOS and MS-Windows systems, it is the name of a printer
1339 device or port. Typical non-default settings would be \"LPT1:\"
1340 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1341 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1342 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1343 printer. You can also set it to a name of a file, in which
1344 case the output gets appended to that file. If you want to
1345 discard the printed output, set this to \"NUL\".
1348 \"\\\\\\\\host\\\\share-name\"
1351 \"/D:\\\\\\\\host\\\\share-name\"
1352 \"\\\\\\\\host\\\\share-name\"
1359 DEFAULT It's a way to set default values when this entry is selected.
1364 That associates VARIABLE with VALUE. when this entry is
1365 selected, it's executed the following command:
1367 (set VARIABLE (eval VALUE))
1369 Note that VALUE can be any valid lisp expression. So, don't
1370 forget to quote symbols and constant lists.
1371 If VARIABLE is the special keyword `inherits-from:', VALUE must
1372 be a symbol name setting defined in `pr-setting-database' from
1373 which the current setting inherits the context. Take care with
1374 circular inheritance.
1376 '(ps-landscape-mode . nil)
1377 '(ps-spool-duplex . t)
1378 '(pr-gs-device . (my-gs-device t))
1380 This variable should be modified by customization engine. If this variable is
1381 modified by other means (for example, a lisp function), use `pr-update-menus'
1382 function (see it for documentation) to update PostScript printer menu.
1386 * On GNU or Unix system:
1388 '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\")
1389 (lps_07c \"lpr\" nil nil \"lps_07c\")
1390 (lps_08c nil nil nil \"lps_08c\")
1393 * On Windows system:
1395 '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\")
1396 (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\")
1397 (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\")
1398 (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\")
1399 (LPT1 \"\" nil \"\" \"LPT1:\")
1400 (PRN \"\" nil \"\" \"PRN\")
1401 (standard \"redpr.exe\" nil \"\" \"\")
1405 :tag
"PostScript Printer"
1406 (symbol :tag
"Printer Symbol Name")
1407 (string :tag
"Printer Command")
1408 (repeat :tag
"Printer Switches"
1409 (sexp :tag
"Switch" :value
""))
1410 (choice :menu-tag
"Printer Name Switch"
1411 :tag
"Printer Name Switch"
1412 (const :tag
"None" nil
)
1414 (choice :menu-tag
"Printer Name"
1416 (const :tag
"None" nil
)
1419 :tag
"Default Value List"
1424 :menu-tag
"Variable"
1426 (const :tag
"Landscape" ps-landscape-mode
)
1427 (const :tag
"Print Header" ps-print-header
)
1428 (const :tag
"Print Header Frame" ps-print-header-frame
)
1429 (const :tag
"Line Number" ps-line-number
)
1430 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
1431 (const :tag
"Duplex" ps-spool-duplex
)
1432 (const :tag
"Tumble" ps-spool-tumble
)
1433 (const :tag
"Upside-Down" ps-print-upside-down
)
1434 (const :tag
"PS File Landscape" pr-file-landscape
)
1435 (const :tag
"PS File Duplex" pr-file-duplex
)
1436 (const :tag
"PS File Tumble" pr-file-tumble
)
1437 (const :tag
"Auto Region" pr-auto-region
)
1438 (const :tag
"Auto Mode" pr-auto-mode
)
1439 (const :tag
"Ghostscript Device" pr-gs-device
)
1440 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
1441 (const :tag
"inherits-from:" inherits-from
:)
1442 (variable :tag
"Other"))
1443 (sexp :tag
"Value")))
1445 :set
'pr-alist-custom-set
1449 (defcustom pr-temp-dir
1451 (if (boundp 'temporary-file-directory
)
1452 (symbol-value 'temporary-file-directory
)
1453 ;; hacked from `temporary-file-directory' variable in files.el
1454 (file-name-as-directory
1455 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
1456 (cond (ps-windows-system "c:/temp")
1457 ((memq system-type
'(vax-vms axp-vms
)) "SYS$SCRATCH:")
1460 "*Specify a directory for temporary files during printing."
1461 :type
'(directory :tag
"Temporary Directory")
1465 (defcustom pr-ps-temp-file
"prspool.ps"
1466 "*Specify PostScript temporary file name."
1467 :type
'(file :tag
"PostScript Temporary File Name")
1471 (defcustom pr-gv-command
1472 (if ps-windows-system
1475 "*Specify path and name of gsview program.
1477 See also `pr-path-alist'."
1478 :type
'(string :tag
"Ghostview Program")
1482 (defcustom pr-gs-command
1483 (if ps-windows-system
1486 "*Specify path and name of ghostscript program.
1488 See also `pr-path-alist'."
1489 :type
'(string :tag
"Ghostscript Program")
1493 (defcustom pr-gs-switches
1494 (if ps-windows-system
1495 '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")
1496 '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
1497 "*Specify ghostscript switches. See the documentation on GS for more info.
1499 It's a list of strings, where each string is one or more ghostscript switches.
1501 A note on the gs switches:
1504 -dNOPAUSE don't wait for user intervention
1505 -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs
1506 -c quit it's added at the end to terminate gs
1508 To see ghostscript documentation for more information:
1510 * On GNU or Unix system:
1511 - for full documentation, type: man gs
1512 - for brief documentation, type: gs -h
1514 * On Windows system:
1515 - for full documentation, see in a browser the file
1516 c:/gstools/gs5.50/index.html, that is, the file index.html which is
1517 located in the same directory as gswin32.exe.
1518 - for brief documentation, type: gswin32.exe -h"
1519 :type
'(repeat (string :tag
"Ghostscript Switch"))
1523 (defcustom pr-gs-device
1524 (if ps-windows-system
1527 "*Specify ghostscript device switch value (-sDEVICE=).
1529 A note on the gs switches:
1531 -sDEVICE=djet500 the printer - works with HP DeskJet 540
1533 See `pr-gs-switches' for documentation.
1534 See also `pr-ps-printer-alist'."
1535 :type
'(string :tag
"Ghostscript Device")
1539 (defcustom pr-gs-resolution
300
1540 "*Specify ghostscript resolution switch value (-r).
1542 A note on the gs switches:
1544 -r300 resolution 300x300
1546 See `pr-gs-switches' for documentation.
1547 See also `pr-ps-printer-alist'."
1548 :type
'(integer :tag
"Ghostscript Resolution")
1552 (defcustom pr-print-using-ghostscript nil
1553 "*Non-nil means print using ghostscript.
1555 This is useful if you don't have a PostScript printer, so you could use the
1556 ghostscript to print a PostScript file.
1558 In GNU or Unix system, if ghostscript is set as a PostScript filter, this
1559 variable should be nil."
1564 (defcustom pr-faces-p nil
1565 "*Non-nil means print with face attributes."
1570 (defcustom pr-spool-p nil
1571 "*Non-nil means spool printing in a buffer."
1576 (defcustom pr-file-landscape nil
1577 "*Non-nil means print PostScript file in landscape orientation."
1582 (defcustom pr-file-duplex nil
1583 "*Non-nil means print PostScript file in duplex mode."
1588 (defcustom pr-file-tumble nil
1589 "*Non-nil means print PostScript file in tumble mode.
1591 If tumble is off, produces a printing suitable for binding on the left or
1593 If tumble is on, produces a printing suitable for binding at the top or
1599 (defcustom pr-auto-region t
1600 "*Non-nil means region is automagically detected.
1602 Note that this will only work if you're using transient mark mode.
1604 When this variable is non-nil, the `*-buffer*' commands will behave like
1605 `*-region*' commands, that is, `*-buffer*' commands will print only the region
1606 marked instead of all buffer."
1611 (defcustom pr-auto-mode t
1612 "*Non-nil means major-mode printing is prefered over normal printing.
1614 That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
1615 and `*-region*' commands will behave like `*-mode*' commands; otherwise,
1616 `*-buffer*' commands will print the current buffer and `*-region*' commands
1617 will print the current region."
1622 (defcustom pr-mode-alist
1623 '((mh-folder-mode ; mh summary buffer
1624 pr-mh-lpr-1 pr-mh-print-1
1626 (ps-article-author ps-article-subject
)
1627 ("/pagenumberstring load" pr-article-date
)
1630 (mh-letter-mode ; mh letter buffer
1631 pr-mh-lpr-2 pr-mh-print-2
1633 (ps-article-author ps-article-subject
)
1634 ("/pagenumberstring load" pr-article-date
)
1637 (rmail-summary-mode ; rmail summary buffer
1638 pr-rmail-lpr pr-rmail-print
1640 (ps-article-subject ps-article-author buffer-name
)
1644 (rmail-mode ; rmail buffer
1645 pr-rmail-lpr pr-rmail-print
1647 (ps-article-subject ps-article-author buffer-name
)
1651 (gnus-summary-mode ; gnus summary buffer
1652 pr-gnus-lpr pr-gnus-print
1654 (ps-article-subject ps-article-author gnus-newsgroup-name
)
1658 (gnus-article-mode ; gnus article buffer
1659 pr-gnus-lpr pr-gnus-print
1661 (ps-article-subject ps-article-author gnus-newsgroup-name
)
1665 (Info-mode ; Info buffer
1666 pr-mode-lpr pr-mode-print
1668 (ps-info-node ps-info-file
)
1673 pr-vm-lpr pr-vm-print
1675 (ps-article-subject ps-article-author buffer-name
)
1680 "*Specify an alist for a major-mode and printing functions.
1682 To customize a major mode printing, just declare the customization in
1683 `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major
1684 mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the
1685 *Summary* buffer, if you forget to switch to the *Article* buffer before
1686 printing, you'll get a nicely formatted list of article subjects shows up at
1687 the printer. With major mode printing you don't need to switch from gnus
1688 *Summary* buffer first.
1690 The elements have the following form:
1702 MAJOR-MODE It's the major mode symbol.
1704 LPR-PRINT It's a symbol function for text printing. It's invoked with
1706 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
1708 Usually LPR-PRINT function prepares the environment or buffer
1709 and then call the function `pr-mode-lpr' which it's used to
1710 process the buffer and send it to text printer.
1712 The `pr-mode-lpr' definition is:
1714 (pr-mode-lpr HEADER-LIST &optional FROM TO)
1716 Where HEADER-LIST is like the argument passed to LPR-PRINT.
1717 FROM and TO are the beginning and end markers, respectively,
1718 for a region. If FROM is nil, it's used (point-min); if TO is
1719 nil, it's used (point-max).
1721 PS-PRINT It's a symbol function for PostScript printing. It's invoked
1722 with 3 arguments: n-up printing, file name and the list:
1723 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
1725 Usually PS-PRINT function prepares the environment or buffer
1726 and then call the function `pr-mode-print' which it's used to
1727 process the buffer and send it to PostScript printer.
1729 The `pr-mode-print' definition is:
1731 (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO)
1733 Where N-UP, FILENAME and HEADER-LIST are like the arguments
1734 passed to PS-PRINT. FROM and TO are the beginning and end
1735 markers, respectively, for a region. If TO is nil, it's used
1738 HEADER-LINES It's the number of header lines; if is nil, it uses
1739 `ps-header-lines' value.
1741 LEFT-HEADER It's the left header part, it's a list of string, variable
1742 symbol or function symbol (with no argument); if is nil, it
1743 uses `ps-left-header' value.
1745 RIGHT-HEADER It's the right header part, it's a list of string, variable
1746 symbol or function symbol (with no argument); if is nil, it
1747 uses `ps-right-header' value.
1750 Non-nil means to kill all buffer local variable declared in
1751 DEFAULT (see below).
1753 DEFAULT It's a way to set default values when this entry is selected.
1756 (VARIABLE-SYM . VALUE)
1758 That associates VARIABLE-SYM with VALUE. when this entry is
1759 selected, it's executed the following command:
1761 (set (make-local-variable VARIABLE-SYM) (eval VALUE))
1763 Note that VALUE can be any valid lisp expression. So, don't
1764 forget to quote symbols and constant lists.
1765 If VARIABLE is the special keyword `inherits-from:', VALUE must
1766 be a symbol name setting defined in `pr-setting-database' from
1767 which the current setting inherits the context. Take care with
1768 circular inheritance.
1770 '(ps-landscape-mode . nil)
1771 '(ps-spool-duplex . t)
1772 '(pr-gs-device . (my-gs-device t))"
1776 (symbol :tag
"Major Mode")
1777 (function :tag
"Text Printing Function")
1778 (function :tag
"PS Printing Function")
1779 (choice :menu-tag
"Number of Header Lines"
1780 :tag
"Number of Header Lines"
1781 (integer :tag
"Number")
1782 (const :tag
"Default Number" nil
))
1783 (repeat :tag
"Left Header List"
1784 (choice :menu-tag
"Left Header"
1787 (repeat :tag
"Right Header List"
1788 (choice :menu-tag
"Right Header"
1791 (boolean :tag
"Kill Local Variable At End")
1793 :tag
"Default Value List"
1798 :menu-tag
"Variable"
1800 (const :tag
"Landscape" ps-landscape-mode
)
1801 (const :tag
"Print Header" ps-print-header
)
1802 (const :tag
"Print Header Frame" ps-print-header-frame
)
1803 (const :tag
"Line Number" ps-line-number
)
1804 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
1805 (const :tag
"Duplex" ps-spool-duplex
)
1806 (const :tag
"Tumble" ps-spool-tumble
)
1807 (const :tag
"Upside-Down" ps-print-upside-down
)
1808 (const :tag
"PS File Landscape" pr-file-landscape
)
1809 (const :tag
"PS File Duplex" pr-file-duplex
)
1810 (const :tag
"PS File Tumble" pr-file-tumble
)
1811 (const :tag
"Auto Region" pr-auto-region
)
1812 (const :tag
"Auto Mode" pr-auto-mode
)
1813 (const :tag
"Ghostscript Device" pr-gs-device
)
1814 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
1815 (const :tag
"inherits-from:" inherits-from
:)
1816 (variable :tag
"Other"))
1817 (sexp :tag
"Value")))
1822 (defcustom pr-ps-utility
'mpage
1823 "*Specify PostScript utility symbol.
1825 This utility symbol should be defined on `pr-ps-utility-alist' (see it for
1828 This variable should be modified by customization engine. If this variable is
1829 modified by other means (for example, a lisp function), use `pr-update-menus'
1830 function (see it for documentation) to update PostScript utility menu.
1832 NOTE: Don't forget to download and install the utilities declared on
1833 `pr-ps-utility-alist'."
1834 :type
'(symbol :tag
"PS File Utility")
1835 :set
'pr-ps-utility-custom-set
1839 (defcustom pr-ps-utility-alist
1840 '((mpage "mpage" nil
"-b%s" "-%d" "-l" "-t" "-T" ">" nil
)
1841 (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil
" " nil
1842 (inherits-from: . no-duplex
))
1845 ;; * On GNU or Unix system:
1846 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
1847 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
1848 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
1850 ;; * On Windows system:
1851 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
1852 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
1854 "*Specify an alist for PostScript utility processing (PS utility database).
1856 The alist element has the form:
1858 (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT
1859 SWITCHES DEFAULT...)
1863 SYMBOL It's a symbol to identify a PostScript utility. It's for
1864 `pr-ps-utility' variable setting and for menu selection.
1869 UTILITY Name of utility for processing a PostScript file.
1870 See also `pr-path-alist'.
1872 . for GNU or Unix system:
1876 . for Windows system:
1877 \"c:/psutils/psnup -q\"
1879 MUST-SWITCHES List of sexp's to pass as options for PostScript utility
1880 program. These options are necessary to process the utility
1881 program and must be place before any other switches.
1886 PAPERSIZE It's a format string to specify paper size switch.
1891 N-UP It's a format string to specify n-up switch.
1896 LANDSCAPE It's a string to specify landscape switch. If the utility
1897 doesn't have landscape switch, set to nil.
1902 DUPLEX It's a string to specify duplex switch. If the utility doesn't
1903 have duplex switch, set to nil.
1908 TUMBLE It's a string to specify tumble switch. If the utility doesn't
1909 have tumble switch, set to nil.
1914 OUTPUT It's a string to specify how to generate an output file. Some
1915 utilities accept an output file option, but some others need
1916 output redirection or some other way to specify an output file.
1919 \" \" ; psnup ... input output
1922 \">\" ; mpage ... input > output
1924 SWITCHES List of sexp's to pass as extra options for PostScript utility
1931 DEFAULT It's a way to set default values when this entry is selected.
1936 That associates VARIABLE with VALUE. when this entry is
1937 selected, it's executed the following command:
1939 (set VARIABLE (eval VALUE))
1941 Note that VALUE can be any valid lisp expression. So, don't
1942 forget to quote symbols and constant lists.
1943 If VARIABLE is the special keyword `inherits-from:', VALUE must
1944 be a symbol name setting defined in `pr-setting-database' from
1945 which the current setting inherits the context. Take care with
1946 circular inheritance.
1948 '(pr-file-landscape . nil)
1949 '(pr-file-duplex . t)
1950 '(pr-gs-device . (my-gs-device t))
1952 This variable should be modified by customization engine. If this variable is
1953 modified by other means (for example, a lisp function), use `pr-update-menus'
1954 function (see it for documentation) to update PostScript utility menu.
1956 NOTE: Don't forget to download and install the utilities declared on
1957 `pr-ps-utility-alist'.
1961 * On GNU or Unix system:
1963 '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil)
1964 (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil
1965 (pr-file-duplex . nil) (pr-file-tumble . nil))
1968 * On Windows system:
1970 '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \"
1971 nil (pr-file-duplex . nil) (pr-file-tumble . nil))
1974 (list :tag
"PS File Utility"
1975 (symbol :tag
"Utility Symbol")
1976 (string :tag
"Utility Name")
1977 (repeat :tag
"Must Utility Switches"
1978 (sexp :tag
"Switch" :value
""))
1979 (choice :menu-tag
"Paper Size"
1981 (const :tag
"No Paper Size" nil
)
1982 (string :tag
"Paper Size Format"))
1983 (choice :menu-tag
"N-Up"
1985 (const :tag
"No N-Up" nil
)
1986 (string :tag
"N-Up Format"))
1987 (choice :menu-tag
"Landscape"
1989 (const :tag
"No Landscape" nil
)
1990 (string :tag
"Landscape Switch"))
1991 (choice :menu-tag
"Duplex"
1993 (const :tag
"No Duplex" nil
)
1994 (string :tag
"Duplex Switch"))
1995 (choice :menu-tag
"Tumble"
1997 (const :tag
"No Tumble" nil
)
1998 (string :tag
"Tumble Switch"))
1999 (string :tag
"Output Separator")
2000 (repeat :tag
"Utility Switches"
2001 (sexp :tag
"Switch" :value
""))
2003 :tag
"Default Value List"
2008 :menu-tag
"Variable"
2010 (const :tag
"PS File Landscape" pr-file-landscape
)
2011 (const :tag
"PS File Duplex" pr-file-duplex
)
2012 (const :tag
"PS File Tumble" pr-file-tumble
)
2013 (const :tag
"Ghostscript Device" pr-gs-device
)
2014 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2015 (const :tag
"inherits-from:" inherits-from
:)
2016 (variable :tag
"Other"))
2017 (sexp :tag
"Value")))
2019 :set
'pr-alist-custom-set
2023 (defcustom pr-menu-lock t
2024 "*Non-nil means menu is locked while selecting toggle options.
2026 See also `pr-menu-char-height' and `pr-menu-char-width'."
2031 (defcustom pr-menu-char-height
2032 (cond ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2033 (pr-e-frame-char-height))
2034 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2035 (pr-x-font-height (face-font 'default
))))
2036 "*Specify menu char height in pixels.
2038 This variable is used to guess which vertical position should be locked the
2039 menu, so don't forget to adjust it if menu position is not ok.
2041 See also `pr-menu-lock' and `pr-menu-char-width'."
2046 (defcustom pr-menu-char-width
2047 (cond ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2048 (pr-e-frame-char-width))
2049 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2050 (pr-x-font-width (face-font 'default
))))
2051 "*Specify menu char width in pixels.
2053 This variable is used to guess which horizontal position should be locked the
2054 menu, so don't forget to adjust it if menu position is not ok.
2056 See also `pr-menu-lock' and `pr-menu-char-height'."
2061 (defcustom pr-setting-database
2062 '((no-duplex ; setting symbol name
2063 nil nil nil
; inherits local kill-local
2064 (pr-file-duplex . nil
) ; settings
2065 (pr-file-tumble . nil
))
2067 "*Specify an alist for settings in general.
2069 The elements have the following form:
2071 (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...)
2075 SYMBOL It's a symbol to identify the setting group.
2077 INHERITS Specify the inheritance for SYMBOL group. It's a symbol name
2078 setting from which the current setting inherits the context.
2079 If INHERITS is nil, means that there is no inheritance.
2080 This is a simple inheritance mechanism.
2082 Let's see an example to illustrate the inheritance mechanism:
2084 (setq pr-setting-database
2085 '((no-duplex ; setting symbol name
2087 nil nil ; local kill-local
2088 (pr-file-duplex . nil) ; settings
2089 (pr-file-tumble . nil)
2091 (no-duplex-and-landscape ; setting symbol name
2092 no-duplex ; inherits
2093 nil nil ; local kill-local
2094 (pr-file-landscape . nil) ; settings
2097 The example above has two setting groups: no-duplex and
2098 no-duplex-and-landscape. When setting no-duplex is activated
2099 through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist'
2100 and `pr-ps-printer-alist'), the variables pr-file-duplex and
2101 pr-file-tumble are both set to nil.
2103 Now when setting no-duplex-and-landscape is activated through
2104 `inherits-from:', the variable pr-file-landscape is set to nil
2105 and also the settings for no-duplex are done, because
2106 no-duplex-and-landscape inherits settings from no-duplex.
2108 Take care with circular inheritance. It's an error if circular
2109 inheritance happens.
2111 LOCAL Non-nil means that all settings for SYMBOL group will be
2112 declared local buffer.
2114 KILL-LOCAL Non-nil means that all settings for SYMBOL group will be
2115 killed at end. It has effect only when LOCAL is non-nil.
2117 SETTING It's a cons like:
2121 That associates VARIABLE with VALUE. when this entry is
2122 selected, it's executed the following command:
2124 * If LOCAL is non-nil:
2125 (set (make-local-variable VARIABLE) (eval VALUE))
2128 (set VARIABLE (eval VALUE))
2130 Note that VALUE can be any valid lisp expression. So, don't
2131 forget to quote symbols and constant lists.
2132 This setting is ignored if VARIABLE is equal to keyword
2135 '(ps-landscape-mode . nil)
2136 '(ps-spool-duplex . t)
2137 '(pr-gs-device . (my-gs-device t))"
2141 (symbol :tag
"Setting Name")
2142 (choice :menu-tag
"Inheritance"
2144 (const :tag
"No Inheritance" nil
)
2145 (symbol :tag
"Inherits From"))
2146 (boolean :tag
"Local Buffer Setting")
2147 (boolean :tag
"Kill Local Variable At End")
2154 :menu-tag
"Variable"
2156 (const :tag
"Landscape" ps-landscape-mode
)
2157 (const :tag
"Print Header" ps-print-header
)
2158 (const :tag
"Print Header Frame" ps-print-header-frame
)
2159 (const :tag
"Line Number" ps-line-number
)
2160 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2161 (const :tag
"Duplex" ps-spool-duplex
)
2162 (const :tag
"Tumble" ps-spool-tumble
)
2163 (const :tag
"Upside-Down" ps-print-upside-down
)
2164 (const :tag
"PS File Landscape" pr-file-landscape
)
2165 (const :tag
"PS File Duplex" pr-file-duplex
)
2166 (const :tag
"PS File Tumble" pr-file-tumble
)
2167 (const :tag
"Auto Region" pr-auto-region
)
2168 (const :tag
"Auto Mode" pr-auto-mode
)
2169 (const :tag
"Ghostscript Device" pr-gs-device
)
2170 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2171 (variable :tag
"Other"))
2172 (sexp :tag
"Value")))
2177 (defcustom pr-visible-entry-list
2178 '(postscript text postscript-options postscript-process printing help
)
2179 "*Specify a list of Printing menu visible entries.
2181 Valid values with the corresponding menu parts are:
2183 +------------------------------+
2184 | Printing Interface |
2185 +------------------------------+
2186 `postscript' | PostScript Preview >|
2187 | PostScript Print >|
2188 | PostScript Printer: name >|
2189 +------------------------------+
2190 `text' | Printify >|
2192 | Text Printer: name >|
2193 +------------------------------+
2194 `postscript-options' |[ ] Landscape |
2196 |[ ] Print Header Frame |
2198 |[ ] Zebra Stripes |
2202 | Print All Pages >|
2203 +------------------------------+
2204 `postscript-process' |[ ] Spool Buffer |
2205 |[ ] Print with-faces |
2206 |[ ] Print Using Ghostscript |
2207 +------------------------------+
2208 `printing' |[ ] Auto Region |
2211 +------------------------------+
2212 `help' | Customize >|
2215 +------------------------------+
2217 Any other value is ignored."
2218 :type
'(repeat :tag
"Menu Visible Part"
2219 (choice :menu-tag
"Menu Part"
2223 (const postscript-options
)
2224 (const postscript-process
)
2230 (defcustom pr-delete-temp-file t
2231 "*Non-nil means delete temporary files.
2233 Set `pr-delete-temp-file' to nil, if the following message (or a similar)
2234 happens when printing:
2236 Error: could not open \"c:\\temp\\prspool.ps\" for reading."
2241 (defcustom pr-list-directory nil
2242 "*Non-nil means list directory when processing a directory.
2244 That is, any subdirectories (and the superdirectory) of the directory (given as
2245 argument of functions below) are also printed (as dired-mode listings).
2247 It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
2248 `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
2249 and `pr-txt-directory'."
2254 (defcustom pr-buffer-name
"*Printing Interface*"
2255 "*Specify the name of the buffer interface for printing package.
2257 It's used by `pr-interface'."
2262 (defcustom pr-buffer-name-ignore
2263 (list (regexp-quote pr-buffer-name
) ; ignore printing interface buffer
2264 "^ .*$") ; ignore invisible buffers
2265 "*Specify a regexp list for buffer names to be ignored in interface buffer.
2267 NOTE: Case is important for matching, that is, `case-fold-search' is always
2270 It's used by `pr-interface'."
2271 :type
'(repeat (regexp :tag
"Buffer Name Regexp"))
2275 (defcustom pr-buffer-verbose t
2276 "*Non-nil means to be verbose when editing a field in interface buffer.
2278 It's used by `pr-interface'."
2283 (defcustom pr-shell-file-name
2284 (if (eq pr-path-style
'windows
)
2287 "*Specify file name to load inferior shells from."
2292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2293 ;; Internal Variables
2296 (defvar pr-txt-command nil
2297 "Name of program for printing a text file.
2298 See `pr-txt-printer-alist'.")
2301 (defvar pr-txt-switches nil
2302 "List of sexp's to pass as extra options for text printer program.
2303 See `pr-txt-printer-alist'.")
2306 (defvar pr-txt-printer nil
2307 "Specify text printer name.
2308 See `pr-txt-printer-alist'.")
2311 (defvar pr-ps-command nil
2312 "Name of program for printing a PostScript file.
2313 See `pr-ps-printer-alist'.")
2316 (defvar pr-ps-switches nil
2317 "List of sexp's to pass as extra options for PostScript printer program.
2318 See `pr-ps-printer-alist'.")
2321 (defvar pr-ps-printer-switch nil
2322 "Specify PostScript printer name switch.
2323 See `pr-ps-printer-alist'.")
2326 (defvar pr-ps-printer nil
2327 "Specify PostScript printer name.
2328 See `pr-ps-printer-alist'.")
2331 (defvar pr-menu-bar nil
2332 "Specify Printing menu-bar entry.")
2335 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2339 (defmacro pr-xemacs-global-menubar
(&rest body
)
2341 (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
2342 ;; be sure to access global menubar
2345 (kill-buffer temp
))))
2348 (defun pr-get-symbol (name)
2349 ;; Recent versions of easy-menu downcase names before interning them.
2350 (and (fboundp 'easy-menu-name-match
)
2351 (setq name
(downcase name
)))
2352 (or (intern-soft name
)
2353 (make-symbol name
)))
2357 (defsubst pr-visible-p
(key)
2358 (memq key pr-visible-entry-list
))
2361 (defsubst pr-mode-alist-p
()
2362 (cdr (assq major-mode pr-mode-alist
)))
2365 (defsubst pr-auto-mode-p
()
2366 (and pr-auto-mode
(pr-mode-alist-p)))
2369 (defsubst pr-using-ghostscript-p
()
2370 (and pr-print-using-ghostscript
(not pr-spool-p
)))
2375 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2376 (defsubst pr-region-active-p
()
2377 (and pr-auto-region transient-mark-mode mark-active
)))
2379 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2380 (defsubst pr-region-active-p
()
2381 (and pr-auto-region
(not zmacs-region-stays
) (ps-mark-active-p)))))
2384 (defconst pr-menu-spec
2386 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2388 ["Printing Interface" pr-interface
2389 :help
"Use buffer interface instead of menu interface"]
2391 ("PostScript Preview" :visible
(pr-visible-p 'postscript
)
2392 :help
"Preview PostScript instead of sending to printer"
2393 ("Directory" :active
(not pr-spool-p
)
2394 ["1-up" (pr-ps-directory-preview 1 nil nil t
) t
]
2395 ["2-up" (pr-ps-directory-preview 2 nil nil t
) t
]
2396 ["4-up" (pr-ps-directory-preview 4 nil nil t
) t
]
2397 ["Other..." (pr-ps-directory-preview nil nil nil t
)
2398 :keys
"\\[pr-ps-buffer-preview]"])
2399 ("Buffer" :active
(not pr-spool-p
)
2400 ["1-up" (pr-ps-buffer-preview 1 t
) t
]
2401 ["2-up" (pr-ps-buffer-preview 2 t
) t
]
2402 ["4-up" (pr-ps-buffer-preview 4 t
) t
]
2403 ["Other..." (pr-ps-buffer-preview nil t
)
2404 :keys
"\\[pr-ps-buffer-preview]"])
2405 ("Region" :active
(and (not pr-spool-p
) (ps-mark-active-p))
2406 ["1-up" (pr-ps-region-preview 1 t
) t
]
2407 ["2-up" (pr-ps-region-preview 2 t
) t
]
2408 ["4-up" (pr-ps-region-preview 4 t
) t
]
2409 ["Other..." (pr-ps-region-preview nil t
)
2410 :keys
"\\[pr-ps-region-preview]"])
2411 ("Mode" :active
(and (not pr-spool-p
) (pr-mode-alist-p))
2412 ["1-up" (pr-ps-mode-preview 1 t
) t
]
2413 ["2-up" (pr-ps-mode-preview 2 t
) t
]
2414 ["4-up" (pr-ps-mode-preview 4 t
) t
]
2415 ["Other..." (pr-ps-mode-preview nil t
)
2416 :keys
"\\[pr-ps-mode-preview]"])
2418 ["As Is..." (call-interactively 'pr-ps-file-preview
)
2419 :keys
"\\[pr-ps-file-preview]"
2420 :help
"Preview PostScript file"]
2422 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
2423 :help
"Select PostScript utility"]
2425 ["1-up..." (pr-ps-file-up-preview 1 t t
) pr-ps-utility-alist
]
2426 ["2-up..." (pr-ps-file-up-preview 2 t t
) pr-ps-utility-alist
]
2427 ["4-up..." (pr-ps-file-up-preview 4 t t
) pr-ps-utility-alist
]
2428 ["Other..." (pr-ps-file-up-preview nil t t
)
2429 :keys
"\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist
]
2431 ["Landscape" pr-toggle-file-landscape
2432 :style toggle
:selected pr-file-landscape
2433 :help
"Toggle landscape for PostScript file"
2434 :active pr-ps-utility-alist
]
2435 ["Duplex" pr-toggle-file-duplex
2436 :style toggle
:selected pr-file-duplex
2437 :help
"Toggle duplex for PostScript file"
2438 :active pr-ps-utility-alist
]
2439 ["Tumble" pr-toggle-file-tumble
2440 :style toggle
:selected pr-file-tumble
2441 :help
"Toggle tumble for PostScript file"
2442 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2443 ["Despool..." (call-interactively 'pr-despool-preview
)
2444 :active pr-spool-p
:keys
"\\[pr-despool-preview]"
2445 :help
"Despool PostScript buffer to printer or file (C-u)"])
2446 ("PostScript Print" :visible
(pr-visible-p 'postscript
)
2447 :help
"Send PostScript to printer or file (C-u)"
2449 ["1-up" (pr-ps-directory-ps-print 1 nil nil t
) t
]
2450 ["2-up" (pr-ps-directory-ps-print 2 nil nil t
) t
]
2451 ["4-up" (pr-ps-directory-ps-print 4 nil nil t
) t
]
2452 ["Other..." (pr-ps-directory-ps-print nil nil nil t
)
2453 :keys
"\\[pr-ps-buffer-ps-print]"])
2455 ["1-up" (pr-ps-buffer-ps-print 1 t
) t
]
2456 ["2-up" (pr-ps-buffer-ps-print 2 t
) t
]
2457 ["4-up" (pr-ps-buffer-ps-print 4 t
) t
]
2458 ["Other..." (pr-ps-buffer-ps-print nil t
)
2459 :keys
"\\[pr-ps-buffer-ps-print]"])
2460 ("Region" :active
(ps-mark-active-p)
2461 ["1-up" (pr-ps-region-ps-print 1 t
) t
]
2462 ["2-up" (pr-ps-region-ps-print 2 t
) t
]
2463 ["4-up" (pr-ps-region-ps-print 4 t
) t
]
2464 ["Other..." (pr-ps-region-ps-print nil t
)
2465 :keys
"\\[pr-ps-region-ps-print]"])
2466 ("Mode" :active
(pr-mode-alist-p)
2467 ["1-up" (pr-ps-mode-ps-print 1 t
) t
]
2468 ["2-up" (pr-ps-mode-ps-print 2 t
) t
]
2469 ["4-up" (pr-ps-mode-ps-print 4 t
) t
]
2470 ["Other..." (pr-ps-mode-ps-print nil t
)
2471 :keys
"\\[pr-ps-mode-ps-print]"])
2473 ["As Is..." (call-interactively 'pr-ps-file-ps-print
)
2474 :keys
"\\[pr-ps-file-ps-print]"
2475 :help
"Send PostScript file to printer"]
2477 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
2478 :help
"Select PostScript utility"]
2480 ["1-up..." (pr-ps-file-up-ps-print 1 t t
) pr-ps-utility-alist
]
2481 ["2-up..." (pr-ps-file-up-ps-print 2 t t
) pr-ps-utility-alist
]
2482 ["4-up..." (pr-ps-file-up-ps-print 4 t t
) pr-ps-utility-alist
]
2483 ["Other..." (pr-ps-file-up-ps-print nil t t
)
2484 :keys
"\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist
]
2486 ["Landscape" pr-toggle-file-landscape
2487 :style toggle
:selected pr-file-landscape
2488 :help
"Toggle landscape for PostScript file"
2489 :active pr-ps-utility-alist
]
2490 ["Duplex" pr-toggle-file-duplex
2491 :style toggle
:selected pr-file-duplex
2492 :help
"Toggle duplex for PostScript file"
2493 :active pr-ps-utility-alist
]
2494 ["Tumble" pr-toggle-file-tumble
2495 :style toggle
:selected pr-file-tumble
2496 :help
"Toggle tumble for PostScript file"
2497 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2498 ["Despool..." (call-interactively 'pr-despool-ps-print
)
2499 :active pr-spool-p
:keys
"\\[pr-despool-ps-print]"
2500 :help
"Despool PostScript buffer to printer or file (C-u)"])
2501 ["PostScript Printers" pr-update-menus
2502 :active pr-ps-printer-alist
:included
(pr-visible-p 'postscript
)
2503 :help
"Select PostScript printer"]
2505 ("Printify" :visible
(pr-visible-p 'text
)
2506 :help
"Replace non-printing chars with printable representations."
2507 ["Directory" pr-printify-directory t
]
2508 ["Buffer" pr-printify-buffer t
]
2509 ["Region" pr-printify-region
(ps-mark-active-p)])
2510 ("Print" :visible
(pr-visible-p 'text
)
2511 :help
"Send text to printer"
2512 ["Directory" pr-txt-directory t
]
2513 ["Buffer" pr-txt-buffer t
]
2514 ["Region" pr-txt-region
(ps-mark-active-p)]
2515 ["Mode" pr-txt-mode
(pr-mode-alist-p)])
2516 ["Text Printers" pr-update-menus
2517 :active pr-txt-printer-alist
:included
(pr-visible-p 'text
)
2518 :help
"Select text printer"]
2520 ["Landscape" pr-toggle-landscape
2521 :style toggle
:selected ps-landscape-mode
2522 :included
(pr-visible-p 'postscript-options
)]
2523 ["Print Header" pr-toggle-header
2524 :style toggle
:selected ps-print-header
2525 :included
(pr-visible-p 'postscript-options
)]
2526 ["Print Header Frame" pr-toggle-header-frame
2527 :style toggle
:selected ps-print-header-frame
:active ps-print-header
2528 :included
(pr-visible-p 'postscript-options
)]
2529 ["Line Number" pr-toggle-line
2530 :style toggle
:selected ps-line-number
2531 :included
(pr-visible-p 'postscript-options
)]
2532 ["Zebra Stripes" pr-toggle-zebra
2533 :style toggle
:selected ps-zebra-stripes
2534 :included
(pr-visible-p 'postscript-options
)]
2535 ["Duplex" pr-toggle-duplex
2536 :style toggle
:selected ps-spool-duplex
2537 :included
(pr-visible-p 'postscript-options
)]
2538 ["Tumble" pr-toggle-tumble
2539 :style toggle
:selected ps-spool-tumble
:active ps-spool-duplex
2540 :included
(pr-visible-p 'postscript-options
)]
2541 ["Upside-Down" pr-toggle-upside-down
2542 :style toggle
:selected ps-print-upside-down
2543 :included
(pr-visible-p 'postscript-options
)]
2544 ("Print All Pages" :visible
(pr-visible-p 'postscript-options
)
2545 :help
"Select odd/even pages/sheets to print"
2546 ["All Pages" (pr-even-or-odd-pages nil
)
2547 :style radio
:selected
(eq ps-even-or-odd-pages nil
)]
2548 ["Even Pages" (pr-even-or-odd-pages 'even-page
)
2549 :style radio
:selected
(eq ps-even-or-odd-pages
'even-page
)]
2550 ["Odd Pages" (pr-even-or-odd-pages 'odd-page
)
2551 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-page
)]
2552 ["Even Sheets" (pr-even-or-odd-pages 'even-sheet
)
2553 :style radio
:selected
(eq ps-even-or-odd-pages
'even-sheet
)]
2554 ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet
)
2555 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-sheet
)])
2557 ["Spool Buffer" pr-toggle-spool
2558 :style toggle
:selected pr-spool-p
2559 :included
(pr-visible-p 'postscript-process
)
2560 :help
"Toggle PostScript spooling"]
2561 ["Print with-faces" pr-toggle-faces
2562 :style toggle
:selected pr-faces-p
2563 :included
(pr-visible-p 'postscript-process
)
2564 :help
"Toggle PostScript printing with faces"]
2565 ["Print Using Ghostscript" pr-toggle-ghostscript
2566 :style toggle
:selected pr-print-using-ghostscript
2567 :included
(pr-visible-p 'postscript-process
)
2568 :help
"Toggle PostScript generation using ghostscript"]
2570 ["Auto Region" pr-toggle-region
2571 :style toggle
:selected pr-auto-region
2572 :included
(pr-visible-p 'printing
)]
2573 ["Auto Mode" pr-toggle-mode
2574 :style toggle
:selected pr-auto-mode
2575 :included
(pr-visible-p 'printing
)]
2576 ["Menu Lock" pr-toggle-lock
2577 :style toggle
:selected pr-menu-lock
2578 :included
(pr-visible-p 'printing
)]
2580 ("Customize" :visible
(pr-visible-p 'help
)
2581 ["printing" pr-customize t
]
2582 ["ps-print" ps-print-customize t
]
2583 ["lpr" lpr-customize t
])
2584 ("Show Settings" :visible
(pr-visible-p 'help
)
2585 ["printing" pr-show-pr-setup t
]
2586 ["ps-print" pr-show-ps-setup t
]
2587 ["lpr" pr-show-lpr-setup t
])
2588 ["Help" pr-help
:active t
:included
(pr-visible-p 'help
)]
2592 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2594 ;; unfortunately XEmacs doesn't support :active or :visible
2595 ;; for submenus, only for items.
2596 ;; It uses :included instead of :active or :visible.
2597 ;; Also, XEmacs doesn't support :help tag.
2599 ["Printing Interface" pr-interface
]
2601 ("PostScript Preview" :included
(pr-visible-p 'postscript
)
2602 ("Directory" :included
(not pr-spool-p
)
2603 ["1-up" (pr-ps-directory-preview 1 nil nil t
) t
]
2604 ["2-up" (pr-ps-directory-preview 2 nil nil t
) t
]
2605 ["4-up" (pr-ps-directory-preview 4 nil nil t
) t
]
2606 ["Other..." (pr-ps-directory-preview nil nil nil t
)
2607 :keys
"\\[pr-ps-buffer-preview]"])
2608 ("Buffer" :included
(not pr-spool-p
)
2609 ["1-up" (pr-ps-buffer-preview 1 t
) t
]
2610 ["2-up" (pr-ps-buffer-preview 2 t
) t
]
2611 ["4-up" (pr-ps-buffer-preview 4 t
) t
]
2612 ["Other..." (pr-ps-buffer-preview nil t
)
2613 :keys
"\\[pr-ps-buffer-preview]"])
2614 ("Region" :included
(and (not pr-spool-p
) (ps-mark-active-p))
2615 ["1-up" (pr-ps-region-preview 1 t
) t
]
2616 ["2-up" (pr-ps-region-preview 2 t
) t
]
2617 ["4-up" (pr-ps-region-preview 4 t
) t
]
2618 ["Other..." (pr-ps-region-preview nil t
)
2619 :keys
"\\[pr-ps-region-preview]"])
2620 ("Mode" :included
(and (not pr-spool-p
) (pr-mode-alist-p))
2621 ["1-up" (pr-ps-mode-preview 1 t
) t
]
2622 ["2-up" (pr-ps-mode-preview 2 t
) t
]
2623 ["4-up" (pr-ps-mode-preview 4 t
) t
]
2624 ["Other..." (pr-ps-mode-preview nil t
)
2625 :keys
"\\[pr-ps-mode-preview]"])
2627 ["As Is..." (call-interactively 'pr-ps-file-preview
)
2628 :keys
"\\[pr-ps-file-preview]"]
2630 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
]
2632 ["1-up..." (pr-ps-file-up-preview 1 t t
) pr-ps-utility-alist
]
2633 ["2-up..." (pr-ps-file-up-preview 2 t t
) pr-ps-utility-alist
]
2634 ["4-up..." (pr-ps-file-up-preview 4 t t
) pr-ps-utility-alist
]
2635 ["Other..." (pr-ps-file-up-preview nil t t
)
2636 :keys
"\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist
]
2638 ["Landscape" pr-toggle-file-landscape
2639 :style toggle
:selected pr-file-landscape
2640 :active pr-ps-utility-alist
]
2641 ["Duplex" pr-toggle-file-duplex
2642 :style toggle
:selected pr-file-duplex
2643 :active pr-ps-utility-alist
]
2644 ["Tumble" pr-toggle-file-tumble
2645 :style toggle
:selected pr-file-tumble
2646 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2647 ["Despool..." (call-interactively 'pr-despool-preview
)
2648 :active pr-spool-p
:keys
"\\[pr-despool-preview]"])
2649 ("PostScript Print" :included
(pr-visible-p 'postscript
)
2651 ["1-up" (pr-ps-directory-ps-print 1 nil nil t
) t
]
2652 ["2-up" (pr-ps-directory-ps-print 2 nil nil t
) t
]
2653 ["4-up" (pr-ps-directory-ps-print 4 nil nil t
) t
]
2654 ["Other..." (pr-ps-directory-ps-print nil nil nil t
)
2655 :keys
"\\[pr-ps-buffer-ps-print]"])
2657 ["1-up" (pr-ps-buffer-ps-print 1 t
) t
]
2658 ["2-up" (pr-ps-buffer-ps-print 2 t
) t
]
2659 ["4-up" (pr-ps-buffer-ps-print 4 t
) t
]
2660 ["Other..." (pr-ps-buffer-ps-print nil t
)
2661 :keys
"\\[pr-ps-buffer-ps-print]"])
2662 ("Region" :included
(ps-mark-active-p)
2663 ["1-up" (pr-ps-region-ps-print 1 t
) t
]
2664 ["2-up" (pr-ps-region-ps-print 2 t
) t
]
2665 ["4-up" (pr-ps-region-ps-print 4 t
) t
]
2666 ["Other..." (pr-ps-region-ps-print nil t
)
2667 :keys
"\\[pr-ps-region-ps-print]"])
2668 ("Mode" :included
(pr-mode-alist-p)
2669 ["1-up" (pr-ps-mode-ps-print 1 t
) t
]
2670 ["2-up" (pr-ps-mode-ps-print 2 t
) t
]
2671 ["4-up" (pr-ps-mode-ps-print 4 t
) t
]
2672 ["Other..." (pr-ps-mode-ps-print nil t
)
2673 :keys
"\\[pr-ps-mode-ps-print]"])
2675 ["As Is..." (call-interactively 'pr-ps-file-ps-print
)
2676 :keys
"\\[pr-ps-file-ps-print]"]
2678 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
]
2680 ["1-up..." (pr-ps-file-up-ps-print 1 t t
) pr-ps-utility-alist
]
2681 ["2-up..." (pr-ps-file-up-ps-print 2 t t
) pr-ps-utility-alist
]
2682 ["4-up..." (pr-ps-file-up-ps-print 4 t t
) pr-ps-utility-alist
]
2683 ["Other..." (pr-ps-file-up-ps-print nil t t
)
2684 :keys
"\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist
]
2686 ["Landscape" pr-toggle-file-landscape
2687 :style toggle
:selected pr-file-landscape
2688 :active pr-ps-utility-alist
]
2689 ["Duplex" pr-toggle-file-duplex
2690 :style toggle
:selected pr-file-duplex
2691 :active pr-ps-utility-alist
]
2692 ["Tumble" pr-toggle-file-tumble
2693 :style toggle
:selected pr-file-tumble
2694 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2695 ["Despool..." (call-interactively 'pr-despool-ps-print
)
2696 :active pr-spool-p
:keys
"\\[pr-despool-ps-print]"])
2697 ["PostScript Printers" pr-update-menus
2698 :active pr-ps-printer-alist
:included
(pr-visible-p 'postscript
)]
2700 ("Printify" :included
(pr-visible-p 'text
)
2701 ["Directory" pr-printify-directory t
]
2702 ["Buffer" pr-printify-buffer t
]
2703 ["Region" pr-printify-region
(ps-mark-active-p)])
2704 ("Print" :included
(pr-visible-p 'text
)
2705 ["Directory" pr-txt-directory t
]
2706 ["Buffer" pr-txt-buffer t
]
2707 ["Region" pr-txt-region
(ps-mark-active-p)]
2708 ["Mode" pr-txt-mode
(pr-mode-alist-p)])
2709 ["Text Printers" pr-update-menus
2710 :active pr-txt-printer-alist
:included
(pr-visible-p 'text
)]
2712 ["Landscape" pr-toggle-landscape
2713 :style toggle
:selected ps-landscape-mode
2714 :included
(pr-visible-p 'postscript-options
)]
2715 ["Print Header" pr-toggle-header
2716 :style toggle
:selected ps-print-header
2717 :included
(pr-visible-p 'postscript-options
)]
2718 ["Print Header Frame" pr-toggle-header-frame
2719 :style toggle
:selected ps-print-header-frame
:active ps-print-header
2720 :included
(pr-visible-p 'postscript-options
)]
2721 ["Line Number" pr-toggle-line
2722 :style toggle
:selected ps-line-number
2723 :included
(pr-visible-p 'postscript-options
)]
2724 ["Zebra Stripes" pr-toggle-zebra
2725 :style toggle
:selected ps-zebra-stripes
2726 :included
(pr-visible-p 'postscript-options
)]
2727 ["Duplex" pr-toggle-duplex
2728 :style toggle
:selected ps-spool-duplex
2729 :included
(pr-visible-p 'postscript-options
)]
2730 ["Tumble" pr-toggle-tumble
2731 :style toggle
:selected ps-spool-tumble
:active ps-spool-duplex
2732 :included
(pr-visible-p 'postscript-options
)]
2733 ["Upside-Down" pr-toggle-upside-down
2734 :style toggle
:selected ps-print-upside-down
2735 :included
(pr-visible-p 'postscript-options
)]
2736 ("Print All Pages" :included
(pr-visible-p 'postscript-options
)
2737 ["All Pages" (pr-even-or-odd-pages nil
)
2738 :style radio
:selected
(eq ps-even-or-odd-pages nil
)]
2739 ["Even Pages" (pr-even-or-odd-pages 'even-page
)
2740 :style radio
:selected
(eq ps-even-or-odd-pages
'even-page
)]
2741 ["Odd Pages" (pr-even-or-odd-pages 'odd-page
)
2742 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-page
)]
2743 ["Even Sheets" (pr-even-or-odd-pages 'even-sheet
)
2744 :style radio
:selected
(eq ps-even-or-odd-pages
'even-sheet
)]
2745 ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet
)
2746 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-sheet
)])
2748 ["Spool Buffer" pr-toggle-spool
2749 :style toggle
:selected pr-spool-p
2750 :included
(pr-visible-p 'postscript-process
)]
2751 ["Print with-faces" pr-toggle-faces
2752 :style toggle
:selected pr-faces-p
2753 :included
(pr-visible-p 'postscript-process
)]
2754 ["Print Using Ghostscript" pr-toggle-ghostscript
2755 :style toggle
:selected pr-print-using-ghostscript
2756 :included
(pr-visible-p 'postscript-process
)]
2758 ["Auto Region" pr-toggle-region
2759 :style toggle
:selected pr-auto-region
2760 :included
(pr-visible-p 'printing
)]
2761 ["Auto Mode" pr-toggle-mode
2762 :style toggle
:selected pr-auto-mode
2763 :included
(pr-visible-p 'printing
)]
2764 ["Menu Lock" pr-toggle-lock
2765 :style toggle
:selected pr-menu-lock
2766 :included
(pr-visible-p 'printing
)]
2768 ("Customize" :included
(pr-visible-p 'help
)
2769 ["printing" pr-customize t
]
2770 ["ps-print" ps-print-customize t
]
2771 ["lpr" lpr-customize t
])
2772 ("Show Settings" :included
(pr-visible-p 'help
)
2773 ["printing" pr-show-pr-setup t
]
2774 ["ps-print" pr-show-ps-setup t
]
2775 ["lpr" pr-show-lpr-setup t
])
2776 ["Help" pr-help
:active t
:included
(pr-visible-p 'help
)]
2782 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2785 ;; Replace existing "print" item by "Printing" item.
2786 ;; If you're changing this file, you'll load it a second,
2787 ;; third... time, but "print" item exists only in the first load.
2788 (defvar pr-menu-print-item
"print")
2791 ((string< emacs-version
"21.")
2792 (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item
)
2793 (when pr-menu-print-item
2794 (easy-menu-remove-item nil
'("tools") pr-menu-print-item
)
2795 (setq pr-menu-print-item nil
2796 pr-menu-bar
(vector 'menu-bar
'tools
2797 (pr-get-symbol "Printing")))))
2800 (easy-menu-change '("files") "Print" pr-menu-spec
"print-buffer")
2801 (let ((items '("print-buffer" "print-region"
2802 "ps-print-buffer-faces" "ps-print-region-faces"
2803 "ps-print-buffer" "ps-print-region")))
2805 (easy-menu-remove-item nil
'("files") (car items
))
2806 (setq items
(cdr items
)))
2807 (setq pr-menu-print-item nil
2808 pr-menu-bar
(vector 'menu-bar
'files
2809 (pr-get-symbol "Print")))))
2811 (easy-menu-change '("files") "Print" pr-menu-spec
)))
2814 (global-set-key [print] 'pr-ps-fast-fire)
2815 (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
2816 (global-set-key [C-print] 'pr-txt-fast-fire))
2819 ((eq ps-print-emacs-type 'xemacs) ; XEmacs
2821 (pr-xemacs-global-menubar
2822 (pr-x-add-submenu nil (cons "Printing" pr-menu-spec) "Apps"))
2825 (global-set-key 'f22 'pr-ps-fast-fire)
2826 (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
2827 (global-set-key '(control f22) 'pr-txt-fast-fire))))
2830 ;;; You can also use something like:
2831 ;;;(global-set-key "\C-ci" 'pr-interface)
2832 ;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print)
2833 ;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview)
2834 ;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
2835 ;;;(global-set-key "\C-crp" 'pr-ps-region-print)
2836 ;;;(global-set-key "\C-crx" 'pr-ps-region-preview)
2837 ;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
2840 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2844 (defconst pr-help-message
2845 (concat "printing.el version " pr-version
2846 " ps-print.el version " ps-print-version
2851 The `printing' menu (Tools/Printing or File/Print) has the following layout:
2853 +-----------------------------+
2854 A 0 | Printing Interface |
2855 +-----------------------------+ +-A---------+ +-B------+
2856 I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
2857 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
2858 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
2859 +-----------------------------+ |Mode >|-- B |Other...|
2860 II 4 | Printify >|-----\\ |File >|--\\ +--------+
2861 5 | Print >|---\\ | |Despool... | |
2862 6 | Text Printer: name >|-\\ | | +-----------+ |
2863 +-----------------------------+ | | | +---------+ +------------+
2864 III 7 |[ ]Landscape | | | \\-|Directory| | As Is... | Ia
2865 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
2866 9 |[ ]Print Header Frame | | | |Region | | name >|- C
2867 10 |[ ]Line Number | | | +---------+ +------------+
2868 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
2869 12 |[ ]Duplex | | \\---|Directory| | 2-up... |
2870 13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... |
2871 14 |[ ]Upside-Down | | |Region | | Other... |
2872 15 | Print All Pages >|--\\ | |Mode | +------------+
2873 +-----------------------------+ | | +---------+ |[ ]Landscape| Id
2874 IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
2875 17 |[ ]Print with-faces | | \\--|( )name A| |[ ]Tumble | If
2876 18 |[ ]Print Using Ghostscript | | |( )name B| +------------+
2877 +-----------------------------+ | |... |
2878 V 19 |[ ]Auto Region | | |(*)name |
2879 20 |[ ]Auto Mode | | |... |
2880 21 |[ ]Menu Lock | | +---------+ +--------------+
2881 +-----------------------------+ \\------------------|(*)All Pages |
2882 VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
2883 23 | Show Settings >|-------|printing| |( )Odd Pages |
2884 24 | Help | |ps-print| |( )Even Sheets|
2885 +-----------------------------+ |lpr | |( )Odd Sheets |
2886 +--------+ +--------------+
2888 See `pr-visible-entry-list' for hiding some parts of the menu.
2890 The menu has the following sections:
2894 0. You can use a buffer interface instead of menus. It looks like the
2895 customization buffer. Basically, it has the same options found in the
2896 menu and some extra options, all this on a buffer.
2898 I. PostScript printing:
2900 1. You can generate a PostScript file (if you type C-u before activating
2901 menu) or PostScript temporary file for a directory, a buffer, a region
2902 or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
2903 after file generation, ghostview is activated using the file generated
2904 as argument. This option is disabled if spooling is on (option 16).
2905 Also, if you already have a PostScript file you can preview it.
2906 Instead of previewing each buffer, region or major mode at once, you
2907 can save temporarily the PostScript code generated in a buffer and
2908 preview it later. The option `Despool...' despools the PostScript
2909 spooling buffer in a temporary file and uses ghostview to preview it.
2910 If you type C-u before choosing this option, the PostScript code
2911 generated is saved in a file instead of saving in a temporary file. To
2912 spool the PostScript code generated you need to turn on the option 16.
2913 The option `Despool...' is enabled if spooling is on (option 16).
2915 NOTE 1: It's possible to customize a major mode printing, just declare
2916 the customization in `pr-mode-alist' and invoke some of
2917 `*-mode*' commands or select Mode option in Printing menu. An
2918 example for major mode usage is when you're using gnus (or mh,
2919 or rmail, etc.) and you're in the *Summary* buffer, if you
2920 forget to switch to the *Article* buffer before printing,
2921 you'll get a nicely formatted list of article subjects shows
2922 up at the printer. With major mode printing you don't need to
2923 switch from gnus *Summary* buffer first.
2925 NOTE 2: There are the following options for PostScript file processing:
2926 Ia. Print the file *as is*, that is, send it directly to
2928 Ib. PostScript utility processing selection.
2929 See `pr-ps-utility-alist' and `pr-setting-database' for
2931 Ic. Do n-up processing before printing.
2932 Id. Toggle on/off landscape for PostScript file processing.
2933 Ie. Toggle on/off duplex for PostScript file processing.
2934 If. Toggle on/off tumble for PostScript file processing.
2936 NOTE 3: Don't forget to download and install the utilities declared on
2937 `pr-ps-utility-alist'.
2939 2. Operate the same way as option 1, but it sends directly the PostScript
2940 code (or put in a file, if you've typed C-u) or it uses ghostscript to
2941 print the PostScript file generated. It depends on option 18, if it's
2942 turned on, it uses ghostscript; otherwise, it sends directly to
2943 printer. If spooling is on (option 16), the PostScript code is saved
2944 temporarily in a buffer instead of printing it or saving it in a file.
2945 Also, if you already have a PostScript file you can print it.
2946 Instead of printing each buffer, region or major mode at once, you can
2947 save temporarily the PostScript code generated in a buffer and print it
2948 later. The option `Despool...' despools the PostScript spooling buffer
2949 directly on a printer. If you type C-u before choosing this option,
2950 the PostScript code generated is saved in a file instead of sending to
2951 printer. To spool the PostScript code generated you need to turn on
2952 the option 16. This option is enabled if spooling is on (option 16).
2953 See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
2955 3. You can select a new PostScript printer to send PostScript code
2956 generated. For selection it's used all PostScript printers defined
2957 in `pr-ps-printer-alist' variable (see it for documentation).
2958 See also `pr-setting-database'.
2962 4. If you have control characters (character code from \\000 to \\037) in a
2963 buffer and you want to print them in a text printer, select this
2964 option. All control characters in your buffer or region will be
2965 replaced by a printable representation. The printable representations
2966 use ^ (for ASCII control characters) or hex. The characters tab,
2967 linefeed, space, return and formfeed are not affected.
2968 You don't need to select this option if you use any option of section
2969 I, the PostScript engine treats control characters properly.
2971 5. If you want to print a directory, buffer, region or major mode in a
2972 text printer, select this option. See also the NOTE 1 on option 1.
2974 6. You can select a new text printer to send text generated. For
2975 selection it's used all text printers defined in `pr-txt-printer-alist'
2976 variable (see it for documentation).
2977 See also `pr-setting-database'.
2979 III. PostScript page toggle options:
2981 7. If you want a PostScript landscape printing, turn on this option.
2983 8. If you want to have a header in each page in your PostScript code,
2984 turn on this option.
2986 9. If you want to draw a gaudy frame around the header, turn on this
2987 option. This option is enabled if print header is on (option 8).
2989 10. If you want that the line number is printed in your PostScript code,
2990 turn on this option.
2992 11. If you want background zebra stripes in your PostScript code, turn on
2995 12. If you want a duplex printing and your PostScript printer has this
2996 feature, turn on this option.
2998 13. If you turned on duplex printing, you can choose if you want to have a
2999 printing suitable for binding on the left or right (tumble off), or to
3000 have a printing suitable for binding at top or bottom (tumble on).
3001 This option is enabled if duplex is on (option 12).
3003 14. If you want a PostScript upside-down printing, turn on this option.
3005 15. With this option, you can choose if you want to print all pages, odd
3006 pages, even pages, odd sheets or even sheets.
3007 See also `ps-even-or-odd-pages'.
3009 IV. PostScript processing toggle options:
3011 16. If you want to spool the PostScript code generated, turn on this
3012 option. To spool the PostScript code generated use option 2. You can
3013 despool later by choosing option 1 or 2, sub-option `Despool...'.
3015 17. If you use colors in your buffers and want to see these colors on your
3016 PostScript code generated, turn on this option. If you have a
3017 black/white PostScript printer, these colors are displayed in gray
3018 scale by PostScript printer interpreter.
3020 18. If you don't have a PostScript printer to send PostScript files, turn
3021 on this option. When this option is on, the ghostscript is used to
3022 print PostScript files. In GNU or Unix system, if ghostscript is set
3023 as a PostScript filter, you don't need to turn on this option.
3025 V. Printing customization:
3027 19. If you want that region is automagically detected, turn on this
3028 option. Note that this will only work if you're using transient mark
3029 mode. When this option is on, the `*-buffer*' commands will behave
3030 like `*-region*' commands, that is, `*-buffer*' commands will print
3031 only the region marked instead of all buffer.
3033 20. Turn this option on if you want that when current major-mode is
3034 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3035 behave like `*-mode*' commands.
3037 21. If you want that Printing menu stays poped while you are setting
3038 toggle options, turn on this option. The variables
3039 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3040 menu position, so don't forget to adjust these variables if menu
3045 22. Besides all options in section III, IV and V, you can customize much
3046 more PostScript options in `ps-print' option. Or you can customize
3047 some `lpr' options for text printing. Or customize `printing'
3050 23. Show current settings for `printing', `ps-print' or `lpr'.
3052 24. Quick help for printing menu layout.
3054 "Printing help message.")
3057 (defconst pr-interface-help-message
3058 (concat "printing.el version " pr-version
3059 " ps-print.el version " ps-print-version
3061 The printing interface buffer has the same functionality as the printing menu.
3062 The major difference is that the states (like sending PostScript generated to a
3063 file, n-up printing, etc.) are set and saved between priting buffer
3064 activation. Also, the landscape, duplex and tumble values are the same for
3065 PostScript file and directory/buffer/region/mode processing; using menu, there
3066 are different value sets for PostScript file and directory/buffer/region/mode
3069 The printing interface buffer has the following sections:
3073 Here you can choose to print/preview a buffer, a directory or a PostScript
3079 Select a buffer from the current buffer list.
3082 If it's on, this means that the selected buffer has an active region,
3083 so you can turn on/off, as you wish.
3084 If it's off when a buffer is selected, this means that the selected
3085 buffer has no active region, so it'll not be possible to turn it on.
3086 If you want to process the region, let this option on.
3087 If you want to process the whole buffer, let this option off.
3090 If it's on, this means that the selected buffer major mode is declared
3091 for major mode processing, so you can turn on/off, as you wish.
3092 If it's off when a buffer is selected, this means that the selected
3093 buffer major mode isn't declared for major mode processing, so it'll
3094 not be possible to turn it on.
3095 If you want the major mode processing, let this option on.
3096 If you don't want the major mode processing, let this option off.
3098 NOTE 1: It's possible to customize a major mode printing, just declare
3099 the customization in `pr-mode-alist' and invoke some of
3100 `*-mode*' commands or select Mode option in Printing menu. An
3101 example for major mode usage is when you're using gnus (or mh,
3102 or rmail, etc.) and you're in the *Summary* buffer, if you
3103 forget to switch to the *Article* buffer before printing,
3104 you'll get a nicely formatted list of article subjects shows
3105 up at the printer. With major mode printing you don't need to
3106 switch from gnus *Summary* buffer first.
3111 Specify a valid directory path.
3114 Specify a file name regexp. All file names in the directory that
3115 match with regexp will be printed/previewed. An empty file name
3116 regexp means to print/preview all files in the directory.
3118 * List Directory Entry:
3119 If it's turned on, list directory entries besides file entries.
3121 1c. PostScript file:
3124 Specify an existent PostScript file to print/preview.
3126 * PostScript Utility:
3127 Select a PostScript utility.
3128 See `pr-ps-utility-alist' and `pr-setting-database' for documentation.
3130 NOTE 2: Don't forget to download and install the utilities declared on
3131 `pr-ps-utility-alist'.
3134 If it's turned on, don't use the PostScript utility to preprocess the
3135 PostScript file before printing/previewing.
3137 2. PostScript printer:
3139 * PostScript Printer:
3140 You can select a new PostScript printer to send PostScript code
3141 generated. For selection it's used all PostScript printers defined
3142 in `pr-ps-printer-alist' variable (see it for documentation).
3143 See also `pr-setting-database'.
3146 If spooling is on, you can turn it on/off, as you wish.
3147 If spooling is off, it'll not be possible to turn it on.
3148 If it's turned on, specify to despools the PostScript spooling buffer in
3149 a temporary file or in the selected PostScript file when
3150 printing/previewing.
3153 Preview the PostScript generated.
3156 Print the PostScript generated.
3159 Quit from printing interface buffer.
3161 * Send to Printer/Temporary File:
3162 If it's turned on, the PostScript generated is sent directly to
3163 PostScript printer or, for previewing, to a temporary file.
3166 Specify a file name to send the PostScript generated.
3169 Specify n-up printing.
3174 Select a new text printer to send text generated. For selection it's used
3175 all text printers defined in `pr-txt-printer-alist' variable (see it for
3176 documentation). See also `pr-setting-database'.
3179 If you have control characters (character code from \\000 to \\037) in a
3180 buffer and you want to print them in a text printer, select this
3181 option. All control characters in your buffer or region will be
3182 replaced by a printable representation. The printable representations
3183 use ^ (for ASCII control characters) or hex. The characters tab,
3184 linefeed, space, return and formfeed are not affected.
3185 You don't need to select this option if you use any option of section
3186 I, the PostScript engine treats control characters properly.
3189 To print a directory, buffer, region or major mode in a
3190 text printer, select this option. See also the NOTE 1 on section 1.
3193 Quit from printing interface buffer.
3197 There are 3 setting columns:
3199 4a. First column (left column):
3202 PostScript landscape printing.
3205 To have a header in each page in your PostScript code.
3207 * Print Header Frame:
3208 To draw a gaudy frame around the header.
3211 The line number is printed in your PostScript code.
3214 Background zebra stripes in your PostScript code.
3217 Duplex printing (if your PostScript printer has this feature).
3220 If duplex printing is on, you can choose if you want to have a
3221 printing suitable for binding on the left or right (tumble off), or to
3222 have a printing suitable for binding at top or bottom (tumble on).
3225 PostScript upside-down printing.
3227 4b. Second column (middle column):
3230 If you want that region is automagically detected, turn on this
3231 option. Note that this will only work if you're using transient mark
3232 mode. When this option is on, the `*-buffer*' commands will behave
3233 like `*-region*' commands, that is, `*-buffer*' commands will print
3234 only the region marked instead of all buffer.
3237 Turn this option on if you want that when current major-mode is
3238 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3239 behave like `*-mode*' commands.
3242 If you want that Printing menu stays poped while you are setting
3243 toggle options, turn on this option. The variables
3244 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3245 menu position, so don't forget to adjust these variables if menu
3249 To spool the PostScript code generated. You can despool later by
3250 setting Despool option on PostScript printer section.
3253 If you use colors in your buffers and want to see these colors on your
3254 PostScript code generated, turn on this option. If you have a
3255 black/white PostScript printer, these colors are displayed in gray
3256 scale by PostScript printer interpreter.
3258 * Print Using Ghostscript:
3259 If you don't have a PostScript printer to send PostScript files, turn
3260 on this option. When this option is on, the ghostscript is used to
3261 print PostScript files. In GNU or Unix system, if ghostscript is set
3262 as a PostScript filter, you don't need to turn on this option.
3265 To print all pages, odd pages, even pages, odd sheets or even sheets.
3266 See also `ps-even-or-odd-pages'.
3268 4c. Third column (right column):
3271 That is, to be verbose when editing a field in interface buffer.
3275 Besides all options in section 4, you can customize much more PostScript
3276 options in `ps-print' option. Or you can customize some `lpr' options for
3277 text printing. Or customize `printing' options.
3281 Show current settings for `printing', `ps-print' or `lpr'.
3285 Quick help for printing interface buffer and printing menu layout. You can
3286 also quit the printing interface buffer or kill all printing help buffer.
3288 "Printing buffer interface help message.")
3291 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3296 (defun pr-interface (&optional buffer)
3297 "Activate the printing interface buffer.
3299 If BUFFER is nil, it uses the current buffer for printing.
3301 For more informations, type \\[pr-interface-help]."
3304 (set-buffer (or buffer (current-buffer)))
3305 (pr-create-interface)))
3309 (defun pr-ps-directory-preview (n-up dir file-regexp &optional filename)
3310 "Preview directory using ghostview.
3312 Interactively, the command prompts for N-UP printing number, a directory, a
3313 file name regexp for matching and, when you use a prefix argument (C-u), the
3314 command prompts the user for a file name, and saves the PostScript image in
3315 that file instead of saving it in a temporary file.
3317 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3318 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3319 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3320 save the image in a temporary file. If FILENAME is a string, save the
3321 PostScript image in a file with that name. If FILENAME is t, prompts for a
3324 See also documentation for `pr-list-directory'."
3325 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir")))
3326 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3327 (pr-prompt "PS preview dir"))
3328 (setq filename (pr-ps-file filename))
3329 (pr-ps-file-list n-up dir file-regexp filename)
3331 (pr-ps-file-preview filename)))
3335 (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp &optional filename)
3336 "Print directory using PostScript through ghostscript.
3338 Interactively, the command prompts for N-UP printing number, a directory, a
3339 file name regexp for matching and, when you use a prefix argument (C-u), the
3340 command prompts the user for a file name, and saves the PostScript image in
3341 that file instead of saving it in a temporary file.
3343 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3344 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3345 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3346 save the image in a temporary file. If FILENAME is a string, save the
3347 PostScript image in a file with that name. If FILENAME is t, prompts for a
3350 See also documentation for `pr-list-directory'."
3351 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS")))
3352 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3353 (pr-prompt "PS print dir GS"))
3354 (let ((file (pr-ps-file filename)))
3355 (pr-ps-file-list n-up dir file-regexp file)
3356 (pr-ps-file-using-ghostscript file)
3357 (or filename (pr-delete-file file))))
3361 (defun pr-ps-directory-print (n-up dir file-regexp &optional filename)
3362 "Print directory using PostScript printer.
3364 Interactively, the command prompts for N-UP printing number, a directory, a
3365 file name regexp for matching and, when you use a prefix argument (C-u), the
3366 command prompts the user for a file name, and saves the PostScript image in
3367 that file instead of saving it in a temporary file.
3369 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3370 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3371 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3372 save the image in a temporary file. If FILENAME is a string, save the
3373 PostScript image in a file with that name. If FILENAME is t, prompts for a
3376 See also documentation for `pr-list-directory'."
3377 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir")))
3378 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3379 (pr-prompt "PS print dir"))
3380 (let ((file (pr-ps-file filename)))
3381 (pr-ps-file-list n-up dir file-regexp file)
3382 (pr-ps-file-print file)
3383 (or filename (pr-delete-file file))))
3387 (defun pr-ps-directory-ps-print (n-up dir file-regexp &optional filename)
3388 "Print directory using PostScript printer or through ghostscript.
3390 It depends on `pr-print-using-ghostscript'.
3392 Interactively, the command prompts for N-UP printing number, a directory, a
3393 file name regexp for matching and, when you use a prefix argument (C-u), the
3394 command prompts the user for a file name, and saves the PostScript image in
3395 that file instead of saving it in a temporary file.
3397 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3398 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3399 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3400 save the image in a temporary file. If FILENAME is a string, save the
3401 PostScript image in a file with that name. If FILENAME is t, prompts for a
3404 See also documentation for `pr-list-directory'."
3405 (interactive (pr-interactive-ps-dir-args
3406 (pr-prompt (pr-prompt-gs "PS print dir"))))
3407 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3408 (pr-prompt (pr-prompt-gs "PS print dir")))
3409 (if (pr-using-ghostscript-p)
3410 (pr-ps-directory-using-ghostscript n-up dir file-regexp filename)
3411 (pr-ps-directory-print n-up dir file-regexp filename)))
3415 (defun pr-ps-buffer-preview (n-up &optional filename)
3416 "Preview buffer using ghostview.
3418 Interactively, the command prompts for N-UP printing number and, when you use a
3419 prefix argument (C-u), the command prompts the user for a file name, and saves
3420 the PostScript image in that file instead of saving it in a temporary file.
3422 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3423 argument FILENAME is treated as follows: if it's nil, save the image in a
3424 temporary file. If FILENAME is a string, save the PostScript image in a file
3425 with that name. If FILENAME is t, prompts for a file name."
3426 (interactive (pr-interactive-n-up-file (pr-prompt "PS preview")))
3427 (if (pr-auto-mode-p)
3428 (pr-ps-mode-preview n-up filename)
3429 (pr-ps-preview (pr-region-active-symbol) n-up filename
3430 (pr-region-active-string "PS preview"))))
3434 (defun pr-ps-buffer-using-ghostscript (n-up &optional filename)
3435 "Print buffer using PostScript through ghostscript.
3437 Interactively, the command prompts for N-UP printing number and, when you use a
3438 prefix argument (C-u), the command prompts the user for a file name, and saves
3439 the PostScript image in that file instead of sending it to the printer.
3441 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3442 argument FILENAME is treated as follows: if it's nil, send the image to the
3443 printer. If FILENAME is a string, save the PostScript image in a file with
3444 that name. If FILENAME is t, prompts for a file name."
3445 (interactive (pr-interactive-n-up-file (pr-prompt "PS print GS")))
3446 (if (pr-auto-mode-p)
3447 (pr-ps-mode-using-ghostscript n-up filename)
3448 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
3449 (pr-region-active-string "PS print GS"))))
3453 (defun pr-ps-buffer-print (n-up &optional filename)
3454 "Print buffer using PostScript printer.
3456 Interactively, the command prompts for N-UP printing number and, when you use a
3457 prefix argument (C-u), the command prompts the user for a file name, and saves
3458 the PostScript image in that file instead of sending it to the printer.
3460 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3461 argument FILENAME is treated as follows: if it's nil, send the image to the
3462 printer. If FILENAME is a string, save the PostScript image in a file with
3463 that name. If FILENAME is t, prompts for a file name."
3464 (interactive (pr-interactive-n-up-file (pr-prompt "PS print")))
3465 (if (pr-auto-mode-p)
3466 (pr-ps-mode-print n-up filename)
3467 (pr-ps-print (pr-region-active-symbol) n-up filename
3468 (pr-region-active-string "PS print"))))
3472 (defun pr-ps-buffer-ps-print (n-up &optional filename)
3473 "Print buffer using PostScript printer or through ghostscript.
3475 It depends on `pr-print-using-ghostscript'.
3477 Interactively, the command prompts for N-UP printing number and, when you use a
3478 prefix argument (C-u), the command prompts the user for a file name, and saves
3479 the PostScript image in that file instead of sending it to the printer.
3481 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3482 argument FILENAME is treated as follows: if it's nil, send the image to the
3483 printer. If FILENAME is a string, save the PostScript image in a file with
3484 that name. If FILENAME is t, prompts for a file name."
3485 (interactive (pr-interactive-n-up-file
3486 (pr-prompt (pr-prompt-gs "PS print"))))
3487 (cond ((pr-auto-mode-p)
3488 (pr-ps-mode-ps-print n-up filename))
3489 ((pr-using-ghostscript-p)
3490 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
3491 (pr-region-active-string "PS print GS")))
3493 (pr-ps-print (pr-region-active-symbol) n-up filename
3494 (pr-region-active-string "PS print")))))
3498 (defun pr-ps-region-preview (n-up &optional filename)
3499 "Preview region using ghostview.
3501 See also `pr-ps-buffer-preview'."
3502 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS preview")))
3503 (if (pr-auto-mode-p)
3504 (let ((pr-auto-region t))
3505 (pr-ps-mode-preview n-up filename))
3506 (pr-ps-preview 'region n-up filename "PS preview region")))
3510 (defun pr-ps-region-using-ghostscript (n-up &optional filename)
3511 "Print region using PostScript through ghostscript.
3513 See also `pr-ps-buffer-using-ghostscript'."
3514 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print GS")))
3515 (if (pr-auto-mode-p)
3516 (let ((pr-auto-region t))
3517 (pr-ps-mode-using-ghostscript n-up filename))
3518 (pr-ps-using-ghostscript 'region n-up filename "PS print GS region")))
3522 (defun pr-ps-region-print (n-up &optional filename)
3523 "Print region using PostScript printer.
3525 See also `pr-ps-buffer-print'."
3526 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print")))
3527 (if (pr-auto-mode-p)
3528 (let ((pr-auto-region t))
3529 (pr-ps-mode-print n-up filename))
3530 (pr-ps-print 'region n-up filename "PS print region")))
3534 (defun pr-ps-region-ps-print (n-up &optional filename)
3535 "Print region using PostScript printer or through ghostscript.
3537 See also `pr-ps-buffer-ps-print'."
3538 (interactive (pr-interactive-n-up-file
3539 (pr-prompt-region (pr-prompt-gs "PS print"))))
3540 (cond ((pr-auto-mode-p)
3541 (let ((pr-auto-region t))
3542 (pr-ps-mode-ps-print n-up filename)))
3543 ((pr-using-ghostscript-p)
3544 (pr-ps-using-ghostscript 'region n-up filename "PS print GS region"))
3546 (pr-ps-print 'region n-up filename "PS print region"))))
3550 (defun pr-ps-mode-preview (n-up &optional filename)
3551 "Preview major mode using ghostview.
3553 See also `pr-ps-buffer-preview'."
3554 (interactive (pr-interactive-n-up-file "PS preview mode"))
3555 (pr-set-n-up-and-filename 'n-up 'filename "PS preview mode")
3556 (let ((file (pr-ps-file filename)))
3557 (and (pr-ps-mode n-up file)
3559 (pr-ps-file-preview file))))
3563 (defun pr-ps-mode-using-ghostscript (n-up &optional filename)
3564 "Print major mode using PostScript through ghostscript.
3566 See also `pr-ps-buffer-using-ghostscript'."
3567 (interactive (pr-interactive-n-up-file "PS print GS mode"))
3568 (pr-set-n-up-and-filename 'n-up 'filename "PS print GS mode")
3569 (let ((file (pr-ps-file filename)))
3570 (when (and (pr-ps-mode n-up file)
3572 (pr-ps-file-using-ghostscript file)
3573 (or filename (pr-delete-file file)))))
3577 (defun pr-ps-mode-print (n-up &optional filename)
3578 "Print major mode using PostScript printer.
3580 See also `pr-ps-buffer-print'."
3581 (interactive (pr-interactive-n-up-file "PS print mode"))
3582 (pr-set-n-up-and-filename 'n-up 'filename "PS print mode")
3583 (pr-ps-mode n-up filename))
3587 (defun pr-ps-mode-ps-print (n-up &optional filename)
3588 "Print major mode using PostScript or through ghostscript.
3590 See also `pr-ps-buffer-ps-print'."
3591 (interactive (pr-interactive-n-up-file (pr-prompt-gs "PS print mode")))
3592 (if (pr-using-ghostscript-p)
3593 (pr-ps-mode-using-ghostscript n-up filename)
3594 (pr-ps-mode-print n-up filename)))
3598 (defun pr-printify-directory (&optional dir file-regexp)
3599 "Replace nonprinting characters in directory with printable representations.
3600 The printable representations use ^ (for ASCII control characters) or hex.
3601 The characters tab, linefeed, space, return and formfeed are not affected.
3603 Interactively, the command prompts for a directory and a file name regexp for
3606 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
3607 prompts for FILE(name)-REGEXP.
3609 See also documentation for `pr-list-directory'."
3610 (interactive (pr-interactive-dir-args "Printify dir"))
3611 (pr-set-dir-args 'dir 'file-regexp "Printify dir")
3612 (pr-file-list dir file-regexp 'pr-printify-buffer))
3616 (defun pr-printify-buffer ()
3617 "Replace nonprinting characters in buffer with printable representations.
3618 The printable representations use ^ (for ASCII control characters) or hex.
3619 The characters tab, linefeed, space, return and formfeed are not affected."
3621 (if (pr-region-active-p)
3622 (pr-printify-region)
3623 (printify-region (point-min) (point-max))))
3627 (defun pr-printify-region ()
3628 "Replace nonprinting characters in region with printable representations.
3629 The printable representations use ^ (for ASCII control characters) or hex.
3630 The characters tab, linefeed, space, return and formfeed are not affected."
3632 (printify-region (point) (mark)))
3636 (defun pr-txt-directory (&optional dir file-regexp)
3637 "Print directory using text printer.
3639 Interactively, the command prompts for a directory and a file name regexp for
3642 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
3643 prompts for FILE(name)-REGEXP.
3645 See also documentation for `pr-list-directory'."
3646 (interactive (pr-interactive-dir-args "Print dir"))
3647 (pr-set-dir-args 'dir 'file-regexp "Print dir")
3648 (pr-file-list dir file-regexp 'pr-txt-buffer))
3652 (defun pr-txt-buffer ()
3653 "Print buffer using text printer."
3655 (cond ((pr-auto-mode-p)
3657 ((pr-region-active-p)
3660 (pr-txt-print (point-min) (point-max)))))
3664 (defun pr-txt-region ()
3665 "Print region using text printer."
3667 (if (pr-auto-mode-p)
3668 (let ((pr-auto-region t))
3670 (pr-txt-print (point) (mark))))
3674 (defun pr-txt-mode ()
3675 "Print major mode using text printer."
3677 (let ((args (pr-mode-alist-p)))
3679 (funcall (car args) (nthcdr 2 args))
3681 (message "`%s' major mode not declared." major-mode))))
3685 (defun pr-despool-preview (&optional filename)
3686 "Preview spooled PostScript.
3688 Interactively, when you use a prefix argument (C-u), the command prompts the
3689 user for a file name, and saves the spooled PostScript image in that file
3690 instead of saving it in a temporary file.
3692 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3693 save the image in a temporary file. If FILENAME is a string, save the
3694 PostScript image in a file with that name."
3695 (interactive (list (ps-print-preprint current-prefix-arg)))
3696 (let ((file (pr-ps-file filename)))
3697 (when (stringp file)
3698 (pr-despool-print file)
3699 (pr-ps-file-preview file))))
3703 (defun pr-despool-using-ghostscript (&optional filename)
3704 "Print spooled PostScript using ghostscript.
3706 Interactively, when you use a prefix argument (C-u), the command prompts the
3707 user for a file name, and saves the spooled PostScript image in that file
3708 instead of sending it to the printer.
3710 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3711 send the image to the printer. If FILENAME is a string, save the PostScript
3712 image in a file with that name."
3713 (interactive (list (ps-print-preprint current-prefix-arg)))
3714 (let ((file (pr-ps-file filename)))
3715 (when (stringp file)
3716 (pr-despool-print file)
3717 (pr-ps-file-using-ghostscript file)
3718 (or filename (pr-delete-file file)))))
3722 (defun pr-despool-print (&optional filename)
3723 "Send the spooled PostScript to the printer.
3725 Interactively, when you use a prefix argument (C-u), the command prompts the
3726 user for a file name, and saves the spooled PostScript image in that file
3727 instead of sending it to the printer.
3729 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3730 send the image to the printer. If FILENAME is a string, save the PostScript
3731 image in a file with that name."
3732 (interactive (list (ps-print-preprint current-prefix-arg)))
3733 (let ((ps-lpr-command (pr-command pr-ps-command))
3734 (ps-lpr-switches pr-ps-switches)
3735 (ps-printer-name-option pr-ps-printer-switch)
3736 (ps-printer-name pr-ps-printer))
3737 (ps-despool filename)))
3741 (defun pr-despool-ps-print (&optional filename)
3742 "Send the spooled PostScript to the printer or use ghostscript to print it.
3744 Interactively, when you use a prefix argument (C-u), the command prompts the
3745 user for a file name, and saves the spooled PostScript image in that file
3746 instead of sending it to the printer.
3748 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3749 send the image to the printer. If FILENAME is a string, save the PostScript
3750 image in a file with that name."
3751 (interactive (list (ps-print-preprint current-prefix-arg)))
3752 (if pr-print-using-ghostscript
3753 (pr-despool-using-ghostscript filename)
3754 (pr-despool-print filename)))
3758 (defun pr-ps-file-preview (filename)
3759 "Preview PostScript file FILENAME."
3760 (interactive (list (pr-ps-infile-preprint "Preview ")))
3761 (and (stringp filename) (file-exists-p filename)
3762 (let ((shell-file-name pr-shell-file-name))
3763 (start-process-shell-command "PREVIEW" "*Messages*"
3764 (pr-command pr-gv-command) filename))))
3768 (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename)
3769 "Preview PostScript file FILENAME."
3770 (interactive (pr-interactive-n-up-inout "PS preview"))
3771 (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename
3773 (pr-ps-utility-process n-up ifilename outfile)
3774 (pr-ps-file-preview outfile)))
3778 (defun pr-ps-file-using-ghostscript (filename)
3779 "Print PostScript file FILENAME using ghostscript."
3780 (interactive (list (pr-ps-infile-preprint "Print preview ")))
3781 (and (stringp filename) (file-exists-p filename)
3782 (let* ((file (pr-expand-file-name filename))
3783 (tempfile (pr-dosify-path (make-temp-name file))))
3786 (concat (pr-command pr-gs-command)
3787 " -sDEVICE=" pr-gs-device
3788 " -r" (int-to-string pr-gs-resolution)
3789 " " (pr-switches-string pr-gs-switches "pr-gs-switches")
3790 " -sOutputFile=" tempfile " " file " -c quit"))
3792 (pr-ps-file-print tempfile)
3794 (pr-delete-file tempfile))))
3798 (defun pr-ps-file-print (filename)
3799 "Print PostScript file FILENAME."
3800 (interactive (list (pr-ps-infile-preprint "Print ")))
3801 (and (stringp filename) (file-exists-p filename)
3803 (let ((file (pr-expand-file-name filename)))
3804 (if (string-equal pr-ps-command "")
3805 (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
3807 (set-buffer ps-spool-buffer)
3809 (insert-file-contents-literally file))
3812 (concat (pr-command pr-ps-command) " "
3813 (pr-switches-string pr-ps-switches "pr-gs-switches") " "
3814 (if (string-match "cp" pr-ps-command)
3815 ;; for "cp" (cmd in out)
3816 (concat "\"" file "\" "
3817 pr-ps-printer-switch pr-ps-printer)
3818 ;; else, for others (cmd out in)
3819 (concat pr-ps-printer-switch pr-ps-printer
3820 " \"" file "\""))))))))
3824 (defun pr-ps-file-ps-print (filename)
3825 "Send PostScript file FILENAME to printer or use ghostscript to print it."
3826 (interactive (list (pr-ps-infile-preprint
3827 (if pr-print-using-ghostscript
3830 (if pr-print-using-ghostscript
3831 (pr-ps-file-using-ghostscript filename)
3832 (pr-ps-file-print filename)))
3836 (defun pr-ps-file-up-ps-print (n-up ifilename &optional ofilename)
3837 "Process a PostScript file IFILENAME and send it to printer.
3839 Interactively, the command prompts for N-UP printing number, for an input
3840 PostScript file IFILENAME and, when you use a prefix argument (C-u), the
3841 command prompts the user for an output PostScript file name OFILENAME, and
3842 saves the PostScript image in that file instead of sending it to the printer.
3844 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3845 argument IFILENAME is treated as follows: if it's t, prompts for an input
3846 PostScript file name; otherwise, it *must* be a string that it's an input
3847 PostScript file name. The argument OFILENAME is treated as follows: if it's
3848 nil, send the image to the printer. If OFILENAME is a string, save the
3849 PostScript image in a file with that name. If OFILENAME is t, prompts for a
3851 (interactive (pr-interactive-n-up-inout
3852 (if pr-print-using-ghostscript
3855 (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename
3856 (if pr-print-using-ghostscript
3859 (pr-ps-utility-process n-up ifilename outfile)
3861 (pr-ps-file-ps-print outfile)
3862 (pr-delete-file outfile))))
3866 (defun pr-toggle-file-duplex ()
3867 "Toggle duplex for PostScript file."
3869 (pr-toggle 'pr-file-duplex "PS file duplex" nil 7 5 nil
3870 '("PostScript Print" "File")))
3874 (defun pr-toggle-file-tumble ()
3875 "Toggle tumble for PostScript file.
3877 If tumble is off, produces a printing suitable for binding on the left or
3879 If tumble is on, produces a printing suitable for binding at the top or
3882 (pr-toggle 'pr-file-tumble "PS file tumble" nil 8 5 nil
3883 '("PostScript Print" "File")))
3887 (defun pr-toggle-file-landscape ()
3888 "Toggle landscape for PostScript file."
3890 (pr-toggle 'pr-file-landscape "PS file landscape" nil 6 5 nil
3891 '("PostScript Print" "File")))
3895 (defun pr-toggle-ghostscript ()
3896 "Toggle printing using ghostscript."
3898 (pr-toggle 'pr-print-using-ghostscript "Printing using ghostscript"
3899 'postscript-process 2 12 'toggle))
3903 (defun pr-toggle-faces ()
3904 "Toggle printing with faces."
3906 (pr-toggle 'pr-faces-p "Printing with-faces"
3907 'postscript-process 1 12 'toggle))
3911 (defun pr-toggle-spool ()
3914 (pr-toggle 'pr-spool-p "Spooling printing"
3915 'postscript-process 0 12 'toggle))
3919 (defun pr-toggle-duplex ()
3922 (pr-toggle 'ps-spool-duplex "Printing duplex"
3923 'postcsript-options 5 12 'toggle))
3927 (defun pr-toggle-tumble ()
3930 If tumble is off, produces a printing suitable for binding on the left or
3932 If tumble is on, produces a printing suitable for binding at the top or
3935 (pr-toggle 'ps-spool-tumble "Tumble"
3936 'postscript-options 6 12 'toggle))
3940 (defun pr-toggle-landscape ()
3943 (pr-toggle 'ps-landscape-mode "Landscape"
3944 'postscript-options 0 12 'toggle))
3948 (defun pr-toggle-upside-down ()
3949 "Toggle upside-down."
3951 (pr-toggle 'ps-print-upside-down "Upside-Down"
3952 'postscript-options 7 12 'toggle))
3956 (defun pr-toggle-line ()
3957 "Toggle line number."
3959 (pr-toggle 'ps-line-number "Line number"
3960 'postscript-options 3 12 'toggle))
3964 (defun pr-toggle-zebra ()
3965 "Toggle zebra stripes."
3967 (pr-toggle 'ps-zebra-stripes "Zebra stripe"
3968 'postscript-options 4 12 'toggle))
3972 (defun pr-toggle-header ()
3973 "Toggle printing header."
3975 (pr-toggle 'ps-print-header "Print header"
3976 'postscript-options 1 12 'toggle))
3980 (defun pr-toggle-header-frame ()
3981 "Toggle printing header frame."
3983 (pr-toggle 'ps-print-header-frame "Print header frame"
3984 'postscript-options 2 12 'toggle))
3988 (defun pr-toggle-lock ()
3991 (pr-toggle 'pr-menu-lock "Menu lock"
3992 'printing 2 12 'toggle))
3996 (defun pr-toggle-region ()
3997 "Toggle auto region."
3999 (pr-toggle 'pr-auto-region "Auto region"
4000 'printing 0 12 'toggle))
4004 (defun pr-toggle-mode ()
4007 (pr-toggle 'pr-auto-mode "Auto mode"
4008 'printing 1 12 'toggle))
4012 (defun pr-customize (&rest ignore)
4013 "Customization of `printing' group."
4015 (customize-group 'printing))
4019 (defun lpr-customize (&rest ignore)
4020 "Customization of `lpr' group."
4022 (customize-group 'lpr))
4026 (defun pr-help (&rest ignore)
4027 "Help for printing package."
4029 (pr-show-setup pr-help-message "*Printing Help*"))
4033 (defun pr-ps-name ()
4034 "Select interactively a PostScript printer."
4036 (pr-menu-set-ps-title
4037 (pr-complete-alist "PostScript printer" pr-ps-printer-alist pr-ps-name)))
4041 (defun pr-txt-name ()
4042 "Select interactively a text printer."
4044 (pr-menu-set-txt-title
4045 (pr-complete-alist "Text printer" pr-txt-printer-alist pr-txt-name)))
4049 (defun pr-ps-utility ()
4050 "Select interactively a PostScript utility."
4052 (pr-menu-set-utility-title
4053 (pr-complete-alist "Postscript utility" pr-ps-utility-alist pr-ps-utility)))
4057 (defun pr-show-ps-setup (&rest ignore)
4058 "Show current ps-print settings."
4060 (pr-show-setup (ps-setup) "*PS Setup*"))
4064 (defun pr-show-pr-setup (&rest ignore)
4065 "Show current printing settings."
4067 (pr-show-setup (pr-setup) "*PR Setup*"))
4071 (defun pr-show-lpr-setup (&rest ignore)
4072 "Show current lpr settings."
4074 (pr-show-setup (lpr-setup) "*LPR Setup*"))
4077 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4082 (defun pr-ps-fast-fire (n-up &optional select)
4083 "Fast fire function for PostScript printing.
4085 If a region is active, the region will be printed instead of the whole buffer.
4086 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4087 `pr-mode-alist' will be used, that is, the current buffer or region will be
4088 printed using `pr-ps-mode-ps-print'.
4091 Interactively, you have the following situations:
4093 M-x pr-ps-fast-fire RET
4094 The command prompts the user for a N-UP value and printing will
4095 immediatelly be done using the current active printer.
4097 C-u M-x pr-ps-fast-fire RET
4098 C-u 0 M-x pr-ps-fast-fire RET
4099 The command prompts the user for a N-UP value and also for a current
4100 PostScript printer, then printing will immediatelly be done using the new
4101 current active printer.
4103 C-u 1 M-x pr-ps-fast-fire RET
4104 The command prompts the user for a N-UP value and also for a file name,
4105 and saves the PostScript image in that file instead of sending it to the
4108 C-u 2 M-x pr-ps-fast-fire RET
4109 The command prompts the user for a N-UP value, then for a current
4110 PostScript printer and, finally, for a file name. Then change the active
4111 printer to that choosen by user and saves the PostScript image in
4112 that file instead of sending it to the printer.
4115 Noninteractively, the argument N-UP should be a positive integer greater than
4116 zero and the argument SELECT is treated as follows:
4118 If it's nil, send the image to the printer.
4120 If it's a list or an integer lesser or equal to zero, the command prompts
4121 the user for a current PostScript printer, then printing will immediatelly
4122 be done using the new current active printer.
4124 If it's an integer equal to 1, the command prompts the user for a file name
4125 and saves the PostScript image in that file instead of sending it to the
4128 If it's an integer greater or equal to 2, the command prompts the user for a
4129 current PostScript printer and for a file name. Then change the active
4130 printer to that choosen by user and saves the PostScript image in that file
4131 instead of sending it to the printer.
4133 If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new
4134 active printer and printing will immediatelly be done using the new active
4137 Otherwise, send the image to the printer.
4140 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4142 (interactive (list (pr-interactive-n-up (pr-prompt-gs "PS print fast"))
4143 current-prefix-arg))
4144 (let ((pr-auto-region t)
4147 (cond ((null select))
4150 ((and (symbolp select)
4151 (assq select pr-ps-printer-alist))
4152 (pr-menu-set-ps-title select))
4156 (and (>= select 1) (not pr-spool-p)
4157 (setq filename (pr-ps-outfile-preprint
4158 (if pr-print-using-ghostscript
4161 (pr-ps-buffer-ps-print
4163 (min (max n-up 1) 100)
4164 (error "n-up must be an integer greater than zero."))
4169 (defun pr-txt-fast-fire (&optional select-printer)
4170 "Fast fire function for text printing.
4172 If a region is active, the region will be printed instead of the whole buffer.
4173 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4174 `pr-mode-alist' will be used, that is, the current buffer or region will be
4175 printed using `pr-txt-mode'.
4177 Interactively, when you use a prefix argument (C-u), the command prompts the
4178 user for a new active text printer.
4180 Noninteractively, the argument SELECT-PRINTER is treated as follows:
4182 If it's nil, the printing is sent to the current active text printer.
4184 If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new
4185 active printer and printing will immediatelly be done using the new active
4188 If it's non-nil, the command prompts the user for a new active text printer.
4190 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4192 (interactive (list current-prefix-arg))
4193 (cond ((null select-printer))
4194 ((and (symbolp select-printer)
4195 (assq select-printer pr-txt-printer-alist))
4196 (pr-menu-set-txt-title select-printer))
4199 (let ((pr-auto-region t)
4204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4209 "Return the current `printing' setup.
4211 This is *not* an interactive command.
4212 One way to see `printing' setup is to switch to a *Scratch* buffer and type:
4214 M-: (insert (pr-setup)) RET
4216 Or choose the menu option Printing/Show Settings/printing."
4217 (let (ps-prefix-quote)
4221 (concat "\n;;; printing.el version " pr-version "\n")
4222 '(19 . pr-shell-file-name)
4223 '(19 . pr-path-style)
4224 '(19 . pr-path-alist)
4227 '(21 . pr-txt-printer-alist)
4230 '(20 . pr-ps-printer-alist)
4233 '(20 . pr-ps-temp-file)
4234 '(20 . pr-delete-temp-file)
4235 '(20 . pr-list-directory)
4237 '(17 . pr-gv-command)
4238 '(17 . pr-gs-command)
4239 '(17 . pr-gs-switches)
4240 '(17 . pr-gs-device)
4241 '(17 . pr-gs-resolution)
4243 '(27 . pr-print-using-ghostscript)
4246 '(27 . pr-file-landscape)
4247 '(27 . pr-file-duplex)
4248 '(27 . pr-file-tumble)
4249 '(27 . pr-auto-region)
4250 '(27 . pr-auto-mode)
4252 '(20 . pr-ps-utility)
4253 '(20 . pr-ps-utility-alist)
4255 '(14 . pr-mode-alist)
4257 '(20 . pr-menu-lock)
4258 '(20 . pr-menu-char-height)
4259 '(20 . pr-menu-char-width)
4261 '(20 . pr-setting-database)
4263 '(22 . pr-visible-entry-list)
4265 '(22 . pr-buffer-verbose)
4266 '(22 . pr-buffer-name)
4267 '(22 . pr-buffer-name-ignore)
4268 ")\n\n;;; printing.el - end of settings\n")
4273 "Return the current `lpr' setup.
4275 This is *not* an interactive command.
4276 One way to see `lpr' setup is to switch to a *Scratch* buffer and type:
4278 M-: (insert (lpr-setup)) RET
4280 Or choose the menu option Printing/Show Settings/lpr."
4281 (let (ps-prefix-quote)
4284 '("\n;;; lpr.el settings\n"
4287 (25 . lpr-add-switches)
4289 (25 . lpr-headers-switches)
4290 (25 . print-region-function)
4291 (25 . lpr-page-header-program)
4292 (25 . lpr-page-header-switches)
4293 ")\n\n;;; lpr.el - end of settings\n")
4297 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4298 ;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>)
4301 (defalias 'pr-mh-get-msg-num 'mh-get-msg-num)
4302 (defalias 'pr-mh-show 'mh-show)
4303 (defalias 'pr-mh-start-of-uncleaned-message 'mh-start-of-uncleaned-message)
4304 (defvar mh-show-buffer nil)
4307 (defun pr-article-date ()
4308 "Find the date of an article or mail message in current buffer.
4309 Return only the dayname, if present, weekday, month, and year."
4311 (goto-char (point-min))
4312 (if (re-search-forward
4313 "^Date:[ \t]+\\(\\([A-Za-z]+, \\)?[0-9]+ [A-Za-z]+ [0-9]+\\)" nil t)
4314 (buffer-substring (match-beginning 1) (match-end 1))
4315 (format-time-string "%Y/%m/%d"))))
4318 (defun pr-mh-current-message ()
4319 "Go to mh-inbox current message."
4320 (let ((msg (or (pr-mh-get-msg-num nil) 0)))
4322 (set-buffer mh-show-buffer)
4323 (goto-char (point-min))
4324 (pr-mh-start-of-uncleaned-message)
4325 (message "Printing message %d" msg)))
4328 (defun pr-mh-print-1 (n-up filename header-list)
4329 "Print mh-inbox current message in PostScript."
4331 (save-window-excursion
4332 (pr-mh-current-message)
4333 (pr-mode-print n-up filename header-list (point)))))
4336 (defun pr-mh-lpr-1 (header-list)
4337 "Print mh-inbox current message in text printer."
4339 (save-window-excursion
4340 (pr-mh-current-message)
4341 (pr-mode-lpr header-list (point)))))
4344 (defalias 'pr-mh-print-2 'pr-mode-print)
4347 (defalias 'pr-mh-lpr-2 'pr-mode-lpr)
4350 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4351 ;; rmail (hacked from ps-print.el)
4354 (defun pr-rmail-lpr (header-list)
4355 "Print RMAIL current message in text printer."
4356 (pr-lpr-message-from-summary header-list
4357 'rmail-buffer 'rmail-summary-buffer))
4360 (defun pr-rmail-print (n-up filename header-list)
4361 "Print RMAIL current message in PostScript."
4362 (pr-ps-message-from-summary n-up filename header-list
4363 'rmail-buffer 'rmail-summary-buffer))
4366 (defun pr-ps-message-from-summary (n-up filename header-list
4367 summary-buffer summary-default)
4368 "Print current message in PostScript."
4369 (let ((buf (or (and (boundp summary-buffer)
4370 (symbol-value summary-buffer))
4371 (symbol-value summary-default))))
4372 (and (get-buffer buf)
4375 (pr-mode-print n-up filename header-list)))))
4378 (defun pr-lpr-message-from-summary (header-list summary-buffer summary-default)
4379 "Print current message in text printer."
4380 (let ((buf (or (and (boundp summary-buffer)
4381 (symbol-value summary-buffer))
4382 (symbol-value summary-default))))
4383 (and (get-buffer buf)
4386 (pr-mode-lpr header-list)))))
4389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4390 ;; gnus (hacked from ps-print.el)
4393 (defvar pr-gnus-article "*Article*")
4396 (defun pr-gnus-print (n-up filename header-list)
4397 "Print *Article* current message in PostScript."
4398 (pr-ps-message-from-summary n-up filename header-list
4399 'gnus-article-buffer 'pr-gnus-article))
4402 (defun pr-gnus-lpr (header-list)
4403 "Print *Article* current message in text printer."
4404 (pr-lpr-message-from-summary header-list
4405 'gnus-article-buffer 'pr-gnus-article))
4408 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4409 ;; vm (hacked from ps-print.el)
4412 (defvar pr-vm-summary "")
4415 (defun pr-vm-print (n-up filename header-list)
4416 "Print current vm message in PostScript."
4417 (pr-ps-message-from-summary n-up filename header-list
4418 'vm-mail-buffer 'pr-vm-summary))
4421 (defun pr-vm-lpr (header-list)
4422 "Print current vm message in text printer."
4423 (pr-lpr-message-from-summary header-list
4424 'vm-mail-buffer 'pr-vm-summary))
4427 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4431 (defun pr-ps-mode (n-up filename)
4432 "If current major mode is declared, print it in PostScript."
4433 (let ((args (pr-mode-alist-p)))
4435 (let ((fun (cdr args)))
4436 (funcall (car fun) n-up filename (cdr fun))
4439 (message "`%s' major mode not declared." major-mode)
4443 (defmacro pr-local-variable (header-list &rest body)
4445 (let ((ps-header-lines (or (nth 0 ,header-list) ps-header-lines))
4446 (ps-left-header (or (nth 1 ,header-list) ps-left-header))
4447 (ps-right-header (or (nth 2 ,header-list) ps-right-header))
4449 (let ((local-var-list (pr-eval-local-alist (nthcdr 4 ,header-list))))
4451 (and (nth 3 ,header-list)
4452 (pr-kill-local-variable local-var-list))))))
4455 (defun pr-mode-print (n-up filename header-list &optional from to)
4456 "Print current major mode in PostScript."
4459 (let ((file (pr-ps-file filename))
4461 ((pr-region-active-p) (region-beginning))
4464 (pr-text2ps (pr-region-active-symbol start) n-up file start
4466 ((pr-region-active-p) (region-end))
4469 (unless (or pr-spool-p filename)
4470 (pr-ps-file-print file)
4471 (pr-delete-file file)))))
4474 (defun pr-mode-lpr (header-list &optional from to)
4475 "Print current major mode in text printer."
4478 (pr-txt-print (cond (from)
4479 ((pr-region-active-p) (region-beginning))
4482 ((pr-region-active-p) (region-end))
4486 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4490 (defconst pr-menu-entry-alist
4493 (postscript-options . 9)
4494 (postscript-process . 3)
4498 "Alist that associates menu part with number of items per part.
4500 It's used by `pr-menu-index'.
4502 Each element has the form:
4504 (MENU-PART . NUMBER-OF-ITEMS)
4506 See `pr-visible-entry-alist'.")
4509 (defun pr-menu-index (entry index)
4511 (cond ((eq entry 'text)
4513 ((eq entry 'postscript-options)
4515 ((eq entry 'postscript-process)
4516 '(postscript text postscript-options))
4517 ((eq entry 'printing)
4518 '(postscript text postscript-options postscript-process))
4524 (setq key (car base-list)
4525 base-list (cdr base-list))
4526 (and (pr-visible-p key)
4527 (setq index (+ index
4528 (cdr (assq key pr-menu-entry-alist)))))))
4534 ((eq ps-print-emacs-type 'xemacs)
4536 (defun pr-menu-position (entry index horizontal)
4540 'x (- (pr-x-event-x-pixel current-mouse-event) ; X
4541 (* horizontal pr-menu-char-width))
4542 'y (- (pr-x-event-y-pixel current-mouse-event) ; Y
4543 (* (pr-menu-index entry index) pr-menu-char-height)))))
4546 ;; GNU Emacs for Windows 9x/NT
4547 (defun pr-menu-position (entry index horizontal)
4548 (let ((pos (cdr (pr-e-mouse-pixel-position))))
4552 (* (pr-menu-index entry index) pr-menu-char-height)))
4553 (selected-frame)))) ; frame
4557 (defun pr-menu-position (entry index horizontal)
4558 (let ((pos (cdr (pr-e-mouse-pixel-position))))
4560 (list (- (car pos) ; X
4561 (* horizontal pr-menu-char-width))
4563 (* (pr-menu-index entry index) pr-menu-char-height)))
4564 (selected-frame)))) ; frame
4568 (defvar pr-menu-position nil)
4569 (defvar pr-menu-state nil)
4573 ((eq ps-print-emacs-type 'emacs)
4575 (defun pr-menu-lock (entry index horizontal state path)
4576 (when (and (not (interactive-p)) pr-menu-lock)
4577 (or (and pr-menu-position (eq state pr-menu-state))
4578 (setq pr-menu-position (pr-menu-position entry index horizontal)
4579 pr-menu-state state))
4580 (let* ((menu (pr-menu-lookup path))
4581 (result (x-popup-menu pr-menu-position menu)))
4583 (let ((command (lookup-key menu (vconcat result))))
4584 (if (fboundp command)
4587 (setq pr-menu-position nil)))
4590 (defun pr-menu-lookup (path)
4591 (let ((ipath pr-menu-bar))
4592 (lookup-key global-map
4595 (mapcar 'pr-get-symbol
4602 ((eq ps-print-emacs-type 'xemacs)
4604 (defun pr-menu-lock (entry index horizontal state path)
4605 (when (and (not (interactive-p)) pr-menu-lock)
4606 (or (and pr-menu-position (eq state pr-menu-state))
4607 (setq pr-menu-position (pr-menu-position entry index horizontal)
4608 pr-menu-state state))
4609 (let* ((menu (pr-menu-lookup path))
4610 (result (pr-x-get-popup-menu-response menu pr-menu-position)))
4611 (and (pr-x-misc-user-event-p result)
4612 (funcall (pr-x-event-function result)
4613 (pr-x-event-object result))))
4614 (setq pr-menu-position nil)))
4617 (defun pr-menu-lookup (path)
4618 (car (pr-x-find-menu-item current-menubar (cons "Printing" path))))))
4621 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4622 ;; Printer & Utility Selection
4625 (defun pr-update-var (var-sym alist)
4626 (or (assq (symbol-value var-sym) alist)
4627 (set var-sym (car (car alist)))))
4630 (defun pr-update-menus (&optional force)
4631 "Update utility, PostScript and text printer menus.
4633 If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist',
4634 `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not;
4635 otherwise, update PostScript printer menu iff `pr-ps-printer-menu-modified' is
4636 non-nil, update text printer menu iff `pr-txt-printer-menu-modified' is
4637 non-nil, and update PostScript File menus iff `pr-ps-utility-menu-modified' is
4640 (pr-update-var 'pr-ps-name pr-ps-printer-alist)
4641 (pr-update-var 'pr-txt-name pr-txt-printer-alist)
4642 (pr-update-var 'pr-ps-utility pr-ps-utility-alist)
4643 (pr-do-update-menus force))
4646 (defvar pr-ps-printer-menu-modified t
4647 "Non-nil means `pr-ps-printer-alist' was modified and need to update menu.")
4648 (defvar pr-txt-printer-menu-modified t
4649 "Non-nil means `pr-txt-printer-alist' was modified and need to update menu.")
4650 (defvar pr-ps-utility-menu-modified t
4651 "Non-nil means `pr-ps-utility-alist' was modified and need to update menu.")
4654 (defconst pr-even-or-odd-alist
4655 '((nil . "Print All Pages")
4656 (even-page . "Print Even Pages")
4657 (odd-page . "Print Odd Pages")
4658 (even-sheet . "Print Even Sheets")
4659 (odd-sheet . "Print Odd Sheets")))
4662 (defun pr-menu-create (name alist var-sym fun entry index)
4666 (let ((sym (car elt)))
4669 (list fun (list 'quote sym) nil (list 'quote entry) index)
4671 :selected (list 'eq var-sym (list 'quote sym)))))
4677 ((eq ps-print-emacs-type 'emacs)
4679 (defalias 'pr-update-mode-line 'force-mode-line-update)
4682 (defun pr-do-update-menus (&optional force)
4683 (pr-menu-alist pr-ps-printer-alist
4685 'pr-menu-set-ps-title
4686 "PostScript Printers"
4687 'pr-ps-printer-menu-modified
4689 "PostScript Printers"
4691 (pr-menu-alist pr-txt-printer-alist
4693 'pr-menu-set-txt-title
4695 'pr-txt-printer-menu-modified
4699 (let ((save-var pr-ps-utility-menu-modified))
4700 (pr-menu-alist pr-ps-utility-alist
4702 'pr-menu-set-utility-title
4703 '("PostScript Print" "File" "PostScript Utility")
4706 "PostScript Utility"
4708 (pr-menu-alist pr-ps-utility-alist
4710 'pr-menu-set-utility-title
4711 '("PostScript Preview" "File" "PostScript Utility")
4712 'pr-ps-utility-menu-modified
4714 "PostScript Utility"
4716 (pr-even-or-odd-pages ps-even-or-odd-pages force))
4719 (defvar pr-temp-menu nil)
4722 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
4724 (when (and alist (or force (symbol-value modified-sym)))
4725 (easy-menu-define pr-temp-menu nil ""
4726 (pr-menu-create name alist var-sym fun entry index))
4727 (let ((item (pr-menu-get-item menu-path)))
4729 (let* ((binding (nthcdr 3 item))
4730 (key-binding (cdr binding)))
4731 (setcar binding pr-temp-menu)
4732 (and key-binding (listp (car key-binding))
4733 (setcdr binding (cdr key-binding))) ; skip KEY-BINDING
4734 (funcall fun (symbol-value var-sym) item))))
4735 (set modified-sym nil)))
4738 (defun pr-menu-set-ps-title (value &optional item entry index)
4739 (pr-menu-set-item-name (or item
4740 (pr-menu-get-item "PostScript Printers"))
4741 (format "PostScript Printer: %s" value))
4742 (pr-ps-set-printer value)
4744 (pr-menu-lock entry index 12 'toggle nil)))
4747 (defun pr-menu-set-txt-title (value &optional item entry index)
4748 (pr-menu-set-item-name (or item
4749 (pr-menu-get-item "Text Printers"))
4750 (format "Text Printer: %s" value))
4751 (pr-txt-set-printer value)
4753 (pr-menu-lock entry index 12 'toggle nil)))
4756 (defun pr-menu-set-utility-title (value &optional item entry index)
4757 (let ((name (symbol-name value)))
4759 (pr-menu-set-item-name item name)
4760 (pr-menu-set-item-name
4762 '("PostScript Print" "File" "PostScript Utility"))
4764 (pr-menu-set-item-name
4766 '("PostScript Preview" "File" "PostScript Utility"))
4768 (pr-ps-set-utility value)
4770 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
4773 (defun pr-even-or-odd-pages (value &optional no-lock)
4774 (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
4775 (cdr (assq value pr-even-or-odd-alist)))
4776 (setq ps-even-or-odd-pages value)
4778 (pr-menu-lock 'postscript-options 8 12 'toggle nil))))
4781 ((eq ps-print-emacs-type 'xemacs)
4783 (defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
4786 (defvar pr-ps-name-old "PostScript Printers")
4787 (defvar pr-txt-name-old "Text Printers")
4788 (defvar pr-ps-utility-old "PostScript Utility")
4789 (defvar pr-even-or-odd-old "Print All Pages")
4792 (defun pr-do-update-menus (&optional force)
4793 (pr-menu-alist pr-ps-printer-alist
4795 'pr-menu-set-ps-title
4797 'pr-ps-printer-menu-modified
4801 (pr-menu-alist pr-txt-printer-alist
4803 'pr-menu-set-txt-title
4805 'pr-txt-printer-menu-modified
4809 (let ((save-var pr-ps-utility-menu-modified))
4810 (pr-menu-alist pr-ps-utility-alist
4812 'pr-menu-set-utility-title
4813 '("Printing" "PostScript Print" "File")
4818 (pr-menu-alist pr-ps-utility-alist
4820 'pr-menu-set-utility-title
4821 '("Printing" "PostScript Preview" "File")
4822 'pr-ps-utility-menu-modified
4826 (pr-even-or-odd-pages ps-even-or-odd-pages force))
4829 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
4831 (when (and alist (or force (symbol-value modified-sym)))
4832 (pr-xemacs-global-menubar
4833 (pr-x-add-submenu menu-path
4834 (pr-menu-create name alist var-sym
4836 (funcall fun (symbol-value var-sym))
4837 (set modified-sym nil)))
4840 (defun pr-menu-set-ps-title (value &optional item entry index)
4841 (pr-relabel-menu-item (format "PostScript Printer: %s" value)
4843 (pr-ps-set-printer value)
4845 (pr-menu-lock entry index 12 'toggle nil)))
4848 (defun pr-menu-set-txt-title (value &optional item entry index)
4849 (pr-relabel-menu-item (format "Text Printer: %s" value)
4851 (pr-txt-set-printer value)
4853 (pr-menu-lock entry index 12 'toggle nil)))
4856 (defun pr-menu-set-utility-title (value &optional item entry index)
4857 (pr-xemacs-global-menubar
4858 (let ((newname (format "%s" value)))
4859 (pr-x-relabel-menu-item
4860 (list "Printing" "PostScript Print" "File" pr-ps-utility-old)
4862 (pr-x-relabel-menu-item
4863 (list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
4865 (setq pr-ps-utility-old newname)))
4866 (pr-ps-set-utility value)
4868 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
4871 (defun pr-even-or-odd-pages (value &optional no-lock)
4872 (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
4873 'pr-even-or-odd-old)
4874 (setq ps-even-or-odd-pages value)
4876 (pr-menu-lock 'postscript-options 8 12 'toggle nil))))))
4879 (defun pr-relabel-menu-item (newname var-sym)
4880 (pr-xemacs-global-menubar
4881 (pr-x-relabel-menu-item
4882 (list "Printing" (symbol-value var-sym))
4884 (set var-sym newname)))
4887 (defun pr-menu-set-item-name (item name)
4889 (setcar (nthcdr 2 item) name))) ; ITEM-NAME
4892 (defun pr-menu-get-item (name-list)
4893 ;; NAME-LIST is a string or a list of strings.
4894 (let ((ipath pr-menu-bar)
4895 (len (and (listp name-list) (length name-list))))
4897 (setq name-list (car name-list)))
4903 ;; list and (length list) > 1
4904 (let* ((copy (copy-sequence name-list))
4905 (name (pr-get-symbol (nth (1- len) copy)))
4907 (setcdr (nthcdr (- len 2) copy) nil)
4913 (mapcar 'pr-get-symbol path))
4915 (assq name (nthcdr 2 menu))))
4918 (let ((name (pr-get-symbol name-list))
4919 (menu (lookup-key global-map ipath)))
4920 (assq name (nthcdr 2 menu)))))))
4923 (defun pr-ps-set-utility (value)
4924 (let ((item (cdr (assq value pr-ps-utility-alist))))
4927 "Invalid PostScript utility name `%s' for variable `pr-ps-utility'."
4929 (setq pr-ps-utility value)
4930 (pr-eval-alist (nthcdr 9 item)))
4931 (pr-update-mode-line))
4934 (defun pr-ps-set-printer (value)
4935 (let ((ps (cdr (assq value pr-ps-printer-alist))))
4938 "Invalid PostScript printer name `%s' for variable `pr-ps-name'."
4940 (setq pr-ps-name value
4941 pr-ps-command (pr-dosify-path (nth 0 ps))
4942 pr-ps-switches (nth 1 ps)
4943 pr-ps-printer-switch (nth 2 ps)
4944 pr-ps-printer (pr-dosify-path (nth 3 ps)))
4945 (or (stringp pr-ps-command)
4947 (cond (ps-windows-system "print")
4951 (or (stringp pr-ps-printer-switch)
4952 (setq pr-ps-printer-switch
4953 (cond (ps-windows-system "/D:")
4957 (pr-eval-alist (nthcdr 4 ps)))
4958 (pr-update-mode-line))
4961 (defun pr-txt-set-printer (value)
4962 (let ((txt (cdr (assq value pr-txt-printer-alist))))
4964 (error "Invalid text printer name `%s' for variable `pr-txt-name'."
4966 (setq pr-txt-name value
4967 pr-txt-command (pr-dosify-path (nth 0 txt))
4968 pr-txt-switches (nth 1 txt)
4969 pr-txt-printer (pr-dosify-path (nth 2 txt))))
4970 (or (stringp pr-txt-command)
4971 (setq pr-txt-command
4972 (cond (ps-windows-system "print")
4976 (pr-update-mode-line))
4979 (defun pr-eval-alist (alist)
4980 (mapcar #'(lambda (option)
4981 (let ((var-sym (car option))
4982 (value (cdr option)))
4983 (if (eq var-sym 'inherits-from:)
4984 (pr-eval-setting-alist value 'global)
4985 (set var-sym (eval value)))))
4989 (defun pr-eval-local-alist (alist)
4991 (mapcar #'(lambda (option)
4992 (let ((var-sym (car option))
4993 (value (cdr option)))
4995 (if (eq var-sym 'inherits-from:)
4996 (nconc (pr-eval-setting-alist value) local-list)
4997 (set (make-local-variable var-sym) (eval value))
4998 (cons var-sym local-list)))))
5003 (defun pr-eval-setting-alist (key &optional global old)
5004 (let ((setting (cdr (assq key pr-setting-database))))
5006 (let ((inherits (nth 0 setting))
5007 (local (nth 1 setting))
5008 (kill (nth 2 setting))
5013 (message "There are local buffer settings for `%S'." key)
5016 (if (memq inherits old)
5017 (error "Circular inheritance for `%S'." inherits)
5019 (pr-eval-setting-alist inherits global
5020 (cons inherits old)))))
5022 (cond ((not local) ; global settings
5024 (let ((var-sym (car option)))
5025 (or (eq var-sym 'inherits-from:)
5026 (set var-sym (eval (cdr option)))))))
5027 (kill ; local settings with killing
5029 (let ((var-sym (car option)))
5030 (unless (eq var-sym 'inherits-from:)
5031 (setq local-list (cons var-sym local-list))
5032 (set (make-local-variable var-sym)
5033 (eval (cdr option)))))))
5034 (t ; local settings without killing
5036 (let ((var-sym (car option)))
5037 (or (eq var-sym 'inherits-from:)
5038 (set (make-local-variable var-sym)
5039 (eval (cdr option))))))))
5044 (defun pr-kill-local-variable (local-var-list)
5045 (mapcar 'kill-local-variable local-var-list))
5048 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5049 ;; Internal Functions (II)
5052 (defun pr-prompt (str)
5053 (if (pr-auto-mode-p)
5054 (concat str " mode")
5055 (pr-region-active-string str)))
5058 (defun pr-prompt-region (str)
5059 (concat str (if (pr-auto-mode-p)
5064 (defun pr-prompt-gs (str)
5065 (if (pr-using-ghostscript-p)
5070 (defun pr-region-active-symbol (&optional region-p)
5071 (if (or region-p (pr-region-active-p))
5076 (defun pr-region-active-string (prefix)
5078 (if (pr-region-active-p)
5083 (defun pr-show-setup (settings buffer-name)
5084 (with-output-to-temp-buffer buffer-name
5086 (print-help-return-message)))
5089 (defun pr-complete-alist (prompt alist default)
5090 (let ((collection (mapcar #'(lambda (elt)
5091 (setq elt (car elt))
5092 (cons (symbol-name elt) elt))
5094 (cdr (assoc (completing-read (concat prompt ": ")
5096 (symbol-name default) nil
5097 (symbol-name default))
5101 (defun pr-delete-file (file)
5102 (and pr-delete-temp-file (delete-file file)))
5105 (defun pr-expand-file-name (filename)
5106 (pr-dosify-path (expand-file-name filename)))
5109 (defun pr-ps-outfile-preprint (&optional mess)
5110 (let* ((prompt (format "%soutput PostScript file name: " (or mess "")))
5111 (res (read-file-name prompt default-directory "" nil)))
5112 (while (cond ((not (file-writable-p res))
5114 (setq prompt "is unwritable"))
5115 ((file-directory-p res)
5117 (setq prompt "is a directory"))
5118 ((file-exists-p res)
5120 (setq prompt "exists")
5121 (not (y-or-n-p (format "File `%s' exists; overwrite? "
5124 (setq res (read-file-name
5125 (format "File %s; PostScript file: " prompt)
5126 (file-name-directory res) nil nil
5127 (file-name-nondirectory res))))
5128 (pr-expand-file-name res)))
5131 (defun pr-ps-infile-preprint (&optional mess)
5132 (let* ((prompt (format "%sinput PostScript file name: " (or mess "")))
5133 (res (read-file-name prompt default-directory "" nil)))
5134 (while (cond ((not (file-exists-p res))
5136 (setq prompt "doesn't exist"))
5137 ((not (file-readable-p res))
5139 (setq prompt "is unreadable"))
5140 ((file-directory-p res)
5142 (setq prompt "is a directory"))
5144 (setq res (read-file-name
5145 (format "File %s; PostScript file: " prompt)
5146 (file-name-directory res) nil nil
5147 (file-name-nondirectory res))))
5148 (pr-expand-file-name res)))
5151 (defun pr-toggle (var-sym mess entry index horizontal state &optional path)
5152 (set var-sym (not (symbol-value var-sym)))
5153 (message "%s is %s" mess (if (symbol-value var-sym) "on" "off"))
5154 (pr-menu-lock entry index horizontal state path))
5157 (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt)
5159 (or (symbol-value n-up-sym)
5160 (set n-up-sym (pr-interactive-n-up prompt)))
5161 (and (eq (symbol-value infile-sym) t)
5162 (set infile-sym (and (not (interactive-p))
5163 (pr-ps-infile-preprint prompt))))
5165 (or (symbol-value infile-sym)
5166 (error "%s: input PostScript file name is missing" prompt))
5167 (set infile-sym (pr-dosify-path (symbol-value infile-sym)))
5169 (and (eq (symbol-value outfile-sym) t)
5170 (set outfile-sym (and (not (interactive-p))
5172 (pr-ps-outfile-preprint prompt))))
5173 (and (symbol-value outfile-sym)
5174 (set outfile-sym (pr-dosify-path (symbol-value outfile-sym))))
5175 (pr-ps-file (symbol-value outfile-sym)))
5178 (defun pr-ps-utility-process (n-up infile outfile)
5180 (and (stringp infile) (file-exists-p infile)
5181 (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist)))
5183 (concat (pr-command (nth 0 item)) " "
5184 (pr-switches-string (nth 1 item)
5185 "pr-ps-utility-alist entry")
5187 (pr-switches-string (nth 8 item)
5188 "pr-ps-utility-alist entry")
5191 (format (nth 2 item) ps-paper-type))
5192 " " (format (nth 3 item) n-up) " "
5193 (and pr-file-landscape (nth 4 item)) " "
5194 (and pr-file-duplex (nth 5 item)) " "
5195 (and pr-file-tumble (nth 6 item))
5196 " \"" (pr-expand-file-name infile) "\" "
5198 " \"" (pr-expand-file-name outfile) "\"")))))
5201 (defun pr-shell-command (command)
5202 (let ((shell-file-name pr-shell-file-name))
5203 (shell-command command)))
5206 (defun pr-txt-print (from to)
5207 (let ((lpr-command (pr-command pr-txt-command))
5208 (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches"))
5209 (printer-name pr-txt-printer))
5210 (lpr-region from to)))
5213 (defun pr-switches-string (switches mess)
5214 (mapconcat 'identity (pr-switches switches mess) " "))
5217 (defun pr-switches (switches mess)
5218 (or (listp switches)
5219 (error "%S should have a list of strings." mess))
5220 (ps-flatten-list ; dynamic evaluation
5221 (mapcar 'ps-eval-switch switches)))
5224 (defun pr-ps-preview (kind n-up filename mess)
5225 (pr-set-n-up-and-filename 'n-up 'filename mess)
5226 (let ((file (pr-ps-file filename)))
5227 (pr-text2ps kind n-up file)
5228 (or pr-spool-p (pr-ps-file-preview file))))
5231 (defun pr-ps-using-ghostscript (kind n-up filename mess)
5232 (pr-set-n-up-and-filename 'n-up 'filename mess)
5233 (let ((file (pr-ps-file filename)))
5234 (pr-text2ps kind n-up file)
5235 (unless (or pr-spool-p filename)
5236 (pr-ps-file-using-ghostscript file)
5237 (pr-delete-file file))))
5240 (defun pr-ps-print (kind n-up filename mess)
5241 (pr-set-n-up-and-filename 'n-up 'filename mess)
5242 (let ((file (pr-ps-file filename)))
5243 (pr-text2ps kind n-up file)
5244 (unless (or pr-spool-p filename)
5245 (pr-ps-file-print file)
5246 (pr-delete-file file))))
5249 (defun pr-ps-file (&optional filename)
5250 (pr-dosify-path (or filename
5251 (convert-standard-filename
5252 (expand-file-name pr-ps-temp-file pr-temp-dir)))))
5255 (defun pr-interactive-n-up (mess)
5256 (or (stringp mess) (setq mess "*"))
5258 (let* ((fmt-prompt "%s[%s] N-up printing: (default 1) ")
5260 (str (pr-f-read-string (format fmt-prompt prompt mess) "1" nil "1"))
5262 (while (if (string-match "^\\s *[0-9]+$" str)
5263 (setq int (string-to-int str)
5264 prompt (cond ((< int 1) "Integer below 1; ")
5265 ((> int 100) "Integer above 100; ")
5267 (setq prompt "Invalid integer syntax; "))
5270 (pr-f-read-string (format fmt-prompt prompt mess) str nil "1")))
5274 (defun pr-interactive-dir (mess)
5275 (let* ((dir-name (file-name-directory (or (buffer-file-name)
5276 default-directory)))
5277 (fmt-prompt (concat "%s[" mess "] Directory to print: "))
5278 (dir (read-file-name (format fmt-prompt "")
5279 "" dir-name nil dir-name))
5281 (while (cond ((not (file-directory-p dir))
5283 (setq prompt "It's not a directory! "))
5284 ((not (file-readable-p dir))
5286 (setq prompt "Directory is unreadable! "))
5288 (setq dir-name (file-name-directory dir)
5289 dir (read-file-name (format fmt-prompt prompt)
5290 "" dir-name nil dir-name)))
5291 (file-name-as-directory dir)))
5294 (defun pr-interactive-regexp (mess)
5295 (pr-f-read-string (format "[%s] File regexp to print: " mess) "" nil ""))
5298 (defun pr-interactive-dir-args (mess)
5300 ;; get directory argument
5301 (pr-interactive-dir mess)
5302 ;; get file name regexp
5303 (pr-interactive-regexp mess)))
5306 (defun pr-interactive-ps-dir-args (mess)
5308 ;; get n-up argument
5309 (pr-interactive-n-up mess)
5310 ;; get directory argument
5311 (pr-interactive-dir mess)
5312 ;; get file name regexp
5313 (pr-interactive-regexp mess)
5314 ;; get output file name
5315 (and (not pr-spool-p)
5316 (ps-print-preprint current-prefix-arg))))
5319 (defun pr-interactive-n-up-file (mess)
5321 ;; get n-up argument
5322 (pr-interactive-n-up mess)
5323 ;; get output file name
5324 (and (not pr-spool-p)
5325 (ps-print-preprint current-prefix-arg))))
5328 (defun pr-interactive-n-up-inout (mess)
5330 ;; get n-up argument
5331 (pr-interactive-n-up mess)
5332 ;; get input file name
5333 (pr-ps-infile-preprint (concat mess " "))
5334 ;; get output file name
5335 (ps-print-preprint current-prefix-arg)))
5338 (defun pr-set-outfilename (filename-sym)
5339 (and (not pr-spool-p)
5340 (eq (symbol-value filename-sym) t)
5341 (set filename-sym (and (not (interactive-p))
5343 (ps-print-preprint current-prefix-arg))))
5344 (and (symbol-value filename-sym)
5345 (set filename-sym (pr-dosify-path (symbol-value filename-sym)))))
5348 (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess)
5350 (or (symbol-value n-up-sym)
5351 (set n-up-sym (pr-interactive-n-up mess)))
5353 (pr-set-outfilename filename-sym))
5356 (defun pr-set-dir-args (dir-sym regexp-sym mess)
5358 (or (symbol-value dir-sym)
5359 (set dir-sym (pr-interactive-dir mess)))
5361 (or (symbol-value regexp-sym)
5362 (set regexp-sym (pr-interactive-regexp mess))))
5365 (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess)
5367 (or (symbol-value n-up-sym)
5368 (set n-up-sym (pr-interactive-n-up mess)))
5369 ;; directory & file name regexp
5370 (pr-set-dir-args dir-sym regexp-sym mess)
5372 (pr-set-outfilename filename-sym))
5375 (defun pr-find-buffer-visiting (file)
5376 (if (not (file-directory-p file))
5377 (find-buffer-visiting (if ps-windows-system
5380 (let ((truename (file-truename file))
5381 (blist (buffer-list))
5383 (while (and (not found) blist)
5385 (set-buffer (car blist))
5386 (and (eq major-mode 'dired-mode)
5388 (goto-char (point-min))
5389 (string= (buffer-substring-no-properties
5395 (setq found (car blist))))
5396 (setq blist (cdr blist)))
5400 (defun pr-file-list (dir file-regexp fun)
5401 (mapcar #'(lambda (file)
5402 (and (or pr-list-directory
5403 (not (file-directory-p file)))
5404 (let ((buffer (pr-find-buffer-visiting file))
5408 (file-readable-p file))
5410 (set-buffer (or buffer
5411 (find-file-noselect file)))
5414 (kill-buffer (current-buffer))))))))
5415 (directory-files dir t file-regexp)))
5418 (defun pr-delete-file-if-exists (filename)
5419 (and (not pr-spool-p) (stringp filename) (file-exists-p filename)
5420 (delete-file filename)))
5423 (defun pr-ps-file-list (n-up dir file-regexp filename)
5424 (pr-delete-file-if-exists (setq filename (pr-expand-file-name filename)))
5425 (let ((pr-spool-p t))
5426 (pr-file-list dir file-regexp
5428 (if (pr-auto-mode-p)
5429 (pr-ps-mode n-up filename)
5430 (pr-text2ps 'buffer n-up filename)))))
5432 (pr-despool-print filename)))
5435 (defun pr-text2ps (kind n-up filename &optional from to)
5436 (let ((ps-n-up-printing n-up)
5437 (ps-spool-config (and (eq ps-spool-config 'setpagedevice)
5439 (pr-delete-file-if-exists filename)
5442 ;; pr-faces-p and pr-spool-p
5443 ;; here FILENAME arg is ignored
5444 (cond ((eq kind 'buffer)
5445 (ps-spool-buffer-with-faces))
5447 (ps-spool-region-with-faces (or from (point))
5450 ;; pr-faces-p and not pr-spool-p
5452 (ps-print-buffer-with-faces filename))
5454 (ps-print-region-with-faces (or from (point))
5455 (or to (mark)) filename))
5458 ;; not pr-faces-p and pr-spool-p
5459 ;; here FILENAME arg is ignored
5460 (cond ((eq kind 'buffer)
5463 (ps-spool-region (or from (point)) (or to (mark))))
5465 ;; not pr-faces-p and not pr-spool-p
5467 (ps-print-buffer filename))
5469 (ps-print-region (or from (point)) (or to (mark)) filename))
5473 (defun pr-command (command)
5474 "Return absolute file name specification for COMMAND.
5476 If COMMAND is already an absolute file name specification, return it.
5477 Else it uses `pr-path-alist' to find COMMAND, if find it then return it;
5478 otherwise, gives an error.
5480 When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and
5481 `unix' are used (see `pr-path-alist' for documentation).
5483 If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND,
5484 COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
5486 (or (pr-find-command command)
5487 (pr-path-command (cond (pr-cygwin-system 'cygwin)
5488 (ps-windows-system 'windows)
5490 (file-name-nondirectory command)
5492 (error "Command not found: %s" (file-name-nondirectory command)))))
5495 (defun pr-path-command (symbol command sym-list)
5496 (let ((lpath (cdr (assq symbol pr-path-alist)))
5499 (and (eq symbol 'PATH) (null lpath)
5500 (setq lpath (parse-colon-path (getenv "PATH"))))
5504 (let ((path (car lpath)))
5508 (and (not (memq path sym-list))
5509 (pr-path-command path command
5510 (cons path sym-list))))
5515 (substitute-in-file-name
5516 (concat (file-name-as-directory path)
5519 (setq lpath (cdr lpath)))
5523 (defun pr-find-command (cmd)
5524 (if ps-windows-system
5526 (let ((ext (cons (file-name-extension cmd t)
5527 (list ".exe" ".bat" ".com")))
5529 (setq cmd (file-name-sans-extension cmd))
5531 (setq found (concat cmd (car ext)))
5532 (not (and (file-regular-p found)
5533 (file-executable-p found))))
5537 ;; non-windows systems
5538 (and (file-regular-p cmd)
5539 (file-executable-p cmd)
5543 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5544 ;; Printing Interface (inspired on ps-print-interface.el)
5552 (defvar pr-i-window-configuration nil)
5554 (defvar pr-i-buffer nil)
5555 (defvar pr-i-region nil)
5556 (defvar pr-i-mode nil)
5557 (defvar pr-i-despool nil)
5558 (defvar pr-i-ps-as-is t)
5559 (defvar pr-i-n-up 1)
5560 (defvar pr-i-directory "./")
5561 (defvar pr-i-regexp "")
5562 (defvar pr-i-ps-file "")
5563 (defvar pr-i-out-file "")
5564 (defvar pr-i-answer-yes nil)
5565 (defvar pr-i-process 'buffer)
5566 (defvar pr-i-ps-send 'printer)
5569 (defvar pr-interface-map nil
5570 "Keymap for pr-interface.")
5572 (if pr-interface-map
5574 (setq pr-interface-map (make-sparse-keymap))
5575 (cond ((eq ps-print-emacs-type 'xemacs) ; XEmacs
5576 (pr-f-set-keymap-parents pr-interface-map (list widget-keymap))
5577 (pr-f-set-keymap-name pr-interface-map 'pr-interface-map))
5578 ((eq ps-print-emacs-type 'emacs) ; GNU Emacs
5579 (pr-f-set-keymap-parents pr-interface-map widget-keymap)))
5580 (define-key pr-interface-map "q" 'pr-interface-quit)
5581 (define-key pr-interface-map "?" 'pr-interface-help))
5584 (defmacro pr-interface-save (&rest body)
5586 (set-buffer pr-i-buffer)
5590 (defun pr-create-interface ()
5591 "Create the front end for printing package."
5592 (setq pr-i-buffer (buffer-name (current-buffer))
5593 pr-i-region (ps-mark-active-p)
5594 pr-i-mode (pr-mode-alist-p)
5595 pr-i-window-configuration (current-window-configuration))
5597 (put 'pr-i-process 'pr-widget-list nil)
5598 (put 'pr-i-ps-send 'pr-widget-list nil)
5600 (delete-other-windows)
5601 (kill-buffer (get-buffer-create pr-buffer-name))
5602 (switch-to-buffer (get-buffer-create pr-buffer-name))
5605 (let ((versions (concat "printing v" pr-version
5606 " ps-print v" ps-print-version)))
5607 (widget-insert (make-string (- 79 (length versions)) ?\ ) versions))
5608 (pr-insert-italic "\nCurrent Directory : " 1)
5609 (pr-insert-italic default-directory)
5611 (pr-insert-section-1) ; 1. Print
5612 (pr-insert-section-2) ; 2. PostScript Printer
5613 (pr-insert-section-3) ; 3. Text Printer
5616 (widget-insert "\n\n " (make-string 77 ?-))
5618 (pr-insert-section-4) ; 4. Settings
5619 (pr-insert-section-5) ; 5. Customize
5620 (pr-insert-section-6) ; 6. Show Settings
5621 (pr-insert-section-7) ; 7. Help
5623 (use-local-map pr-interface-map)
5625 (goto-char (point-min))
5627 (and pr-i-region ; let region activated
5628 (pr-keep-region-active)))
5631 (defun pr-insert-section-1 ()
5633 (pr-insert-italic "\nPrint :" 1)
5636 ;; 1a. Buffer: Buffer List
5637 (pr-insert-radio-button 'pr-i-process 'buffer)
5638 (pr-insert-menu "Buffer List" 'pr-i-buffer
5639 (let ((blist (buffer-list))
5640 case-fold-search choices)
5642 (let ((name (buffer-name (car blist)))
5643 (ignore pr-buffer-name-ignore)
5645 (setq blist (cdr blist))
5646 (while (and ignore (not found))
5647 (setq found (string-match (car ignore) name)
5648 ignore (cdr ignore)))
5660 (setq pr-i-region (ps-mark-active-p)
5661 pr-i-mode (pr-mode-alist-p)))
5662 (pr-update-checkbox 'pr-i-region)
5663 (pr-update-checkbox 'pr-i-mode)))
5664 ;; 1a. Buffer: Region
5665 (put 'pr-i-region 'pr-widget
5669 #'(lambda (widget &rest ignore)
5670 (let ((region-p (pr-interface-save
5671 (ps-mark-active-p))))
5672 (cond ((null (widget-value widget)) ; widget is nil
5673 (setq pr-i-region nil))
5674 (region-p ; widget is true and there is a region
5675 (setq pr-i-region t)
5676 (widget-value-set widget t)
5677 (widget-setup)) ; MUST be called after widget-value-set
5678 (t ; widget is true and there is no region
5680 (message "There is no region active")
5681 (setq pr-i-region nil)
5682 (widget-value-set widget nil)
5683 (widget-setup))))) ; MUST be called after widget-value-set
5686 (put 'pr-i-mode 'pr-widget
5690 #'(lambda (widget &rest ignore)
5691 (let ((mode-p (pr-interface-save
5692 (pr-mode-alist-p))))
5694 ((null (widget-value widget)) ; widget is nil
5695 (setq pr-i-mode nil))
5696 (mode-p ; widget is true and there is a `mode'
5698 (widget-value-set widget t)
5699 (widget-setup)) ; MUST be called after widget-value-set
5700 (t ; widget is true and there is no `mode'
5703 "This buffer isn't in a mode that printing treats specially.")
5704 (setq pr-i-mode nil)
5705 (widget-value-set widget nil)
5706 (widget-setup))))) ; MUST be called after widget-value-set
5710 (pr-insert-radio-button 'pr-i-process 'directory)
5714 :format " Directory : %v"
5715 :notify 'pr-interface-directory
5716 :action (lambda (widget &optional event)
5717 (if (pr-interface-directory widget)
5718 (pr-widget-field-action widget event)
5720 (message "It should be a readable directory")))
5722 ;; 1b. Directory: File Regexp
5723 (widget-create 'regexp
5725 :format "\n File Regexp : %v\n"
5726 :notify (lambda (widget &rest ignore)
5727 (setq pr-i-regexp (widget-value widget)))
5729 ;; 1b. Directory: List Directory Entry
5731 (pr-insert-toggle 'pr-list-directory " List Directory Entry\n")
5733 ;; 1c. PostScript File:
5734 (pr-insert-radio-button 'pr-i-process 'file)
5738 :format " PostScript File : %v"
5739 :notify 'pr-interface-infile
5740 :action (lambda (widget &rest event)
5741 (if (pr-interface-infile widget)
5742 (pr-widget-field-action widget event)
5744 (message "It should be a readable PostScript file")))
5746 ;; 1c. PostScript File: PostScript Utility
5747 (pr-insert-menu "PostScript Utility" 'pr-ps-utility
5748 (pr-choice-alist pr-ps-utility-alist)
5749 "\n PostScript Utility : "
5751 ;; 1c. PostScript File: Use It AS-IS
5752 (pr-insert-toggle 'pr-i-ps-as-is " Use It ")
5753 (pr-insert-italic "AS-IS"))
5756 (defun pr-insert-section-2 ()
5757 ;; 2. PostScript Printer:
5758 ;; 2. PostScript Printer: PostScript Printer List
5759 (pr-insert-italic "\n\nPostScript Printer : " 2 20)
5760 (pr-insert-menu "PostScript Printer" 'pr-ps-name
5761 (pr-choice-alist pr-ps-printer-alist))
5762 ;; 2. PostScript Printer: Despool
5763 (put 'pr-i-despool 'pr-widget
5767 #'(lambda (widget &rest ignore)
5769 (setq pr-i-despool (not pr-i-despool))
5771 (message "It despool only when it's spooling")
5772 (setq pr-i-despool nil))
5773 (widget-value-set widget pr-i-despool)
5774 (widget-setup)) ; MUST be called after widget-value-set
5776 ;; 2. PostScript Printer: Preview Print Quit
5777 (pr-insert-button 'pr-interface-preview "Preview" " ")
5778 (pr-insert-button 'pr-interface-ps-print "Print" " ")
5779 (pr-insert-button 'pr-interface-quit "Quit")
5780 ;; 2. PostScript Printer: Send to Printer/Temporary File
5781 (pr-insert-radio-button 'pr-i-ps-send 'printer)
5782 (widget-insert " Send to Printer/Temporary File")
5783 ;; 2. PostScript Printer: Send to File
5784 (pr-insert-radio-button 'pr-i-ps-send 'file)
5788 :format " Send to File : %v"
5789 :notify 'pr-interface-outfile
5790 :action (lambda (widget &rest event)
5791 (if (and (pr-interface-outfile widget)
5792 (or (not (file-exists-p pr-i-out-file))
5793 (setq pr-i-answer-yes
5794 (y-or-n-p "File exists; overwrite? "))))
5795 (pr-widget-field-action widget event)
5797 (message "It should be a writable PostScript file")))
5799 ;; 2. PostScript Printer: N-Up
5803 :format "\n N-Up : %v"
5804 :notify (lambda (widget &rest ignore)
5805 (let ((value (if (string= (widget-apply widget :value-get) "")
5807 (widget-value widget))))
5808 (if (and (integerp value)
5809 (<= 1 value) (<= value 100))
5812 (setq pr-i-n-up value))
5814 (message "It should be an integer between 1 and 100"))))
5818 (defun pr-insert-section-3 ()
5820 (pr-insert-italic "\n\nText Printer : " 2 14)
5821 (pr-insert-menu "Text Printer" 'pr-txt-name
5822 (pr-choice-alist pr-txt-printer-alist)
5824 (pr-insert-button 'pr-interface-printify "Printify" " ")
5825 (pr-insert-button 'pr-interface-txt-print "Print" " ")
5826 (pr-insert-button 'pr-interface-quit "Quit"))
5829 (defun pr-insert-section-4 ()
5831 ;; 4. Settings: Landscape Auto Region Verbose
5832 (pr-insert-checkbox "\n\n " 'ps-landscape-mode
5833 #'(lambda (&rest ignore)
5834 (setq ps-landscape-mode (not ps-landscape-mode)
5835 pr-file-landscape ps-landscape-mode))
5837 (pr-insert-toggle 'pr-auto-region " Auto Region ")
5838 (pr-insert-toggle 'pr-buffer-verbose " Verbose\n ")
5840 ;; 4. Settings: Print Header Auto Mode
5841 (pr-insert-toggle 'ps-print-header " Print Header ")
5842 (pr-insert-toggle 'pr-auto-mode " Auto Mode\n ")
5844 ;; 4. Settings: Print Header Frame Menu Lock
5845 (pr-insert-toggle 'ps-print-header-frame " Print Header Frame ")
5846 (pr-insert-toggle 'pr-menu-lock " Menu Lock\n ")
5848 ;; 4. Settings: Line Number
5849 (pr-insert-toggle 'ps-line-number " Line Number\n ")
5851 ;; 4. Settings: Zebra Stripes Spool Buffer
5852 (pr-insert-toggle 'ps-zebra-stripes " Zebra Stripes")
5853 (pr-insert-checkbox " "
5855 #'(lambda (&rest ignore)
5856 (setq pr-spool-p (not pr-spool-p))
5858 (setq pr-i-despool nil)
5859 (pr-update-checkbox 'pr-i-despool)))
5862 ;; 4. Settings: Duplex Print with-faces
5863 (pr-insert-checkbox "\n "
5865 #'(lambda (&rest ignore)
5866 (setq ps-spool-duplex (not ps-spool-duplex)
5867 pr-file-duplex ps-spool-duplex))
5869 (pr-insert-toggle 'pr-faces-p " Print with-faces")
5871 ;; 4. Settings: Tumble Print Using Ghostscript
5872 (pr-insert-checkbox "\n "
5874 #'(lambda (&rest ignore)
5875 (setq ps-spool-tumble (not ps-spool-tumble)
5876 pr-file-tumble ps-spool-tumble))
5878 (pr-insert-toggle 'pr-print-using-ghostscript " Print Using Ghostscript\n ")
5880 ;; 4. Settings: Upside-Down Page Parity
5881 (pr-insert-toggle 'ps-print-upside-down " Upside-Down ")
5882 (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages
5883 (mapcar #'(lambda (alist)
5888 :value (car alist))))
5889 pr-even-or-odd-alist)))
5892 (defun pr-insert-section-5 ()
5894 (pr-insert-italic "\n\nCustomize : " 2 11)
5895 (pr-insert-button 'pr-customize "printing" " ")
5896 (pr-insert-button #'(lambda (&rest ignore) (ps-print-customize))
5898 (pr-insert-button 'lpr-customize "lpr"))
5901 (defun pr-insert-section-6 ()
5902 ;; 6. Show Settings:
5903 (pr-insert-italic "\nShow Settings : " 1 14)
5904 (pr-insert-button 'pr-show-pr-setup "printing" " ")
5905 (pr-insert-button 'pr-show-ps-setup "ps-print" " ")
5906 (pr-insert-button 'pr-show-lpr-setup "lpr"))
5909 (defun pr-insert-section-7 ()
5911 (pr-insert-italic "\nHelp : " 1 5)
5912 (pr-insert-button 'pr-interface-help "Interface Help" " ")
5913 (pr-insert-button 'pr-help "Menu Help" " ")
5914 (pr-insert-button 'pr-interface-quit "Quit" "\n ")
5915 (pr-insert-button 'pr-kill-help "Kill All Printing Help Buffer"))
5918 (defun pr-kill-help (&rest ignore)
5919 "Kill all printing help buffer."
5921 (let ((help '("*Printing Interface Help*" "*Printing Help*"
5922 "*LPR Setup*" "*PR Setup*" "*PS Setup*")))
5924 (let ((buffer (get-buffer (car help))))
5925 (setq help (cdr help))
5927 (delete-windows-on buffer)
5928 (kill-buffer buffer)))))
5929 (recenter (- (window-height) 2)))
5932 (defun pr-interface-quit (&rest ignore)
5933 "Kill the printing buffer interface and quit."
5935 (kill-buffer pr-buffer-name)
5936 (set-window-configuration pr-i-window-configuration))
5939 (defun pr-interface-help (&rest ignore)
5940 "printing buffer interface help."
5942 (pr-show-setup pr-interface-help-message "*Printing Interface Help*"))
5945 (defun pr-interface-txt-print (&rest ignore)
5946 "Print using lpr package."
5948 (condition-case data
5950 ((eq pr-i-process 'directory)
5953 (pr-txt-directory pr-i-directory pr-i-regexp)))
5954 ((eq pr-i-process 'buffer)
5957 (let ((pr-auto-mode pr-i-mode))
5960 (let (pr-auto-region)
5963 (let (pr-auto-mode pr-auto-region)
5966 ((eq pr-i-process 'file)
5967 (error "It should be a text file"))
5969 (error "Internal error: `pr-i-process' = %S" pr-i-process))
5974 (message (error-message-string data)))))
5977 (defun pr-interface-printify (&rest ignore)
5978 "Printify a buffer."
5980 (condition-case data
5982 ((eq pr-i-process 'directory)
5985 (pr-printify-directory pr-i-directory pr-i-regexp)))
5986 ((eq pr-i-process 'buffer)
5989 (pr-printify-region)
5990 (pr-printify-buffer))))
5991 ((eq pr-i-process 'file)
5992 (error "It can't printify a PostScript file"))
5994 (error "Internal error: `pr-i-process' = %S" pr-i-process))
5999 (message (error-message-string data)))))
6002 (defun pr-interface-ps-print (&rest ignore)
6003 "Print using ps-print package."
6005 (pr-interface-ps 'pr-despool-ps-print 'pr-ps-directory-ps-print
6006 'pr-ps-file-ps-print 'pr-ps-file-up-ps-print
6007 'pr-ps-region-ps-print 'pr-ps-mode-ps-print
6008 'pr-ps-buffer-ps-print))
6011 (defun pr-interface-preview (&rest ignore)
6012 "Preview a PostScript file."
6014 (pr-interface-ps 'pr-despool-preview 'pr-ps-directory-preview
6015 'pr-ps-file-preview 'pr-ps-file-up-preview
6016 'pr-ps-region-preview 'pr-ps-mode-preview
6017 'pr-ps-buffer-preview))
6020 (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region
6022 (condition-case data
6023 (let ((outfile (or (and (eq pr-i-process 'file) pr-i-ps-as-is)
6026 ((and pr-i-despool pr-spool-p)
6028 (funcall ps-despool outfile))
6029 (setq pr-i-despool nil)
6030 (pr-update-checkbox 'pr-i-despool))
6031 ((eq pr-i-process 'directory)
6034 (funcall ps-directory
6035 pr-i-n-up pr-i-directory pr-i-regexp outfile)))
6036 ((eq pr-i-process 'file)
6037 (cond ((or (file-directory-p pr-i-ps-file)
6038 (not (file-readable-p pr-i-ps-file)))
6039 (error "It should be a readable PostScript file"))
6042 (funcall ps-file pr-i-ps-file)))
6045 (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile)))
6047 ((eq pr-i-process 'buffer)
6050 (let ((pr-auto-mode pr-i-mode))
6051 (funcall ps-region pr-i-n-up outfile)))
6053 (let (pr-auto-region)
6054 (funcall ps-mode pr-i-n-up outfile)))
6056 (let (pr-auto-mode pr-auto-region)
6057 (funcall ps-buffer pr-i-n-up outfile)))
6060 (error "Internal error: `pr-i-process' = %S" pr-i-process))
6065 (message (error-message-string data)))))
6068 (defun pr-i-ps-send ()
6069 (cond ((eq pr-i-ps-send 'printer)
6071 ((not (eq pr-i-ps-send 'file))
6072 (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send))
6073 ((or (file-directory-p pr-i-out-file)
6074 (not (file-writable-p pr-i-out-file)))
6075 (error "It should be a writable PostScript file"))
6076 ((or (not (file-exists-p pr-i-out-file))
6078 (setq pr-i-answer-yes
6079 (y-or-n-p (format "File `%s' exists; overwrite? "
6083 (error "File already exists"))))
6086 (defun pr-i-directory ()
6087 (or (and (file-directory-p pr-i-directory)
6088 (file-readable-p pr-i-directory))
6089 (error "It should be a readable directory")))
6092 (defun pr-interface-directory (widget &rest ignore)
6093 (and pr-buffer-verbose
6094 (message "Type M-TAB or ESC TAB for file completion"))
6095 (let ((dir (widget-value widget)))
6096 (and (file-directory-p dir)
6097 (file-readable-p dir)
6098 (setq pr-i-directory dir))))
6101 (defun pr-interface-infile (widget &rest ignore)
6102 (and pr-buffer-verbose
6103 (message "Type M-TAB or ESC TAB for file completion"))
6104 (let ((file (widget-value widget)))
6105 (and (not (file-directory-p file))
6106 (file-readable-p file)
6107 (setq pr-i-ps-file file))))
6110 (defun pr-interface-outfile (widget &rest ignore)
6111 (setq pr-i-answer-yes nil)
6112 (and pr-buffer-verbose
6113 (message "Type M-TAB or ESC TAB for file completion"))
6114 (let ((file (widget-value widget)))
6115 (and (not (file-directory-p file))
6116 (file-writable-p file)
6117 (setq pr-i-out-file file))))
6120 (defun pr-widget-field-action (widget event)
6121 (and (get-buffer "*Completions*") ; clean frame window
6122 (delete-windows-on "*Completions*"))
6123 (message " ") ; clean echo area
6124 (widget-field-action widget event))
6127 (defun pr-insert-italic (str &optional from to)
6128 (let ((len (length str)))
6129 (put-text-property (if from (max from 0) 0)
6130 (if to (max to len) len)
6132 (widget-insert str)))
6135 (defun pr-insert-checkbox (before var-sym fun label)
6136 (widget-insert before)
6138 (widget-create 'checkbox
6140 (symbol-value var-sym))
6141 (widget-insert label)))
6144 (defun pr-insert-toggle (var-sym label)
6145 (widget-create 'checkbox
6146 :notify `(lambda (&rest ignore)
6147 (setq ,var-sym (not ,var-sym)))
6148 (symbol-value var-sym))
6149 (widget-insert label))
6152 (defun pr-insert-button (fun label &optional separator)
6153 (widget-create 'push-button
6157 (widget-insert separator)))
6160 (defun pr-insert-menu (tag var-sym choices &optional before after &rest body)
6161 (and before (widget-insert before))
6162 (eval `(widget-create 'menu-choice
6167 :notify (lambda (widget &rest ignore)
6168 (setq ,var-sym (widget-value widget))
6170 :void '(choice-item :format "%[%t%]"
6171 :tag "Can not display value!")
6173 (and after (widget-insert after)))
6176 (defun pr-insert-radio-button (var-sym sym)
6177 (widget-insert "\n")
6178 (let ((wid-list (get var-sym 'pr-widget-list))
6179 (wid (eval `(widget-create
6182 :value (eq ,var-sym (quote ,sym))
6183 :notify (lambda (&rest ignore)
6184 (setq ,var-sym (quote ,sym))
6185 (pr-update-radio-button (quote ,var-sym)))))))
6186 (put var-sym 'pr-widget-list (cons (cons wid sym) wid-list))))
6189 (defun pr-update-radio-button (var-sym)
6190 (let ((wid-list (get var-sym 'pr-widget-list)))
6192 (let ((wid (car (car wid-list)))
6193 (value (cdr (car wid-list))))
6194 (setq wid-list (cdr wid-list))
6195 (widget-value-set wid (eq (symbol-value var-sym) value))))
6199 (defun pr-update-checkbox (var-sym)
6200 (let ((wid (get var-sym 'pr-widget)))
6202 (widget-value-set wid (symbol-value var-sym))
6206 (defun pr-choice-alist (alist)
6207 (let ((max (apply 'max (mapcar #'(lambda (alist)
6208 (length (symbol-name (car alist))))
6210 (mapcar #'(lambda (alist)
6211 (let* ((sym (car alist))
6212 (name (symbol-name sym)))
6219 (make-string (- max (length name)) ?_))
6224 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6233 ;;; printing.el ends here