1 ;;; printing.el --- printing utilities
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004
4 ;; Free Software Foundation, Inc.
6 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
7 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
8 ;; Time-stamp: <2004/02/29 23:18:15 vinicius>
9 ;; Keywords: wp, print, PostScript
11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
13 (defconst pr-version
"6.7.2"
14 "printing.el, v 6.7.2 <2004/02/29 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' interactively select a PostScript printer.
259 ;; `pr-txt-name' interactively select a text printer.
260 ;; `pr-ps-utility' interactively select 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 the gsview/gv
387 ;; `pr-gs-command' Specify path and name of the ghostscript
390 ;; `pr-gs-switches' Specify ghostscript switches.
392 ;; `pr-gs-device' Specify ghostscript device switch value.
394 ;; `pr-gs-resolution' Specify ghostscript resolution switch value.
396 ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript.
398 ;; `pr-faces-p' Non-nil means print with face attributes.
400 ;; `pr-spool-p' Non-nil means spool printing in a buffer.
402 ;; `pr-file-landscape' Non-nil means print PostScript file in
403 ;; landscape orientation.
405 ;; `pr-file-duplex' Non-nil means print PostScript file in duplex
408 ;; `pr-file-tumble' Non-nil means print PostScript file in tumble
411 ;; `pr-auto-region' Non-nil means region is automagically detected.
413 ;; `pr-auto-mode' Non-nil means major-mode specific printing is
414 ;; prefered over normal printing.
416 ;; `pr-mode-alist' Specify an alist for a major-mode and printing
419 ;; `pr-ps-utility' Specify PostScript utility processing.
421 ;; `pr-ps-utility-alist' Specify an alist for PostScript utility
424 ;; `pr-menu-lock' Non-nil means menu is locked while selecting
427 ;; `pr-menu-char-height' Specify menu char height in pixels.
429 ;; `pr-menu-char-width' Specify menu char width in pixels.
431 ;; `pr-setting-database' Specify an alist for settings in general.
433 ;; `pr-visible-entry-list' Specify a list of Printing menu visible
436 ;; `pr-delete-temp-file' Non-nil means delete temporary files.
438 ;; `pr-list-directory' Non-nil means list directory when processing a
441 ;; `pr-buffer-name' Specify the name of the buffer interface for
444 ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be
445 ;; ignored in interface buffer.
447 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a
448 ;; field in interface buffer.
450 ;; `pr-shell-file-name' Specify file name to load inferior shells
453 ;; To set the above options you may:
455 ;; a) insert the code in your ~/.emacs, like:
457 ;; (setq pr-faces-p t)
459 ;; This way always keep your default settings when you enter a new Emacs
462 ;; b) or use `set-variable' in your Emacs session, like:
464 ;; M-x set-variable RET pr-faces-p RET t RET
466 ;; This way keep your settings only during the current Emacs session.
468 ;; c) or use customization, for example:
469 ;; click on menu-bar *Help* option,
470 ;; then click on *Customize*,
471 ;; then click on *Browse Customization Groups*,
472 ;; expand *PostScript* group,
473 ;; expand *Printing* group
474 ;; and then customize `printing' options.
475 ;; Through this way, you may choose if the settings are kept or not when
476 ;; you leave out the current Emacs session.
478 ;; d) or see the option value:
480 ;; C-h v pr-faces-p RET
482 ;; and click the *customize* hypertext button.
483 ;; Through this way, you may choose if the settings are kept or not when
484 ;; you leave out the current Emacs session.
488 ;; M-x pr-customize RET
490 ;; and then customize `printing' options.
491 ;; Through this way, you may choose if the settings are kept or not when
492 ;; you leave out the current Emacs session.
494 ;; f) or use menu bar, for example:
495 ;; click on menu-bar *File* option,
496 ;; then click on *Printing*,
497 ;; then click on *Customize*,
498 ;; then click on *printing*
499 ;; and then customize `printing' options.
500 ;; Through this way, you may choose if the settings are kept or not when
501 ;; you leave out the current Emacs session.
507 ;; The `printing' menu (Tools/Printing or File/Print) has the following layout:
509 ;; +-----------------------------+
510 ;; A 0 | Printing Interface |
511 ;; +-----------------------------+ +-A---------+ +-B------+
512 ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
513 ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
514 ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
515 ;; +-----------------------------+ |Mode >|-- B |Other...|
516 ;; II 4 | Printify >|-----\ |File >|--\ +--------+
517 ;; 5 | Print >|---\ | |Despool... | |
518 ;; 6 | Text Printer: name >|-\ | | +-----------+ |
519 ;; +-----------------------------+ | | | +---------+ +------------+
520 ;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia
521 ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
522 ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C
523 ;; 10 |[ ]Line Number | | | +---------+ +------------+
524 ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
525 ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... |
526 ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... |
527 ;; 14 |[ ]Upside-Down | | |Region | | Other... |
528 ;; 15 | Print All Pages >|--\ | |Mode | +------------+
529 ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id
530 ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
531 ;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If
532 ;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
533 ;; +-----------------------------+ | |... |
534 ;; V 19 |[ ]Auto Region | | |(*)name |
535 ;; 20 |[ ]Auto Mode | | |... |
536 ;; 21 |[ ]Menu Lock | | +---------+ +--------------+
537 ;; +-----------------------------+ \------------------|(*)All Pages |
538 ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
539 ;; 23 | Show Settings >|-------|printing| |( )Odd Pages |
540 ;; 24 | Help | |ps-print| |( )Even Sheets|
541 ;; +-----------------------------+ |lpr | |( )Odd Sheets |
542 ;; +--------+ +--------------+
544 ;; See `pr-visible-entry-list' for hiding some parts of the menu.
546 ;; The menu has the following sections:
550 ;; 0. You can use a buffer interface instead of menus. It looks like the
551 ;; customization buffer. Basically, it has the same options found in the
552 ;; menu and some extra options, all this on a buffer.
554 ;; I. PostScript printing:
556 ;; 1. You can generate a PostScript file (if you type C-u before activating
557 ;; menu) or PostScript temporary file for a directory, a buffer, a region
558 ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
559 ;; after file generation, ghostview is activated using the file generated
560 ;; as argument. This option is disabled if spooling is on (option 16).
561 ;; Also, if you already have a PostScript file you can preview it.
562 ;; Instead of previewing each buffer, region or major mode at once, you
563 ;; can save temporarily the PostScript code generated in a buffer and
564 ;; preview it later. The option `Despool...' despools the PostScript
565 ;; spooling buffer in a temporary file and uses ghostview to preview it.
566 ;; If you type C-u before choosing this option, the PostScript code
567 ;; generated is saved in a file instead of saving in a temporary file.
568 ;; To spool the PostScript code generated you need to turn on the option
569 ;; 16. The option `Despool...' is enabled if spooling is on (option
572 ;; NOTE 1: It's possible to customize a major mode printing, just declare
573 ;; the customization in `pr-mode-alist' and invoke some of
574 ;; `*-mode*' commands or select Mode option in Printing menu. An
575 ;; example for major mode usage is when you're using gnus (or mh,
576 ;; or rmail, etc.) and you're in the *Summary* buffer, if you
577 ;; forget to switch to the *Article* buffer before printing,
578 ;; you'll get a nicely formatted list of article subjects shows
579 ;; up at the printer. With major mode printing you don't need to
580 ;; switch from gnus *Summary* buffer first.
582 ;; NOTE 2: There are the following options for PostScript file
584 ;; Ia. Print the file *No Preprocessing*, that is, send it
585 ;; directly to PostScript printer.
586 ;; Ib. PostScript utility processing selection.
587 ;; See `pr-ps-utility-alist' and `pr-setting-database' for
589 ;; Ic. Do n-up processing before printing.
590 ;; Id. Toggle on/off landscape for PostScript file processing.
591 ;; Ie. Toggle on/off duplex for PostScript file processing.
592 ;; If. Toggle on/off tumble for PostScript file processing.
594 ;; NOTE 3: Don't forget to download and install the utilities declared on
595 ;; `pr-ps-utility-alist'.
597 ;; 2. Operate the same way as option 1, but it sends directly the PostScript
598 ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to
599 ;; print the PostScript file generated. It depends on option 18, if it's
600 ;; turned on, it uses ghostscript; otherwise, it sends directly to
601 ;; printer. If spooling is on (option 16), the PostScript code is saved
602 ;; temporarily in a buffer instead of printing it or saving it in a file.
603 ;; Also, if you already have a PostScript file you can print it. Instead
604 ;; of printing each buffer, region or major mode at once, you can save
605 ;; temporarily the PostScript code generated in a buffer and print it
606 ;; later. The option `Despool...' despools the PostScript spooling
607 ;; buffer directly on a printer. If you type C-u before choosing this
608 ;; option, the PostScript code generated is saved in a file instead of
609 ;; sending to printer. To spool the PostScript code generated you need
610 ;; to turn on the option 16. This option is enabled if spooling is on
611 ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
613 ;; 3. You can select a new PostScript printer to send PostScript code
614 ;; generated. For selection it's used all PostScript printers defined
615 ;; in `pr-ps-printer-alist' variable (see it for documentation).
616 ;; See also `pr-setting-database'.
618 ;; II. Text printing:
620 ;; 4. If you have control characters (character code from \000 to \037) in a
621 ;; buffer and you want to print them in a text printer, select this
622 ;; option. All control characters in your buffer or region will be
623 ;; replaced by a printable representation. The printable representations
624 ;; use ^ (for ASCII control characters) or hex. The characters tab,
625 ;; linefeed, space, return and formfeed are not affected. You don't need
626 ;; to select this option if you use any option of section I, the
627 ;; PostScript engine treats control characters properly.
629 ;; 5. If you want to print a directory, buffer, region or major mode in a
630 ;; text printer, select this option. See also the NOTE 1 on option 1.
632 ;; 6. You can select a new text printer to send text generated. For
633 ;; selection it's used all text printers defined in
634 ;; `pr-txt-printer-alist' variable (see it for documentation).
635 ;; See also `pr-setting-database'.
637 ;; III. PostScript page toggle options:
639 ;; 7. If you want a PostScript landscape printing, turn on this option.
641 ;; 8. If you want to have a header in each page in your PostScript code,
642 ;; turn on this option.
644 ;; 9. If you want to draw a gaudy frame around the header, turn on this
645 ;; option. This option is enabled if print header is on (option 8).
647 ;; 10. If you want that the line number is printed in your PostScript code,
648 ;; turn on this option.
650 ;; 11. If you want background zebra stripes in your PostScript code, turn on
653 ;; 12. If you want a duplex printing and your PostScript printer has this
654 ;; feature, turn on this option.
656 ;; 13. If you turned on duplex printing, you can choose if you want to have
657 ;; a printing suitable for binding on the left or right (tumble off), or
658 ;; to have a printing suitable for binding at top or bottom (tumble on).
659 ;; This option is enabled if duplex is on (option 12).
661 ;; 14. If you want a PostScript upside-down printing, turn on this option.
663 ;; 15. With this option, you can choose if you want to print all pages, odd
664 ;; pages, even pages, odd sheets or even sheets.
665 ;; See also `ps-even-or-odd-pages'.
667 ;; IV. PostScript processing toggle options:
669 ;; 16. If you want to spool the PostScript code generated, turn on this
670 ;; option. To spool the PostScript code generated use option 2. You
671 ;; can despool later by choosing option 1 or 2, sub-option `Despool...'.
673 ;; 17. If you use colors in your buffers and want to see these colors on
674 ;; your PostScript code generated, turn on this option. If you have a
675 ;; black/white PostScript printer, these colors are displayed in gray
676 ;; scale by PostScript printer interpreter.
678 ;; 18. If you don't have a PostScript printer to send PostScript files, turn
679 ;; on this option. When this option is on, the ghostscript is used to
680 ;; print PostScript files. In GNU or Unix system, if ghostscript is set
681 ;; as a PostScript filter, you don't need to turn on this option.
683 ;; V. Printing customization:
685 ;; 19. If you want that region is automagically detected, turn on this
686 ;; option. Note that this will only work if you're using transient mark
687 ;; mode. When this option is on, the `*-buffer*' commands will behave
688 ;; like `*-region*' commands, that is, `*-buffer*' commands will print
689 ;; only the region marked instead of all buffer.
691 ;; 20. Turn this option on if you want that when current major-mode is
692 ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
693 ;; behave like `*-mode*' commands.
695 ;; 21. If you want that Printing menu stays open while you are setting
696 ;; toggle options, turn on this option. The variables
697 ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
698 ;; menu position, so don't forget to adjust these variables if menu
699 ;; position is not ok.
701 ;; VI. Customization:
703 ;; 22. Besides all options in section III, IV and V, you can customize much
704 ;; more PostScript options in `ps-print' option. Or you can customize
705 ;; some `lpr' options for text printing. Or customize `printing'
708 ;; 23. Show current settings for `printing', `ps-print' or `lpr'.
710 ;; 24. Quick help for printing menu layout.
716 ;; Below it's shown only the main options that affect all `printing' package.
717 ;; Check all the settings below *BEFORE* running `printing' commands.
719 ;; * Example of setting for GNU or Unix system:
721 ;; (require 'printing)
722 ;; (setq pr-path-alist
723 ;; '((unix "." "~/bin" ghostview mpage PATH)
724 ;; (ghostview "$HOME/bin/gsview-dir")
725 ;; (mpage "$HOME/bin/mpage-dir")
727 ;; (setq pr-txt-name 'prt_06a)
728 ;; (setq pr-txt-printer-alist
729 ;; '((prt_06a "lpr" nil "prt_06a")
730 ;; (prt_07c nil nil "prt_07c")
732 ;; (setq pr-ps-name 'lps_06b)
733 ;; (setq pr-ps-printer-alist
734 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
735 ;; (lps_07c "lpr" nil nil "lps_07c")
736 ;; (lps_08c nil nil nil "lps_08c")
738 ;; (setq pr-temp-dir "/tmp/")
739 ;; (setq pr-gv-command "gv")
740 ;; (setq pr-gs-command "gs")
741 ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
742 ;; (setq pr-gs-device "uniprint")
743 ;; (setq pr-gs-resolution 300)
744 ;; (setq pr-ps-utility 'mpage)
745 ;; (setq pr-ps-utility-alist
746 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
747 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
748 ;; (inherits-from: . no-duplex))
750 ;; (setq pr-setting-database
753 ;; (pr-file-duplex . nil)
754 ;; (pr-file-tumble . nil))
756 ;; (pr-update-menus t) ; update now printer and utility menus
758 ;; * Example of setting for Windows system:
760 ;; (require 'printing)
761 ;; (setq pr-path-alist
762 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
763 ;; (ghostview "c:/gs/gsview-dir")
764 ;; (mpage "c:/mpage-dir")
766 ;; (setq pr-txt-name 'prt_06a)
767 ;; (setq pr-txt-printer-alist
768 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
769 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
770 ;; (PRN "" nil "PRN")
771 ;; (standard "redpr.exe" nil "")
773 ;; (setq pr-ps-name 'lps_06b)
774 ;; (setq pr-ps-printer-alist
775 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
776 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
777 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
778 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
779 ;; (LPT1 "" nil "" "LPT1:")
780 ;; (PRN "" nil "" "PRN")
781 ;; (standard "redpr.exe" nil "" "")
783 ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/")
784 ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe")
785 ;; (setq pr-gs-command "c:/gs/gswin32.exe")
786 ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts"))
787 ;; (setq pr-gs-device "mswinpr2")
788 ;; (setq pr-gs-resolution 300)
789 ;; (setq pr-ps-utility 'psnup)
790 ;; (setq pr-ps-utility-alist
791 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " "
792 ;; nil (inherits-from: . no-duplex))
794 ;; (setq pr-setting-database
797 ;; (pr-file-duplex . nil)
798 ;; (pr-file-tumble . nil))
800 ;; (pr-update-menus t) ; update now printer and utility menus
802 ;; NOTE: Don't forget to download and install the utilities declared on
803 ;; `pr-ps-utility-alist'.
809 ;; `printing' package has the following utilities:
811 ;; `pr-setup' Return the current `printing' setup.
813 ;; `lpr-setup' Return the current `lpr' setup.
815 ;; `pr-update-menus' Update utility, PostScript and text printer menus.
817 ;; Below are some URL where you can find good utilities.
819 ;; * For `printing' package:
821 ;; printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz'
822 ;; ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'
824 ;; * For GNU or Unix system:
826 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
827 ;; enscript `http://people.ssh.fi/mtr/genscript/'
828 ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html'
829 ;; mpage `http://www.mesa.nl/pub/mpage/'
831 ;; * For Windows system:
834 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'
835 ;; enscript `http://people.ssh.fi/mtr/genscript/'
836 ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html'
837 ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/'
843 ;; Thanks to Drew Adams <?@?> for directory processing and `pr-path-alist'
846 ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests.
848 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging
849 ;; and for suggestions:
850 ;; - even/odd pages printing.
851 ;; - ghostscript parameters for `pr-ps-printer-alist'.
852 ;; - default printer name.
853 ;; - completion functions.
854 ;; - automagic region detection.
855 ;; - menu entry hiding.
856 ;; - fast fire PostScript printing command.
857 ;; - `pr-path-style' variable.
859 ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions:
860 ;; - PostScript Print and PostScript Print Preview merge.
861 ;; - Tools/Printing menu.
862 ;; - replace *-using-preview by *-using-ghostscript.
863 ;; - printer selection.
864 ;; - extra parameters for `pr-ps-printer-alist'.
867 ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el
868 ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el
869 ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el
870 ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el
871 ;; And to all people who contributed with them.
874 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
883 (and (string< ps-print-version
"6.5.7")
884 (error "`printing' requires `ps-print' package version 6.5.7 or later."))
888 (defconst pr-cygwin-system
889 (and ps-windows-system
(getenv "OSTYPE")
890 (string-match "cygwin" (getenv "OSTYPE")))))
893 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
894 ;; To avoid compilation gripes
899 (or (fboundp 'subst-char-in-string
)
900 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
901 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
902 Unless optional argument INPLACE is non-nil, return a new string."
903 (let ((i (length string
))
904 (newstr (if inplace string
(copy-sequence string
))))
905 (while (> (setq i
(1- i
)) 0)
906 (if (eq (aref newstr i
) fromchar
)
907 (aset newstr i tochar
)))
911 (defalias 'pr-e-frame-char-height
'frame-char-height
)
912 (defalias 'pr-e-frame-char-width
'frame-char-width
)
913 (defalias 'pr-e-mouse-pixel-position
'mouse-pixel-position
)
915 (defalias 'pr-x-add-submenu
'add-submenu
)
916 (defalias 'pr-x-event-function
'event-function
)
917 (defalias 'pr-x-event-object
'event-object
)
918 (defalias 'pr-x-find-menu-item
'find-menu-item
)
919 (defalias 'pr-x-font-height
'font-height
)
920 (defalias 'pr-x-font-width
'font-width
)
921 (defalias 'pr-x-get-popup-menu-response
'get-popup-menu-response
)
922 (defalias 'pr-x-make-event
'make-event
)
923 (defalias 'pr-x-misc-user-event-p
'misc-user-event-p
)
924 (defalias 'pr-x-relabel-menu-item
'relabel-menu-item
)
925 (defalias 'pr-x-event-x-pixel
'event-x-pixel
)
926 (defalias 'pr-x-event-y-pixel
'event-y-pixel
)
929 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
930 (defvar deactivate-mark nil
)
931 (defalias 'pr-f-set-keymap-parents
'set-keymap-parent
)
932 (defalias 'pr-f-set-keymap-name
'ignore
)
933 (defalias 'pr-f-read-string
'read-string
)
934 (defun pr-keep-region-active ()
935 (setq deactivate-mark nil
)))
937 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
938 (defvar current-menubar nil
)
939 (defvar current-mouse-event nil
)
940 (defvar zmacs-region-stays nil
)
941 (defalias 'pr-f-set-keymap-parents
'set-keymap-parents
)
942 (defalias 'pr-f-set-keymap-name
'set-keymap-name
)
943 (defun pr-f-read-string (prompt initial history default
)
944 (let ((str (read-string prompt initial
)))
945 (if (and str
(not (string= str
"")))
948 (defun pr-keep-region-active ()
949 (setq zmacs-region-stays t
)))))
952 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
953 ;; Customization Functions
956 (defun pr-alist-custom-set (symbol value
)
957 "Set the value of custom variables for printer & utility selection."
959 (and (featurep 'printing
) ; update only after printing is loaded
960 (pr-update-menus t
)))
963 (defun pr-ps-utility-custom-set (symbol value
)
964 "Update utility menu entry."
966 (and (featurep 'printing
) ; update only after printing is loaded
967 (pr-menu-set-utility-title value
)))
970 (defun pr-ps-name-custom-set (symbol value
)
971 "Update `PostScript Printer:' menu entry."
973 (and (featurep 'printing
) ; update only after printing is loaded
974 (pr-menu-set-ps-title value
)))
977 (defun pr-txt-name-custom-set (symbol value
)
978 "Update `Text Printer:' menu entry."
980 (and (featurep 'printing
) ; update only after printing is loaded
981 (pr-menu-set-txt-title value
)))
984 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
985 ;; User Interface (I)
988 (defgroup printing nil
989 "Printing Utilities group"
990 :tag
"Printing Utilities"
991 :link
'(emacs-library-link :tag
"Source Lisp File" "printing.el")
997 (defcustom pr-path-style
998 (if (and (not pr-cygwin-system
)
1002 "*Specify which path style to use for external commands.
1006 windows Windows 9x/NT style (\\)
1008 unix Unix style (/)"
1009 :type
'(choice :tag
"Path style"
1010 (const :tag
"Windows 9x/NT Style (\\)" :value windows
)
1011 (const :tag
"Unix Style (/)" :value unix
))
1015 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1016 ;; Internal Functions (I)
1019 (defun pr-dosify-path (path)
1020 "Replace unix-style directory separator character with dos/windows one."
1021 (interactive "sPath: ")
1022 (if (eq pr-path-style
'windows
)
1023 (subst-char-in-string ?
/ ?
\\ path
)
1027 (defun pr-unixify-path (path)
1028 "Replace dos/windows-style directory separator character with unix one."
1029 (interactive "sPath: ")
1030 (if (eq pr-path-style
'windows
)
1031 (subst-char-in-string ?
\\ ?
/ path
)
1035 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1036 ;; User Interface (II)
1039 (defcustom pr-path-alist
1043 "*Specify an alist for command paths.
1045 It's used to find commands used for printing package, like gv, gs, gsview.exe,
1046 mpage, print.exe, etc. See also `pr-command' function.
1048 Each element has the form:
1050 (ENTRY DIRECTORY...)
1054 ENTRY It's a symbol, used to identify this entry.
1055 There must exist at least one of the following entries:
1057 unix this entry is used when Emacs is running on GNU or
1060 cygwin this entry is used when Emacs is running on Windows
1061 95/98/NT/2000 with Cygwin.
1063 windows this entry is used when Emacs is running on Windows
1066 DIRECTORY It should be a string or a symbol. If it's a symbol, it should
1067 exist an equal entry in `pr-path-alist'. If it's a string,
1068 it's considered a directory specification.
1070 The directory specification may contain:
1071 $var environment variable expansion
1073 ./ current directory
1074 ../ previous directory
1076 For example, let's say the home directory is /home/my and the
1077 current directory is /home/my/dir, so:
1079 THE ENTRY IS EXPANDED TO
1080 ~/entry /home/my/entry
1081 ./entry /home/my/dir/entry
1082 ../entry /home/my/entry
1083 $HOME/entry /home/my/entry
1084 $HOME/~/other/../my/entry /home/my/entry
1086 SPECIAL SYMBOL: If the symbol `PATH' is used in the directory
1087 list and there isn't a `PATH' entry in `pr-path-alist' or the
1088 `PATH' entry has a null directory list, the PATH environment
1093 * On GNU or Unix system:
1095 '((unix \".\" \"~/bin\" ghostview mpage PATH)
1096 (ghostview \"$HOME/bin/gsview-dir\")
1097 (mpage \"$HOME/bin/mpage-dir\")
1100 * On Windows system:
1102 '((windows \"c:/applications/executables\" PATH ghostview mpage)
1103 (ghostview \"c:/gs/gsview-dir\")
1104 (mpage \"c:/mpage-dir\")
1108 (symbol :tag
"Identifier ")
1109 (repeat :tag
"Directory List"
1110 (choice :menu-tag
"Directory"
1113 (symbol :value symbol
)))))
1117 (defcustom pr-txt-name
'default
1118 "*Specify a printer for printing a text file.
1120 The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
1123 This variable should be modified by customization engine. If this variable is
1124 modified by other means (for example, a lisp function), use `pr-update-menus'
1125 function (see it for documentation) to update text printer menu."
1127 :set
'pr-txt-name-custom-set
1131 (defcustom pr-txt-printer-alist
1132 (list (list 'default lpr-command nil
1133 (cond ((boundp 'printer-name
) printer-name
)
1134 (ps-windows-system "PRN")
1138 ;; * On GNU or Unix system:
1139 ;; '((prt_06a "lpr" nil "prt_06a")
1140 ;; (prt_07c nil nil "prt_07c")
1142 ;; * On Windows system:
1143 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
1144 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
1145 ;; (PRN "" nil "PRN")
1146 ;; (standard "redpr.exe" nil "")
1148 "*Specify an alist of all text printers (text printer database).
1150 The alist element has the form:
1152 (SYMBOL COMMAND SWITCHES NAME)
1156 SYMBOL It's a symbol to identify a text printer. It's for
1157 `pr-txt-name' variable setting and for menu selection.
1162 COMMAND Name of the program for printing a text file. On MS-DOS and
1163 MS-Windows systems, if the value is an empty string, then Emacs
1164 will write directly to the printer port given by NAME (see text
1165 below), that is, the NAME should be something like \"PRN\" or
1167 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1168 COMMAND shouldn't be an empty string.
1169 The programs `print' and `nprint' (the standard print programs
1170 on Windows NT and Novell Netware respectively) are handled
1171 specially, using NAME as the destination for output; any other
1172 program is treated like `lpr' except that an explicit filename
1173 is given as the last argument.
1174 If COMMAND is nil, it's used the default printing program:
1175 `print' for Windows system, `lp' for lp system and `lpr' for
1176 all other systems. See also `pr-path-alist'.
1182 SWITCHES List of sexp's to pass as extra options for text printer
1183 program. It is recommended to set NAME (see text below)
1184 instead of including an explicit switch on this list.
1190 NAME A string that specifies a text printer name.
1191 On Unix-like systems, a string value should be a name
1192 understood by lpr's -P option (or lp's -d option).
1193 On MS-DOS and MS-Windows systems, it is the name of a printer
1194 device or port. Typical non-default settings would be \"LPT1:\"
1195 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1196 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1197 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1198 printer. You can also set it to a name of a file, in which
1199 case the output gets appended to that file. If you want to
1200 discard the printed output, set this to \"NUL\".
1203 \"/D:\\\\\\\\host\\\\share-name\"
1210 This variable should be modified by customization engine. If this variable is
1211 modified by other means (for example, a lisp function), use `pr-update-menus'
1212 function (see it for documentation) to update text printer menu.
1216 * On GNU or Unix system:
1218 '((prt_06a \"lpr\" nil \"prt_06a\")
1219 (prt_07c nil nil \"prt_07c\")
1222 * On Windows system:
1224 '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\")
1225 (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\")
1226 (PRN \"\" nil \"PRN\")
1227 (standard \"redpr.exe\" nil \"\")
1230 (list :tag
"Text Printer"
1231 (symbol :tag
"Printer Symbol Name")
1232 (string :tag
"Printer Command")
1233 (repeat :tag
"Printer Switches"
1234 (sexp :tag
"Switch" :value
""))
1235 (choice :menu-tag
"Printer Name"
1237 (const :tag
"None" nil
)
1239 :set
'pr-alist-custom-set
1243 (defcustom pr-ps-name
'default
1244 "*Specify a printer for printing a PostScript file.
1246 This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
1249 This variable should be modified by customization engine. If this variable is
1250 modified by other means (for example, a lisp function), use `pr-update-menus'
1251 function (see it for documentation) to update PostScript printer menu."
1253 :set
'pr-ps-name-custom-set
1257 (defcustom pr-ps-printer-alist
1258 (list (list 'default lpr-command nil
1259 (cond (ps-windows-system nil
)
1262 (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name
)))
1264 ;; * On GNU or Unix system:
1265 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
1266 ;; (lps_07c "lpr" nil nil "lps_07c")
1267 ;; (lps_08c nil nil nil "lps_08c")
1269 ;; * On Windows system:
1270 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
1271 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
1272 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
1273 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
1274 ;; (LPT1 "" nil "" "LPT1:")
1275 ;; (PRN "" nil "" "PRN")
1276 ;; (standard "redpr.exe" nil "" "")
1278 "*Specify an alist for all PostScript printers (PostScript printer database).
1280 The alist element has the form:
1282 (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...)
1286 SYMBOL It's a symbol to identify a PostScript printer. It's for
1287 `pr-ps-name' variable setting and for menu selection.
1292 COMMAND Name of the program for printing a PostScript file. On MS-DOS
1293 and MS-Windows systems, if the value is an empty string then
1294 Emacs will write directly to the printer port given by NAME
1295 (see text below), that is, the NAME should be something like
1296 \"PRN\" or \"LPT1:\".
1297 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1298 COMMAND shouldn't be an empty string.
1299 The programs `print' and `nprint' (the standard print programs
1300 on Windows NT and Novell Netware respectively) are handled
1301 specially, using NAME as the destination for output; any other
1302 program is treated like `lpr' except that an explicit filename
1303 is given as the last argument.
1304 If COMMAND is nil, it's used the default printing program:
1305 `print' for Windows system, `lp' for lp system and `lpr' for
1306 all other systems. See also `pr-path-alist'.
1313 SWITCHES List of sexp's to pass as extra options for PostScript printer
1314 program. It is recommended to set NAME (see text below)
1315 instead of including an explicit switch on this list.
1321 PRINTER-SWITCH A string that specifies PostScript printer name switch. If
1322 it's necessary to have a space between PRINTER-SWITCH and NAME,
1323 it should be inserted at the end of PRINTER-SWITCH string.
1324 If PRINTER-SWITCH is nil, it's used the default printer name
1325 switch: `/D:' for Windows system, `-d' for lp system and `-P'
1326 for all other systems.
1337 NAME A string that specifies a PostScript printer name.
1338 On Unix-like systems, a string value should be a name
1339 understood by lpr's -P option (or lp's -d option).
1340 On MS-DOS and MS-Windows systems, it is the name of a printer
1341 device or port. Typical non-default settings would be \"LPT1:\"
1342 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1343 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1344 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1345 printer. You can also set it to a name of a file, in which
1346 case the output gets appended to that file. If you want to
1347 discard the printed output, set this to \"NUL\".
1350 \"\\\\\\\\host\\\\share-name\"
1353 \"/D:\\\\\\\\host\\\\share-name\"
1354 \"\\\\\\\\host\\\\share-name\"
1361 DEFAULT It's a way to set default values when this entry is selected.
1366 That associates VARIABLE with VALUE. when this entry is
1367 selected, it's executed the following command:
1369 (set VARIABLE (eval VALUE))
1371 Note that VALUE can be any valid lisp expression. So, don't
1372 forget to quote symbols and constant lists.
1373 If VARIABLE is the special keyword `inherits-from:', VALUE must
1374 be a symbol name setting defined in `pr-setting-database' from
1375 which the current setting inherits the context. Take care with
1376 circular inheritance.
1378 '(ps-landscape-mode . nil)
1379 '(ps-spool-duplex . t)
1380 '(pr-gs-device . (my-gs-device t))
1382 This variable should be modified by customization engine. If this variable is
1383 modified by other means (for example, a lisp function), use `pr-update-menus'
1384 function (see it for documentation) to update PostScript printer menu.
1388 * On GNU or Unix system:
1390 '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\")
1391 (lps_07c \"lpr\" nil nil \"lps_07c\")
1392 (lps_08c nil nil nil \"lps_08c\")
1395 * On Windows system:
1397 '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\")
1398 (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\")
1399 (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\")
1400 (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\")
1401 (LPT1 \"\" nil \"\" \"LPT1:\")
1402 (PRN \"\" nil \"\" \"PRN\")
1403 (standard \"redpr.exe\" nil \"\" \"\")
1407 :tag
"PostScript Printer"
1408 (symbol :tag
"Printer Symbol Name")
1409 (string :tag
"Printer Command")
1410 (repeat :tag
"Printer Switches"
1411 (sexp :tag
"Switch" :value
""))
1412 (choice :menu-tag
"Printer Name Switch"
1413 :tag
"Printer Name Switch"
1414 (const :tag
"None" nil
)
1416 (choice :menu-tag
"Printer Name"
1418 (const :tag
"None" nil
)
1421 :tag
"Default Value List"
1426 :menu-tag
"Variable"
1428 (const :tag
"Landscape" ps-landscape-mode
)
1429 (const :tag
"Print Header" ps-print-header
)
1430 (const :tag
"Print Header Frame" ps-print-header-frame
)
1431 (const :tag
"Line Number" ps-line-number
)
1432 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
1433 (const :tag
"Duplex" ps-spool-duplex
)
1434 (const :tag
"Tumble" ps-spool-tumble
)
1435 (const :tag
"Upside-Down" ps-print-upside-down
)
1436 (const :tag
"PS File Landscape" pr-file-landscape
)
1437 (const :tag
"PS File Duplex" pr-file-duplex
)
1438 (const :tag
"PS File Tumble" pr-file-tumble
)
1439 (const :tag
"Auto Region" pr-auto-region
)
1440 (const :tag
"Auto Mode" pr-auto-mode
)
1441 (const :tag
"Ghostscript Device" pr-gs-device
)
1442 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
1443 (const :tag
"inherits-from:" inherits-from
:)
1444 (variable :tag
"Other"))
1445 (sexp :tag
"Value")))
1447 :set
'pr-alist-custom-set
1451 (defcustom pr-temp-dir
1453 (if (boundp 'temporary-file-directory
)
1454 (symbol-value 'temporary-file-directory
)
1455 ;; hacked from `temporary-file-directory' variable in files.el
1456 (file-name-as-directory
1457 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
1458 (cond (ps-windows-system "c:/temp")
1459 ((memq system-type
'(vax-vms axp-vms
)) "SYS$SCRATCH:")
1462 "*Specify a directory for temporary files during printing."
1463 :type
'(directory :tag
"Temporary Directory")
1467 (defcustom pr-ps-temp-file
"prspool.ps"
1468 "*Specify PostScript temporary file name."
1469 :type
'(file :tag
"PostScript Temporary File Name")
1473 (defcustom pr-gv-command
1474 (if ps-windows-system
1477 "*Specify path and name of the gsview/gv utility.
1479 See also `pr-path-alist'."
1480 :type
'(string :tag
"Ghostview Utility")
1484 (defcustom pr-gs-command
1485 (if ps-windows-system
1488 "*Specify path and name of the ghostscript utility.
1490 See also `pr-path-alist'."
1491 :type
'(string :tag
"Ghostscript Utility")
1495 (defcustom pr-gs-switches
1496 (if ps-windows-system
1497 '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")
1498 '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
1499 "*Specify ghostscript switches. See the documentation on GS for more info.
1501 It's a list of strings, where each string is one or more ghostscript switches.
1503 A note on the gs switches:
1506 -dNOPAUSE don't wait for user intervention
1507 -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs
1508 -c quit it's added at the end to terminate gs
1510 To see ghostscript documentation for more information:
1512 * On GNU or Unix system:
1513 - for full documentation, type: man gs
1514 - for brief documentation, type: gs -h
1516 * On Windows system:
1517 - for full documentation, see in a browser the file
1518 c:/gstools/gs5.50/index.html, that is, the file index.html which is
1519 located in the same directory as gswin32.exe.
1520 - for brief documentation, type: gswin32.exe -h"
1521 :type
'(repeat (string :tag
"Ghostscript Switch"))
1525 (defcustom pr-gs-device
1526 (if ps-windows-system
1529 "*Specify the ghostscript device switch value (-sDEVICE=).
1531 A note on the gs switches:
1533 -sDEVICE=djet500 the printer - works with HP DeskJet 540
1535 See `pr-gs-switches' for documentation.
1536 See also `pr-ps-printer-alist'."
1537 :type
'(string :tag
"Ghostscript Device")
1541 (defcustom pr-gs-resolution
300
1542 "*Specify ghostscript resolution switch value (-r).
1544 A note on the gs switches:
1546 -r300 resolution 300x300
1548 See `pr-gs-switches' for documentation.
1549 See also `pr-ps-printer-alist'."
1550 :type
'(integer :tag
"Ghostscript Resolution")
1554 (defcustom pr-print-using-ghostscript nil
1555 "*Non-nil means print using ghostscript.
1557 This is useful if you don't have a PostScript printer, so you could use the
1558 ghostscript to print a PostScript file.
1560 In GNU or Unix system, if ghostscript is set as a PostScript filter, this
1561 variable should be nil."
1566 (defcustom pr-faces-p nil
1567 "*Non-nil means print with face attributes."
1572 (defcustom pr-spool-p nil
1573 "*Non-nil means spool printing in a buffer."
1578 (defcustom pr-file-landscape nil
1579 "*Non-nil means print PostScript file in landscape orientation."
1584 (defcustom pr-file-duplex nil
1585 "*Non-nil means print PostScript file in duplex mode."
1590 (defcustom pr-file-tumble nil
1591 "*Non-nil means print PostScript file in tumble mode.
1593 If tumble is off, produces a printing suitable for binding on the left or
1595 If tumble is on, produces a printing suitable for binding at the top or
1601 (defcustom pr-auto-region t
1602 "*Non-nil means region is automagically detected.
1604 Note that this will only work if you're using transient mark mode.
1606 When this variable is non-nil, the `*-buffer*' commands will behave like
1607 `*-region*' commands, that is, `*-buffer*' commands will print only the region
1608 marked instead of all buffer."
1613 (defcustom pr-auto-mode t
1614 "*Non-nil means major-mode specific printing is prefered over normal printing.
1616 That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
1617 and `*-region*' commands will behave like `*-mode*' commands; otherwise,
1618 `*-buffer*' commands will print the current buffer and `*-region*' commands
1619 will print the current region."
1624 (defcustom pr-mode-alist
1625 '((mh-folder-mode ; mh summary buffer
1626 pr-mh-lpr-1 pr-mh-print-1
1628 (ps-article-author ps-article-subject
)
1629 ("/pagenumberstring load" pr-article-date
)
1632 (mh-letter-mode ; mh letter buffer
1633 pr-mh-lpr-2 pr-mh-print-2
1635 (ps-article-author ps-article-subject
)
1636 ("/pagenumberstring load" pr-article-date
)
1639 (rmail-summary-mode ; rmail summary buffer
1640 pr-rmail-lpr pr-rmail-print
1642 (ps-article-subject ps-article-author buffer-name
)
1646 (rmail-mode ; rmail buffer
1647 pr-rmail-lpr pr-rmail-print
1649 (ps-article-subject ps-article-author buffer-name
)
1653 (gnus-summary-mode ; gnus summary buffer
1654 pr-gnus-lpr pr-gnus-print
1656 (ps-article-subject ps-article-author gnus-newsgroup-name
)
1660 (gnus-article-mode ; gnus article buffer
1661 pr-gnus-lpr pr-gnus-print
1663 (ps-article-subject ps-article-author gnus-newsgroup-name
)
1667 (Info-mode ; Info buffer
1668 pr-mode-lpr pr-mode-print
1670 (ps-info-node ps-info-file
)
1675 pr-vm-lpr pr-vm-print
1677 (ps-article-subject ps-article-author buffer-name
)
1682 "*Specify an alist for a major-mode and printing functions.
1684 To customize a major mode printing, just declare the customization in
1685 `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major
1686 mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the
1687 *Summary* buffer, if you forget to switch to the *Article* buffer before
1688 printing, you'll get a nicely formatted list of article subjects shows up at
1689 the printer. With major mode printing you don't need to switch from gnus
1690 *Summary* buffer first.
1692 The elements have the following form:
1704 MAJOR-MODE It's the major mode symbol.
1706 LPR-PRINT It's a symbol function for text printing. It's invoked with
1708 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
1710 Usually LPR-PRINT function prepares the environment or buffer
1711 and then call the function `pr-mode-lpr' which it's used to
1712 process the buffer and send it to text printer.
1714 The `pr-mode-lpr' definition is:
1716 (pr-mode-lpr HEADER-LIST &optional FROM TO)
1718 Where HEADER-LIST is like the argument passed to LPR-PRINT.
1719 FROM and TO are the beginning and end markers, respectively,
1720 for a region. If FROM is nil, it's used (point-min); if TO is
1721 nil, it's used (point-max).
1723 PS-PRINT It's a symbol function for PostScript printing. It's invoked
1724 with 3 arguments: n-up printing, file name and the list:
1725 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
1727 Usually PS-PRINT function prepares the environment or buffer
1728 and then call the function `pr-mode-print' which it's used to
1729 process the buffer and send it to PostScript printer.
1731 The `pr-mode-print' definition is:
1733 (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO)
1735 Where N-UP, FILENAME and HEADER-LIST are like the arguments
1736 passed to PS-PRINT. FROM and TO are the beginning and end
1737 markers, respectively, for a region. If TO is nil, it's used
1740 HEADER-LINES It's the number of header lines; if is nil, it uses
1741 `ps-header-lines' value.
1743 LEFT-HEADER It's the left header part, it's a list of string, variable
1744 symbol or function symbol (with no argument); if is nil, it
1745 uses `ps-left-header' value.
1747 RIGHT-HEADER It's the right header part, it's a list of string, variable
1748 symbol or function symbol (with no argument); if is nil, it
1749 uses `ps-right-header' value.
1752 Non-nil means to kill all buffer local variable declared in
1753 DEFAULT (see below).
1755 DEFAULT It's a way to set default values when this entry is selected.
1758 (VARIABLE-SYM . VALUE)
1760 That associates VARIABLE-SYM with VALUE. when this entry is
1761 selected, it's executed the following command:
1763 (set (make-local-variable VARIABLE-SYM) (eval VALUE))
1765 Note that VALUE can be any valid lisp expression. So, don't
1766 forget to quote symbols and constant lists.
1767 If VARIABLE is the special keyword `inherits-from:', VALUE must
1768 be a symbol name setting defined in `pr-setting-database' from
1769 which the current setting inherits the context. Take care with
1770 circular inheritance.
1772 '(ps-landscape-mode . nil)
1773 '(ps-spool-duplex . t)
1774 '(pr-gs-device . (my-gs-device t))"
1778 (symbol :tag
"Major Mode")
1779 (function :tag
"Text Printing Function")
1780 (function :tag
"PS Printing Function")
1781 (choice :menu-tag
"Number of Header Lines"
1782 :tag
"Number of Header Lines"
1783 (integer :tag
"Number")
1784 (const :tag
"Default Number" nil
))
1785 (repeat :tag
"Left Header List"
1786 (choice :menu-tag
"Left Header"
1789 (repeat :tag
"Right Header List"
1790 (choice :menu-tag
"Right Header"
1793 (boolean :tag
"Kill Local Variable At End")
1795 :tag
"Default Value List"
1800 :menu-tag
"Variable"
1802 (const :tag
"Landscape" ps-landscape-mode
)
1803 (const :tag
"Print Header" ps-print-header
)
1804 (const :tag
"Print Header Frame" ps-print-header-frame
)
1805 (const :tag
"Line Number" ps-line-number
)
1806 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
1807 (const :tag
"Duplex" ps-spool-duplex
)
1808 (const :tag
"Tumble" ps-spool-tumble
)
1809 (const :tag
"Upside-Down" ps-print-upside-down
)
1810 (const :tag
"PS File Landscape" pr-file-landscape
)
1811 (const :tag
"PS File Duplex" pr-file-duplex
)
1812 (const :tag
"PS File Tumble" pr-file-tumble
)
1813 (const :tag
"Auto Region" pr-auto-region
)
1814 (const :tag
"Auto Mode" pr-auto-mode
)
1815 (const :tag
"Ghostscript Device" pr-gs-device
)
1816 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
1817 (const :tag
"inherits-from:" inherits-from
:)
1818 (variable :tag
"Other"))
1819 (sexp :tag
"Value")))
1824 (defcustom pr-ps-utility
'mpage
1825 "*Specify PostScript utility symbol.
1827 This utility symbol should be defined on `pr-ps-utility-alist' (see it for
1830 This variable should be modified by customization engine. If this variable is
1831 modified by other means (for example, a lisp function), use `pr-update-menus'
1832 function (see it for documentation) to update PostScript utility menu.
1834 NOTE: Don't forget to download and install the utilities declared on
1835 `pr-ps-utility-alist'."
1836 :type
'(symbol :tag
"PS File Utility")
1837 :set
'pr-ps-utility-custom-set
1841 (defcustom pr-ps-utility-alist
1842 '((mpage "mpage" nil
"-b%s" "-%d" "-l" "-t" "-T" ">" nil
)
1843 (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil
" " nil
1844 (inherits-from: . no-duplex
))
1847 ;; * On GNU or Unix system:
1848 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
1849 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
1850 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
1852 ;; * On Windows system:
1853 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
1854 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
1856 "*Specify an alist for PostScript utility processing (PS utility database).
1858 The alist element has the form:
1860 (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT
1861 SWITCHES DEFAULT...)
1865 SYMBOL It's a symbol to identify a PostScript utility. It's for
1866 `pr-ps-utility' variable setting and for menu selection.
1871 UTILITY Name of utility for processing a PostScript file.
1872 See also `pr-path-alist'.
1874 . for GNU or Unix system:
1878 . for Windows system:
1879 \"c:/psutils/psnup -q\"
1881 MUST-SWITCHES List of sexp's to pass as options to the PostScript utility
1882 program. These options are necessary to process the utility
1883 program and must be placed before any other switches.
1888 PAPERSIZE It's a format string to specify paper size switch.
1893 N-UP It's a format string to specify n-up switch.
1898 LANDSCAPE It's a string to specify landscape switch. If the utility
1899 doesn't have landscape switch, set to nil.
1904 DUPLEX It's a string to specify duplex switch. If the utility doesn't
1905 have duplex switch, set to nil.
1910 TUMBLE It's a string to specify tumble switch. If the utility doesn't
1911 have tumble switch, set to nil.
1916 OUTPUT It's a string to specify how to generate an output file. Some
1917 utilities accept an output file option, but some others need
1918 output redirection or some other way to specify an output file.
1921 \" \" ; psnup ... input output
1924 \">\" ; mpage ... input > output
1926 SWITCHES List of sexp's to pass as extra options to the PostScript utility
1933 DEFAULT It's a way to set default values when this entry is selected.
1938 That associates VARIABLE with VALUE. when this entry is
1939 selected, it's executed the following command:
1941 (set VARIABLE (eval VALUE))
1943 Note that VALUE can be any valid lisp expression. So, don't
1944 forget to quote symbols and constant lists.
1945 If VARIABLE is the special keyword `inherits-from:', VALUE must
1946 be a symbol name setting defined in `pr-setting-database' from
1947 which the current setting inherits the context. Take care with
1948 circular inheritance.
1950 '(pr-file-landscape . nil)
1951 '(pr-file-duplex . t)
1952 '(pr-gs-device . (my-gs-device t))
1954 This variable should be modified by customization engine. If this variable is
1955 modified by other means (for example, a lisp function), use `pr-update-menus'
1956 function (see it for documentation) to update PostScript utility menu.
1958 NOTE: Don't forget to download and install the utilities declared on
1959 `pr-ps-utility-alist'.
1963 * On GNU or Unix system:
1965 '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil)
1966 (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil
1967 (pr-file-duplex . nil) (pr-file-tumble . nil))
1970 * On Windows system:
1972 '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \"
1973 nil (pr-file-duplex . nil) (pr-file-tumble . nil))
1976 (list :tag
"PS File Utility"
1977 (symbol :tag
"Utility Symbol")
1978 (string :tag
"Utility Name")
1979 (repeat :tag
"Must Utility Switches"
1980 (sexp :tag
"Switch" :value
""))
1981 (choice :menu-tag
"Paper Size"
1983 (const :tag
"No Paper Size" nil
)
1984 (string :tag
"Paper Size Format"))
1985 (choice :menu-tag
"N-Up"
1987 (const :tag
"No N-Up" nil
)
1988 (string :tag
"N-Up Format"))
1989 (choice :menu-tag
"Landscape"
1991 (const :tag
"No Landscape" nil
)
1992 (string :tag
"Landscape Switch"))
1993 (choice :menu-tag
"Duplex"
1995 (const :tag
"No Duplex" nil
)
1996 (string :tag
"Duplex Switch"))
1997 (choice :menu-tag
"Tumble"
1999 (const :tag
"No Tumble" nil
)
2000 (string :tag
"Tumble Switch"))
2001 (string :tag
"Output Separator")
2002 (repeat :tag
"Utility Switches"
2003 (sexp :tag
"Switch" :value
""))
2005 :tag
"Default Value List"
2010 :menu-tag
"Variable"
2012 (const :tag
"PS File Landscape" pr-file-landscape
)
2013 (const :tag
"PS File Duplex" pr-file-duplex
)
2014 (const :tag
"PS File Tumble" pr-file-tumble
)
2015 (const :tag
"Ghostscript Device" pr-gs-device
)
2016 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2017 (const :tag
"inherits-from:" inherits-from
:)
2018 (variable :tag
"Other"))
2019 (sexp :tag
"Value")))
2021 :set
'pr-alist-custom-set
2025 (defcustom pr-menu-lock t
2026 "*Non-nil means menu is locked while selecting toggle options.
2028 See also `pr-menu-char-height' and `pr-menu-char-width'."
2033 (defcustom pr-menu-char-height
2034 (cond ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2035 (pr-e-frame-char-height))
2036 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2037 (pr-x-font-height (face-font 'default
))))
2038 "*Specify menu char height in pixels.
2040 This variable is used to guess which vertical position should be locked the
2041 menu, so don't forget to adjust it if menu position is not ok.
2043 See also `pr-menu-lock' and `pr-menu-char-width'."
2048 (defcustom pr-menu-char-width
2049 (cond ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2050 (pr-e-frame-char-width))
2051 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2052 (pr-x-font-width (face-font 'default
))))
2053 "*Specify menu char width in pixels.
2055 This variable is used to guess which horizontal position should be locked the
2056 menu, so don't forget to adjust it if menu position is not ok.
2058 See also `pr-menu-lock' and `pr-menu-char-height'."
2063 (defcustom pr-setting-database
2064 '((no-duplex ; setting symbol name
2065 nil nil nil
; inherits local kill-local
2066 (pr-file-duplex . nil
) ; settings
2067 (pr-file-tumble . nil
))
2069 "*Specify an alist for settings in general.
2071 The elements have the following form:
2073 (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...)
2077 SYMBOL It's a symbol to identify the setting group.
2079 INHERITS Specify the inheritance for SYMBOL group. It's a symbol name
2080 setting from which the current setting inherits the context.
2081 If INHERITS is nil, means that there is no inheritance.
2082 This is a simple inheritance mechanism.
2084 Let's see an example to illustrate the inheritance mechanism:
2086 (setq pr-setting-database
2087 '((no-duplex ; setting symbol name
2089 nil nil ; local kill-local
2090 (pr-file-duplex . nil) ; settings
2091 (pr-file-tumble . nil)
2093 (no-duplex-and-landscape ; setting symbol name
2094 no-duplex ; inherits
2095 nil nil ; local kill-local
2096 (pr-file-landscape . nil) ; settings
2099 The example above has two setting groups: no-duplex and
2100 no-duplex-and-landscape. When setting no-duplex is activated
2101 through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist'
2102 and `pr-ps-printer-alist'), the variables pr-file-duplex and
2103 pr-file-tumble are both set to nil.
2105 Now when setting no-duplex-and-landscape is activated through
2106 `inherits-from:', the variable pr-file-landscape is set to nil
2107 and also the settings for no-duplex are done, because
2108 no-duplex-and-landscape inherits settings from no-duplex.
2110 Take care with circular inheritance. It's an error if circular
2111 inheritance happens.
2113 LOCAL Non-nil means that all settings for SYMBOL group will be
2114 declared local buffer.
2116 KILL-LOCAL Non-nil means that all settings for SYMBOL group will be
2117 killed at end. It has effect only when LOCAL is non-nil.
2119 SETTING It's a cons like:
2123 That associates VARIABLE with VALUE. when this entry is
2124 selected, it's executed the following command:
2126 * If LOCAL is non-nil:
2127 (set (make-local-variable VARIABLE) (eval VALUE))
2130 (set VARIABLE (eval VALUE))
2132 Note that VALUE can be any valid lisp expression. So, don't
2133 forget to quote symbols and constant lists.
2134 This setting is ignored if VARIABLE is equal to keyword
2137 '(ps-landscape-mode . nil)
2138 '(ps-spool-duplex . t)
2139 '(pr-gs-device . (my-gs-device t))"
2143 (symbol :tag
"Setting Name")
2144 (choice :menu-tag
"Inheritance"
2146 (const :tag
"No Inheritance" nil
)
2147 (symbol :tag
"Inherits From"))
2148 (boolean :tag
"Local Buffer Setting")
2149 (boolean :tag
"Kill Local Variable At End")
2156 :menu-tag
"Variable"
2158 (const :tag
"Landscape" ps-landscape-mode
)
2159 (const :tag
"Print Header" ps-print-header
)
2160 (const :tag
"Print Header Frame" ps-print-header-frame
)
2161 (const :tag
"Line Number" ps-line-number
)
2162 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2163 (const :tag
"Duplex" ps-spool-duplex
)
2164 (const :tag
"Tumble" ps-spool-tumble
)
2165 (const :tag
"Upside-Down" ps-print-upside-down
)
2166 (const :tag
"PS File Landscape" pr-file-landscape
)
2167 (const :tag
"PS File Duplex" pr-file-duplex
)
2168 (const :tag
"PS File Tumble" pr-file-tumble
)
2169 (const :tag
"Auto Region" pr-auto-region
)
2170 (const :tag
"Auto Mode" pr-auto-mode
)
2171 (const :tag
"Ghostscript Device" pr-gs-device
)
2172 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2173 (variable :tag
"Other"))
2174 (sexp :tag
"Value")))
2179 (defcustom pr-visible-entry-list
2180 '(postscript text postscript-options postscript-process printing help
)
2181 "*Specify a list of Printing menu visible entries.
2183 Valid values with the corresponding menu parts are:
2185 +------------------------------+
2186 | Printing Interface |
2187 +------------------------------+
2188 `postscript' | PostScript Preview >|
2189 | PostScript Print >|
2190 | PostScript Printer: name >|
2191 +------------------------------+
2192 `text' | Printify >|
2194 | Text Printer: name >|
2195 +------------------------------+
2196 `postscript-options' |[ ] Landscape |
2198 |[ ] Print Header Frame |
2200 |[ ] Zebra Stripes |
2204 | Print All Pages >|
2205 +------------------------------+
2206 `postscript-process' |[ ] Spool Buffer |
2207 |[ ] Print with faces |
2208 |[ ] Print via Ghostscript |
2209 +------------------------------+
2210 `printing' |[ ] Auto Region |
2213 +------------------------------+
2214 `help' | Customize >|
2217 +------------------------------+
2219 Any other value is ignored."
2220 :type
'(repeat :tag
"Menu Visible Part"
2221 (choice :menu-tag
"Menu Part"
2225 (const postscript-options
)
2226 (const postscript-process
)
2232 (defcustom pr-delete-temp-file t
2233 "*Non-nil means delete temporary files.
2235 Set `pr-delete-temp-file' to nil, if the following message (or a similar)
2236 happens when printing:
2238 Error: could not open \"c:\\temp\\prspool.ps\" for reading."
2243 (defcustom pr-list-directory nil
2244 "*Non-nil means list directory when processing a directory.
2246 That is, any subdirectories (and the superdirectory) of the directory (given as
2247 argument of functions below) are also printed (as dired-mode listings).
2249 It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
2250 `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
2251 and `pr-txt-directory'."
2256 (defcustom pr-buffer-name
"*Printing Interface*"
2257 "*Specify the name of the buffer interface for printing package.
2259 It's used by `pr-interface'."
2264 (defcustom pr-buffer-name-ignore
2265 (list (regexp-quote pr-buffer-name
) ; ignore printing interface buffer
2266 "^ .*$") ; ignore invisible buffers
2267 "*Specify a regexp list for buffer names to be ignored in interface buffer.
2269 NOTE: Case is important for matching, that is, `case-fold-search' is always
2272 It's used by `pr-interface'."
2273 :type
'(repeat (regexp :tag
"Buffer Name Regexp"))
2277 (defcustom pr-buffer-verbose t
2278 "*Non-nil means to be verbose when editing a field in interface buffer.
2280 It's used by `pr-interface'."
2285 (defcustom pr-shell-file-name
2286 (if (eq pr-path-style
'windows
)
2289 "*Specify file name to load inferior shells from."
2294 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2295 ;; Internal Variables
2298 (defvar pr-txt-command nil
2299 "Name of program for printing a text file.
2300 See `pr-txt-printer-alist'.")
2303 (defvar pr-txt-switches nil
2304 "List of sexp's to pass as extra options to the text printer program.
2305 See `pr-txt-printer-alist'.")
2308 (defvar pr-txt-printer nil
2309 "Specify text printer name.
2310 See `pr-txt-printer-alist'.")
2313 (defvar pr-ps-command nil
2314 "Name of program for printing a PostScript file.
2315 See `pr-ps-printer-alist'.")
2318 (defvar pr-ps-switches nil
2319 "List of sexp's to pass as extra options to the PostScript printer program.
2320 See `pr-ps-printer-alist'.")
2323 (defvar pr-ps-printer-switch nil
2324 "Specify PostScript printer name switch.
2325 See `pr-ps-printer-alist'.")
2328 (defvar pr-ps-printer nil
2329 "Specify PostScript printer name.
2330 See `pr-ps-printer-alist'.")
2333 (defvar pr-menu-bar nil
2334 "Specify Printing menu-bar entry.")
2337 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2341 (defmacro pr-xemacs-global-menubar
(&rest body
)
2343 (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
2344 ;; be sure to access global menubar
2347 (kill-buffer temp
))))
2350 (defsubst pr-visible-p
(key)
2351 (memq key pr-visible-entry-list
))
2354 (defsubst pr-mode-alist-p
()
2355 (cdr (assq major-mode pr-mode-alist
)))
2358 (defsubst pr-auto-mode-p
()
2359 (and pr-auto-mode
(pr-mode-alist-p)))
2362 (defsubst pr-using-ghostscript-p
()
2363 (and pr-print-using-ghostscript
(not pr-spool-p
)))
2367 (defun pr-get-symbol (name)
2368 ;; Recent versions of easy-menu downcase names before interning them.
2369 (and (fboundp 'easy-menu-name-match
)
2370 (setq name
(downcase name
)))
2371 (or (intern-soft name
)
2372 (make-symbol name
)))
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 ["No Preprocessing..." (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 ["No Preprocessing..." (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 via 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 ["No Preprocessing..." (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 ["No Preprocessing..." (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 via 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| | No Prep... | 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 via 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 *No Preprocessing*, that is, send it
2927 directly to PostScript printer.
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 it to
2951 the printer. To spool the PostScript code generated you need to turn on
2952 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 open 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 open 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 via 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, the current buffer is used for printing.
3301 For more information, 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= 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 the `printing' group."
4015 (customize-group 'printing))
4019 (defun lpr-customize (&rest ignore)
4020 "Customization of the `lpr' group."
4022 (customize-group 'lpr))
4026 (defun pr-help (&rest ignore)
4027 "Help for the printing package."
4029 (pr-show-setup pr-help-message "*Printing Help*"))
4033 (defun pr-ps-name ()
4034 "Interactively select 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 "Interactively select 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 "Interactively select 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)))))))
4532 (defvar pr-menu-position nil)
4533 (defvar pr-menu-state nil)
4538 ((eq ps-print-emacs-type 'xemacs)
4540 (defun pr-menu-position (entry index horizontal)
4544 'x (- (pr-x-event-x-pixel current-mouse-event) ; X
4545 (* horizontal pr-menu-char-width))
4546 'y (- (pr-x-event-y-pixel current-mouse-event) ; Y
4547 (* (pr-menu-index entry index) pr-menu-char-height)))))
4550 ;; GNU Emacs for Windows 9x/NT
4551 (defun pr-menu-position (entry index horizontal)
4552 (let ((pos (cdr (pr-e-mouse-pixel-position))))
4556 (* (pr-menu-index entry index) pr-menu-char-height)))
4557 (selected-frame)))) ; frame
4561 (defun pr-menu-position (entry index horizontal)
4562 (let ((pos (cdr (pr-e-mouse-pixel-position))))
4564 (list (- (car pos) ; X
4565 (* horizontal pr-menu-char-width))
4567 (* (pr-menu-index entry index) pr-menu-char-height)))
4568 (selected-frame)))) ; frame
4572 ((eq ps-print-emacs-type 'emacs)
4574 (defun pr-menu-lookup (path)
4575 (let ((ipath pr-menu-bar))
4576 (lookup-key global-map
4579 (mapcar 'pr-get-symbol
4586 (defun pr-menu-lock (entry index horizontal state path)
4587 (when (and (not (interactive-p)) pr-menu-lock)
4588 (or (and pr-menu-position (eq state pr-menu-state))
4589 (setq pr-menu-position (pr-menu-position entry index horizontal)
4590 pr-menu-state state))
4591 (let* ((menu (pr-menu-lookup path))
4592 (result (x-popup-menu pr-menu-position menu)))
4594 (let ((command (lookup-key menu (vconcat result))))
4595 (if (fboundp command)
4598 (setq pr-menu-position nil))))
4601 ((eq ps-print-emacs-type 'xemacs)
4603 (defun pr-menu-lookup (path)
4604 (car (pr-x-find-menu-item current-menubar (cons "Printing" path))))
4607 (defun pr-menu-lock (entry index horizontal state path)
4608 (when (and (not (interactive-p)) pr-menu-lock)
4609 (or (and pr-menu-position (eq state pr-menu-state))
4610 (setq pr-menu-position (pr-menu-position entry index horizontal)
4611 pr-menu-state state))
4612 (let* ((menu (pr-menu-lookup path))
4613 (result (pr-x-get-popup-menu-response menu pr-menu-position)))
4614 (and (pr-x-misc-user-event-p result)
4615 (funcall (pr-x-event-function result)
4616 (pr-x-event-object result))))
4617 (setq pr-menu-position nil))))))
4620 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4621 ;; Printer & Utility Selection
4624 (defun pr-update-var (var-sym alist)
4625 (or (assq (symbol-value var-sym) alist)
4626 (set var-sym (car (car alist)))))
4629 (defun pr-update-menus (&optional force)
4630 "Update utility, PostScript and text printer menus.
4632 If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist',
4633 `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not;
4634 otherwise, update PostScript printer menu iff `pr-ps-printer-menu-modified' is
4635 non-nil, update text printer menu iff `pr-txt-printer-menu-modified' is
4636 non-nil, and update PostScript File menus iff `pr-ps-utility-menu-modified' is
4639 (pr-update-var 'pr-ps-name pr-ps-printer-alist)
4640 (pr-update-var 'pr-txt-name pr-txt-printer-alist)
4641 (pr-update-var 'pr-ps-utility pr-ps-utility-alist)
4642 (pr-do-update-menus force))
4645 (defvar pr-ps-printer-menu-modified t
4646 "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.")
4647 (defvar pr-txt-printer-menu-modified t
4648 "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.")
4649 (defvar pr-ps-utility-menu-modified t
4650 "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.")
4653 (defconst pr-even-or-odd-alist
4654 '((nil . "Print All Pages")
4655 (even-page . "Print Even Pages")
4656 (odd-page . "Print Odd Pages")
4657 (even-sheet . "Print Even Sheets")
4658 (odd-sheet . "Print Odd Sheets")))
4661 (defun pr-menu-create (name alist var-sym fun entry index)
4665 (let ((sym (car elt)))
4668 (list fun (list 'quote sym) nil (list 'quote entry) index)
4670 :selected (list 'eq var-sym (list 'quote sym)))))
4676 ((eq ps-print-emacs-type 'emacs)
4678 (defalias 'pr-update-mode-line 'force-mode-line-update)
4681 (defun pr-do-update-menus (&optional force)
4682 (pr-menu-alist pr-ps-printer-alist
4684 'pr-menu-set-ps-title
4685 "PostScript Printers"
4686 'pr-ps-printer-menu-modified
4688 "PostScript Printers"
4690 (pr-menu-alist pr-txt-printer-alist
4692 'pr-menu-set-txt-title
4694 'pr-txt-printer-menu-modified
4698 (let ((save-var pr-ps-utility-menu-modified))
4699 (pr-menu-alist pr-ps-utility-alist
4701 'pr-menu-set-utility-title
4702 '("PostScript Print" "File" "PostScript Utility")
4705 "PostScript Utility"
4707 (pr-menu-alist pr-ps-utility-alist
4709 'pr-menu-set-utility-title
4710 '("PostScript Preview" "File" "PostScript Utility")
4711 'pr-ps-utility-menu-modified
4713 "PostScript Utility"
4715 (pr-even-or-odd-pages ps-even-or-odd-pages force))
4718 (defvar pr-temp-menu nil)
4721 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
4723 (when (and alist (or force (symbol-value modified-sym)))
4724 (easy-menu-define pr-temp-menu nil ""
4725 (pr-menu-create name alist var-sym fun entry index))
4726 (let ((item (pr-menu-get-item menu-path)))
4728 (let* ((binding (nthcdr 3 item))
4729 (key-binding (cdr binding)))
4730 (setcar binding pr-temp-menu)
4731 (and key-binding (listp (car key-binding))
4732 (setcdr binding (cdr key-binding))) ; skip KEY-BINDING
4733 (funcall fun (symbol-value var-sym) item))))
4734 (set modified-sym nil)))
4737 (defun pr-menu-set-ps-title (value &optional item entry index)
4738 (pr-menu-set-item-name (or item
4739 (pr-menu-get-item "PostScript Printers"))
4740 (format "PostScript Printer: %s" value))
4741 (pr-ps-set-printer value)
4743 (pr-menu-lock entry index 12 'toggle nil)))
4746 (defun pr-menu-set-txt-title (value &optional item entry index)
4747 (pr-menu-set-item-name (or item
4748 (pr-menu-get-item "Text Printers"))
4749 (format "Text Printer: %s" value))
4750 (pr-txt-set-printer value)
4752 (pr-menu-lock entry index 12 'toggle nil)))
4755 (defun pr-menu-set-utility-title (value &optional item entry index)
4756 (let ((name (symbol-name value)))
4758 (pr-menu-set-item-name item name)
4759 (pr-menu-set-item-name
4761 '("PostScript Print" "File" "PostScript Utility"))
4763 (pr-menu-set-item-name
4765 '("PostScript Preview" "File" "PostScript Utility"))
4767 (pr-ps-set-utility value)
4769 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
4772 (defun pr-even-or-odd-pages (value &optional no-lock)
4773 (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
4774 (cdr (assq value pr-even-or-odd-alist)))
4775 (setq ps-even-or-odd-pages value)
4777 (pr-menu-lock 'postscript-options 8 12 'toggle nil))))
4780 ((eq ps-print-emacs-type 'xemacs)
4782 (defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
4785 (defvar pr-ps-name-old "PostScript Printers")
4786 (defvar pr-txt-name-old "Text Printers")
4787 (defvar pr-ps-utility-old "PostScript Utility")
4788 (defvar pr-even-or-odd-old "Print All Pages")
4791 (defun pr-do-update-menus (&optional force)
4792 (pr-menu-alist pr-ps-printer-alist
4794 'pr-menu-set-ps-title
4796 'pr-ps-printer-menu-modified
4800 (pr-menu-alist pr-txt-printer-alist
4802 'pr-menu-set-txt-title
4804 'pr-txt-printer-menu-modified
4808 (let ((save-var pr-ps-utility-menu-modified))
4809 (pr-menu-alist pr-ps-utility-alist
4811 'pr-menu-set-utility-title
4812 '("Printing" "PostScript Print" "File")
4817 (pr-menu-alist pr-ps-utility-alist
4819 'pr-menu-set-utility-title
4820 '("Printing" "PostScript Preview" "File")
4821 'pr-ps-utility-menu-modified
4825 (pr-even-or-odd-pages ps-even-or-odd-pages force))
4828 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
4830 (when (and alist (or force (symbol-value modified-sym)))
4831 (pr-xemacs-global-menubar
4832 (pr-x-add-submenu menu-path
4833 (pr-menu-create name alist var-sym
4835 (funcall fun (symbol-value var-sym))
4836 (set modified-sym nil)))
4839 (defun pr-menu-set-ps-title (value &optional item entry index)
4840 (pr-relabel-menu-item (format "PostScript Printer: %s" value)
4842 (pr-ps-set-printer value)
4844 (pr-menu-lock entry index 12 'toggle nil)))
4847 (defun pr-menu-set-txt-title (value &optional item entry index)
4848 (pr-relabel-menu-item (format "Text Printer: %s" value)
4850 (pr-txt-set-printer value)
4852 (pr-menu-lock entry index 12 'toggle nil)))
4855 (defun pr-menu-set-utility-title (value &optional item entry index)
4856 (pr-xemacs-global-menubar
4857 (let ((newname (format "%s" value)))
4858 (pr-x-relabel-menu-item
4859 (list "Printing" "PostScript Print" "File" pr-ps-utility-old)
4861 (pr-x-relabel-menu-item
4862 (list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
4864 (setq pr-ps-utility-old newname)))
4865 (pr-ps-set-utility value)
4867 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
4870 (defun pr-even-or-odd-pages (value &optional no-lock)
4871 (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
4872 'pr-even-or-odd-old)
4873 (setq ps-even-or-odd-pages value)
4875 (pr-menu-lock 'postscript-options 8 12 'toggle nil))))))
4878 (defun pr-relabel-menu-item (newname var-sym)
4879 (pr-xemacs-global-menubar
4880 (pr-x-relabel-menu-item
4881 (list "Printing" (symbol-value var-sym))
4883 (set var-sym newname)))
4886 (defun pr-menu-set-item-name (item name)
4888 (setcar (nthcdr 2 item) name))) ; ITEM-NAME
4891 (defun pr-menu-get-item (name-list)
4892 ;; NAME-LIST is a string or a list of strings.
4893 (let ((ipath pr-menu-bar)
4894 (len (and (listp name-list) (length name-list))))
4896 (setq name-list (car name-list)))
4902 ;; list and (length list) > 1
4903 (let* ((copy (copy-sequence name-list))
4904 (name (pr-get-symbol (nth (1- len) copy)))
4906 (setcdr (nthcdr (- len 2) copy) nil)
4912 (mapcar 'pr-get-symbol path))
4914 (assq name (nthcdr 2 menu))))
4917 (let ((name (pr-get-symbol name-list))
4918 (menu (lookup-key global-map ipath)))
4919 (assq name (nthcdr 2 menu)))))))
4922 (defun pr-ps-set-utility (value)
4923 (let ((item (cdr (assq value pr-ps-utility-alist))))
4926 "Invalid PostScript utility name `%s' for variable `pr-ps-utility'."
4928 (setq pr-ps-utility value)
4929 (pr-eval-alist (nthcdr 9 item)))
4930 (pr-update-mode-line))
4933 (defun pr-ps-set-printer (value)
4934 (let ((ps (cdr (assq value pr-ps-printer-alist))))
4937 "Invalid PostScript printer name `%s' for variable `pr-ps-name'."
4939 (setq pr-ps-name value
4940 pr-ps-command (pr-dosify-path (nth 0 ps))
4941 pr-ps-switches (nth 1 ps)
4942 pr-ps-printer-switch (nth 2 ps)
4943 pr-ps-printer (pr-dosify-path (nth 3 ps)))
4944 (or (stringp pr-ps-command)
4946 (cond (ps-windows-system "print")
4950 (or (stringp pr-ps-printer-switch)
4951 (setq pr-ps-printer-switch
4952 (cond (ps-windows-system "/D:")
4956 (pr-eval-alist (nthcdr 4 ps)))
4957 (pr-update-mode-line))
4960 (defun pr-txt-set-printer (value)
4961 (let ((txt (cdr (assq value pr-txt-printer-alist))))
4963 (error "Invalid text printer name `%s' for variable `pr-txt-name'."
4965 (setq pr-txt-name value
4966 pr-txt-command (pr-dosify-path (nth 0 txt))
4967 pr-txt-switches (nth 1 txt)
4968 pr-txt-printer (pr-dosify-path (nth 2 txt))))
4969 (or (stringp pr-txt-command)
4970 (setq pr-txt-command
4971 (cond (ps-windows-system "print")
4975 (pr-update-mode-line))
4978 (defun pr-eval-alist (alist)
4979 (mapcar #'(lambda (option)
4980 (let ((var-sym (car option))
4981 (value (cdr option)))
4982 (if (eq var-sym 'inherits-from:)
4983 (pr-eval-setting-alist value 'global)
4984 (set var-sym (eval value)))))
4988 (defun pr-eval-local-alist (alist)
4990 (mapcar #'(lambda (option)
4991 (let ((var-sym (car option))
4992 (value (cdr option)))
4994 (if (eq var-sym 'inherits-from:)
4995 (nconc (pr-eval-setting-alist value) local-list)
4996 (set (make-local-variable var-sym) (eval value))
4997 (cons var-sym local-list)))))
5002 (defun pr-eval-setting-alist (key &optional global old)
5003 (let ((setting (cdr (assq key pr-setting-database))))
5005 (let ((inherits (nth 0 setting))
5006 (local (nth 1 setting))
5007 (kill (nth 2 setting))
5012 (message "There are local buffer settings for `%S'." key)
5015 (if (memq inherits old)
5016 (error "Circular inheritance for `%S'." inherits)
5018 (pr-eval-setting-alist inherits global
5019 (cons inherits old)))))
5021 (cond ((not local) ; global settings
5023 (let ((var-sym (car option)))
5024 (or (eq var-sym 'inherits-from:)
5025 (set var-sym (eval (cdr option)))))))
5026 (kill ; local settings with killing
5028 (let ((var-sym (car option)))
5029 (unless (eq var-sym 'inherits-from:)
5030 (setq local-list (cons var-sym local-list))
5031 (set (make-local-variable var-sym)
5032 (eval (cdr option)))))))
5033 (t ; local settings without killing
5035 (let ((var-sym (car option)))
5036 (or (eq var-sym 'inherits-from:)
5037 (set (make-local-variable var-sym)
5038 (eval (cdr option))))))))
5043 (defun pr-kill-local-variable (local-var-list)
5044 (mapcar 'kill-local-variable local-var-list))
5047 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5048 ;; Internal Functions (II)
5051 (defun pr-prompt (str)
5052 (if (pr-auto-mode-p)
5053 (concat str " mode")
5054 (pr-region-active-string str)))
5057 (defun pr-prompt-region (str)
5058 (concat str (if (pr-auto-mode-p)
5063 (defun pr-prompt-gs (str)
5064 (if (pr-using-ghostscript-p)
5069 (defun pr-region-active-symbol (&optional region-p)
5070 (if (or region-p (pr-region-active-p))
5075 (defun pr-region-active-string (prefix)
5077 (if (pr-region-active-p)
5082 (defun pr-show-setup (settings buffer-name)
5083 (with-output-to-temp-buffer buffer-name
5085 (print-help-return-message)))
5088 (defun pr-complete-alist (prompt alist default)
5089 (let ((collection (mapcar #'(lambda (elt)
5090 (setq elt (car elt))
5091 (cons (symbol-name elt) elt))
5093 (cdr (assoc (completing-read (concat prompt ": ")
5095 (symbol-name default) nil
5096 (symbol-name default))
5100 (defun pr-delete-file (file)
5101 (and pr-delete-temp-file (delete-file file)))
5104 (defun pr-expand-file-name (filename)
5105 (pr-dosify-path (expand-file-name filename)))
5108 (defun pr-ps-outfile-preprint (&optional mess)
5109 (let* ((prompt (format "%soutput PostScript file name: " (or mess "")))
5110 (res (read-file-name prompt default-directory "" nil)))
5111 (while (cond ((not (file-writable-p res))
5113 (setq prompt "is unwritable"))
5114 ((file-directory-p res)
5116 (setq prompt "is a directory"))
5117 ((file-exists-p res)
5119 (setq prompt "exists")
5120 (not (y-or-n-p (format "File `%s' exists; overwrite? "
5123 (setq res (read-file-name
5124 (format "File %s; PostScript file: " prompt)
5125 (file-name-directory res) nil nil
5126 (file-name-nondirectory res))))
5127 (pr-expand-file-name res)))
5130 (defun pr-ps-infile-preprint (&optional mess)
5131 (let* ((prompt (format "%sinput PostScript file name: " (or mess "")))
5132 (res (read-file-name prompt default-directory "" nil)))
5133 (while (cond ((not (file-exists-p res))
5135 (setq prompt "doesn't exist"))
5136 ((not (file-readable-p res))
5138 (setq prompt "is unreadable"))
5139 ((file-directory-p res)
5141 (setq prompt "is a directory"))
5143 (setq res (read-file-name
5144 (format "File %s; PostScript file: " prompt)
5145 (file-name-directory res) nil nil
5146 (file-name-nondirectory res))))
5147 (pr-expand-file-name res)))
5150 (defun pr-toggle (var-sym mess entry index horizontal state &optional path)
5151 (set var-sym (not (symbol-value var-sym)))
5152 (message "%s is %s" mess (if (symbol-value var-sym) "on" "off"))
5153 (pr-menu-lock entry index horizontal state path))
5156 (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt)
5158 (or (symbol-value n-up-sym)
5159 (set n-up-sym (pr-interactive-n-up prompt)))
5160 (and (eq (symbol-value infile-sym) t)
5161 (set infile-sym (and (not (interactive-p))
5162 (pr-ps-infile-preprint prompt))))
5164 (or (symbol-value infile-sym)
5165 (error "%s: input PostScript file name is missing" prompt))
5166 (set infile-sym (pr-dosify-path (symbol-value infile-sym)))
5168 (and (eq (symbol-value outfile-sym) t)
5169 (set outfile-sym (and (not (interactive-p))
5171 (pr-ps-outfile-preprint prompt))))
5172 (and (symbol-value outfile-sym)
5173 (set outfile-sym (pr-dosify-path (symbol-value outfile-sym))))
5174 (pr-ps-file (symbol-value outfile-sym)))
5177 (defun pr-ps-utility-process (n-up infile outfile)
5179 (and (stringp infile) (file-exists-p infile)
5180 (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist)))
5182 (concat (pr-command (nth 0 item)) " "
5183 (pr-switches-string (nth 1 item)
5184 "pr-ps-utility-alist entry")
5186 (pr-switches-string (nth 8 item)
5187 "pr-ps-utility-alist entry")
5190 (format (nth 2 item) ps-paper-type))
5191 " " (format (nth 3 item) n-up) " "
5192 (and pr-file-landscape (nth 4 item)) " "
5193 (and pr-file-duplex (nth 5 item)) " "
5194 (and pr-file-tumble (nth 6 item))
5195 " \"" (pr-expand-file-name infile) "\" "
5197 " \"" (pr-expand-file-name outfile) "\"")))))
5200 (defun pr-shell-command (command)
5201 (let ((shell-file-name pr-shell-file-name))
5202 (shell-command command)))
5205 (defun pr-txt-print (from to)
5206 (let ((lpr-command (pr-command pr-txt-command))
5207 (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches"))
5208 (printer-name pr-txt-printer))
5209 (lpr-region from to)))
5212 (defun pr-switches-string (switches mess)
5213 (mapconcat 'identity (pr-switches switches mess) " "))
5216 (defun pr-switches (switches mess)
5217 (or (listp switches)
5218 (error "%S should have a list of strings." mess))
5219 (ps-flatten-list ; dynamic evaluation
5220 (mapcar 'ps-eval-switch switches)))
5223 (defun pr-ps-preview (kind n-up filename mess)
5224 (pr-set-n-up-and-filename 'n-up 'filename mess)
5225 (let ((file (pr-ps-file filename)))
5226 (pr-text2ps kind n-up file)
5227 (or pr-spool-p (pr-ps-file-preview file))))
5230 (defun pr-ps-using-ghostscript (kind n-up filename mess)
5231 (pr-set-n-up-and-filename 'n-up 'filename mess)
5232 (let ((file (pr-ps-file filename)))
5233 (pr-text2ps kind n-up file)
5234 (unless (or pr-spool-p filename)
5235 (pr-ps-file-using-ghostscript file)
5236 (pr-delete-file file))))
5239 (defun pr-ps-print (kind n-up filename mess)
5240 (pr-set-n-up-and-filename 'n-up 'filename mess)
5241 (let ((file (pr-ps-file filename)))
5242 (pr-text2ps kind n-up file)
5243 (unless (or pr-spool-p filename)
5244 (pr-ps-file-print file)
5245 (pr-delete-file file))))
5248 (defun pr-ps-file (&optional filename)
5249 (pr-dosify-path (or filename
5250 (convert-standard-filename
5251 (expand-file-name pr-ps-temp-file pr-temp-dir)))))
5254 (defun pr-interactive-n-up (mess)
5255 (or (stringp mess) (setq mess "*"))
5257 (let* ((fmt-prompt "%s[%s] N-up printing: (default 1) ")
5259 (str (pr-f-read-string (format fmt-prompt prompt mess) "1" nil "1"))
5261 (while (if (string-match "^\\s *[0-9]+$" str)
5262 (setq int (string-to-int str)
5263 prompt (cond ((< int 1) "Integer below 1; ")
5264 ((> int 100) "Integer above 100; ")
5266 (setq prompt "Invalid integer syntax; "))
5269 (pr-f-read-string (format fmt-prompt prompt mess) str nil "1")))
5273 (defun pr-interactive-dir (mess)
5274 (let* ((dir-name (file-name-directory (or (buffer-file-name)
5275 default-directory)))
5276 (fmt-prompt (concat "%s[" mess "] Directory to print: "))
5277 (dir (read-file-name (format fmt-prompt "")
5278 "" dir-name nil dir-name))
5280 (while (cond ((not (file-directory-p dir))
5282 (setq prompt "It's not a directory! "))
5283 ((not (file-readable-p dir))
5285 (setq prompt "Directory is unreadable! "))
5287 (setq dir-name (file-name-directory dir)
5288 dir (read-file-name (format fmt-prompt prompt)
5289 "" dir-name nil dir-name)))
5290 (file-name-as-directory dir)))
5293 (defun pr-interactive-regexp (mess)
5294 (pr-f-read-string (format "[%s] File regexp to print: " mess) "" nil ""))
5297 (defun pr-interactive-dir-args (mess)
5299 ;; get directory argument
5300 (pr-interactive-dir mess)
5301 ;; get file name regexp
5302 (pr-interactive-regexp mess)))
5305 (defun pr-interactive-ps-dir-args (mess)
5307 ;; get n-up argument
5308 (pr-interactive-n-up mess)
5309 ;; get directory argument
5310 (pr-interactive-dir mess)
5311 ;; get file name regexp
5312 (pr-interactive-regexp mess)
5313 ;; get output file name
5314 (and (not pr-spool-p)
5315 (ps-print-preprint current-prefix-arg))))
5318 (defun pr-interactive-n-up-file (mess)
5320 ;; get n-up argument
5321 (pr-interactive-n-up mess)
5322 ;; get output file name
5323 (and (not pr-spool-p)
5324 (ps-print-preprint current-prefix-arg))))
5327 (defun pr-interactive-n-up-inout (mess)
5329 ;; get n-up argument
5330 (pr-interactive-n-up mess)
5331 ;; get input file name
5332 (pr-ps-infile-preprint (concat mess " "))
5333 ;; get output file name
5334 (ps-print-preprint current-prefix-arg)))
5337 (defun pr-set-outfilename (filename-sym)
5338 (and (not pr-spool-p)
5339 (eq (symbol-value filename-sym) t)
5340 (set filename-sym (and (not (interactive-p))
5342 (ps-print-preprint current-prefix-arg))))
5343 (and (symbol-value filename-sym)
5344 (set filename-sym (pr-dosify-path (symbol-value filename-sym)))))
5347 (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess)
5349 (or (symbol-value n-up-sym)
5350 (set n-up-sym (pr-interactive-n-up mess)))
5352 (pr-set-outfilename filename-sym))
5355 (defun pr-set-dir-args (dir-sym regexp-sym mess)
5357 (or (symbol-value dir-sym)
5358 (set dir-sym (pr-interactive-dir mess)))
5360 (or (symbol-value regexp-sym)
5361 (set regexp-sym (pr-interactive-regexp mess))))
5364 (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess)
5366 (or (symbol-value n-up-sym)
5367 (set n-up-sym (pr-interactive-n-up mess)))
5368 ;; directory & file name regexp
5369 (pr-set-dir-args dir-sym regexp-sym mess)
5371 (pr-set-outfilename filename-sym))
5374 (defun pr-find-buffer-visiting (file)
5375 (if (not (file-directory-p file))
5376 (find-buffer-visiting (if ps-windows-system
5379 (let ((truename (file-truename file))
5380 (blist (buffer-list))
5382 (while (and (not found) blist)
5384 (set-buffer (car blist))
5385 (and (eq major-mode 'dired-mode)
5387 (goto-char (point-min))
5388 (string= (buffer-substring-no-properties
5394 (setq found (car blist))))
5395 (setq blist (cdr blist)))
5399 (defun pr-file-list (dir file-regexp fun)
5400 (mapcar #'(lambda (file)
5401 (and (or pr-list-directory
5402 (not (file-directory-p file)))
5403 (let ((buffer (pr-find-buffer-visiting file))
5407 (file-readable-p file))
5409 (set-buffer (or buffer
5410 (find-file-noselect file)))
5413 (kill-buffer (current-buffer))))))))
5414 (directory-files dir t file-regexp)))
5417 (defun pr-delete-file-if-exists (filename)
5418 (and (not pr-spool-p) (stringp filename) (file-exists-p filename)
5419 (delete-file filename)))
5422 (defun pr-ps-file-list (n-up dir file-regexp filename)
5423 (pr-delete-file-if-exists (setq filename (pr-expand-file-name filename)))
5424 (let ((pr-spool-p t))
5425 (pr-file-list dir file-regexp
5427 (if (pr-auto-mode-p)
5428 (pr-ps-mode n-up filename)
5429 (pr-text2ps 'buffer n-up filename)))))
5431 (pr-despool-print filename)))
5434 (defun pr-text2ps (kind n-up filename &optional from to)
5435 (let ((ps-n-up-printing n-up)
5436 (ps-spool-config (and (eq ps-spool-config 'setpagedevice)
5438 (pr-delete-file-if-exists filename)
5441 ;; pr-faces-p and pr-spool-p
5442 ;; here FILENAME arg is ignored
5443 (cond ((eq kind 'buffer)
5444 (ps-spool-buffer-with-faces))
5446 (ps-spool-region-with-faces (or from (point))
5449 ;; pr-faces-p and not pr-spool-p
5451 (ps-print-buffer-with-faces filename))
5453 (ps-print-region-with-faces (or from (point))
5454 (or to (mark)) filename))
5457 ;; not pr-faces-p and pr-spool-p
5458 ;; here FILENAME arg is ignored
5459 (cond ((eq kind 'buffer)
5462 (ps-spool-region (or from (point)) (or to (mark))))
5464 ;; not pr-faces-p and not pr-spool-p
5466 (ps-print-buffer filename))
5468 (ps-print-region (or from (point)) (or to (mark)) filename))
5472 (defun pr-command (command)
5473 "Return absolute file name specification for COMMAND.
5475 If COMMAND is an empty string, return it.
5477 If COMMAND is already an absolute file name specification, return it.
5478 Else it uses `pr-path-alist' to find COMMAND, if find it then return it;
5479 otherwise, gives an error.
5481 When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and
5482 `unix' are used (see `pr-path-alist' for documentation).
5484 If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND,
5485 COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
5486 (if (string= command "")
5489 (or (pr-find-command command)
5490 (pr-path-command (cond (pr-cygwin-system 'cygwin)
5491 (ps-windows-system 'windows)
5493 (file-name-nondirectory command)
5495 (error "Command not found: %s"
5496 (file-name-nondirectory command))))))
5499 (defun pr-path-command (symbol command sym-list)
5500 (let ((lpath (cdr (assq symbol pr-path-alist)))
5503 (and (eq symbol 'PATH) (null lpath)
5504 (setq lpath (parse-colon-path (getenv "PATH"))))
5508 (let ((path (car lpath)))
5512 (and (not (memq path sym-list))
5513 (pr-path-command path command
5514 (cons path sym-list))))
5519 (substitute-in-file-name
5520 (concat (file-name-as-directory path)
5523 (setq lpath (cdr lpath)))
5527 (defun pr-find-command (cmd)
5528 (if ps-windows-system
5530 (let ((ext (cons (file-name-extension cmd t)
5531 (list ".exe" ".bat" ".com")))
5533 (setq cmd (file-name-sans-extension cmd))
5535 (setq found (concat cmd (car ext)))
5536 (not (and (file-regular-p found)
5537 (file-executable-p found))))
5541 ;; non-windows systems
5542 (and (file-regular-p cmd)
5543 (file-executable-p cmd)
5547 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5548 ;; Printing Interface (inspired on ps-print-interface.el)
5556 (defvar pr-i-window-configuration nil)
5558 (defvar pr-i-buffer nil)
5559 (defvar pr-i-region nil)
5560 (defvar pr-i-mode nil)
5561 (defvar pr-i-despool nil)
5562 (defvar pr-i-ps-as-is t)
5563 (defvar pr-i-n-up 1)
5564 (defvar pr-i-directory "./")
5565 (defvar pr-i-regexp "")
5566 (defvar pr-i-ps-file "")
5567 (defvar pr-i-out-file "")
5568 (defvar pr-i-answer-yes nil)
5569 (defvar pr-i-process 'buffer)
5570 (defvar pr-i-ps-send 'printer)
5573 (defvar pr-interface-map nil
5574 "Keymap for pr-interface.")
5576 (if pr-interface-map
5578 (setq pr-interface-map (make-sparse-keymap))
5579 (cond ((eq ps-print-emacs-type 'xemacs) ; XEmacs
5580 (pr-f-set-keymap-parents pr-interface-map (list widget-keymap))
5581 (pr-f-set-keymap-name pr-interface-map 'pr-interface-map))
5582 ((eq ps-print-emacs-type 'emacs) ; GNU Emacs
5583 (pr-f-set-keymap-parents pr-interface-map widget-keymap)))
5584 (define-key pr-interface-map "q" 'pr-interface-quit)
5585 (define-key pr-interface-map "?" 'pr-interface-help))
5588 (defmacro pr-interface-save (&rest body)
5590 (set-buffer pr-i-buffer)
5594 (defun pr-create-interface ()
5595 "Create the front end for printing package."
5596 (setq pr-i-buffer (buffer-name (current-buffer))
5597 pr-i-region (ps-mark-active-p)
5598 pr-i-mode (pr-mode-alist-p)
5599 pr-i-window-configuration (current-window-configuration))
5601 (put 'pr-i-process 'pr-widget-list nil)
5602 (put 'pr-i-ps-send 'pr-widget-list nil)
5604 (delete-other-windows)
5605 (kill-buffer (get-buffer-create pr-buffer-name))
5606 (switch-to-buffer (get-buffer-create pr-buffer-name))
5609 (let ((versions (concat "printing v" pr-version
5610 " ps-print v" ps-print-version)))
5611 (widget-insert (make-string (- 79 (length versions)) ?\ ) versions))
5612 (pr-insert-italic "\nCurrent Directory : " 1)
5613 (pr-insert-italic default-directory)
5615 (pr-insert-section-1) ; 1. Print
5616 (pr-insert-section-2) ; 2. PostScript Printer
5617 (pr-insert-section-3) ; 3. Text Printer
5620 (widget-insert "\n\n " (make-string 77 ?-))
5622 (pr-insert-section-4) ; 4. Settings
5623 (pr-insert-section-5) ; 5. Customize
5624 (pr-insert-section-6) ; 6. Show Settings
5625 (pr-insert-section-7) ; 7. Help
5627 (use-local-map pr-interface-map)
5629 (goto-char (point-min))
5631 (and pr-i-region ; let region activated
5632 (pr-keep-region-active)))
5635 (defun pr-insert-section-1 ()
5637 (pr-insert-italic "\nPrint :" 1)
5640 ;; 1a. Buffer: Buffer List
5641 (pr-insert-radio-button 'pr-i-process 'buffer)
5642 (pr-insert-menu "Buffer List" 'pr-i-buffer
5643 (let ((blist (buffer-list))
5644 case-fold-search choices)
5646 (let ((name (buffer-name (car blist)))
5647 (ignore pr-buffer-name-ignore)
5649 (setq blist (cdr blist))
5650 (while (and ignore (not found))
5651 (setq found (string-match (car ignore) name)
5652 ignore (cdr ignore)))
5664 (setq pr-i-region (ps-mark-active-p)
5665 pr-i-mode (pr-mode-alist-p)))
5666 (pr-update-checkbox 'pr-i-region)
5667 (pr-update-checkbox 'pr-i-mode)))
5668 ;; 1a. Buffer: Region
5669 (put 'pr-i-region 'pr-widget
5673 #'(lambda (widget &rest ignore)
5674 (let ((region-p (pr-interface-save
5675 (ps-mark-active-p))))
5676 (cond ((null (widget-value widget)) ; widget is nil
5677 (setq pr-i-region nil))
5678 (region-p ; widget is true and there is a region
5679 (setq pr-i-region t)
5680 (widget-value-set widget t)
5681 (widget-setup)) ; MUST be called after widget-value-set
5682 (t ; widget is true and there is no region
5684 (message "There is no region active")
5685 (setq pr-i-region nil)
5686 (widget-value-set widget nil)
5687 (widget-setup))))) ; MUST be called after widget-value-set
5690 (put 'pr-i-mode 'pr-widget
5694 #'(lambda (widget &rest ignore)
5695 (let ((mode-p (pr-interface-save
5696 (pr-mode-alist-p))))
5698 ((null (widget-value widget)) ; widget is nil
5699 (setq pr-i-mode nil))
5700 (mode-p ; widget is true and there is a `mode'
5702 (widget-value-set widget t)
5703 (widget-setup)) ; MUST be called after widget-value-set
5704 (t ; widget is true and there is no `mode'
5707 "This buffer isn't in a mode that printing treats specially.")
5708 (setq pr-i-mode nil)
5709 (widget-value-set widget nil)
5710 (widget-setup))))) ; MUST be called after widget-value-set
5714 (pr-insert-radio-button 'pr-i-process 'directory)
5718 :format " Directory : %v"
5719 :notify 'pr-interface-directory
5720 :action (lambda (widget &optional event)
5721 (if (pr-interface-directory widget)
5722 (pr-widget-field-action widget event)
5724 (message "Please specify a readable directory")))
5726 ;; 1b. Directory: File Regexp
5727 (widget-create 'regexp
5729 :format "\n File Regexp : %v\n"
5730 :notify (lambda (widget &rest ignore)
5731 (setq pr-i-regexp (widget-value widget)))
5733 ;; 1b. Directory: List Directory Entry
5735 (pr-insert-toggle 'pr-list-directory " List Directory Entry\n")
5737 ;; 1c. PostScript File:
5738 (pr-insert-radio-button 'pr-i-process 'file)
5742 :format " PostScript File : %v"
5743 :notify 'pr-interface-infile
5744 :action (lambda (widget &rest event)
5745 (if (pr-interface-infile widget)
5746 (pr-widget-field-action widget event)
5748 (message "Please specify a readable PostScript file")))
5750 ;; 1c. PostScript File: PostScript Utility
5751 (pr-insert-menu "PostScript Utility" 'pr-ps-utility
5752 (pr-choice-alist pr-ps-utility-alist)
5753 "\n PostScript Utility : "
5755 ;; 1c. PostScript File: No Preprocessing
5756 (pr-insert-toggle 'pr-i-ps-as-is " No Preprocessing"))
5759 (defun pr-insert-section-2 ()
5760 ;; 2. PostScript Printer:
5761 ;; 2. PostScript Printer: PostScript Printer List
5762 (pr-insert-italic "\n\nPostScript Printer : " 2 20)
5763 (pr-insert-menu "PostScript Printer" 'pr-ps-name
5764 (pr-choice-alist pr-ps-printer-alist))
5765 ;; 2. PostScript Printer: Despool
5766 (put 'pr-i-despool 'pr-widget
5770 #'(lambda (widget &rest ignore)
5772 (setq pr-i-despool (not pr-i-despool))
5774 (message "Can despool only when spooling is actually selected")
5775 (setq pr-i-despool nil))
5776 (widget-value-set widget pr-i-despool)
5777 (widget-setup)) ; MUST be called after widget-value-set
5779 ;; 2. PostScript Printer: Preview Print Quit
5780 (pr-insert-button 'pr-interface-preview "Preview" " ")
5781 (pr-insert-button 'pr-interface-ps-print "Print" " ")
5782 (pr-insert-button 'pr-interface-quit "Quit")
5783 ;; 2. PostScript Printer: Send to Printer/Temporary File
5784 (pr-insert-radio-button 'pr-i-ps-send 'printer)
5785 (widget-insert " Send to Printer/Temporary File")
5786 ;; 2. PostScript Printer: Send to File
5787 (pr-insert-radio-button 'pr-i-ps-send 'file)
5791 :format " Send to File : %v"
5792 :notify 'pr-interface-outfile
5793 :action (lambda (widget &rest event)
5794 (if (and (pr-interface-outfile widget)
5795 (or (not (file-exists-p pr-i-out-file))
5796 (setq pr-i-answer-yes
5797 (y-or-n-p "File exists; overwrite? "))))
5798 (pr-widget-field-action widget event)
5800 (message "Please specify a writable PostScript file")))
5802 ;; 2. PostScript Printer: N-Up
5806 :format "\n N-Up : %v"
5807 :notify (lambda (widget &rest ignore)
5808 (let ((value (if (string= (widget-apply widget :value-get) "")
5810 (widget-value widget))))
5811 (if (and (integerp value)
5812 (<= 1 value) (<= value 100))
5815 (setq pr-i-n-up value))
5817 (message "Please specify an integer between 1 and 100"))))
5821 (defun pr-insert-section-3 ()
5823 (pr-insert-italic "\n\nText Printer : " 2 14)
5824 (pr-insert-menu "Text Printer" 'pr-txt-name
5825 (pr-choice-alist pr-txt-printer-alist)
5827 (pr-insert-button 'pr-interface-printify "Printify" " ")
5828 (pr-insert-button 'pr-interface-txt-print "Print" " ")
5829 (pr-insert-button 'pr-interface-quit "Quit"))
5832 (defun pr-insert-section-4 ()
5834 ;; 4. Settings: Landscape Auto Region Verbose
5835 (pr-insert-checkbox "\n\n " 'ps-landscape-mode
5836 #'(lambda (&rest ignore)
5837 (setq ps-landscape-mode (not ps-landscape-mode)
5838 pr-file-landscape ps-landscape-mode))
5840 (pr-insert-toggle 'pr-auto-region " Auto Region ")
5841 (pr-insert-toggle 'pr-buffer-verbose " Verbose\n ")
5843 ;; 4. Settings: Print Header Auto Mode
5844 (pr-insert-toggle 'ps-print-header " Print Header ")
5845 (pr-insert-toggle 'pr-auto-mode " Auto Mode\n ")
5847 ;; 4. Settings: Print Header Frame Menu Lock
5848 (pr-insert-toggle 'ps-print-header-frame " Print Header Frame ")
5849 (pr-insert-toggle 'pr-menu-lock " Menu Lock\n ")
5851 ;; 4. Settings: Line Number
5852 (pr-insert-toggle 'ps-line-number " Line Number\n ")
5854 ;; 4. Settings: Zebra Stripes Spool Buffer
5855 (pr-insert-toggle 'ps-zebra-stripes " Zebra Stripes")
5856 (pr-insert-checkbox " "
5858 #'(lambda (&rest ignore)
5859 (setq pr-spool-p (not pr-spool-p))
5861 (setq pr-i-despool nil)
5862 (pr-update-checkbox 'pr-i-despool)))
5865 ;; 4. Settings: Duplex Print with faces
5866 (pr-insert-checkbox "\n "
5868 #'(lambda (&rest ignore)
5869 (setq ps-spool-duplex (not ps-spool-duplex)
5870 pr-file-duplex ps-spool-duplex))
5872 (pr-insert-toggle 'pr-faces-p " Print with faces")
5874 ;; 4. Settings: Tumble Print via Ghostscript
5875 (pr-insert-checkbox "\n "
5877 #'(lambda (&rest ignore)
5878 (setq ps-spool-tumble (not ps-spool-tumble)
5879 pr-file-tumble ps-spool-tumble))
5881 (pr-insert-toggle 'pr-print-using-ghostscript " Print via Ghostscript\n ")
5883 ;; 4. Settings: Upside-Down Page Parity
5884 (pr-insert-toggle 'ps-print-upside-down " Upside-Down")
5885 (pr-insert-italic "\n\nSelect Pages : " 2 14)
5886 (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages
5887 (mapcar #'(lambda (alist)
5892 :value (car alist))))
5893 pr-even-or-odd-alist)))
5896 (defun pr-insert-section-5 ()
5898 (pr-insert-italic "\n\nCustomize : " 2 11)
5899 (pr-insert-button 'pr-customize "printing" " ")
5900 (pr-insert-button #'(lambda (&rest ignore) (ps-print-customize))
5902 (pr-insert-button 'lpr-customize "lpr"))
5905 (defun pr-insert-section-6 ()
5906 ;; 6. Show Settings:
5907 (pr-insert-italic "\nShow Settings : " 1 14)
5908 (pr-insert-button 'pr-show-pr-setup "printing" " ")
5909 (pr-insert-button 'pr-show-ps-setup "ps-print" " ")
5910 (pr-insert-button 'pr-show-lpr-setup "lpr"))
5913 (defun pr-insert-section-7 ()
5915 (pr-insert-italic "\nHelp : " 1 5)
5916 (pr-insert-button 'pr-interface-help "Interface Help" " ")
5917 (pr-insert-button 'pr-help "Menu Help" " ")
5918 (pr-insert-button 'pr-interface-quit "Quit" "\n ")
5919 (pr-insert-button 'pr-kill-help "Kill All Printing Help Buffer"))
5922 (defun pr-kill-help (&rest ignore)
5923 "Kill all printing help buffer."
5925 (let ((help '("*Printing Interface Help*" "*Printing Help*"
5926 "*LPR Setup*" "*PR Setup*" "*PS Setup*")))
5928 (let ((buffer (get-buffer (car help))))
5929 (setq help (cdr help))
5931 (delete-windows-on buffer)
5932 (kill-buffer buffer)))))
5933 (recenter (- (window-height) 2)))
5936 (defun pr-interface-quit (&rest ignore)
5937 "Kill the printing buffer interface and quit."
5939 (kill-buffer pr-buffer-name)
5940 (set-window-configuration pr-i-window-configuration))
5943 (defun pr-interface-help (&rest ignore)
5944 "printing buffer interface help."
5946 (pr-show-setup pr-interface-help-message "*Printing Interface Help*"))
5949 (defun pr-interface-txt-print (&rest ignore)
5950 "Print using lpr package."
5952 (condition-case data
5954 ((eq pr-i-process 'directory)
5957 (pr-txt-directory pr-i-directory pr-i-regexp)))
5958 ((eq pr-i-process 'buffer)
5961 (let ((pr-auto-mode pr-i-mode))
5964 (let (pr-auto-region)
5967 (let (pr-auto-mode pr-auto-region)
5970 ((eq pr-i-process 'file)
5971 (error "Please specify a text file"))
5973 (error "Internal error: `pr-i-process' = %S" pr-i-process))
5978 (message (error-message-string data)))))
5981 (defun pr-interface-printify (&rest ignore)
5982 "Printify a buffer."
5984 (condition-case data
5986 ((eq pr-i-process 'directory)
5989 (pr-printify-directory pr-i-directory pr-i-regexp)))
5990 ((eq pr-i-process 'buffer)
5993 (pr-printify-region)
5994 (pr-printify-buffer))))
5995 ((eq pr-i-process 'file)
5996 (error "Cannot printify a PostScript file"))
5998 (error "Internal error: `pr-i-process' = %S" pr-i-process))
6003 (message (error-message-string data)))))
6006 (defun pr-interface-ps-print (&rest ignore)
6007 "Print using ps-print package."
6009 (pr-interface-ps 'pr-despool-ps-print 'pr-ps-directory-ps-print
6010 'pr-ps-file-ps-print 'pr-ps-file-up-ps-print
6011 'pr-ps-region-ps-print 'pr-ps-mode-ps-print
6012 'pr-ps-buffer-ps-print))
6015 (defun pr-interface-preview (&rest ignore)
6016 "Preview a PostScript file."
6018 (pr-interface-ps 'pr-despool-preview 'pr-ps-directory-preview
6019 'pr-ps-file-preview 'pr-ps-file-up-preview
6020 'pr-ps-region-preview 'pr-ps-mode-preview
6021 'pr-ps-buffer-preview))
6024 (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region
6026 (condition-case data
6027 (let ((outfile (or (and (eq pr-i-process 'file) pr-i-ps-as-is)
6030 ((and pr-i-despool pr-spool-p)
6032 (funcall ps-despool outfile))
6033 (setq pr-i-despool nil)
6034 (pr-update-checkbox 'pr-i-despool))
6035 ((eq pr-i-process 'directory)
6038 (funcall ps-directory
6039 pr-i-n-up pr-i-directory pr-i-regexp outfile)))
6040 ((eq pr-i-process 'file)
6041 (cond ((or (file-directory-p pr-i-ps-file)
6042 (not (file-readable-p pr-i-ps-file)))
6043 (error "Please specify a readable PostScript file"))
6046 (funcall ps-file pr-i-ps-file)))
6049 (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile)))
6051 ((eq pr-i-process 'buffer)
6054 (let ((pr-auto-mode pr-i-mode))
6055 (funcall ps-region pr-i-n-up outfile)))
6057 (let (pr-auto-region)
6058 (funcall ps-mode pr-i-n-up outfile)))
6060 (let (pr-auto-mode pr-auto-region)
6061 (funcall ps-buffer pr-i-n-up outfile)))
6064 (error "Internal error: `pr-i-process' = %S" pr-i-process))
6069 (message (error-message-string data)))))
6072 (defun pr-i-ps-send ()
6073 (cond ((eq pr-i-ps-send 'printer)
6075 ((not (eq pr-i-ps-send 'file))
6076 (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send))
6077 ((or (file-directory-p pr-i-out-file)
6078 (not (file-writable-p pr-i-out-file)))
6079 (error "Please specify a writable PostScript file"))
6080 ((or (not (file-exists-p pr-i-out-file))
6082 (setq pr-i-answer-yes
6083 (y-or-n-p (format "File `%s' exists; overwrite? "
6087 (error "File already exists"))))
6090 (defun pr-i-directory ()
6091 (or (and (file-directory-p pr-i-directory)
6092 (file-readable-p pr-i-directory))
6093 (error "Please specify be a readable directory")))
6096 (defun pr-interface-directory (widget &rest ignore)
6097 (and pr-buffer-verbose
6098 (message "You can use M-TAB or ESC TAB for file completion"))
6099 (let ((dir (widget-value widget)))
6100 (and (file-directory-p dir)
6101 (file-readable-p dir)
6102 (setq pr-i-directory dir))))
6105 (defun pr-interface-infile (widget &rest ignore)
6106 (and pr-buffer-verbose
6107 (message "You can use M-TAB or ESC TAB for file completion"))
6108 (let ((file (widget-value widget)))
6109 (and (not (file-directory-p file))
6110 (file-readable-p file)
6111 (setq pr-i-ps-file file))))
6114 (defun pr-interface-outfile (widget &rest ignore)
6115 (setq pr-i-answer-yes nil)
6116 (and pr-buffer-verbose
6117 (message "You can use M-TAB or ESC TAB for file completion"))
6118 (let ((file (widget-value widget)))
6119 (and (not (file-directory-p file))
6120 (file-writable-p file)
6121 (setq pr-i-out-file file))))
6124 (defun pr-widget-field-action (widget event)
6125 (and (get-buffer "*Completions*") ; clean frame window
6126 (delete-windows-on "*Completions*"))
6127 (message " ") ; clean echo area
6128 (widget-field-action widget event))
6131 (defun pr-insert-italic (str &optional from to)
6132 (let ((len (length str)))
6133 (put-text-property (if from (max from 0) 0)
6134 (if to (max to len) len)
6136 (widget-insert str)))
6139 (defun pr-insert-checkbox (before var-sym fun label)
6140 (widget-insert before)
6142 (widget-create 'checkbox
6144 (symbol-value var-sym))
6145 (widget-insert label)))
6148 (defun pr-insert-toggle (var-sym label)
6149 (widget-create 'checkbox
6150 :notify `(lambda (&rest ignore)
6151 (setq ,var-sym (not ,var-sym)))
6152 (symbol-value var-sym))
6153 (widget-insert label))
6156 (defun pr-insert-button (fun label &optional separator)
6157 (widget-create 'push-button
6161 (widget-insert separator)))
6164 (defun pr-insert-menu (tag var-sym choices &optional before after &rest body)
6165 (and before (widget-insert before))
6166 (eval `(widget-create 'menu-choice
6171 :notify (lambda (widget &rest ignore)
6172 (setq ,var-sym (widget-value widget))
6174 :void '(choice-item :format "%[%t%]"
6175 :tag "Can not display value!")
6177 (and after (widget-insert after)))
6180 (defun pr-insert-radio-button (var-sym sym)
6181 (widget-insert "\n")
6182 (let ((wid-list (get var-sym 'pr-widget-list))
6183 (wid (eval `(widget-create
6186 :value (eq ,var-sym (quote ,sym))
6187 :notify (lambda (&rest ignore)
6188 (setq ,var-sym (quote ,sym))
6189 (pr-update-radio-button (quote ,var-sym)))))))
6190 (put var-sym 'pr-widget-list (cons (cons wid sym) wid-list))))
6193 (defun pr-update-radio-button (var-sym)
6194 (let ((wid-list (get var-sym 'pr-widget-list)))
6196 (let ((wid (car (car wid-list)))
6197 (value (cdr (car wid-list))))
6198 (setq wid-list (cdr wid-list))
6199 (widget-value-set wid (eq (symbol-value var-sym) value))))
6203 (defun pr-update-checkbox (var-sym)
6204 (let ((wid (get var-sym 'pr-widget)))
6206 (widget-value-set wid (symbol-value var-sym))
6210 (defun pr-choice-alist (alist)
6211 (let ((max (apply 'max (mapcar #'(lambda (alist)
6212 (length (symbol-name (car alist))))
6214 (mapcar #'(lambda (alist)
6215 (let* ((sym (car alist))
6216 (name (symbol-name sym)))
6223 (make-string (- max (length name)) ?_))
6228 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6237 ;;; arch-tag: 9ce9ac3f-0f60-4370-900b-1943215d9d18
6238 ;;; printing.el ends here