1 ;;; printing.el --- printing utilities
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004
4 ;; Free Software Foundation, Inc.
6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8 ;; Time-stamp: <2004/07/12 21:10:35 vinicius>
9 ;; Keywords: wp, print, PostScript
11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
13 (defconst pr-version
"6.8"
14 "printing.el, v 6.8 <2004/07/12 vinicius>
16 Please send all bug fixes and enhancements to
17 Vinicius Jose Latorre <viniciusjl@ig.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 an user interface to some printing utilities that
44 ;; includes 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). It also includes a
47 ;; PostScript/text printer database.
49 ;; Indeed, there are two user interfaces:
52 ;; When `printing' is loaded, the menubar is modified to use `printing'
53 ;; menu instead of the print options in menubar.
54 ;; This is the default user interface.
56 ;; * Buffer interface:
57 ;; It is an option of `printing' menu, but it can be binded into another
58 ;; key, so user can activate the buffer interface directly without using
59 ;; a menu. See `pr-interface' command.
61 ;; `printing' was inspired on:
63 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr>
64 ;; Special printing functions for Windows NT
66 ;; mh-e-init.el Tom Vogels <tov@ece.cmu.edu>
67 ;; PS-print for mail messages
69 ;; win32-ps-print.el Matthew O. Persico <mpersico@erols.com>
70 ;; PostScript printing with ghostscript
72 ;; ps-print-interface.el Volker Franz <volker.franz@tuebingen.mpg.de>
73 ;; Graphical front end for ps-print and previewing
75 ;; `printing' is prepared to run on GNU, Unix and NT systems.
76 ;; On GNU or Unix system, `printing' depends on gs and gv utilities.
77 ;; On NT system, `printing' depends on gstools (gswin32.exe and gsview32.exe).
78 ;; To obtain ghostscript, ghostview and GSview see the URL
79 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'.
81 ;; `printing' depends on ps-print package to generate PostScript files, to
82 ;; spool and to despool PostScript buffer. So, `printing' provides an
83 ;; interface to ps-print package and it also provides some extra stuff.
85 ;; To download the latest ps-print package see
86 ;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'.
87 ;; Please, see README file for ps-print installation instructions.
93 ;; The buffer *Printing Command Output* is where the `printing' log messages
94 ;; are inserted. All program called by `printing' has a log entry in the
95 ;; buffer *Printing Command Output*. A log entry has the following form:
102 ;; PROGRAM is the program activated by `printing',
103 ;; ARG is an argument passed to PROGRAM (it can have more than one argument),
104 ;; MESSAGE is an error message returned by PROGRAM (it can have no message, if
105 ;; PROGRAM is successful),
106 ;; and CODE is a numeric exit status or a signal description string.
108 ;; For example, after previewing a PostScript file, *Printing Command Output*
109 ;; will have the following entry:
111 ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps")
114 ;; In the example above, the previewing was successful. If during previewing,
115 ;; you quit gv execution (by typing C-g during Emacs session), the log entry
118 ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps")
121 ;; So, if something goes wrong, a good place to take a look is the buffer
122 ;; *Printing Command Output*. Don't forget to see also the buffer *Messages*,
126 ;; Novices (First Users)
127 ;; ---------------------
129 ;; First of all, take a glance of printing documentation only to have an idea
130 ;; of what `printing' is capable.
132 ;; Then try to set the variables: `pr-ps-name', `pr-ps-printer-alist',
133 ;; `pr-txt-name', `pr-txt-printer-alist' and `pr-path-alist'. These variables
134 ;; are the main variables for printing processing.
136 ;; Now, please, see these variables documentation more in deep. You can do
137 ;; this by typing C-h v pr-ps-name RET (for example) if you already loaded
138 ;; printing package, or by browsing printing.el source file.
140 ;; If the documentation isn't clear or if you find a way to improve the
141 ;; documentation, please, send an email to maintainer. All printing users
144 ;; One way to set variables is by calling `pr-customize', customize all
145 ;; variables and save the customization by future sessions (see Options
146 ;; section). Other way is by coding your settings on Emacs init file (that is,
147 ;; .emacs file), see below for a first setting template that it should be
148 ;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT
151 ;; * Example of setting for Windows system:
153 ;; (require 'printing) ; load printing package
154 ;; (setq pr-path-alist
155 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
156 ;; (ghostview "c:/gs/gsview-dir")
157 ;; (mpage "c:/mpage-dir")
159 ;; (setq pr-txt-name 'prt_06a)
160 ;; (setq pr-txt-printer-alist
161 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
162 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
163 ;; (PRN "" nil "PRN")
164 ;; (standard "redpr.exe" nil "")
166 ;; (setq pr-ps-name 'lps_06b)
167 ;; (setq pr-ps-printer-alist
168 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
169 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
170 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
171 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
172 ;; (LPT1 "" nil "" "LPT1:")
173 ;; (PRN "" nil "" "PRN")
174 ;; (standard "redpr.exe" nil "" "")
176 ;; (pr-update-menus t) ; update now printer and utility menus
178 ;; * Example of setting for GNU or Unix system:
180 ;; (require 'printing) ; load printing package
181 ;; (setq pr-path-alist
182 ;; '((unix "." "~/bin" ghostview mpage PATH)
183 ;; (ghostview "$HOME/bin/gsview-dir")
184 ;; (mpage "$HOME/bin/mpage-dir")
186 ;; (setq pr-txt-name 'prt_06a)
187 ;; (setq pr-txt-printer-alist
188 ;; '((prt_06a "lpr" nil "prt_06a")
189 ;; (prt_07c nil nil "prt_07c")
191 ;; (setq pr-ps-name 'lps_06b)
192 ;; (setq pr-ps-printer-alist
193 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
194 ;; (lps_07c "lpr" nil nil "lps_07c")
195 ;; (lps_08c nil nil nil "lps_08c")
197 ;; (pr-update-menus t) ; update now printer and utility menus
200 ;; NOTE 1: Don't forget to download and install ghostscript utilities (see
201 ;; Utilities section).
203 ;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be
204 ;; set, as they are implicit set by `pr-ps-printer-alist' and
205 ;; `pr-txt-printer-alist'.
207 ;; NOTE 3: The duplex feature will only work on PostScript printers that
208 ;; support this feature.
209 ;; You can check if your PostScript printer supports duplex feature
210 ;; by checking the printer manual. Or you can try these steps:
211 ;; 1. Open a buffer (or use the *scratch* buffer).
213 ;; First line (on first page)
215 ;; Second line (on second page)
216 ;; 3. Print this buffer with duplex turned on.
217 ;; If it's printed 2 (two) sheets of paper, then your PostScript
218 ;; printer doesn't have duplex feature; otherwise, it's ok, your
219 ;; printer does have duplex feature.
221 ;; NOTE 4: See Tips section.
227 ;; 1. If you have a local printer, that is, a printer which is connected
228 ;; directly to your computer, don't forget to connect the printer to your
229 ;; computer before printing.
231 ;; 2. If you try to print a file and it seems that the file was printed, but
232 ;; there is no paper in the printer, then try to set `pr-delete-temp-file'
233 ;; to nil. Probably `printing' is deleting the temporary file before your
234 ;; local system can get it to send to the printer.
236 ;; 3. Don't try to print a dynamic buffer, that is, a buffer which is
237 ;; modifying while `printing' tries to print. Eventually you got an error
238 ;; message. Instead, save the dynamic buffer to a file or copy it in
239 ;; another buffer and, then, print the file or the new static buffer.
240 ;; An example of dynamic buffer is the *Messages* buffer.
242 ;; 4. When running Emacs on Windows (with or without cygwin), check if your
243 ;; printer is a text printer or not by typing in a DOS window:
245 ;; print /D:\\host\printer somefile.txt
247 ;; Where, `host' is the machine where the printer is directly connected,
248 ;; `printer' is the printer name and `somefile.txt' is a text file.
250 ;; If the printer `\\host\printer' doesn't print the content of
251 ;; `somefile.txt' or, instead, it returns the following message:
253 ;; PostScript Error Handler
254 ;; Offending Command = CCC
257 ;; Where `CCC' is whatever is at the beginning of the text to be printed.
259 ;; Therefore, the printer `\\host\printer' is not a text printer, but a
260 ;; PostScript printer. So, please, don't include this printer in
261 ;; `pr-txt-printer-alist' (which see).
267 ;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're
268 ;; using Windows 9x/NT or MS-DOS):
270 ;; (require 'printing)
272 ;; When `printing' is loaded:
274 ;; it replaces the Tools/Print menu by Tools/Printing menu.
276 ;; it replaces the File/Print* menu entries by File/Print menu.
277 ;; Please, see section Menu Layout below for menu explanation.
279 ;; To use `printing' utilities you can use the Printing menu options, type M-x
280 ;; followed by one of the commands below, or type a key associated with the
281 ;; command you want (if there is a key binding).
283 ;; `printing' has the following commands:
286 ;; pr-ps-directory-preview
287 ;; pr-ps-directory-using-ghostscript
288 ;; pr-ps-directory-print
289 ;; pr-ps-directory-ps-print
290 ;; pr-ps-buffer-preview
291 ;; pr-ps-buffer-using-ghostscript
292 ;; pr-ps-buffer-print
293 ;; pr-ps-buffer-ps-print
294 ;; pr-ps-region-preview
295 ;; pr-ps-region-using-ghostscript
296 ;; pr-ps-region-print
297 ;; pr-ps-region-ps-print
298 ;; pr-ps-mode-preview
299 ;; pr-ps-mode-using-ghostscript
301 ;; pr-ps-mode-ps-print
302 ;; pr-ps-file-preview
303 ;; pr-ps-file-up-preview
304 ;; pr-ps-file-using-ghostscript
306 ;; pr-ps-file-ps-print
307 ;; pr-ps-file-up-ps-print
309 ;; pr-despool-preview
310 ;; pr-despool-using-ghostscript
312 ;; pr-despool-ps-print
313 ;; pr-printify-directory
314 ;; pr-printify-buffer
315 ;; pr-printify-region
321 ;; pr-toggle-file-duplex
322 ;; pr-toggle-file-tumble
323 ;; pr-toggle-file-landscape
324 ;; pr-toggle-ghostscript
329 ;; pr-toggle-landscape
330 ;; pr-toggle-upside-down
347 ;; The general meanings of above commands are:
350 ;; `pr-interface' buffer interface for printing package.
351 ;; `pr-help' help for printing package.
352 ;; `pr-ps-name' interactively select a PostScript printer.
353 ;; `pr-txt-name' interactively select a text printer.
354 ;; `pr-ps-utility' interactively select a PostScript utility.
355 ;; `pr-show-*-setup' show current settings.
356 ;; `pr-ps-*' deal with PostScript code generation.
357 ;; `pr-txt-*' deal with text generation.
358 ;; `pr-toggle-*' toggle on/off some boolean variable.
359 ;; `pr-despool-*' despool the PostScript spooling buffer.
360 ;; `pr-printify-*' replace nonprintable ASCII by printable ASCII
364 ;; `*-customize' customization.
365 ;; `*-preview' preview a PostScript file.
366 ;; `*-using-ghostscript' use ghostscript to print.
367 ;; `*-fast-fire' fast fire command (see it for documentation).
368 ;; `*-print' send PostScript directly to printer.
369 ;; `*-ps-print' send PostScript directly to printer or use
370 ;; ghostscript to print. It depends on
371 ;; `pr-print-using-ghostscript' option.
374 ;; `*-directory*' process a directory.
375 ;; `*-buffer*' process a buffer.
376 ;; `*-region*' process a region.
377 ;; `*-mode*' process a major mode (see explanation below).
378 ;; `*-file-*' process a PostScript file.
379 ;; `*-file-up-*' process a PostScript file using a filter utility.
381 ;; Here are some examples:
383 ;; `pr-ps-buffer-using-ghostscript'
384 ;; Use ghostscript to print a buffer.
386 ;; `pr-ps-file-print'
387 ;; Print a PostScript file.
390 ;; Toggle spooling buffer.
392 ;; So you can preview through ghostview, use ghostscript to print (if you don't
393 ;; have a PostScript printer) or send directly to printer a PostScript code
394 ;; generated by `ps-print' package.
396 ;; Besides operating one buffer or region each time, you also can postpone
397 ;; previewing or printing by saving the PostScript code generated in a
398 ;; temporary Emacs buffer. This way you can save banner pages between
399 ;; successive printing. You can toggle on/off spooling by invoking
400 ;; `pr-toggle-spool' interactively or through menu bar.
402 ;; If you type, for example:
404 ;; C-u M-x pr-ps-buffer-print RET
406 ;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and
407 ;; a file name, and save the PostScript code generated to the file name instead
408 ;; of sending to printer.
410 ;; This behavior is similar with the commands that deal with PostScript code
411 ;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If
412 ;; spooling is on, only `pr-despool-*' commands prompt for a file name and save
413 ;; the PostScript code spooled in this file.
415 ;; Besides the behavior described above, the `*-directory*' commands also
416 ;; prompt for a directory and a file name regexp. So, it's possible to process
417 ;; all or certain files on a directory at once (see also documentation for
418 ;; `pr-list-directory').
420 ;; `printing' has also a special way to handle some major mode through
421 ;; `*-mode*' commands. So it's possible to customize a major mode printing,
422 ;; it's only needed to declare the customization in `pr-mode-alist' (see
423 ;; section Options) and invoke some of `*-mode*' commands. An example for
424 ;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and
425 ;; you're in the *Summary* buffer, if you forget to switch to the *Article*
426 ;; buffer before printing, you'll get a nicely formatted list of article
427 ;; subjects shows up at the printer. With major mode printing you don't need
428 ;; to switch from gnus *Summary* buffer first.
430 ;; Current global keyboard mapping for GNU Emacs is:
432 ;; (global-set-key [print] 'pr-ps-fast-fire)
433 ;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
434 ;; (global-set-key [C-print] 'pr-txt-fast-fire)
436 ;; And for XEmacs is:
438 ;; (global-set-key 'f22 'pr-ps-fast-fire)
439 ;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
440 ;; (global-set-key '(control f22) 'pr-txt-fast-fire)
442 ;; As a suggestion of global keyboard mapping for some `printing' commands:
444 ;; (global-set-key "\C-ci" 'pr-interface)
445 ;; (global-set-key "\C-cbp" 'pr-ps-buffer-print)
446 ;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview)
447 ;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
448 ;; (global-set-key "\C-crp" 'pr-ps-region-print)
449 ;; (global-set-key "\C-crx" 'pr-ps-region-preview)
450 ;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
456 ;; Below it's shown a brief description of `printing' options, please, see the
457 ;; options declaration in the code for a long documentation.
459 ;; `pr-path-style' Specify which path style to use for external
462 ;; `pr-path-alist' Specify an alist for command paths.
464 ;; `pr-txt-name' Specify a printer for printing a text file.
466 ;; `pr-txt-printer-alist' Specify an alist of all text printers.
468 ;; `pr-ps-name' Specify a printer for printing a PostScript
471 ;; `pr-ps-printer-alist' Specify an alist for all PostScript printers.
473 ;; `pr-temp-dir' Specify a directory for temporary files during
476 ;; `pr-ps-temp-file' Specify PostScript temporary file name.
478 ;; `pr-gv-command' Specify path and name of the gsview/gv
481 ;; `pr-gs-command' Specify path and name of the ghostscript
484 ;; `pr-gs-switches' Specify ghostscript switches.
486 ;; `pr-gs-device' Specify ghostscript device switch value.
488 ;; `pr-gs-resolution' Specify ghostscript resolution switch value.
490 ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript.
492 ;; `pr-faces-p' Non-nil means print with face attributes.
494 ;; `pr-spool-p' Non-nil means spool printing in a buffer.
496 ;; `pr-file-landscape' Non-nil means print PostScript file in
497 ;; landscape orientation.
499 ;; `pr-file-duplex' Non-nil means print PostScript file in duplex
502 ;; `pr-file-tumble' Non-nil means print PostScript file in tumble
505 ;; `pr-auto-region' Non-nil means region is automagically detected.
507 ;; `pr-auto-mode' Non-nil means major-mode specific printing is
508 ;; prefered over normal printing.
510 ;; `pr-mode-alist' Specify an alist for a major-mode and printing
513 ;; `pr-ps-utility' Specify PostScript utility processing.
515 ;; `pr-ps-utility-alist' Specify an alist for PostScript utility
518 ;; `pr-menu-lock' Non-nil means menu is locked while selecting
521 ;; `pr-menu-char-height' Specify menu char height in pixels.
523 ;; `pr-menu-char-width' Specify menu char width in pixels.
525 ;; `pr-setting-database' Specify an alist for settings in general.
527 ;; `pr-visible-entry-list' Specify a list of Printing menu visible
530 ;; `pr-delete-temp-file' Non-nil means delete temporary files.
532 ;; `pr-list-directory' Non-nil means list directory when processing a
535 ;; `pr-buffer-name' Specify the name of the buffer interface for
538 ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be
539 ;; ignored in interface buffer.
541 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a
542 ;; field in interface buffer.
544 ;; To set the above options you may:
546 ;; a) insert the code in your ~/.emacs, like:
548 ;; (setq pr-faces-p t)
550 ;; This way always keep your default settings when you enter a new Emacs
553 ;; b) or use `set-variable' in your Emacs session, like:
555 ;; M-x set-variable RET pr-faces-p RET t RET
557 ;; This way keep your settings only during the current Emacs session.
559 ;; c) or use customization, for example:
560 ;; click on menu-bar *Help* option,
561 ;; then click on *Customize*,
562 ;; then click on *Browse Customization Groups*,
563 ;; expand *PostScript* group,
564 ;; expand *Printing* group
565 ;; and then customize `printing' options.
566 ;; Through this way, you may choose if the settings are kept or not when
567 ;; you leave out the current Emacs session.
569 ;; d) or see the option value:
571 ;; C-h v pr-faces-p RET
573 ;; and click the *customize* hypertext button.
574 ;; Through this way, you may choose if the settings are kept or not when
575 ;; you leave out the current Emacs session.
579 ;; M-x pr-customize RET
581 ;; and then customize `printing' options.
582 ;; Through this way, you may choose if the settings are kept or not when
583 ;; you leave out the current Emacs session.
585 ;; f) or use menu bar, for example:
586 ;; click on menu-bar *File* option,
587 ;; then click on *Printing*,
588 ;; then click on *Customize*,
589 ;; then click on *printing*
590 ;; and then customize `printing' options.
591 ;; Through this way, you may choose if the settings are kept or not when
592 ;; you leave out the current Emacs session.
598 ;; The `printing' menu (Tools/Printing or File/Print) has the following layout:
600 ;; +-----------------------------+
601 ;; A 0 | Printing Interface |
602 ;; +-----------------------------+ +-A---------+ +-B------+
603 ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
604 ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
605 ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
606 ;; +-----------------------------+ |Mode >|-- B |Other...|
607 ;; II 4 | Printify >|-----\ |File >|--\ +--------+
608 ;; 5 | Print >|---\ | |Despool... | |
609 ;; 6 | Text Printer: name >|-\ | | +-----------+ |
610 ;; +-----------------------------+ | | | +---------+ +------------+
611 ;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia
612 ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
613 ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C
614 ;; 10 |[ ]Line Number | | | +---------+ +------------+
615 ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
616 ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... |
617 ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... |
618 ;; 14 |[ ]Upside-Down | | |Region | | Other... |
619 ;; 15 | Print All Pages >|--\ | |Mode | +------------+
620 ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id
621 ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
622 ;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If
623 ;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
624 ;; +-----------------------------+ | |... |
625 ;; V 19 |[ ]Auto Region | | |(*)name |
626 ;; 20 |[ ]Auto Mode | | |... |
627 ;; 21 |[ ]Menu Lock | | +---------+ +--------------+
628 ;; +-----------------------------+ \------------------|(*)All Pages |
629 ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
630 ;; 23 | Show Settings >|-------|printing| |( )Odd Pages |
631 ;; 24 | Help | |ps-print| |( )Even Sheets|
632 ;; +-----------------------------+ |lpr | |( )Odd Sheets |
633 ;; +--------+ +--------------+
635 ;; See `pr-visible-entry-list' for hiding some parts of the menu.
637 ;; The menu has the following sections:
641 ;; 0. You can use a buffer interface instead of menus. It looks like the
642 ;; customization buffer. Basically, it has the same options found in the
643 ;; menu and some extra options, all this on a buffer.
645 ;; I. PostScript printing:
647 ;; 1. You can generate a PostScript file (if you type C-u before activating
648 ;; menu) or PostScript temporary file for a directory, a buffer, a region
649 ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
650 ;; after file generation, ghostview is activated using the file generated
651 ;; as argument. This option is disabled if spooling is on (option 16).
652 ;; Also, if you already have a PostScript file you can preview it.
653 ;; Instead of previewing each buffer, region or major mode at once, you
654 ;; can save temporarily the PostScript code generated in a buffer and
655 ;; preview it later. The option `Despool...' despools the PostScript
656 ;; spooling buffer in a temporary file and uses ghostview to preview it.
657 ;; If you type C-u before choosing this option, the PostScript code
658 ;; generated is saved in a file instead of saving in a temporary file.
659 ;; To spool the PostScript code generated you need to turn on the option
660 ;; 16. The option `Despool...' is enabled if spooling is on (option
663 ;; NOTE 1: It's possible to customize a major mode printing, just declare
664 ;; the customization in `pr-mode-alist' and invoke some of
665 ;; `*-mode*' commands or select Mode option in Printing menu. An
666 ;; example for major mode usage is when you're using gnus (or mh,
667 ;; or rmail, etc.) and you're in the *Summary* buffer, if you
668 ;; forget to switch to the *Article* buffer before printing,
669 ;; you'll get a nicely formatted list of article subjects shows
670 ;; up at the printer. With major mode printing you don't need to
671 ;; switch from gnus *Summary* buffer first.
673 ;; NOTE 2: There are the following options for PostScript file
675 ;; Ia. Print the file *No Preprocessing*, that is, send it
676 ;; directly to PostScript printer.
677 ;; Ib. PostScript utility processing selection.
678 ;; See `pr-ps-utility-alist' and `pr-setting-database' for
680 ;; Ic. Do n-up processing before printing.
681 ;; Id. Toggle on/off landscape for PostScript file processing.
682 ;; Ie. Toggle on/off duplex for PostScript file processing.
683 ;; If. Toggle on/off tumble for PostScript file processing.
685 ;; NOTE 3: Don't forget to download and install the utilities declared on
686 ;; `pr-ps-utility-alist'.
688 ;; 2. Operate the same way as option 1, but it sends directly the PostScript
689 ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to
690 ;; print the PostScript file generated. It depends on option 18, if it's
691 ;; turned on, it uses ghostscript; otherwise, it sends directly to
692 ;; printer. If spooling is on (option 16), the PostScript code is saved
693 ;; temporarily in a buffer instead of printing it or saving it in a file.
694 ;; Also, if you already have a PostScript file you can print it. Instead
695 ;; of printing each buffer, region or major mode at once, you can save
696 ;; temporarily the PostScript code generated in a buffer and print it
697 ;; later. The option `Despool...' despools the PostScript spooling
698 ;; buffer directly on a printer. If you type C-u before choosing this
699 ;; option, the PostScript code generated is saved in a file instead of
700 ;; sending to printer. To spool the PostScript code generated you need
701 ;; to turn on the option 16. This option is enabled if spooling is on
702 ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
704 ;; 3. You can select a new PostScript printer to send PostScript code
705 ;; generated. For selection it's used all PostScript printers defined
706 ;; in `pr-ps-printer-alist' variable (see it for documentation).
707 ;; See also `pr-setting-database'.
709 ;; II. Text printing:
711 ;; 4. If you have control characters (character code from \000 to \037) in a
712 ;; buffer and you want to print them in a text printer, select this
713 ;; option. All control characters in your buffer or region will be
714 ;; replaced by a printable representation. The printable representations
715 ;; use ^ (for ASCII control characters) or hex. The characters tab,
716 ;; linefeed, space, return and formfeed are not affected. You don't need
717 ;; to select this option if you use any option of section I, the
718 ;; PostScript engine treats control characters properly.
720 ;; 5. If you want to print a directory, buffer, region or major mode in a
721 ;; text printer, select this option. See also the NOTE 1 on option 1.
723 ;; 6. You can select a new text printer to send text generated. For
724 ;; selection it's used all text printers defined in
725 ;; `pr-txt-printer-alist' variable (see it for documentation).
726 ;; See also `pr-setting-database'.
728 ;; III. PostScript page toggle options:
730 ;; 7. If you want a PostScript landscape printing, turn on this option.
732 ;; 8. If you want to have a header in each page in your PostScript code,
733 ;; turn on this option.
735 ;; 9. If you want to draw a gaudy frame around the header, turn on this
736 ;; option. This option is enabled if print header is on (option 8).
738 ;; 10. If you want that the line number is printed in your PostScript code,
739 ;; turn on this option.
741 ;; 11. If you want background zebra stripes in your PostScript code, turn on
744 ;; 12. If you want a duplex printing and your PostScript printer has this
745 ;; feature, turn on this option.
747 ;; 13. If you turned on duplex printing, you can choose if you want to have
748 ;; a printing suitable for binding on the left or right (tumble off), or
749 ;; to have a printing suitable for binding at top or bottom (tumble on).
750 ;; This option is enabled if duplex is on (option 12).
752 ;; 14. If you want a PostScript upside-down printing, turn on this option.
754 ;; 15. With this option, you can choose if you want to print all pages, odd
755 ;; pages, even pages, odd sheets or even sheets.
756 ;; See also `ps-even-or-odd-pages'.
758 ;; IV. PostScript processing toggle options:
760 ;; 16. If you want to spool the PostScript code generated, turn on this
761 ;; option. To spool the PostScript code generated use option 2. You
762 ;; can despool later by choosing option 1 or 2, sub-option `Despool...'.
764 ;; 17. If you use colors in your buffers and want to see these colors on
765 ;; your PostScript code generated, turn on this option. If you have a
766 ;; black/white PostScript printer, these colors are displayed in gray
767 ;; scale by PostScript printer interpreter.
769 ;; 18. If you don't have a PostScript printer to send PostScript files, turn
770 ;; on this option. When this option is on, the ghostscript is used to
771 ;; print PostScript files. In GNU or Unix system, if ghostscript is set
772 ;; as a PostScript filter, you don't need to turn on this option.
774 ;; V. Printing customization:
776 ;; 19. If you want that region is automagically detected, turn on this
777 ;; option. Note that this will only work if you're using transient mark
778 ;; mode. When this option is on, the `*-buffer*' commands will behave
779 ;; like `*-region*' commands, that is, `*-buffer*' commands will print
780 ;; only the region marked instead of all buffer.
782 ;; 20. Turn this option on if you want that when current major-mode is
783 ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
784 ;; behave like `*-mode*' commands.
786 ;; 21. If you want that Printing menu stays open while you are setting
787 ;; toggle options, turn on this option. The variables
788 ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
789 ;; menu position, so don't forget to adjust these variables if menu
790 ;; position is not ok.
792 ;; VI. Customization:
794 ;; 22. Besides all options in section III, IV and V, you can customize much
795 ;; more PostScript options in `ps-print' option. Or you can customize
796 ;; some `lpr' options for text printing. Or customize `printing'
799 ;; 23. Show current settings for `printing', `ps-print' or `lpr'.
801 ;; 24. Quick help for printing menu layout.
807 ;; Below it's shown only the main options that affect all `printing' package.
808 ;; Check all the settings below *BEFORE* running `printing' commands.
810 ;; * Example of setting for GNU or Unix system:
812 ;; (require 'printing)
813 ;; (setq pr-path-alist
814 ;; '((unix "." "~/bin" ghostview mpage PATH)
815 ;; (ghostview "$HOME/bin/gsview-dir")
816 ;; (mpage "$HOME/bin/mpage-dir")
818 ;; (setq pr-txt-name 'prt_06a)
819 ;; (setq pr-txt-printer-alist
820 ;; '((prt_06a "lpr" nil "prt_06a")
821 ;; (prt_07c nil nil "prt_07c")
823 ;; (setq pr-ps-name 'lps_06b)
824 ;; (setq pr-ps-printer-alist
825 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
826 ;; (lps_07c "lpr" nil nil "lps_07c")
827 ;; (lps_08c nil nil nil "lps_08c")
829 ;; (setq pr-temp-dir "/tmp/")
830 ;; (setq pr-gv-command "gv")
831 ;; (setq pr-gs-command "gs")
832 ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
833 ;; (setq pr-gs-device "uniprint")
834 ;; (setq pr-gs-resolution 300)
835 ;; (setq pr-ps-utility 'mpage)
836 ;; (setq pr-ps-utility-alist
837 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
838 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
839 ;; (inherits-from: . no-duplex))
841 ;; (setq pr-setting-database
844 ;; (pr-file-duplex . nil)
845 ;; (pr-file-tumble . nil))
847 ;; (pr-update-menus t) ; update now printer and utility menus
849 ;; * Example of setting for Windows system:
851 ;; (require 'printing)
852 ;; (setq pr-path-alist
853 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
854 ;; (ghostview "c:/gs/gsview-dir")
855 ;; (mpage "c:/mpage-dir")
857 ;; (setq pr-txt-name 'prt_06a)
858 ;; (setq pr-txt-printer-alist
859 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
860 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
861 ;; (PRN "" nil "PRN")
862 ;; (standard "redpr.exe" nil "")
864 ;; (setq pr-ps-name 'lps_06b)
865 ;; (setq pr-ps-printer-alist
866 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
867 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
868 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
869 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
870 ;; (LPT1 "" nil "" "LPT1:")
871 ;; (PRN "" nil "" "PRN")
872 ;; (standard "redpr.exe" nil "" "")
874 ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/")
875 ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe")
876 ;; (setq pr-gs-command "c:/gs/gswin32.exe")
877 ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts"))
878 ;; (setq pr-gs-device "mswinpr2")
879 ;; (setq pr-gs-resolution 300)
880 ;; (setq pr-ps-utility 'psnup)
881 ;; (setq pr-ps-utility-alist
882 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " "
883 ;; nil (inherits-from: . no-duplex))
885 ;; (setq pr-setting-database
888 ;; (pr-file-duplex . nil)
889 ;; (pr-file-tumble . nil))
891 ;; (pr-update-menus t) ; update now printer and utility menus
893 ;; NOTE: Don't forget to download and install the utilities declared on
894 ;; `pr-ps-utility-alist'.
900 ;; `printing' package has the following utilities:
902 ;; `pr-setup' Return the current `printing' setup.
904 ;; `lpr-setup' Return the current `lpr' setup.
906 ;; `pr-update-menus' Update utility, PostScript and text printer menus.
908 ;; Below are some URL where you can find good utilities.
910 ;; * For `printing' package:
912 ;; printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz'
913 ;; ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'
915 ;; * For GNU or Unix system:
917 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
918 ;; enscript `http://people.ssh.fi/mtr/genscript/'
919 ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html'
920 ;; mpage `http://www.mesa.nl/pub/mpage/'
922 ;; * For Windows system:
925 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'
926 ;; enscript `http://people.ssh.fi/mtr/genscript/'
927 ;; psnup `http://www.dcs.ed.ac.uk/home/ajcd/psutils/index.html'
928 ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/'
934 ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions:
935 ;; - directory processing.
936 ;; - `pr-path-alist' variable.
938 ;; - a lot of tests on Windows.
940 ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests.
942 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging
943 ;; and for suggestions:
944 ;; - even/odd pages printing.
945 ;; - ghostscript parameters for `pr-ps-printer-alist'.
946 ;; - default printer name.
947 ;; - completion functions.
948 ;; - automagic region detection.
949 ;; - menu entry hiding.
950 ;; - fast fire PostScript printing command.
951 ;; - `pr-path-style' variable.
953 ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions:
954 ;; - PostScript Print and PostScript Print Preview merge.
955 ;; - Tools/Printing menu.
956 ;; - replace *-using-preview by *-using-ghostscript.
957 ;; - printer selection.
958 ;; - extra parameters for `pr-ps-printer-alist'.
961 ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el
962 ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el
963 ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el
964 ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el
965 ;; And to all people who contributed with them.
968 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
977 (and (string< ps-print-version
"6.6.4")
978 (error "`printing' requires `ps-print' package version 6.6.4 or later."))
982 (defconst pr-cygwin-system
983 (and ps-windows-system
(getenv "OSTYPE")
984 (string-match "cygwin" (getenv "OSTYPE")))))
987 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
988 ;; To avoid compilation gripes
993 (or (fboundp 'subst-char-in-string
)
994 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
995 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
996 Unless optional argument INPLACE is non-nil, return a new string."
997 (let ((i (length string
))
998 (newstr (if inplace string
(copy-sequence string
))))
999 (while (> (setq i
(1- i
)) 0)
1000 (if (eq (aref newstr i
) fromchar
)
1001 (aset newstr i tochar
)))
1005 (defalias 'pr-e-frame-char-height
'frame-char-height
)
1006 (defalias 'pr-e-frame-char-width
'frame-char-width
)
1007 (defalias 'pr-e-mouse-pixel-position
'mouse-pixel-position
)
1009 (defalias 'pr-x-add-submenu
'add-submenu
)
1010 (defalias 'pr-x-event-function
'event-function
)
1011 (defalias 'pr-x-event-object
'event-object
)
1012 (defalias 'pr-x-find-menu-item
'find-menu-item
)
1013 (defalias 'pr-x-font-height
'font-height
)
1014 (defalias 'pr-x-font-width
'font-width
)
1015 (defalias 'pr-x-get-popup-menu-response
'get-popup-menu-response
)
1016 (defalias 'pr-x-make-event
'make-event
)
1017 (defalias 'pr-x-misc-user-event-p
'misc-user-event-p
)
1018 (defalias 'pr-x-relabel-menu-item
'relabel-menu-item
)
1019 (defalias 'pr-x-event-x-pixel
'event-x-pixel
)
1020 (defalias 'pr-x-event-y-pixel
'event-y-pixel
)
1023 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
1024 (defvar deactivate-mark nil
)
1025 (defalias 'pr-f-set-keymap-parents
'set-keymap-parent
)
1026 (defalias 'pr-f-set-keymap-name
'ignore
)
1027 (defalias 'pr-f-read-string
'read-string
)
1028 (defun pr-keep-region-active ()
1029 (setq deactivate-mark nil
)))
1031 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
1032 (defvar current-menubar nil
)
1033 (defvar current-mouse-event nil
)
1034 (defvar zmacs-region-stays nil
)
1035 (defalias 'pr-f-set-keymap-parents
'set-keymap-parents
)
1036 (defalias 'pr-f-set-keymap-name
'set-keymap-name
)
1037 (defun pr-f-read-string (prompt initial history default
)
1038 (let ((str (read-string prompt initial
)))
1039 (if (and str
(not (string= str
"")))
1042 (defun pr-keep-region-active ()
1043 (setq zmacs-region-stays t
)))))
1046 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1047 ;; Customization Functions
1050 (defun pr-alist-custom-set (symbol value
)
1051 "Set the value of custom variables for printer & utility selection."
1053 (and (featurep 'printing
) ; update only after printing is loaded
1054 (pr-update-menus t
)))
1057 (defun pr-ps-utility-custom-set (symbol value
)
1058 "Update utility menu entry."
1060 (and (featurep 'printing
) ; update only after printing is loaded
1061 (pr-menu-set-utility-title value
)))
1064 (defun pr-ps-name-custom-set (symbol value
)
1065 "Update `PostScript Printer:' menu entry."
1067 (and (featurep 'printing
) ; update only after printing is loaded
1068 (pr-menu-set-ps-title value
)))
1071 (defun pr-txt-name-custom-set (symbol value
)
1072 "Update `Text Printer:' menu entry."
1074 (and (featurep 'printing
) ; update only after printing is loaded
1075 (pr-menu-set-txt-title value
)))
1078 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1079 ;; User Interface (I)
1082 (defgroup printing nil
1083 "Printing Utilities group"
1084 :tag
"Printing Utilities"
1085 :link
'(emacs-library-link :tag
"Source Lisp File" "printing.el")
1091 (defcustom pr-path-style
1092 (if (and (not pr-cygwin-system
)
1096 "*Specify which path style to use for external commands.
1100 windows Windows 9x/NT style (\\)
1102 unix Unix style (/)"
1103 :type
'(choice :tag
"Path style"
1104 (const :tag
"Windows 9x/NT Style (\\)" :value windows
)
1105 (const :tag
"Unix Style (/)" :value unix
))
1109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1110 ;; Internal Functions (I)
1113 (defun pr-dosify-file-name (path)
1114 "Replace unix-style directory separator character with dos/windows one."
1115 (interactive "sPath: ")
1116 (if (eq pr-path-style
'windows
)
1117 (subst-char-in-string ?
/ ?
\\ path
)
1121 (defun pr-unixify-file-name (path)
1122 "Replace dos/windows-style directory separator character with unix one."
1123 (interactive "sPath: ")
1124 (if (eq pr-path-style
'windows
)
1125 (subst-char-in-string ?
\\ ?
/ path
)
1129 (defun pr-standard-file-name (path)
1130 "Ensure the proper directory separator depending on the OS.
1131 That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory
1132 separator; otherwise, ensure unix-style directory separator."
1133 (if (or pr-cygwin-system ps-windows-system
)
1134 (subst-char-in-string ?
/ ?
\\ path
)
1135 (subst-char-in-string ?
\\ ?
/ path
)))
1138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1139 ;; User Interface (II)
1142 (defcustom pr-path-alist
1146 "*Specify an alist for command paths.
1148 It's used to find commands used for printing package, like gv, gs, gsview.exe,
1149 mpage, print.exe, etc. See also `pr-command' function.
1151 Each element has the form:
1153 (ENTRY DIRECTORY...)
1157 ENTRY It's a symbol, used to identify this entry.
1158 There must exist at least one of the following entries:
1160 unix this entry is used when Emacs is running on GNU or
1163 cygwin this entry is used when Emacs is running on Windows
1164 95/98/NT/2000 with Cygwin.
1166 windows this entry is used when Emacs is running on Windows
1169 DIRECTORY It should be a string or a symbol. If it's a symbol, it should
1170 exist an equal entry in `pr-path-alist'. If it's a string,
1171 it's considered a directory specification.
1173 The directory specification may contain:
1174 $var environment variable expansion
1176 ./ current directory
1177 ../ previous directory
1179 For example, let's say the home directory is /home/my and the
1180 current directory is /home/my/dir, so:
1182 THE ENTRY IS EXPANDED TO
1183 ~/entry /home/my/entry
1184 ./entry /home/my/dir/entry
1185 ../entry /home/my/entry
1186 $HOME/entry /home/my/entry
1187 $HOME/~/other/../my/entry /home/my/entry
1189 SPECIAL SYMBOL: If the symbol `PATH' is used in the directory
1190 list and there isn't a `PATH' entry in `pr-path-alist' or the
1191 `PATH' entry has a null directory list, the PATH environment
1196 * On GNU or Unix system:
1198 '((unix \".\" \"~/bin\" ghostview mpage PATH)
1199 (ghostview \"$HOME/bin/gsview-dir\")
1200 (mpage \"$HOME/bin/mpage-dir\")
1203 * On Windows system:
1205 '((windows \"c:/applications/executables\" PATH ghostview mpage)
1206 (ghostview \"c:/gs/gsview-dir\")
1207 (mpage \"c:/mpage-dir\")
1211 (symbol :tag
"Identifier ")
1212 (repeat :tag
"Directory List"
1213 (choice :menu-tag
"Directory"
1216 (symbol :value symbol
)))))
1220 (defcustom pr-txt-name
'default
1221 "*Specify a printer for printing a text file.
1223 The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
1226 This variable should be modified by customization engine. If this variable is
1227 modified by other means (for example, a lisp function), use `pr-update-menus'
1228 function (see it for documentation) to update text printer menu."
1230 :set
'pr-txt-name-custom-set
1234 (defcustom pr-txt-printer-alist
1235 (list (list 'default lpr-command nil
1236 (cond ((boundp 'printer-name
) printer-name
)
1237 (ps-windows-system "PRN")
1241 ;; * On GNU or Unix system:
1242 ;; '((prt_06a "lpr" nil "prt_06a")
1243 ;; (prt_07c nil nil "prt_07c")
1245 ;; * On Windows system:
1246 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
1247 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
1248 ;; (PRN "" nil "PRN")
1249 ;; (standard "redpr.exe" nil "")
1251 "*Specify an alist of all text printers (text printer database).
1253 The alist element has the form:
1255 (SYMBOL COMMAND SWITCHES NAME)
1259 SYMBOL It's a symbol to identify a text printer. It's for
1260 `pr-txt-name' variable setting and for menu selection.
1265 COMMAND Name of the program for printing a text file. On MS-DOS and
1266 MS-Windows systems, if the value is an empty string, then Emacs
1267 will write directly to the printer port given by NAME (see text
1268 below), that is, the NAME should be something like \"PRN\" or
1270 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1271 COMMAND shouldn't be an empty string.
1272 The programs `print' and `nprint' (the standard print programs
1273 on Windows NT and Novell Netware respectively) are handled
1274 specially, using NAME as the destination for output; any other
1275 program is treated like `lpr' except that an explicit filename
1276 is given as the last argument.
1277 If COMMAND is nil, it's used the default printing program:
1278 `print' for Windows system, `lp' for lp system and `lpr' for
1279 all other systems. See also `pr-path-alist'.
1285 SWITCHES List of sexp's to pass as extra options for text printer
1286 program. It is recommended to set NAME (see text below)
1287 instead of including an explicit switch on this list.
1293 NAME A string that specifies a text printer name.
1294 On Unix-like systems, a string value should be a name
1295 understood by lpr's -P option (or lp's -d option).
1296 On MS-DOS and MS-Windows systems, it is the name of a printer
1297 device or port. Typical non-default settings would be \"LPT1:\"
1298 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1299 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1300 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1301 printer. You can also set it to a name of a file, in which
1302 case the output gets appended to that file. If you want to
1303 discard the printed output, set this to \"NUL\".
1306 \"/D:\\\\\\\\host\\\\share-name\"
1313 This variable should be modified by customization engine. If this variable is
1314 modified by other means (for example, a lisp function), use `pr-update-menus'
1315 function (see it for documentation) to update text printer menu.
1319 * On GNU or Unix system:
1321 '((prt_06a \"lpr\" nil \"prt_06a\")
1322 (prt_07c nil nil \"prt_07c\")
1325 * On Windows system:
1327 '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\")
1328 (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\")
1329 (PRN \"\" nil \"PRN\")
1330 (standard \"redpr.exe\" nil \"\")
1333 (list :tag
"Text Printer"
1334 (symbol :tag
"Printer Symbol Name")
1335 (string :tag
"Printer Command")
1336 (repeat :tag
"Printer Switches"
1337 (sexp :tag
"Switch" :value
""))
1338 (choice :menu-tag
"Printer Name"
1340 (const :tag
"None" nil
)
1342 :set
'pr-alist-custom-set
1346 (defcustom pr-ps-name
'default
1347 "*Specify a printer for printing a PostScript file.
1349 This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
1352 This variable should be modified by customization engine. If this variable is
1353 modified by other means (for example, a lisp function), use `pr-update-menus'
1354 function (see it for documentation) to update PostScript printer menu."
1356 :set
'pr-ps-name-custom-set
1360 (defcustom pr-ps-printer-alist
1361 (list (list 'default lpr-command nil
1362 (cond (ps-windows-system nil
)
1365 (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name
)))
1367 ;; * On GNU or Unix system:
1368 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
1369 ;; (lps_07c "lpr" nil nil "lps_07c")
1370 ;; (lps_08c nil nil nil "lps_08c")
1372 ;; * On Windows system:
1373 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
1374 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
1375 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
1376 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
1377 ;; (LPT1 "" nil "" "LPT1:")
1378 ;; (PRN "" nil "" "PRN")
1379 ;; (standard "redpr.exe" nil "" "")
1381 "*Specify an alist for all PostScript printers (PostScript printer database).
1383 The alist element has the form:
1385 (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...)
1389 SYMBOL It's a symbol to identify a PostScript printer. It's for
1390 `pr-ps-name' variable setting and for menu selection.
1395 COMMAND Name of the program for printing a PostScript file. On MS-DOS
1396 and MS-Windows systems, if the value is an empty string then
1397 Emacs will write directly to the printer port given by NAME
1398 (see text below), that is, the NAME should be something like
1399 \"PRN\" or \"LPT1:\".
1400 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1401 COMMAND shouldn't be an empty string.
1402 The programs `print' and `nprint' (the standard print programs
1403 on Windows NT and Novell Netware respectively) are handled
1404 specially, using NAME as the destination for output; any other
1405 program is treated like `lpr' except that an explicit filename
1406 is given as the last argument.
1407 If COMMAND is nil, it's used the default printing program:
1408 `print' for Windows system, `lp' for lp system and `lpr' for
1409 all other systems. See also `pr-path-alist'.
1416 SWITCHES List of sexp's to pass as extra options for PostScript printer
1417 program. It is recommended to set NAME (see text below)
1418 instead of including an explicit switch on this list.
1424 PRINTER-SWITCH A string that specifies PostScript printer name switch. If
1425 it's necessary to have a space between PRINTER-SWITCH and NAME,
1426 it should be inserted at the end of PRINTER-SWITCH string.
1427 If PRINTER-SWITCH is nil, it's used the default printer name
1428 switch: `/D:' for Windows system, `-d' for lp system and `-P'
1429 for all other systems.
1440 NAME A string that specifies a PostScript printer name.
1441 On Unix-like systems, a string value should be a name
1442 understood by lpr's -P option (or lp's -d option).
1443 On MS-DOS and MS-Windows systems, it is the name of a printer
1444 device or port. Typical non-default settings would be \"LPT1:\"
1445 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1446 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1447 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1448 printer. You can also set it to a name of a file, in which
1449 case the output gets appended to that file. If you want to
1450 discard the printed output, set this to \"NUL\".
1453 \"\\\\\\\\host\\\\share-name\"
1456 \"/D:\\\\\\\\host\\\\share-name\"
1457 \"\\\\\\\\host\\\\share-name\"
1464 DEFAULT It's a way to set default values when this entry is selected.
1469 That associates VARIABLE with VALUE. when this entry is
1470 selected, it's executed the following command:
1472 (set VARIABLE (eval VALUE))
1474 Note that VALUE can be any valid lisp expression. So, don't
1475 forget to quote symbols and constant lists.
1476 If VARIABLE is the special keyword `inherits-from:', VALUE must
1477 be a symbol name setting defined in `pr-setting-database' from
1478 which the current setting inherits the context. Take care with
1479 circular inheritance.
1481 '(ps-landscape-mode . nil)
1482 '(ps-spool-duplex . t)
1483 '(pr-gs-device . (my-gs-device t))
1485 This variable should be modified by customization engine. If this variable is
1486 modified by other means (for example, a lisp function), use `pr-update-menus'
1487 function (see it for documentation) to update PostScript printer menu.
1491 * On GNU or Unix system:
1493 '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\")
1494 (lps_07c \"lpr\" nil nil \"lps_07c\")
1495 (lps_08c nil nil nil \"lps_08c\")
1498 * On Windows system:
1500 '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\")
1501 (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\")
1502 (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\")
1503 (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\")
1504 (LPT1 \"\" nil \"\" \"LPT1:\")
1505 (PRN \"\" nil \"\" \"PRN\")
1506 (standard \"redpr.exe\" nil \"\" \"\")
1510 :tag
"PostScript Printer"
1511 (symbol :tag
"Printer Symbol Name")
1512 (string :tag
"Printer Command")
1513 (repeat :tag
"Printer Switches"
1514 (sexp :tag
"Switch" :value
""))
1515 (choice :menu-tag
"Printer Name Switch"
1516 :tag
"Printer Name Switch"
1517 (const :tag
"None" nil
)
1519 (choice :menu-tag
"Printer Name"
1521 (const :tag
"None" nil
)
1524 :tag
"Default Value List"
1529 :menu-tag
"Variable"
1531 (const :tag
"Landscape" ps-landscape-mode
)
1532 (const :tag
"Print Header" ps-print-header
)
1533 (const :tag
"Print Header Frame" ps-print-header-frame
)
1534 (const :tag
"Line Number" ps-line-number
)
1535 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
1536 (const :tag
"Duplex" ps-spool-duplex
)
1537 (const :tag
"Tumble" ps-spool-tumble
)
1538 (const :tag
"Upside-Down" ps-print-upside-down
)
1539 (const :tag
"PS File Landscape" pr-file-landscape
)
1540 (const :tag
"PS File Duplex" pr-file-duplex
)
1541 (const :tag
"PS File Tumble" pr-file-tumble
)
1542 (const :tag
"Auto Region" pr-auto-region
)
1543 (const :tag
"Auto Mode" pr-auto-mode
)
1544 (const :tag
"Ghostscript Device" pr-gs-device
)
1545 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
1546 (const :tag
"inherits-from:" inherits-from
:)
1547 (variable :tag
"Other"))
1548 (sexp :tag
"Value")))
1550 :set
'pr-alist-custom-set
1554 (defcustom pr-temp-dir
1555 (pr-dosify-file-name
1556 (if (boundp 'temporary-file-directory
)
1557 (symbol-value 'temporary-file-directory
)
1558 ;; hacked from `temporary-file-directory' variable in files.el
1559 (file-name-as-directory
1560 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
1561 (cond (ps-windows-system "c:/temp")
1562 ((memq system-type
'(vax-vms axp-vms
)) "SYS$SCRATCH:")
1565 "*Specify a directory for temporary files during printing."
1566 :type
'(directory :tag
"Temporary Directory")
1570 (defcustom pr-ps-temp-file
"prspool.ps"
1571 "*Specify PostScript temporary file name."
1572 :type
'(file :tag
"PostScript Temporary File Name")
1576 (defcustom pr-gv-command
1577 (if ps-windows-system
1580 "*Specify path and name of the gsview/gv utility.
1582 See also `pr-path-alist'."
1583 :type
'(string :tag
"Ghostview Utility")
1587 (defcustom pr-gs-command
1588 (if ps-windows-system
1591 "*Specify path and name of the ghostscript utility.
1593 See also `pr-path-alist'."
1594 :type
'(string :tag
"Ghostscript Utility")
1598 (defcustom pr-gs-switches
1599 (if ps-windows-system
1600 '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")
1601 '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
1602 "*Specify ghostscript switches. See the documentation on GS for more info.
1604 It's a list of strings, where each string is one or more ghostscript switches.
1606 A note on the gs switches:
1609 -dNOPAUSE don't wait for user intervention
1610 -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs
1611 -c quit it's added at the end to terminate gs
1613 To see ghostscript documentation for more information:
1615 * On GNU or Unix system:
1616 - for full documentation, type: man gs
1617 - for brief documentation, type: gs -h
1619 * On Windows system:
1620 - for full documentation, see in a browser the file
1621 c:/gstools/gs5.50/index.html, that is, the file index.html which is
1622 located in the same directory as gswin32.exe.
1623 - for brief documentation, type: gswin32.exe -h"
1624 :type
'(repeat (string :tag
"Ghostscript Switch"))
1628 (defcustom pr-gs-device
1629 (if ps-windows-system
1632 "*Specify the ghostscript device switch value (-sDEVICE=).
1634 A note on the gs switches:
1636 -sDEVICE=djet500 the printer - works with HP DeskJet 540
1638 See `pr-gs-switches' for documentation.
1639 See also `pr-ps-printer-alist'."
1640 :type
'(string :tag
"Ghostscript Device")
1644 (defcustom pr-gs-resolution
300
1645 "*Specify ghostscript resolution switch value (-r).
1647 A note on the gs switches:
1649 -r300 resolution 300x300
1651 See `pr-gs-switches' for documentation.
1652 See also `pr-ps-printer-alist'."
1653 :type
'(integer :tag
"Ghostscript Resolution")
1657 (defcustom pr-print-using-ghostscript nil
1658 "*Non-nil means print using ghostscript.
1660 This is useful if you don't have a PostScript printer, so you could use the
1661 ghostscript to print a PostScript file.
1663 In GNU or Unix system, if ghostscript is set as a PostScript filter, this
1664 variable should be nil."
1669 (defcustom pr-faces-p nil
1670 "*Non-nil means print with face attributes."
1675 (defcustom pr-spool-p nil
1676 "*Non-nil means spool printing in a buffer."
1681 (defcustom pr-file-landscape nil
1682 "*Non-nil means print PostScript file in landscape orientation."
1687 (defcustom pr-file-duplex nil
1688 "*Non-nil means print PostScript file in duplex mode."
1693 (defcustom pr-file-tumble nil
1694 "*Non-nil means print PostScript file in tumble mode.
1696 If tumble is off, produces a printing suitable for binding on the left or
1698 If tumble is on, produces a printing suitable for binding at the top or
1704 (defcustom pr-auto-region t
1705 "*Non-nil means region is automagically detected.
1707 Note that this will only work if you're using transient mark mode.
1709 When this variable is non-nil, the `*-buffer*' commands will behave like
1710 `*-region*' commands, that is, `*-buffer*' commands will print only the region
1711 marked instead of all buffer."
1716 (defcustom pr-auto-mode t
1717 "*Non-nil means major-mode specific printing is prefered over normal printing.
1719 That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
1720 and `*-region*' commands will behave like `*-mode*' commands; otherwise,
1721 `*-buffer*' commands will print the current buffer and `*-region*' commands
1722 will print the current region."
1727 (defcustom pr-mode-alist
1728 '((mh-folder-mode ; mh summary buffer
1729 pr-mh-lpr-1 pr-mh-print-1
1731 (ps-article-author ps-article-subject
)
1732 ("/pagenumberstring load" pr-article-date
)
1735 (mh-letter-mode ; mh letter buffer
1736 pr-mh-lpr-2 pr-mh-print-2
1738 (ps-article-author ps-article-subject
)
1739 ("/pagenumberstring load" pr-article-date
)
1742 (rmail-summary-mode ; rmail summary buffer
1743 pr-rmail-lpr pr-rmail-print
1745 (ps-article-subject ps-article-author buffer-name
)
1749 (rmail-mode ; rmail buffer
1750 pr-rmail-lpr pr-rmail-print
1752 (ps-article-subject ps-article-author buffer-name
)
1756 (gnus-summary-mode ; gnus summary buffer
1757 pr-gnus-lpr pr-gnus-print
1759 (ps-article-subject ps-article-author gnus-newsgroup-name
)
1763 (gnus-article-mode ; gnus article buffer
1764 pr-gnus-lpr pr-gnus-print
1766 (ps-article-subject ps-article-author gnus-newsgroup-name
)
1770 (Info-mode ; Info buffer
1771 pr-mode-lpr pr-mode-print
1773 (ps-info-node ps-info-file
)
1778 pr-vm-lpr pr-vm-print
1780 (ps-article-subject ps-article-author buffer-name
)
1785 "*Specify an alist for a major-mode and printing functions.
1787 To customize a major mode printing, just declare the customization in
1788 `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major
1789 mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the
1790 *Summary* buffer, if you forget to switch to the *Article* buffer before
1791 printing, you'll get a nicely formatted list of article subjects shows up at
1792 the printer. With major mode printing you don't need to switch from gnus
1793 *Summary* buffer first.
1795 The elements have the following form:
1807 MAJOR-MODE It's the major mode symbol.
1809 LPR-PRINT It's a symbol function for text printing. It's invoked with
1811 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
1813 Usually LPR-PRINT function prepares the environment or buffer
1814 and then call the function `pr-mode-lpr' which it's used to
1815 process the buffer and send it to text printer.
1817 The `pr-mode-lpr' definition is:
1819 (pr-mode-lpr HEADER-LIST &optional FROM TO)
1821 Where HEADER-LIST is like the argument passed to LPR-PRINT.
1822 FROM and TO are the beginning and end markers, respectively,
1823 for a region. If FROM is nil, it's used (point-min); if TO is
1824 nil, it's used (point-max).
1826 PS-PRINT It's a symbol function for PostScript printing. It's invoked
1827 with 3 arguments: n-up printing, file name and the list:
1828 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
1830 Usually PS-PRINT function prepares the environment or buffer
1831 and then call the function `pr-mode-print' which it's used to
1832 process the buffer and send it to PostScript printer.
1834 The `pr-mode-print' definition is:
1836 (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO)
1838 Where N-UP, FILENAME and HEADER-LIST are like the arguments
1839 passed to PS-PRINT. FROM and TO are the beginning and end
1840 markers, respectively, for a region. If TO is nil, it's used
1843 HEADER-LINES It's the number of header lines; if is nil, it uses
1844 `ps-header-lines' value.
1846 LEFT-HEADER It's the left header part, it's a list of string, variable
1847 symbol or function symbol (with no argument); if is nil, it
1848 uses `ps-left-header' value.
1850 RIGHT-HEADER It's the right header part, it's a list of string, variable
1851 symbol or function symbol (with no argument); if is nil, it
1852 uses `ps-right-header' value.
1855 Non-nil means to kill all buffer local variable declared in
1856 DEFAULT (see below).
1858 DEFAULT It's a way to set default values when this entry is selected.
1861 (VARIABLE-SYM . VALUE)
1863 That associates VARIABLE-SYM with VALUE. when this entry is
1864 selected, it's executed the following command:
1866 (set (make-local-variable VARIABLE-SYM) (eval VALUE))
1868 Note that VALUE can be any valid lisp expression. So, don't
1869 forget to quote symbols and constant lists.
1870 If VARIABLE is the special keyword `inherits-from:', VALUE must
1871 be a symbol name setting defined in `pr-setting-database' from
1872 which the current setting inherits the context. Take care with
1873 circular inheritance.
1875 '(ps-landscape-mode . nil)
1876 '(ps-spool-duplex . t)
1877 '(pr-gs-device . (my-gs-device t))"
1881 (symbol :tag
"Major Mode")
1882 (function :tag
"Text Printing Function")
1883 (function :tag
"PS Printing Function")
1884 (choice :menu-tag
"Number of Header Lines"
1885 :tag
"Number of Header Lines"
1886 (integer :tag
"Number")
1887 (const :tag
"Default Number" nil
))
1888 (repeat :tag
"Left Header List"
1889 (choice :menu-tag
"Left Header"
1892 (repeat :tag
"Right Header List"
1893 (choice :menu-tag
"Right Header"
1896 (boolean :tag
"Kill Local Variable At End")
1898 :tag
"Default Value List"
1903 :menu-tag
"Variable"
1905 (const :tag
"Landscape" ps-landscape-mode
)
1906 (const :tag
"Print Header" ps-print-header
)
1907 (const :tag
"Print Header Frame" ps-print-header-frame
)
1908 (const :tag
"Line Number" ps-line-number
)
1909 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
1910 (const :tag
"Duplex" ps-spool-duplex
)
1911 (const :tag
"Tumble" ps-spool-tumble
)
1912 (const :tag
"Upside-Down" ps-print-upside-down
)
1913 (const :tag
"PS File Landscape" pr-file-landscape
)
1914 (const :tag
"PS File Duplex" pr-file-duplex
)
1915 (const :tag
"PS File Tumble" pr-file-tumble
)
1916 (const :tag
"Auto Region" pr-auto-region
)
1917 (const :tag
"Auto Mode" pr-auto-mode
)
1918 (const :tag
"Ghostscript Device" pr-gs-device
)
1919 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
1920 (const :tag
"inherits-from:" inherits-from
:)
1921 (variable :tag
"Other"))
1922 (sexp :tag
"Value")))
1927 (defcustom pr-ps-utility
'mpage
1928 "*Specify PostScript utility symbol.
1930 This utility symbol should be defined on `pr-ps-utility-alist' (see it for
1933 This variable should be modified by customization engine. If this variable is
1934 modified by other means (for example, a lisp function), use `pr-update-menus'
1935 function (see it for documentation) to update PostScript utility menu.
1937 NOTE: Don't forget to download and install the utilities declared on
1938 `pr-ps-utility-alist'."
1939 :type
'(symbol :tag
"PS File Utility")
1940 :set
'pr-ps-utility-custom-set
1944 (defcustom pr-ps-utility-alist
1945 '((mpage "mpage" nil
"-b%s" "-%d" "-l" "-t" "-T" ">" nil
)
1946 (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil
" " nil
1947 (inherits-from: . no-duplex
))
1950 ;; * On GNU or Unix system:
1951 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
1952 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
1953 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
1955 ;; * On Windows system:
1956 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
1957 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
1959 "*Specify an alist for PostScript utility processing (PS utility database).
1961 The alist element has the form:
1963 (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT
1964 SWITCHES DEFAULT...)
1968 SYMBOL It's a symbol to identify a PostScript utility. It's for
1969 `pr-ps-utility' variable setting and for menu selection.
1974 UTILITY Name of utility for processing a PostScript file.
1975 See also `pr-path-alist'.
1977 . for GNU or Unix system:
1981 . for Windows system:
1982 \"c:/psutils/psnup -q\"
1984 MUST-SWITCHES List of sexp's to pass as options to the PostScript utility
1985 program. These options are necessary to process the utility
1986 program and must be placed before any other switches.
1991 PAPERSIZE It's a format string to specify paper size switch.
1996 N-UP It's a format string to specify n-up switch.
2001 LANDSCAPE It's a string to specify landscape switch. If the utility
2002 doesn't have landscape switch, set to nil.
2007 DUPLEX It's a string to specify duplex switch. If the utility doesn't
2008 have duplex switch, set to nil.
2013 TUMBLE It's a string to specify tumble switch. If the utility doesn't
2014 have tumble switch, set to nil.
2019 OUTPUT It's a string to specify how to generate an output file. Some
2020 utilities accept an output file option, but some others need
2021 output redirection or some other way to specify an output file.
2024 \" \" ; psnup ... input output
2027 \">\" ; mpage ... input > output
2029 SWITCHES List of sexp's to pass as extra options to the PostScript utility
2036 DEFAULT It's a way to set default values when this entry is selected.
2041 That associates VARIABLE with VALUE. when this entry is
2042 selected, it's executed the following command:
2044 (set VARIABLE (eval VALUE))
2046 Note that VALUE can be any valid lisp expression. So, don't
2047 forget to quote symbols and constant lists.
2048 If VARIABLE is the special keyword `inherits-from:', VALUE must
2049 be a symbol name setting defined in `pr-setting-database' from
2050 which the current setting inherits the context. Take care with
2051 circular inheritance.
2053 '(pr-file-landscape . nil)
2054 '(pr-file-duplex . t)
2055 '(pr-gs-device . (my-gs-device t))
2057 This variable should be modified by customization engine. If this variable is
2058 modified by other means (for example, a lisp function), use `pr-update-menus'
2059 function (see it for documentation) to update PostScript utility menu.
2061 NOTE: Don't forget to download and install the utilities declared on
2062 `pr-ps-utility-alist'.
2066 * On GNU or Unix system:
2068 '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil)
2069 (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil
2070 (pr-file-duplex . nil) (pr-file-tumble . nil))
2073 * On Windows system:
2075 '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \"
2076 nil (pr-file-duplex . nil) (pr-file-tumble . nil))
2079 (list :tag
"PS File Utility"
2080 (symbol :tag
"Utility Symbol")
2081 (string :tag
"Utility Name")
2082 (repeat :tag
"Must Utility Switches"
2083 (sexp :tag
"Switch" :value
""))
2084 (choice :menu-tag
"Paper Size"
2086 (const :tag
"No Paper Size" nil
)
2087 (string :tag
"Paper Size Format"))
2088 (choice :menu-tag
"N-Up"
2090 (const :tag
"No N-Up" nil
)
2091 (string :tag
"N-Up Format"))
2092 (choice :menu-tag
"Landscape"
2094 (const :tag
"No Landscape" nil
)
2095 (string :tag
"Landscape Switch"))
2096 (choice :menu-tag
"Duplex"
2098 (const :tag
"No Duplex" nil
)
2099 (string :tag
"Duplex Switch"))
2100 (choice :menu-tag
"Tumble"
2102 (const :tag
"No Tumble" nil
)
2103 (string :tag
"Tumble Switch"))
2104 (string :tag
"Output Separator")
2105 (repeat :tag
"Utility Switches"
2106 (sexp :tag
"Switch" :value
""))
2108 :tag
"Default Value List"
2113 :menu-tag
"Variable"
2115 (const :tag
"PS File Landscape" pr-file-landscape
)
2116 (const :tag
"PS File Duplex" pr-file-duplex
)
2117 (const :tag
"PS File Tumble" pr-file-tumble
)
2118 (const :tag
"Ghostscript Device" pr-gs-device
)
2119 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2120 (const :tag
"inherits-from:" inherits-from
:)
2121 (variable :tag
"Other"))
2122 (sexp :tag
"Value")))
2124 :set
'pr-alist-custom-set
2128 (defcustom pr-menu-lock t
2129 "*Non-nil means menu is locked while selecting toggle options.
2131 See also `pr-menu-char-height' and `pr-menu-char-width'."
2136 (defcustom pr-menu-char-height
2137 (cond ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2138 (pr-e-frame-char-height))
2139 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2140 (pr-x-font-height (face-font 'default
))))
2141 "*Specify menu char height in pixels.
2143 This variable is used to guess which vertical position should be locked the
2144 menu, so don't forget to adjust it if menu position is not ok.
2146 See also `pr-menu-lock' and `pr-menu-char-width'."
2151 (defcustom pr-menu-char-width
2152 (cond ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2153 (pr-e-frame-char-width))
2154 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2155 (pr-x-font-width (face-font 'default
))))
2156 "*Specify menu char width in pixels.
2158 This variable is used to guess which horizontal position should be locked the
2159 menu, so don't forget to adjust it if menu position is not ok.
2161 See also `pr-menu-lock' and `pr-menu-char-height'."
2166 (defcustom pr-setting-database
2167 '((no-duplex ; setting symbol name
2168 nil nil nil
; inherits local kill-local
2169 (pr-file-duplex . nil
) ; settings
2170 (pr-file-tumble . nil
))
2172 "*Specify an alist for settings in general.
2174 The elements have the following form:
2176 (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...)
2180 SYMBOL It's a symbol to identify the setting group.
2182 INHERITS Specify the inheritance for SYMBOL group. It's a symbol name
2183 setting from which the current setting inherits the context.
2184 If INHERITS is nil, means that there is no inheritance.
2185 This is a simple inheritance mechanism.
2187 Let's see an example to illustrate the inheritance mechanism:
2189 (setq pr-setting-database
2190 '((no-duplex ; setting symbol name
2192 nil nil ; local kill-local
2193 (pr-file-duplex . nil) ; settings
2194 (pr-file-tumble . nil)
2196 (no-duplex-and-landscape ; setting symbol name
2197 no-duplex ; inherits
2198 nil nil ; local kill-local
2199 (pr-file-landscape . nil) ; settings
2202 The example above has two setting groups: no-duplex and
2203 no-duplex-and-landscape. When setting no-duplex is activated
2204 through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist'
2205 and `pr-ps-printer-alist'), the variables pr-file-duplex and
2206 pr-file-tumble are both set to nil.
2208 Now when setting no-duplex-and-landscape is activated through
2209 `inherits-from:', the variable pr-file-landscape is set to nil
2210 and also the settings for no-duplex are done, because
2211 no-duplex-and-landscape inherits settings from no-duplex.
2213 Take care with circular inheritance. It's an error if circular
2214 inheritance happens.
2216 LOCAL Non-nil means that all settings for SYMBOL group will be
2217 declared local buffer.
2219 KILL-LOCAL Non-nil means that all settings for SYMBOL group will be
2220 killed at end. It has effect only when LOCAL is non-nil.
2222 SETTING It's a cons like:
2226 That associates VARIABLE with VALUE. when this entry is
2227 selected, it's executed the following command:
2229 * If LOCAL is non-nil:
2230 (set (make-local-variable VARIABLE) (eval VALUE))
2233 (set VARIABLE (eval VALUE))
2235 Note that VALUE can be any valid lisp expression. So, don't
2236 forget to quote symbols and constant lists.
2237 This setting is ignored if VARIABLE is equal to keyword
2240 '(ps-landscape-mode . nil)
2241 '(ps-spool-duplex . t)
2242 '(pr-gs-device . (my-gs-device t))"
2246 (symbol :tag
"Setting Name")
2247 (choice :menu-tag
"Inheritance"
2249 (const :tag
"No Inheritance" nil
)
2250 (symbol :tag
"Inherits From"))
2251 (boolean :tag
"Local Buffer Setting")
2252 (boolean :tag
"Kill Local Variable At End")
2259 :menu-tag
"Variable"
2261 (const :tag
"Landscape" ps-landscape-mode
)
2262 (const :tag
"Print Header" ps-print-header
)
2263 (const :tag
"Print Header Frame" ps-print-header-frame
)
2264 (const :tag
"Line Number" ps-line-number
)
2265 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2266 (const :tag
"Duplex" ps-spool-duplex
)
2267 (const :tag
"Tumble" ps-spool-tumble
)
2268 (const :tag
"Upside-Down" ps-print-upside-down
)
2269 (const :tag
"PS File Landscape" pr-file-landscape
)
2270 (const :tag
"PS File Duplex" pr-file-duplex
)
2271 (const :tag
"PS File Tumble" pr-file-tumble
)
2272 (const :tag
"Auto Region" pr-auto-region
)
2273 (const :tag
"Auto Mode" pr-auto-mode
)
2274 (const :tag
"Ghostscript Device" pr-gs-device
)
2275 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2276 (variable :tag
"Other"))
2277 (sexp :tag
"Value")))
2282 (defcustom pr-visible-entry-list
2283 '(postscript text postscript-options postscript-process printing help
)
2284 "*Specify a list of Printing menu visible entries.
2286 Valid values with the corresponding menu parts are:
2288 +------------------------------+
2289 | Printing Interface |
2290 +------------------------------+
2291 `postscript' | PostScript Preview >|
2292 | PostScript Print >|
2293 | PostScript Printer: name >|
2294 +------------------------------+
2295 `text' | Printify >|
2297 | Text Printer: name >|
2298 +------------------------------+
2299 `postscript-options' |[ ] Landscape |
2301 |[ ] Print Header Frame |
2303 |[ ] Zebra Stripes |
2307 | Print All Pages >|
2308 +------------------------------+
2309 `postscript-process' |[ ] Spool Buffer |
2310 |[ ] Print with faces |
2311 |[ ] Print via Ghostscript |
2312 +------------------------------+
2313 `printing' |[ ] Auto Region |
2316 +------------------------------+
2317 `help' | Customize >|
2320 +------------------------------+
2322 Any other value is ignored."
2323 :type
'(repeat :tag
"Menu Visible Part"
2324 (choice :menu-tag
"Menu Part"
2328 (const postscript-options
)
2329 (const postscript-process
)
2335 (defcustom pr-delete-temp-file t
2336 "*Non-nil means delete temporary files.
2338 Set `pr-delete-temp-file' to nil, if the following message (or a similar)
2339 happens when printing:
2341 Error: could not open \"c:\\temp\\prspool.ps\" for reading."
2346 (defcustom pr-list-directory nil
2347 "*Non-nil means list directory when processing a directory.
2349 That is, any subdirectories (and the superdirectory) of the directory (given as
2350 argument of functions below) are also printed (as dired-mode listings).
2352 It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
2353 `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
2354 and `pr-txt-directory'."
2359 (defcustom pr-buffer-name
"*Printing Interface*"
2360 "*Specify the name of the buffer interface for printing package.
2362 It's used by `pr-interface'."
2367 (defcustom pr-buffer-name-ignore
2368 (list (regexp-quote pr-buffer-name
) ; ignore printing interface buffer
2369 "^ .*$") ; ignore invisible buffers
2370 "*Specify a regexp list for buffer names to be ignored in interface buffer.
2372 NOTE: Case is important for matching, that is, `case-fold-search' is always
2375 It's used by `pr-interface'."
2376 :type
'(repeat (regexp :tag
"Buffer Name Regexp"))
2380 (defcustom pr-buffer-verbose t
2381 "*Non-nil means to be verbose when editing a field in interface buffer.
2383 It's used by `pr-interface'."
2388 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2389 ;; Internal Variables
2392 (defvar pr-txt-command nil
2393 "Name of program for printing a text file.
2394 See `pr-txt-printer-alist'.")
2397 (defvar pr-txt-switches nil
2398 "List of sexp's to pass as extra options to the text printer program.
2399 See `pr-txt-printer-alist'.")
2402 (defvar pr-txt-printer nil
2403 "Specify text printer name.
2404 See `pr-txt-printer-alist'.")
2407 (defvar pr-ps-command nil
2408 "Name of program for printing a PostScript file.
2409 See `pr-ps-printer-alist'.")
2412 (defvar pr-ps-switches nil
2413 "List of sexp's to pass as extra options to the PostScript printer program.
2414 See `pr-ps-printer-alist'.")
2417 (defvar pr-ps-printer-switch nil
2418 "Specify PostScript printer name switch.
2419 See `pr-ps-printer-alist'.")
2422 (defvar pr-ps-printer nil
2423 "Specify PostScript printer name.
2424 See `pr-ps-printer-alist'.")
2427 (defvar pr-menu-bar nil
2428 "Specify Printing menu-bar entry.")
2431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2435 (defmacro pr-xemacs-global-menubar
(&rest body
)
2437 (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
2438 ;; be sure to access global menubar
2441 (kill-buffer temp
))))
2444 (defsubst pr-visible-p
(key)
2445 (memq key pr-visible-entry-list
))
2448 (defsubst pr-mode-alist-p
()
2449 (cdr (assq major-mode pr-mode-alist
)))
2452 (defsubst pr-auto-mode-p
()
2453 (and pr-auto-mode
(pr-mode-alist-p)))
2456 (defsubst pr-using-ghostscript-p
()
2457 (and pr-print-using-ghostscript
(not pr-spool-p
)))
2461 (defun pr-get-symbol (name)
2462 ;; Recent versions of easy-menu downcase names before interning them.
2463 (and (fboundp 'easy-menu-name-match
)
2464 (setq name
(downcase name
)))
2465 (or (intern-soft name
)
2466 (make-symbol name
)))
2469 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2470 (defsubst pr-region-active-p
()
2471 (and pr-auto-region transient-mark-mode mark-active
)))
2473 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2474 (defvar zmacs-region-stays nil
) ; to avoid compilation gripes
2475 (defsubst pr-region-active-p
()
2476 (and pr-auto-region
(not zmacs-region-stays
) (ps-mark-active-p)))))
2479 (defconst pr-menu-spec
2481 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2483 ["Printing Interface" pr-interface
2484 :help
"Use buffer interface instead of menu interface"]
2486 ("PostScript Preview" :visible
(pr-visible-p 'postscript
)
2487 :help
"Preview PostScript instead of sending to printer"
2488 ("Directory" :active
(not pr-spool-p
)
2489 ["1-up" (pr-ps-directory-preview 1 nil nil t
) t
]
2490 ["2-up" (pr-ps-directory-preview 2 nil nil t
) t
]
2491 ["4-up" (pr-ps-directory-preview 4 nil nil t
) t
]
2492 ["Other..." (pr-ps-directory-preview nil nil nil t
)
2493 :keys
"\\[pr-ps-buffer-preview]"])
2494 ("Buffer" :active
(not pr-spool-p
)
2495 ["1-up" (pr-ps-buffer-preview 1 t
) t
]
2496 ["2-up" (pr-ps-buffer-preview 2 t
) t
]
2497 ["4-up" (pr-ps-buffer-preview 4 t
) t
]
2498 ["Other..." (pr-ps-buffer-preview nil t
)
2499 :keys
"\\[pr-ps-buffer-preview]"])
2500 ("Region" :active
(and (not pr-spool-p
) (ps-mark-active-p))
2501 ["1-up" (pr-ps-region-preview 1 t
) t
]
2502 ["2-up" (pr-ps-region-preview 2 t
) t
]
2503 ["4-up" (pr-ps-region-preview 4 t
) t
]
2504 ["Other..." (pr-ps-region-preview nil t
)
2505 :keys
"\\[pr-ps-region-preview]"])
2506 ("Mode" :active
(and (not pr-spool-p
) (pr-mode-alist-p))
2507 ["1-up" (pr-ps-mode-preview 1 t
) t
]
2508 ["2-up" (pr-ps-mode-preview 2 t
) t
]
2509 ["4-up" (pr-ps-mode-preview 4 t
) t
]
2510 ["Other..." (pr-ps-mode-preview nil t
)
2511 :keys
"\\[pr-ps-mode-preview]"])
2513 ["No Preprocessing..." (call-interactively 'pr-ps-file-preview
)
2514 :keys
"\\[pr-ps-file-preview]"
2515 :help
"Preview PostScript file"]
2517 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
2518 :help
"Select PostScript utility"]
2520 ["1-up..." (pr-ps-file-up-preview 1 t t
) pr-ps-utility-alist
]
2521 ["2-up..." (pr-ps-file-up-preview 2 t t
) pr-ps-utility-alist
]
2522 ["4-up..." (pr-ps-file-up-preview 4 t t
) pr-ps-utility-alist
]
2523 ["Other..." (pr-ps-file-up-preview nil t t
)
2524 :keys
"\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist
]
2526 ["Landscape" pr-toggle-file-landscape
2527 :style toggle
:selected pr-file-landscape
2528 :help
"Toggle landscape for PostScript file"
2529 :active pr-ps-utility-alist
]
2530 ["Duplex" pr-toggle-file-duplex
2531 :style toggle
:selected pr-file-duplex
2532 :help
"Toggle duplex for PostScript file"
2533 :active pr-ps-utility-alist
]
2534 ["Tumble" pr-toggle-file-tumble
2535 :style toggle
:selected pr-file-tumble
2536 :help
"Toggle tumble for PostScript file"
2537 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2538 ["Despool..." (call-interactively 'pr-despool-preview
)
2539 :active pr-spool-p
:keys
"\\[pr-despool-preview]"
2540 :help
"Despool PostScript buffer to printer or file (C-u)"])
2541 ("PostScript Print" :visible
(pr-visible-p 'postscript
)
2542 :help
"Send PostScript to printer or file (C-u)"
2544 ["1-up" (pr-ps-directory-ps-print 1 nil nil t
) t
]
2545 ["2-up" (pr-ps-directory-ps-print 2 nil nil t
) t
]
2546 ["4-up" (pr-ps-directory-ps-print 4 nil nil t
) t
]
2547 ["Other..." (pr-ps-directory-ps-print nil nil nil t
)
2548 :keys
"\\[pr-ps-buffer-ps-print]"])
2550 ["1-up" (pr-ps-buffer-ps-print 1 t
) t
]
2551 ["2-up" (pr-ps-buffer-ps-print 2 t
) t
]
2552 ["4-up" (pr-ps-buffer-ps-print 4 t
) t
]
2553 ["Other..." (pr-ps-buffer-ps-print nil t
)
2554 :keys
"\\[pr-ps-buffer-ps-print]"])
2555 ("Region" :active
(ps-mark-active-p)
2556 ["1-up" (pr-ps-region-ps-print 1 t
) t
]
2557 ["2-up" (pr-ps-region-ps-print 2 t
) t
]
2558 ["4-up" (pr-ps-region-ps-print 4 t
) t
]
2559 ["Other..." (pr-ps-region-ps-print nil t
)
2560 :keys
"\\[pr-ps-region-ps-print]"])
2561 ("Mode" :active
(pr-mode-alist-p)
2562 ["1-up" (pr-ps-mode-ps-print 1 t
) t
]
2563 ["2-up" (pr-ps-mode-ps-print 2 t
) t
]
2564 ["4-up" (pr-ps-mode-ps-print 4 t
) t
]
2565 ["Other..." (pr-ps-mode-ps-print nil t
)
2566 :keys
"\\[pr-ps-mode-ps-print]"])
2568 ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print
)
2569 :keys
"\\[pr-ps-file-ps-print]"
2570 :help
"Send PostScript file to printer"]
2572 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
2573 :help
"Select PostScript utility"]
2575 ["1-up..." (pr-ps-file-up-ps-print 1 t t
) pr-ps-utility-alist
]
2576 ["2-up..." (pr-ps-file-up-ps-print 2 t t
) pr-ps-utility-alist
]
2577 ["4-up..." (pr-ps-file-up-ps-print 4 t t
) pr-ps-utility-alist
]
2578 ["Other..." (pr-ps-file-up-ps-print nil t t
)
2579 :keys
"\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist
]
2581 ["Landscape" pr-toggle-file-landscape
2582 :style toggle
:selected pr-file-landscape
2583 :help
"Toggle landscape for PostScript file"
2584 :active pr-ps-utility-alist
]
2585 ["Duplex" pr-toggle-file-duplex
2586 :style toggle
:selected pr-file-duplex
2587 :help
"Toggle duplex for PostScript file"
2588 :active pr-ps-utility-alist
]
2589 ["Tumble" pr-toggle-file-tumble
2590 :style toggle
:selected pr-file-tumble
2591 :help
"Toggle tumble for PostScript file"
2592 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2593 ["Despool..." (call-interactively 'pr-despool-ps-print
)
2594 :active pr-spool-p
:keys
"\\[pr-despool-ps-print]"
2595 :help
"Despool PostScript buffer to printer or file (C-u)"])
2596 ["PostScript Printers" pr-update-menus
2597 :active pr-ps-printer-alist
:included
(pr-visible-p 'postscript
)
2598 :help
"Select PostScript printer"]
2600 ("Printify" :visible
(pr-visible-p 'text
)
2601 :help
"Replace non-printing chars with printable representations."
2602 ["Directory" pr-printify-directory t
]
2603 ["Buffer" pr-printify-buffer t
]
2604 ["Region" pr-printify-region
(ps-mark-active-p)])
2605 ("Print" :visible
(pr-visible-p 'text
)
2606 :help
"Send text to printer"
2607 ["Directory" pr-txt-directory t
]
2608 ["Buffer" pr-txt-buffer t
]
2609 ["Region" pr-txt-region
(ps-mark-active-p)]
2610 ["Mode" pr-txt-mode
(pr-mode-alist-p)])
2611 ["Text Printers" pr-update-menus
2612 :active pr-txt-printer-alist
:included
(pr-visible-p 'text
)
2613 :help
"Select text printer"]
2615 ["Landscape" pr-toggle-landscape
2616 :style toggle
:selected ps-landscape-mode
2617 :included
(pr-visible-p 'postscript-options
)]
2618 ["Print Header" pr-toggle-header
2619 :style toggle
:selected ps-print-header
2620 :included
(pr-visible-p 'postscript-options
)]
2621 ["Print Header Frame" pr-toggle-header-frame
2622 :style toggle
:selected ps-print-header-frame
:active ps-print-header
2623 :included
(pr-visible-p 'postscript-options
)]
2624 ["Line Number" pr-toggle-line
2625 :style toggle
:selected ps-line-number
2626 :included
(pr-visible-p 'postscript-options
)]
2627 ["Zebra Stripes" pr-toggle-zebra
2628 :style toggle
:selected ps-zebra-stripes
2629 :included
(pr-visible-p 'postscript-options
)]
2630 ["Duplex" pr-toggle-duplex
2631 :style toggle
:selected ps-spool-duplex
2632 :included
(pr-visible-p 'postscript-options
)]
2633 ["Tumble" pr-toggle-tumble
2634 :style toggle
:selected ps-spool-tumble
:active ps-spool-duplex
2635 :included
(pr-visible-p 'postscript-options
)]
2636 ["Upside-Down" pr-toggle-upside-down
2637 :style toggle
:selected ps-print-upside-down
2638 :included
(pr-visible-p 'postscript-options
)]
2639 ("Print All Pages" :visible
(pr-visible-p 'postscript-options
)
2640 :help
"Select odd/even pages/sheets to print"
2641 ["All Pages" (pr-even-or-odd-pages nil
)
2642 :style radio
:selected
(eq ps-even-or-odd-pages nil
)]
2643 ["Even Pages" (pr-even-or-odd-pages 'even-page
)
2644 :style radio
:selected
(eq ps-even-or-odd-pages
'even-page
)]
2645 ["Odd Pages" (pr-even-or-odd-pages 'odd-page
)
2646 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-page
)]
2647 ["Even Sheets" (pr-even-or-odd-pages 'even-sheet
)
2648 :style radio
:selected
(eq ps-even-or-odd-pages
'even-sheet
)]
2649 ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet
)
2650 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-sheet
)])
2652 ["Spool Buffer" pr-toggle-spool
2653 :style toggle
:selected pr-spool-p
2654 :included
(pr-visible-p 'postscript-process
)
2655 :help
"Toggle PostScript spooling"]
2656 ["Print with faces" pr-toggle-faces
2657 :style toggle
:selected pr-faces-p
2658 :included
(pr-visible-p 'postscript-process
)
2659 :help
"Toggle PostScript printing with faces"]
2660 ["Print via Ghostscript" pr-toggle-ghostscript
2661 :style toggle
:selected pr-print-using-ghostscript
2662 :included
(pr-visible-p 'postscript-process
)
2663 :help
"Toggle PostScript generation using ghostscript"]
2665 ["Auto Region" pr-toggle-region
2666 :style toggle
:selected pr-auto-region
2667 :included
(pr-visible-p 'printing
)]
2668 ["Auto Mode" pr-toggle-mode
2669 :style toggle
:selected pr-auto-mode
2670 :included
(pr-visible-p 'printing
)]
2671 ["Menu Lock" pr-toggle-lock
2672 :style toggle
:selected pr-menu-lock
2673 :included
(pr-visible-p 'printing
)]
2675 ("Customize" :visible
(pr-visible-p 'help
)
2676 ["printing" pr-customize t
]
2677 ["ps-print" ps-print-customize t
]
2678 ["lpr" lpr-customize t
])
2679 ("Show Settings" :visible
(pr-visible-p 'help
)
2680 ["printing" pr-show-pr-setup t
]
2681 ["ps-print" pr-show-ps-setup t
]
2682 ["lpr" pr-show-lpr-setup t
])
2683 ["Help" pr-help
:active t
:included
(pr-visible-p 'help
)]
2687 ((eq ps-print-emacs-type
'xemacs
) ; XEmacs
2689 ;; unfortunately XEmacs doesn't support :active or :visible
2690 ;; for submenus, only for items.
2691 ;; It uses :included instead of :active or :visible.
2692 ;; Also, XEmacs doesn't support :help tag.
2694 ["Printing Interface" pr-interface
]
2696 ("PostScript Preview" :included
(pr-visible-p 'postscript
)
2697 ("Directory" :included
(not pr-spool-p
)
2698 ["1-up" (pr-ps-directory-preview 1 nil nil t
) t
]
2699 ["2-up" (pr-ps-directory-preview 2 nil nil t
) t
]
2700 ["4-up" (pr-ps-directory-preview 4 nil nil t
) t
]
2701 ["Other..." (pr-ps-directory-preview nil nil nil t
)
2702 :keys
"\\[pr-ps-buffer-preview]"])
2703 ("Buffer" :included
(not pr-spool-p
)
2704 ["1-up" (pr-ps-buffer-preview 1 t
) t
]
2705 ["2-up" (pr-ps-buffer-preview 2 t
) t
]
2706 ["4-up" (pr-ps-buffer-preview 4 t
) t
]
2707 ["Other..." (pr-ps-buffer-preview nil t
)
2708 :keys
"\\[pr-ps-buffer-preview]"])
2709 ("Region" :included
(and (not pr-spool-p
) (ps-mark-active-p))
2710 ["1-up" (pr-ps-region-preview 1 t
) t
]
2711 ["2-up" (pr-ps-region-preview 2 t
) t
]
2712 ["4-up" (pr-ps-region-preview 4 t
) t
]
2713 ["Other..." (pr-ps-region-preview nil t
)
2714 :keys
"\\[pr-ps-region-preview]"])
2715 ("Mode" :included
(and (not pr-spool-p
) (pr-mode-alist-p))
2716 ["1-up" (pr-ps-mode-preview 1 t
) t
]
2717 ["2-up" (pr-ps-mode-preview 2 t
) t
]
2718 ["4-up" (pr-ps-mode-preview 4 t
) t
]
2719 ["Other..." (pr-ps-mode-preview nil t
)
2720 :keys
"\\[pr-ps-mode-preview]"])
2722 ["No Preprocessing..." (call-interactively 'pr-ps-file-preview
)
2723 :keys
"\\[pr-ps-file-preview]"]
2725 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
]
2727 ["1-up..." (pr-ps-file-up-preview 1 t t
) pr-ps-utility-alist
]
2728 ["2-up..." (pr-ps-file-up-preview 2 t t
) pr-ps-utility-alist
]
2729 ["4-up..." (pr-ps-file-up-preview 4 t t
) pr-ps-utility-alist
]
2730 ["Other..." (pr-ps-file-up-preview nil t t
)
2731 :keys
"\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist
]
2733 ["Landscape" pr-toggle-file-landscape
2734 :style toggle
:selected pr-file-landscape
2735 :active pr-ps-utility-alist
]
2736 ["Duplex" pr-toggle-file-duplex
2737 :style toggle
:selected pr-file-duplex
2738 :active pr-ps-utility-alist
]
2739 ["Tumble" pr-toggle-file-tumble
2740 :style toggle
:selected pr-file-tumble
2741 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2742 ["Despool..." (call-interactively 'pr-despool-preview
)
2743 :active pr-spool-p
:keys
"\\[pr-despool-preview]"])
2744 ("PostScript Print" :included
(pr-visible-p 'postscript
)
2746 ["1-up" (pr-ps-directory-ps-print 1 nil nil t
) t
]
2747 ["2-up" (pr-ps-directory-ps-print 2 nil nil t
) t
]
2748 ["4-up" (pr-ps-directory-ps-print 4 nil nil t
) t
]
2749 ["Other..." (pr-ps-directory-ps-print nil nil nil t
)
2750 :keys
"\\[pr-ps-buffer-ps-print]"])
2752 ["1-up" (pr-ps-buffer-ps-print 1 t
) t
]
2753 ["2-up" (pr-ps-buffer-ps-print 2 t
) t
]
2754 ["4-up" (pr-ps-buffer-ps-print 4 t
) t
]
2755 ["Other..." (pr-ps-buffer-ps-print nil t
)
2756 :keys
"\\[pr-ps-buffer-ps-print]"])
2757 ("Region" :included
(ps-mark-active-p)
2758 ["1-up" (pr-ps-region-ps-print 1 t
) t
]
2759 ["2-up" (pr-ps-region-ps-print 2 t
) t
]
2760 ["4-up" (pr-ps-region-ps-print 4 t
) t
]
2761 ["Other..." (pr-ps-region-ps-print nil t
)
2762 :keys
"\\[pr-ps-region-ps-print]"])
2763 ("Mode" :included
(pr-mode-alist-p)
2764 ["1-up" (pr-ps-mode-ps-print 1 t
) t
]
2765 ["2-up" (pr-ps-mode-ps-print 2 t
) t
]
2766 ["4-up" (pr-ps-mode-ps-print 4 t
) t
]
2767 ["Other..." (pr-ps-mode-ps-print nil t
)
2768 :keys
"\\[pr-ps-mode-ps-print]"])
2770 ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print
)
2771 :keys
"\\[pr-ps-file-ps-print]"]
2773 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
]
2775 ["1-up..." (pr-ps-file-up-ps-print 1 t t
) pr-ps-utility-alist
]
2776 ["2-up..." (pr-ps-file-up-ps-print 2 t t
) pr-ps-utility-alist
]
2777 ["4-up..." (pr-ps-file-up-ps-print 4 t t
) pr-ps-utility-alist
]
2778 ["Other..." (pr-ps-file-up-ps-print nil t t
)
2779 :keys
"\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist
]
2781 ["Landscape" pr-toggle-file-landscape
2782 :style toggle
:selected pr-file-landscape
2783 :active pr-ps-utility-alist
]
2784 ["Duplex" pr-toggle-file-duplex
2785 :style toggle
:selected pr-file-duplex
2786 :active pr-ps-utility-alist
]
2787 ["Tumble" pr-toggle-file-tumble
2788 :style toggle
:selected pr-file-tumble
2789 :active
(and pr-file-duplex pr-ps-utility-alist
)])
2790 ["Despool..." (call-interactively 'pr-despool-ps-print
)
2791 :active pr-spool-p
:keys
"\\[pr-despool-ps-print]"])
2792 ["PostScript Printers" pr-update-menus
2793 :active pr-ps-printer-alist
:included
(pr-visible-p 'postscript
)]
2795 ("Printify" :included
(pr-visible-p 'text
)
2796 ["Directory" pr-printify-directory t
]
2797 ["Buffer" pr-printify-buffer t
]
2798 ["Region" pr-printify-region
(ps-mark-active-p)])
2799 ("Print" :included
(pr-visible-p 'text
)
2800 ["Directory" pr-txt-directory t
]
2801 ["Buffer" pr-txt-buffer t
]
2802 ["Region" pr-txt-region
(ps-mark-active-p)]
2803 ["Mode" pr-txt-mode
(pr-mode-alist-p)])
2804 ["Text Printers" pr-update-menus
2805 :active pr-txt-printer-alist
:included
(pr-visible-p 'text
)]
2807 ["Landscape" pr-toggle-landscape
2808 :style toggle
:selected ps-landscape-mode
2809 :included
(pr-visible-p 'postscript-options
)]
2810 ["Print Header" pr-toggle-header
2811 :style toggle
:selected ps-print-header
2812 :included
(pr-visible-p 'postscript-options
)]
2813 ["Print Header Frame" pr-toggle-header-frame
2814 :style toggle
:selected ps-print-header-frame
:active ps-print-header
2815 :included
(pr-visible-p 'postscript-options
)]
2816 ["Line Number" pr-toggle-line
2817 :style toggle
:selected ps-line-number
2818 :included
(pr-visible-p 'postscript-options
)]
2819 ["Zebra Stripes" pr-toggle-zebra
2820 :style toggle
:selected ps-zebra-stripes
2821 :included
(pr-visible-p 'postscript-options
)]
2822 ["Duplex" pr-toggle-duplex
2823 :style toggle
:selected ps-spool-duplex
2824 :included
(pr-visible-p 'postscript-options
)]
2825 ["Tumble" pr-toggle-tumble
2826 :style toggle
:selected ps-spool-tumble
:active ps-spool-duplex
2827 :included
(pr-visible-p 'postscript-options
)]
2828 ["Upside-Down" pr-toggle-upside-down
2829 :style toggle
:selected ps-print-upside-down
2830 :included
(pr-visible-p 'postscript-options
)]
2831 ("Print All Pages" :included
(pr-visible-p 'postscript-options
)
2832 ["All Pages" (pr-even-or-odd-pages nil
)
2833 :style radio
:selected
(eq ps-even-or-odd-pages nil
)]
2834 ["Even Pages" (pr-even-or-odd-pages 'even-page
)
2835 :style radio
:selected
(eq ps-even-or-odd-pages
'even-page
)]
2836 ["Odd Pages" (pr-even-or-odd-pages 'odd-page
)
2837 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-page
)]
2838 ["Even Sheets" (pr-even-or-odd-pages 'even-sheet
)
2839 :style radio
:selected
(eq ps-even-or-odd-pages
'even-sheet
)]
2840 ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet
)
2841 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-sheet
)])
2843 ["Spool Buffer" pr-toggle-spool
2844 :style toggle
:selected pr-spool-p
2845 :included
(pr-visible-p 'postscript-process
)]
2846 ["Print with faces" pr-toggle-faces
2847 :style toggle
:selected pr-faces-p
2848 :included
(pr-visible-p 'postscript-process
)]
2849 ["Print via Ghostscript" pr-toggle-ghostscript
2850 :style toggle
:selected pr-print-using-ghostscript
2851 :included
(pr-visible-p 'postscript-process
)]
2853 ["Auto Region" pr-toggle-region
2854 :style toggle
:selected pr-auto-region
2855 :included
(pr-visible-p 'printing
)]
2856 ["Auto Mode" pr-toggle-mode
2857 :style toggle
:selected pr-auto-mode
2858 :included
(pr-visible-p 'printing
)]
2859 ["Menu Lock" pr-toggle-lock
2860 :style toggle
:selected pr-menu-lock
2861 :included
(pr-visible-p 'printing
)]
2863 ("Customize" :included
(pr-visible-p 'help
)
2864 ["printing" pr-customize t
]
2865 ["ps-print" ps-print-customize t
]
2866 ["lpr" lpr-customize t
])
2867 ("Show Settings" :included
(pr-visible-p 'help
)
2868 ["printing" pr-show-pr-setup t
]
2869 ["ps-print" pr-show-ps-setup t
]
2870 ["lpr" pr-show-lpr-setup t
])
2871 ["Help" pr-help
:active t
:included
(pr-visible-p 'help
)]
2877 ((eq ps-print-emacs-type
'emacs
) ; GNU Emacs
2880 ;; Replace existing "print" item by "Printing" item.
2881 ;; If you're changing this file, you'll load it a second,
2882 ;; third... time, but "print" item exists only in the first load.
2883 (defvar pr-menu-print-item
"print")
2886 ((string< emacs-version
"21.")
2887 (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item
)
2888 (when pr-menu-print-item
2889 (easy-menu-remove-item nil
'("tools") pr-menu-print-item
)
2890 (setq pr-menu-print-item nil
2891 pr-menu-bar
(vector 'menu-bar
'tools
2892 (pr-get-symbol "Printing")))))
2895 (easy-menu-change '("files") "Print" pr-menu-spec
"print-buffer")
2896 (let ((items '("print-buffer" "print-region"
2897 "ps-print-buffer-faces" "ps-print-region-faces"
2898 "ps-print-buffer" "ps-print-region")))
2900 (easy-menu-remove-item nil
'("files") (car items
))
2901 (setq items
(cdr items
)))
2902 (setq pr-menu-print-item nil
2903 pr-menu-bar
(vector 'menu-bar
'files
2904 (pr-get-symbol "Print")))))
2906 (easy-menu-change '("files") "Print" pr-menu-spec
)))
2909 (global-set-key [print] 'pr-ps-fast-fire)
2910 (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
2911 (global-set-key [C-print] 'pr-txt-fast-fire))
2914 ((eq ps-print-emacs-type 'xemacs) ; XEmacs
2916 (pr-xemacs-global-menubar
2917 (pr-x-add-submenu nil (cons "Printing" pr-menu-spec) "Apps"))
2920 (global-set-key 'f22 'pr-ps-fast-fire)
2921 (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
2922 (global-set-key '(control f22) 'pr-txt-fast-fire))))
2925 ;;; You can also use something like:
2926 ;;;(global-set-key "\C-ci" 'pr-interface)
2927 ;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print)
2928 ;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview)
2929 ;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
2930 ;;;(global-set-key "\C-crp" 'pr-ps-region-print)
2931 ;;;(global-set-key "\C-crx" 'pr-ps-region-preview)
2932 ;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
2935 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2939 (defconst pr-help-message
2940 (concat "printing.el version " pr-version
2941 " ps-print.el version " ps-print-version
2946 The `printing' menu (Tools/Printing or File/Print) has the following layout:
2948 +-----------------------------+
2949 A 0 | Printing Interface |
2950 +-----------------------------+ +-A---------+ +-B------+
2951 I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
2952 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
2953 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
2954 +-----------------------------+ |Mode >|-- B |Other...|
2955 II 4 | Printify >|-----\\ |File >|--\\ +--------+
2956 5 | Print >|---\\ | |Despool... | |
2957 6 | Text Printer: name >|-\\ | | +-----------+ |
2958 +-----------------------------+ | | | +---------+ +------------+
2959 III 7 |[ ]Landscape | | | \\-|Directory| | No Prep... | Ia
2960 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
2961 9 |[ ]Print Header Frame | | | |Region | | name >|- C
2962 10 |[ ]Line Number | | | +---------+ +------------+
2963 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
2964 12 |[ ]Duplex | | \\---|Directory| | 2-up... |
2965 13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... |
2966 14 |[ ]Upside-Down | | |Region | | Other... |
2967 15 | Print All Pages >|--\\ | |Mode | +------------+
2968 +-----------------------------+ | | +---------+ |[ ]Landscape| Id
2969 IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
2970 17 |[ ]Print with faces | | \\--|( )name A| |[ ]Tumble | If
2971 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
2972 +-----------------------------+ | |... |
2973 V 19 |[ ]Auto Region | | |(*)name |
2974 20 |[ ]Auto Mode | | |... |
2975 21 |[ ]Menu Lock | | +---------+ +--------------+
2976 +-----------------------------+ \\------------------|(*)All Pages |
2977 VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
2978 23 | Show Settings >|-------|printing| |( )Odd Pages |
2979 24 | Help | |ps-print| |( )Even Sheets|
2980 +-----------------------------+ |lpr | |( )Odd Sheets |
2981 +--------+ +--------------+
2983 See `pr-visible-entry-list' for hiding some parts of the menu.
2985 The menu has the following sections:
2989 0. You can use a buffer interface instead of menus. It looks like the
2990 customization buffer. Basically, it has the same options found in the
2991 menu and some extra options, all this on a buffer.
2993 I. PostScript printing:
2995 1. You can generate a PostScript file (if you type C-u before activating
2996 menu) or PostScript temporary file for a directory, a buffer, a region
2997 or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
2998 after file generation, ghostview is activated using the file generated
2999 as argument. This option is disabled if spooling is on (option 16).
3000 Also, if you already have a PostScript file you can preview it.
3001 Instead of previewing each buffer, region or major mode at once, you
3002 can save temporarily the PostScript code generated in a buffer and
3003 preview it later. The option `Despool...' despools the PostScript
3004 spooling buffer in a temporary file and uses ghostview to preview it.
3005 If you type C-u before choosing this option, the PostScript code
3006 generated is saved in a file instead of saving in a temporary file. To
3007 spool the PostScript code generated you need to turn on the option 16.
3008 The option `Despool...' is enabled if spooling is on (option 16).
3010 NOTE 1: It's possible to customize a major mode printing, just declare
3011 the customization in `pr-mode-alist' and invoke some of
3012 `*-mode*' commands or select Mode option in Printing menu. An
3013 example for major mode usage is when you're using gnus (or mh,
3014 or rmail, etc.) and you're in the *Summary* buffer, if you
3015 forget to switch to the *Article* buffer before printing,
3016 you'll get a nicely formatted list of article subjects shows
3017 up at the printer. With major mode printing you don't need to
3018 switch from gnus *Summary* buffer first.
3020 NOTE 2: There are the following options for PostScript file processing:
3021 Ia. Print the file *No Preprocessing*, that is, send it
3022 directly to PostScript printer.
3023 Ib. PostScript utility processing selection.
3024 See `pr-ps-utility-alist' and `pr-setting-database' for
3026 Ic. Do n-up processing before printing.
3027 Id. Toggle on/off landscape for PostScript file processing.
3028 Ie. Toggle on/off duplex for PostScript file processing.
3029 If. Toggle on/off tumble for PostScript file processing.
3031 NOTE 3: Don't forget to download and install the utilities declared on
3032 `pr-ps-utility-alist'.
3034 2. Operate the same way as option 1, but it sends directly the PostScript
3035 code (or put in a file, if you've typed C-u) or it uses ghostscript to
3036 print the PostScript file generated. It depends on option 18, if it's
3037 turned on, it uses ghostscript; otherwise, it sends directly to
3038 printer. If spooling is on (option 16), the PostScript code is saved
3039 temporarily in a buffer instead of printing it or saving it in a file.
3040 Also, if you already have a PostScript file you can print it.
3041 Instead of printing each buffer, region or major mode at once, you can
3042 save temporarily the PostScript code generated in a buffer and print it
3043 later. The option `Despool...' despools the PostScript spooling buffer
3044 directly on a printer. If you type C-u before choosing this option,
3045 the PostScript code generated is saved in a file instead of sending it to
3046 the printer. To spool the PostScript code generated you need to turn on
3047 option 16. This option is enabled if spooling is on (option 16).
3048 See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
3050 3. You can select a new PostScript printer to send PostScript code
3051 generated. For selection it's used all PostScript printers defined
3052 in `pr-ps-printer-alist' variable (see it for documentation).
3053 See also `pr-setting-database'.
3057 4. If you have control characters (character code from \\000 to \\037) in a
3058 buffer and you want to print them in a text printer, select this
3059 option. All control characters in your buffer or region will be
3060 replaced by a printable representation. The printable representations
3061 use ^ (for ASCII control characters) or hex. The characters tab,
3062 linefeed, space, return and formfeed are not affected.
3063 You don't need to select this option if you use any option of section
3064 I, the PostScript engine treats control characters properly.
3066 5. If you want to print a directory, buffer, region or major mode in a
3067 text printer, select this option. See also the NOTE 1 on option 1.
3069 6. You can select a new text printer to send text generated. For
3070 selection it's used all text printers defined in `pr-txt-printer-alist'
3071 variable (see it for documentation).
3072 See also `pr-setting-database'.
3074 III. PostScript page toggle options:
3076 7. If you want a PostScript landscape printing, turn on this option.
3078 8. If you want to have a header in each page in your PostScript code,
3079 turn on this option.
3081 9. If you want to draw a gaudy frame around the header, turn on this
3082 option. This option is enabled if print header is on (option 8).
3084 10. If you want that the line number is printed in your PostScript code,
3085 turn on this option.
3087 11. If you want background zebra stripes in your PostScript code, turn on
3090 12. If you want a duplex printing and your PostScript printer has this
3091 feature, turn on this option.
3093 13. If you turned on duplex printing, you can choose if you want to have a
3094 printing suitable for binding on the left or right (tumble off), or to
3095 have a printing suitable for binding at top or bottom (tumble on).
3096 This option is enabled if duplex is on (option 12).
3098 14. If you want a PostScript upside-down printing, turn on this option.
3100 15. With this option, you can choose if you want to print all pages, odd
3101 pages, even pages, odd sheets or even sheets.
3102 See also `ps-even-or-odd-pages'.
3104 IV. PostScript processing toggle options:
3106 16. If you want to spool the PostScript code generated, turn on this
3107 option. To spool the PostScript code generated use option 2. You can
3108 despool later by choosing option 1 or 2, sub-option `Despool...'.
3110 17. If you use colors in your buffers and want to see these colors on your
3111 PostScript code generated, turn on this option. If you have a
3112 black/white PostScript printer, these colors are displayed in gray
3113 scale by PostScript printer interpreter.
3115 18. If you don't have a PostScript printer to send PostScript files, turn
3116 on this option. When this option is on, the ghostscript is used to
3117 print PostScript files. In GNU or Unix system, if ghostscript is set
3118 as a PostScript filter, you don't need to turn on this option.
3120 V. Printing customization:
3122 19. If you want that region is automagically detected, turn on this
3123 option. Note that this will only work if you're using transient mark
3124 mode. When this option is on, the `*-buffer*' commands will behave
3125 like `*-region*' commands, that is, `*-buffer*' commands will print
3126 only the region marked instead of all buffer.
3128 20. Turn this option on if you want that when current major-mode is
3129 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3130 behave like `*-mode*' commands.
3132 21. If you want that Printing menu stays open while you are setting
3133 toggle options, turn on this option. The variables
3134 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3135 menu position, so don't forget to adjust these variables if menu
3140 22. Besides all options in section III, IV and V, you can customize much
3141 more PostScript options in `ps-print' option. Or you can customize
3142 some `lpr' options for text printing. Or customize `printing'
3145 23. Show current settings for `printing', `ps-print' or `lpr'.
3147 24. Quick help for printing menu layout.
3149 "Printing help message.")
3152 (defconst pr-interface-help-message
3153 (concat "printing.el version " pr-version
3154 " ps-print.el version " ps-print-version
3156 The printing interface buffer has the same functionality as the printing menu.
3157 The major difference is that the states (like sending PostScript generated to a
3158 file, n-up printing, etc.) are set and saved between priting buffer
3159 activation. Also, the landscape, duplex and tumble values are the same for
3160 PostScript file and directory/buffer/region/mode processing; using menu, there
3161 are different value sets for PostScript file and directory/buffer/region/mode
3164 The printing interface buffer has the following sections:
3168 Here you can choose to print/preview a buffer, a directory or a PostScript
3174 Select a buffer from the current buffer list.
3177 If it's on, this means that the selected buffer has an active region,
3178 so you can turn on/off, as you wish.
3179 If it's off when a buffer is selected, this means that the selected
3180 buffer has no active region, so it'll not be possible to turn it on.
3181 If you want to process the region, let this option on.
3182 If you want to process the whole buffer, let this option off.
3185 If it's on, this means that the selected buffer major mode is declared
3186 for major mode processing, so you can turn on/off, as you wish.
3187 If it's off when a buffer is selected, this means that the selected
3188 buffer major mode isn't declared for major mode processing, so it'll
3189 not be possible to turn it on.
3190 If you want the major mode processing, let this option on.
3191 If you don't want the major mode processing, let this option off.
3193 NOTE 1: It's possible to customize a major mode printing, just declare
3194 the customization in `pr-mode-alist' and invoke some of
3195 `*-mode*' commands or select Mode option in Printing menu. An
3196 example for major mode usage is when you're using gnus (or mh,
3197 or rmail, etc.) and you're in the *Summary* buffer, if you
3198 forget to switch to the *Article* buffer before printing,
3199 you'll get a nicely formatted list of article subjects shows
3200 up at the printer. With major mode printing you don't need to
3201 switch from gnus *Summary* buffer first.
3206 Specify a valid directory path.
3209 Specify a file name regexp. All file names in the directory that
3210 match with regexp will be printed/previewed. An empty file name
3211 regexp means to print/preview all files in the directory.
3213 * List Directory Entry:
3214 If it's turned on, list directory entries besides file entries.
3216 1c. PostScript file:
3219 Specify an existent PostScript file to print/preview.
3221 * PostScript Utility:
3222 Select a PostScript utility.
3223 See `pr-ps-utility-alist' and `pr-setting-database' for documentation.
3225 NOTE 2: Don't forget to download and install the utilities declared on
3226 `pr-ps-utility-alist'.
3229 If it's turned on, don't use the PostScript utility to preprocess the
3230 PostScript file before printing/previewing.
3232 2. PostScript printer:
3234 * PostScript Printer:
3235 You can select a new PostScript printer to send PostScript code
3236 generated. For selection it's used all PostScript printers defined
3237 in `pr-ps-printer-alist' variable (see it for documentation).
3238 See also `pr-setting-database'.
3241 If spooling is on, you can turn it on/off, as you wish.
3242 If spooling is off, it'll not be possible to turn it on.
3243 If it's turned on, specify to despools the PostScript spooling buffer in
3244 a temporary file or in the selected PostScript file when
3245 printing/previewing.
3248 Preview the PostScript generated.
3251 Print the PostScript generated.
3254 Quit from printing interface buffer.
3256 * Send to Printer/Temporary File:
3257 If it's turned on, the PostScript generated is sent directly to
3258 PostScript printer or, for previewing, to a temporary file.
3261 Specify a file name to send the PostScript generated.
3264 Specify n-up printing.
3269 Select a new text printer to send text generated. For selection it's used
3270 all text printers defined in `pr-txt-printer-alist' variable (see it for
3271 documentation). See also `pr-setting-database'.
3274 If you have control characters (character code from \\000 to \\037) in a
3275 buffer and you want to print them in a text printer, select this
3276 option. All control characters in your buffer or region will be
3277 replaced by a printable representation. The printable representations
3278 use ^ (for ASCII control characters) or hex. The characters tab,
3279 linefeed, space, return and formfeed are not affected.
3280 You don't need to select this option if you use any option of section
3281 I, the PostScript engine treats control characters properly.
3284 To print a directory, buffer, region or major mode in a
3285 text printer, select this option. See also the NOTE 1 on section 1.
3288 Quit from printing interface buffer.
3292 There are 3 setting columns:
3294 4a. First column (left column):
3297 PostScript landscape printing.
3300 To have a header in each page in your PostScript code.
3302 * Print Header Frame:
3303 To draw a gaudy frame around the header.
3306 The line number is printed in your PostScript code.
3309 Background zebra stripes in your PostScript code.
3312 Duplex printing (if your PostScript printer has this feature).
3315 If duplex printing is on, you can choose if you want to have a
3316 printing suitable for binding on the left or right (tumble off), or to
3317 have a printing suitable for binding at top or bottom (tumble on).
3320 PostScript upside-down printing.
3322 4b. Second column (middle column):
3325 If you want that region is automagically detected, turn on this
3326 option. Note that this will only work if you're using transient mark
3327 mode. When this option is on, the `*-buffer*' commands will behave
3328 like `*-region*' commands, that is, `*-buffer*' commands will print
3329 only the region marked instead of all buffer.
3332 Turn this option on if you want that when current major-mode is
3333 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3334 behave like `*-mode*' commands.
3337 If you want that Printing menu stays open while you are setting
3338 toggle options, turn on this option. The variables
3339 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3340 menu position, so don't forget to adjust these variables if menu
3344 To spool the PostScript code generated. You can despool later by
3345 setting Despool option on PostScript printer section.
3348 If you use colors in your buffers and want to see these colors on your
3349 PostScript code generated, turn on this option. If you have a
3350 black/white PostScript printer, these colors are displayed in gray
3351 scale by PostScript printer interpreter.
3353 * Print via Ghostscript:
3354 If you don't have a PostScript printer to send PostScript files, turn
3355 on this option. When this option is on, the ghostscript is used to
3356 print PostScript files. In GNU or Unix system, if ghostscript is set
3357 as a PostScript filter, you don't need to turn on this option.
3360 To print all pages, odd pages, even pages, odd sheets or even sheets.
3361 See also `ps-even-or-odd-pages'.
3363 4c. Third column (right column):
3366 That is, to be verbose when editing a field in interface buffer.
3370 Besides all options in section 4, you can customize much more PostScript
3371 options in `ps-print' option. Or you can customize some `lpr' options for
3372 text printing. Or customize `printing' options.
3376 Show current settings for `printing', `ps-print' or `lpr'.
3380 Quick help for printing interface buffer and printing menu layout. You can
3381 also quit the printing interface buffer or kill all printing help buffer.
3383 "Printing buffer interface help message.")
3386 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3391 (defun pr-interface (&optional buffer)
3392 "Activate the printing interface buffer.
3394 If BUFFER is nil, the current buffer is used for printing.
3396 For more information, type \\[pr-interface-help]."
3399 (set-buffer (or buffer (current-buffer)))
3400 (pr-create-interface)))
3404 (defun pr-ps-directory-preview (n-up dir file-regexp &optional filename)
3405 "Preview directory using ghostview.
3407 Interactively, the command prompts for N-UP printing number, a directory, a
3408 file name regexp for matching and, when you use a prefix argument (C-u), the
3409 command prompts the user for a file name, and saves the PostScript image in
3410 that file instead of saving it in a temporary file.
3412 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3413 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3414 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3415 save the image in a temporary file. If FILENAME is a string, save the
3416 PostScript image in a file with that name. If FILENAME is t, prompts for a
3419 See also documentation for `pr-list-directory'."
3420 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir")))
3421 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3422 (pr-prompt "PS preview dir"))
3423 (setq filename (pr-ps-file filename))
3424 (pr-ps-file-list n-up dir file-regexp filename)
3426 (pr-ps-file-preview filename)))
3430 (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp &optional filename)
3431 "Print directory using PostScript through ghostscript.
3433 Interactively, the command prompts for N-UP printing number, a directory, a
3434 file name regexp for matching and, when you use a prefix argument (C-u), the
3435 command prompts the user for a file name, and saves the PostScript image in
3436 that file instead of saving it in a temporary file.
3438 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3439 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3440 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3441 save the image in a temporary file. If FILENAME is a string, save the
3442 PostScript image in a file with that name. If FILENAME is t, prompts for a
3445 See also documentation for `pr-list-directory'."
3446 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS")))
3447 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3448 (pr-prompt "PS print dir GS"))
3449 (let ((file (pr-ps-file filename)))
3450 (pr-ps-file-list n-up dir file-regexp file)
3451 (pr-ps-file-using-ghostscript file)
3452 (or filename (pr-delete-file file))))
3456 (defun pr-ps-directory-print (n-up dir file-regexp &optional filename)
3457 "Print directory using PostScript printer.
3459 Interactively, the command prompts for N-UP printing number, a directory, a
3460 file name regexp for matching and, when you use a prefix argument (C-u), the
3461 command prompts the user for a file name, and saves the PostScript image in
3462 that file instead of saving it in a temporary file.
3464 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3465 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3466 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3467 save the image in a temporary file. If FILENAME is a string, save the
3468 PostScript image in a file with that name. If FILENAME is t, prompts for a
3471 See also documentation for `pr-list-directory'."
3472 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir")))
3473 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3474 (pr-prompt "PS print dir"))
3475 (let ((file (pr-ps-file filename)))
3476 (pr-ps-file-list n-up dir file-regexp file)
3477 (pr-ps-file-print file)
3478 (or filename (pr-delete-file file))))
3482 (defun pr-ps-directory-ps-print (n-up dir file-regexp &optional filename)
3483 "Print directory using PostScript printer or through ghostscript.
3485 It depends on `pr-print-using-ghostscript'.
3487 Interactively, the command prompts for N-UP printing number, a directory, a
3488 file name regexp for matching and, when you use a prefix argument (C-u), the
3489 command prompts the user for a file name, and saves the PostScript image in
3490 that file instead of saving it in a temporary file.
3492 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3493 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3494 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3495 save the image in a temporary file. If FILENAME is a string, save the
3496 PostScript image in a file with that name. If FILENAME is t, prompts for a
3499 See also documentation for `pr-list-directory'."
3500 (interactive (pr-interactive-ps-dir-args
3501 (pr-prompt (pr-prompt-gs "PS print dir"))))
3502 (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
3503 (pr-prompt (pr-prompt-gs "PS print dir")))
3504 (if (pr-using-ghostscript-p)
3505 (pr-ps-directory-using-ghostscript n-up dir file-regexp filename)
3506 (pr-ps-directory-print n-up dir file-regexp filename)))
3510 (defun pr-ps-buffer-preview (n-up &optional filename)
3511 "Preview buffer using ghostview.
3513 Interactively, the command prompts for N-UP printing number and, when you use a
3514 prefix argument (C-u), the command prompts the user for a file name, and saves
3515 the PostScript image in that file instead of saving it in a temporary file.
3517 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3518 argument FILENAME is treated as follows: if it's nil, save the image in a
3519 temporary file. If FILENAME is a string, save the PostScript image in a file
3520 with that name. If FILENAME is t, prompts for a file name."
3521 (interactive (pr-interactive-n-up-file (pr-prompt "PS preview")))
3522 (if (pr-auto-mode-p)
3523 (pr-ps-mode-preview n-up filename)
3524 (pr-ps-preview (pr-region-active-symbol) n-up filename
3525 (pr-region-active-string "PS preview"))))
3529 (defun pr-ps-buffer-using-ghostscript (n-up &optional filename)
3530 "Print buffer using PostScript through ghostscript.
3532 Interactively, the command prompts for N-UP printing number and, when you use a
3533 prefix argument (C-u), the command prompts the user for a file name, and saves
3534 the PostScript image in that file instead of sending it to the printer.
3536 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3537 argument FILENAME is treated as follows: if it's nil, send the image to the
3538 printer. If FILENAME is a string, save the PostScript image in a file with
3539 that name. If FILENAME is t, prompts for a file name."
3540 (interactive (pr-interactive-n-up-file (pr-prompt "PS print GS")))
3541 (if (pr-auto-mode-p)
3542 (pr-ps-mode-using-ghostscript n-up filename)
3543 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
3544 (pr-region-active-string "PS print GS"))))
3548 (defun pr-ps-buffer-print (n-up &optional filename)
3549 "Print buffer using PostScript printer.
3551 Interactively, the command prompts for N-UP printing number and, when you use a
3552 prefix argument (C-u), the command prompts the user for a file name, and saves
3553 the PostScript image in that file instead of sending it to the printer.
3555 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3556 argument FILENAME is treated as follows: if it's nil, send the image to the
3557 printer. If FILENAME is a string, save the PostScript image in a file with
3558 that name. If FILENAME is t, prompts for a file name."
3559 (interactive (pr-interactive-n-up-file (pr-prompt "PS print")))
3560 (if (pr-auto-mode-p)
3561 (pr-ps-mode-print n-up filename)
3562 (pr-ps-print (pr-region-active-symbol) n-up filename
3563 (pr-region-active-string "PS print"))))
3567 (defun pr-ps-buffer-ps-print (n-up &optional filename)
3568 "Print buffer using PostScript printer or through ghostscript.
3570 It depends on `pr-print-using-ghostscript'.
3572 Interactively, the command prompts for N-UP printing number and, when you use a
3573 prefix argument (C-u), the command prompts the user for a file name, and saves
3574 the PostScript image in that file instead of sending it to the printer.
3576 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3577 argument FILENAME is treated as follows: if it's nil, send the image to the
3578 printer. If FILENAME is a string, save the PostScript image in a file with
3579 that name. If FILENAME is t, prompts for a file name."
3580 (interactive (pr-interactive-n-up-file
3581 (pr-prompt (pr-prompt-gs "PS print"))))
3582 (cond ((pr-auto-mode-p)
3583 (pr-ps-mode-ps-print n-up filename))
3584 ((pr-using-ghostscript-p)
3585 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
3586 (pr-region-active-string "PS print GS")))
3588 (pr-ps-print (pr-region-active-symbol) n-up filename
3589 (pr-region-active-string "PS print")))))
3593 (defun pr-ps-region-preview (n-up &optional filename)
3594 "Preview region using ghostview.
3596 See also `pr-ps-buffer-preview'."
3597 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS preview")))
3598 (if (pr-auto-mode-p)
3599 (let ((pr-auto-region t))
3600 (pr-ps-mode-preview n-up filename))
3601 (pr-ps-preview 'region n-up filename "PS preview region")))
3605 (defun pr-ps-region-using-ghostscript (n-up &optional filename)
3606 "Print region using PostScript through ghostscript.
3608 See also `pr-ps-buffer-using-ghostscript'."
3609 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print GS")))
3610 (if (pr-auto-mode-p)
3611 (let ((pr-auto-region t))
3612 (pr-ps-mode-using-ghostscript n-up filename))
3613 (pr-ps-using-ghostscript 'region n-up filename "PS print GS region")))
3617 (defun pr-ps-region-print (n-up &optional filename)
3618 "Print region using PostScript printer.
3620 See also `pr-ps-buffer-print'."
3621 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print")))
3622 (if (pr-auto-mode-p)
3623 (let ((pr-auto-region t))
3624 (pr-ps-mode-print n-up filename))
3625 (pr-ps-print 'region n-up filename "PS print region")))
3629 (defun pr-ps-region-ps-print (n-up &optional filename)
3630 "Print region using PostScript printer or through ghostscript.
3632 See also `pr-ps-buffer-ps-print'."
3633 (interactive (pr-interactive-n-up-file
3634 (pr-prompt-region (pr-prompt-gs "PS print"))))
3635 (cond ((pr-auto-mode-p)
3636 (let ((pr-auto-region t))
3637 (pr-ps-mode-ps-print n-up filename)))
3638 ((pr-using-ghostscript-p)
3639 (pr-ps-using-ghostscript 'region n-up filename "PS print GS region"))
3641 (pr-ps-print 'region n-up filename "PS print region"))))
3645 (defun pr-ps-mode-preview (n-up &optional filename)
3646 "Preview major mode using ghostview.
3648 See also `pr-ps-buffer-preview'."
3649 (interactive (pr-interactive-n-up-file "PS preview mode"))
3650 (pr-set-n-up-and-filename 'n-up 'filename "PS preview mode")
3651 (let ((file (pr-ps-file filename)))
3652 (and (pr-ps-mode n-up file)
3654 (pr-ps-file-preview file))))
3658 (defun pr-ps-mode-using-ghostscript (n-up &optional filename)
3659 "Print major mode using PostScript through ghostscript.
3661 See also `pr-ps-buffer-using-ghostscript'."
3662 (interactive (pr-interactive-n-up-file "PS print GS mode"))
3663 (pr-set-n-up-and-filename 'n-up 'filename "PS print GS mode")
3664 (let ((file (pr-ps-file filename)))
3665 (when (and (pr-ps-mode n-up file)
3667 (pr-ps-file-using-ghostscript file)
3668 (or filename (pr-delete-file file)))))
3672 (defun pr-ps-mode-print (n-up &optional filename)
3673 "Print major mode using PostScript printer.
3675 See also `pr-ps-buffer-print'."
3676 (interactive (pr-interactive-n-up-file "PS print mode"))
3677 (pr-set-n-up-and-filename 'n-up 'filename "PS print mode")
3678 (pr-ps-mode n-up filename))
3682 (defun pr-ps-mode-ps-print (n-up &optional filename)
3683 "Print major mode using PostScript or through ghostscript.
3685 See also `pr-ps-buffer-ps-print'."
3686 (interactive (pr-interactive-n-up-file (pr-prompt-gs "PS print mode")))
3687 (if (pr-using-ghostscript-p)
3688 (pr-ps-mode-using-ghostscript n-up filename)
3689 (pr-ps-mode-print n-up filename)))
3693 (defun pr-printify-directory (&optional dir file-regexp)
3694 "Replace nonprinting characters in directory with printable representations.
3695 The printable representations use ^ (for ASCII control characters) or hex.
3696 The characters tab, linefeed, space, return and formfeed are not affected.
3698 Interactively, the command prompts for a directory and a file name regexp for
3701 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
3702 prompts for FILE(name)-REGEXP.
3704 See also documentation for `pr-list-directory'."
3705 (interactive (pr-interactive-dir-args "Printify dir"))
3706 (pr-set-dir-args 'dir 'file-regexp "Printify dir")
3707 (pr-file-list dir file-regexp 'pr-printify-buffer))
3711 (defun pr-printify-buffer ()
3712 "Replace nonprinting characters in buffer with printable representations.
3713 The printable representations use ^ (for ASCII control characters) or hex.
3714 The characters tab, linefeed, space, return and formfeed are not affected."
3716 (if (pr-region-active-p)
3717 (pr-printify-region)
3718 (printify-region (point-min) (point-max))))
3722 (defun pr-printify-region ()
3723 "Replace nonprinting characters in region with printable representations.
3724 The printable representations use ^ (for ASCII control characters) or hex.
3725 The characters tab, linefeed, space, return and formfeed are not affected."
3727 (printify-region (point) (mark)))
3731 (defun pr-txt-directory (&optional dir file-regexp)
3732 "Print directory using text printer.
3734 Interactively, the command prompts for a directory and a file name regexp for
3737 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
3738 prompts for FILE(name)-REGEXP.
3740 See also documentation for `pr-list-directory'."
3741 (interactive (pr-interactive-dir-args "Print dir"))
3742 (pr-set-dir-args 'dir 'file-regexp "Print dir")
3743 (pr-file-list dir file-regexp 'pr-txt-buffer))
3747 (defun pr-txt-buffer ()
3748 "Print buffer using text printer."
3750 (cond ((pr-auto-mode-p)
3752 ((pr-region-active-p)
3755 (pr-txt-print (point-min) (point-max)))))
3759 (defun pr-txt-region ()
3760 "Print region using text printer."
3762 (if (pr-auto-mode-p)
3763 (let ((pr-auto-region t))
3765 (pr-txt-print (point) (mark))))
3769 (defun pr-txt-mode ()
3770 "Print major mode using text printer."
3772 (let ((args (pr-mode-alist-p)))
3774 (funcall (car args) (nthcdr 2 args))
3776 (message "`%s' major mode not declared." major-mode))))
3780 (defun pr-despool-preview (&optional filename)
3781 "Preview spooled PostScript.
3783 Interactively, when you use a prefix argument (C-u), the command prompts the
3784 user for a file name, and saves the spooled PostScript image in that file
3785 instead of saving it in a temporary file.
3787 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3788 save the image in a temporary file. If FILENAME is a string, save the
3789 PostScript image in a file with that name."
3790 (interactive (list (ps-print-preprint current-prefix-arg)))
3791 (let ((file (pr-ps-file filename)))
3792 (when (stringp file)
3793 (pr-despool-print file)
3794 (pr-ps-file-preview file))))
3798 (defun pr-despool-using-ghostscript (&optional filename)
3799 "Print spooled PostScript using ghostscript.
3801 Interactively, when you use a prefix argument (C-u), the command prompts the
3802 user for a file name, and saves the spooled PostScript image in that file
3803 instead of sending it to the printer.
3805 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3806 send the image to the printer. If FILENAME is a string, save the PostScript
3807 image in a file with that name."
3808 (interactive (list (ps-print-preprint current-prefix-arg)))
3809 (let ((file (pr-ps-file filename)))
3810 (when (stringp file)
3811 (pr-despool-print file)
3812 (pr-ps-file-using-ghostscript file)
3813 (or filename (pr-delete-file file)))))
3817 (defun pr-despool-print (&optional filename)
3818 "Send the spooled PostScript to the printer.
3820 Interactively, when you use a prefix argument (C-u), the command prompts the
3821 user for a file name, and saves the spooled PostScript image in that file
3822 instead of sending it to the printer.
3824 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3825 send the image to the printer. If FILENAME is a string, save the PostScript
3826 image in a file with that name."
3827 (interactive (list (ps-print-preprint current-prefix-arg)))
3828 (let ((ps-lpr-command (pr-command pr-ps-command))
3829 (ps-lpr-switches pr-ps-switches)
3830 (ps-printer-name-option pr-ps-printer-switch)
3831 (ps-printer-name pr-ps-printer))
3832 (ps-despool filename)))
3836 (defun pr-despool-ps-print (&optional filename)
3837 "Send the spooled PostScript to the printer or use ghostscript to print it.
3839 Interactively, when you use a prefix argument (C-u), the command prompts the
3840 user for a file name, and saves the spooled PostScript image in that file
3841 instead of sending it to the printer.
3843 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3844 send the image to the printer. If FILENAME is a string, save the PostScript
3845 image in a file with that name."
3846 (interactive (list (ps-print-preprint current-prefix-arg)))
3847 (if pr-print-using-ghostscript
3848 (pr-despool-using-ghostscript filename)
3849 (pr-despool-print filename)))
3853 (defun pr-ps-file-preview (filename)
3854 "Preview PostScript file FILENAME."
3855 (interactive (list (pr-ps-infile-preprint "Preview ")))
3856 (and (stringp filename) (file-exists-p filename)
3857 (pr-call-process pr-gv-command filename)))
3861 (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename)
3862 "Preview PostScript file FILENAME."
3863 (interactive (pr-interactive-n-up-inout "PS preview"))
3864 (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename
3866 (pr-ps-utility-process n-up ifilename outfile)
3867 (pr-ps-file-preview outfile)))
3871 (defun pr-ps-file-using-ghostscript (filename)
3872 "Print PostScript file FILENAME using ghostscript."
3873 (interactive (list (pr-ps-infile-preprint "Print preview ")))
3874 (and (stringp filename) (file-exists-p filename)
3875 (let* ((file (pr-expand-file-name filename))
3876 (tempfile (pr-dosify-file-name (make-temp-name file))))
3878 (pr-call-process pr-gs-command
3879 (format "-sDEVICE=%s" pr-gs-device)
3880 (format "-r%d" pr-gs-resolution)
3881 (pr-switches-string pr-gs-switches "pr-gs-switches")
3882 (format "-sOutputFile=\"%s\"" tempfile)
3886 (pr-ps-file-print tempfile)
3888 (pr-delete-file tempfile))))
3892 (defun pr-ps-file-print (filename)
3893 "Print PostScript file FILENAME."
3894 (interactive (list (pr-ps-infile-preprint "Print ")))
3895 (and (stringp filename) (file-exists-p filename)
3897 (let ((file (pr-expand-file-name filename)))
3898 (if (string= pr-ps-command "")
3899 (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
3901 (set-buffer ps-spool-buffer)
3903 (insert-file-contents-literally file))
3905 (apply 'pr-call-process
3907 (pr-switches-string pr-ps-switches "pr-gs-switches")
3908 (if (string-match "cp" pr-ps-command)
3909 ;; for "cp" (cmd in out)
3911 (concat pr-ps-printer-switch pr-ps-printer))
3912 ;; else, for others (cmd out in)
3913 (list (concat pr-ps-printer-switch pr-ps-printer)
3918 (defun pr-ps-file-ps-print (filename)
3919 "Send PostScript file FILENAME to printer or use ghostscript to print it."
3920 (interactive (list (pr-ps-infile-preprint
3921 (if pr-print-using-ghostscript
3924 (if pr-print-using-ghostscript
3925 (pr-ps-file-using-ghostscript filename)
3926 (pr-ps-file-print filename)))
3930 (defun pr-ps-file-up-ps-print (n-up ifilename &optional ofilename)
3931 "Process a PostScript file IFILENAME and send it to printer.
3933 Interactively, the command prompts for N-UP printing number, for an input
3934 PostScript file IFILENAME and, when you use a prefix argument (C-u), the
3935 command prompts the user for an output PostScript file name OFILENAME, and
3936 saves the PostScript image in that file instead of sending it to the printer.
3938 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
3939 argument IFILENAME is treated as follows: if it's t, prompts for an input
3940 PostScript file name; otherwise, it *must* be a string that it's an input
3941 PostScript file name. The argument OFILENAME is treated as follows: if it's
3942 nil, send the image to the printer. If OFILENAME is a string, save the
3943 PostScript image in a file with that name. If OFILENAME is t, prompts for a
3945 (interactive (pr-interactive-n-up-inout
3946 (if pr-print-using-ghostscript
3949 (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename
3950 (if pr-print-using-ghostscript
3953 (pr-ps-utility-process n-up ifilename outfile)
3955 (pr-ps-file-ps-print outfile)
3956 (pr-delete-file outfile))))
3960 (defun pr-toggle-file-duplex ()
3961 "Toggle duplex for PostScript file."
3963 (pr-toggle 'pr-file-duplex "PS file duplex" nil 7 5 nil
3964 '("PostScript Print" "File")))
3968 (defun pr-toggle-file-tumble ()
3969 "Toggle tumble for PostScript file.
3971 If tumble is off, produces a printing suitable for binding on the left or
3973 If tumble is on, produces a printing suitable for binding at the top or
3976 (pr-toggle 'pr-file-tumble "PS file tumble" nil 8 5 nil
3977 '("PostScript Print" "File")))
3981 (defun pr-toggle-file-landscape ()
3982 "Toggle landscape for PostScript file."
3984 (pr-toggle 'pr-file-landscape "PS file landscape" nil 6 5 nil
3985 '("PostScript Print" "File")))
3989 (defun pr-toggle-ghostscript ()
3990 "Toggle printing using ghostscript."
3992 (pr-toggle 'pr-print-using-ghostscript "Printing using ghostscript"
3993 'postscript-process 2 12 'toggle))
3997 (defun pr-toggle-faces ()
3998 "Toggle printing with faces."
4000 (pr-toggle 'pr-faces-p "Printing with faces"
4001 'postscript-process 1 12 'toggle))
4005 (defun pr-toggle-spool ()
4008 (pr-toggle 'pr-spool-p "Spooling printing"
4009 'postscript-process 0 12 'toggle))
4013 (defun pr-toggle-duplex ()
4016 (pr-toggle 'ps-spool-duplex "Printing duplex"
4017 'postcsript-options 5 12 'toggle))
4021 (defun pr-toggle-tumble ()
4024 If tumble is off, produces a printing suitable for binding on the left or
4026 If tumble is on, produces a printing suitable for binding at the top or
4029 (pr-toggle 'ps-spool-tumble "Tumble"
4030 'postscript-options 6 12 'toggle))
4034 (defun pr-toggle-landscape ()
4037 (pr-toggle 'ps-landscape-mode "Landscape"
4038 'postscript-options 0 12 'toggle))
4042 (defun pr-toggle-upside-down ()
4043 "Toggle upside-down."
4045 (pr-toggle 'ps-print-upside-down "Upside-Down"
4046 'postscript-options 7 12 'toggle))
4050 (defun pr-toggle-line ()
4051 "Toggle line number."
4053 (pr-toggle 'ps-line-number "Line number"
4054 'postscript-options 3 12 'toggle))
4058 (defun pr-toggle-zebra ()
4059 "Toggle zebra stripes."
4061 (pr-toggle 'ps-zebra-stripes "Zebra stripe"
4062 'postscript-options 4 12 'toggle))
4066 (defun pr-toggle-header ()
4067 "Toggle printing header."
4069 (pr-toggle 'ps-print-header "Print header"
4070 'postscript-options 1 12 'toggle))
4074 (defun pr-toggle-header-frame ()
4075 "Toggle printing header frame."
4077 (pr-toggle 'ps-print-header-frame "Print header frame"
4078 'postscript-options 2 12 'toggle))
4082 (defun pr-toggle-lock ()
4085 (pr-toggle 'pr-menu-lock "Menu lock"
4086 'printing 2 12 'toggle))
4090 (defun pr-toggle-region ()
4091 "Toggle auto region."
4093 (pr-toggle 'pr-auto-region "Auto region"
4094 'printing 0 12 'toggle))
4098 (defun pr-toggle-mode ()
4101 (pr-toggle 'pr-auto-mode "Auto mode"
4102 'printing 1 12 'toggle))
4106 (defun pr-customize (&rest ignore)
4107 "Customization of the `printing' group."
4109 (customize-group 'printing))
4113 (defun lpr-customize (&rest ignore)
4114 "Customization of the `lpr' group."
4116 (customize-group 'lpr))
4120 (defun pr-help (&rest ignore)
4121 "Help for the printing package."
4123 (pr-show-setup pr-help-message "*Printing Help*"))
4127 (defun pr-ps-name ()
4128 "Interactively select a PostScript printer."
4130 (pr-menu-set-ps-title
4131 (pr-complete-alist "PostScript printer" pr-ps-printer-alist pr-ps-name)))
4135 (defun pr-txt-name ()
4136 "Interactively select a text printer."
4138 (pr-menu-set-txt-title
4139 (pr-complete-alist "Text printer" pr-txt-printer-alist pr-txt-name)))
4143 (defun pr-ps-utility ()
4144 "Interactively select a PostScript utility."
4146 (pr-menu-set-utility-title
4147 (pr-complete-alist "Postscript utility" pr-ps-utility-alist pr-ps-utility)))
4151 (defun pr-show-ps-setup (&rest ignore)
4152 "Show current ps-print settings."
4154 (pr-show-setup (ps-setup) "*PS Setup*"))
4158 (defun pr-show-pr-setup (&rest ignore)
4159 "Show current printing settings."
4161 (pr-show-setup (pr-setup) "*PR Setup*"))
4165 (defun pr-show-lpr-setup (&rest ignore)
4166 "Show current lpr settings."
4168 (pr-show-setup (lpr-setup) "*LPR Setup*"))
4171 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4176 (defun pr-ps-fast-fire (n-up &optional select)
4177 "Fast fire function for PostScript printing.
4179 If a region is active, the region will be printed instead of the whole buffer.
4180 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4181 `pr-mode-alist' will be used, that is, the current buffer or region will be
4182 printed using `pr-ps-mode-ps-print'.
4185 Interactively, you have the following situations:
4187 M-x pr-ps-fast-fire RET
4188 The command prompts the user for a N-UP value and printing will
4189 immediatelly be done using the current active printer.
4191 C-u M-x pr-ps-fast-fire RET
4192 C-u 0 M-x pr-ps-fast-fire RET
4193 The command prompts the user for a N-UP value and also for a current
4194 PostScript printer, then printing will immediatelly be done using the new
4195 current active printer.
4197 C-u 1 M-x pr-ps-fast-fire RET
4198 The command prompts the user for a N-UP value and also for a file name,
4199 and saves the PostScript image in that file instead of sending it to the
4202 C-u 2 M-x pr-ps-fast-fire RET
4203 The command prompts the user for a N-UP value, then for a current
4204 PostScript printer and, finally, for a file name. Then change the active
4205 printer to that choosen by user and saves the PostScript image in
4206 that file instead of sending it to the printer.
4209 Noninteractively, the argument N-UP should be a positive integer greater than
4210 zero and the argument SELECT is treated as follows:
4212 If it's nil, send the image to the printer.
4214 If it's a list or an integer lesser or equal to zero, the command prompts
4215 the user for a current PostScript printer, then printing will immediatelly
4216 be done using the new current active printer.
4218 If it's an integer equal to 1, the command prompts the user for a file name
4219 and saves the PostScript image in that file instead of sending it to the
4222 If it's an integer greater or equal to 2, the command prompts the user for a
4223 current PostScript printer and for a file name. Then change the active
4224 printer to that choosen by user and saves the PostScript image in that file
4225 instead of sending it to the printer.
4227 If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new
4228 active printer and printing will immediatelly be done using the new active
4231 Otherwise, send the image to the printer.
4234 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4236 (interactive (list (pr-interactive-n-up (pr-prompt-gs "PS print fast"))
4237 current-prefix-arg))
4238 (let ((pr-auto-region t)
4241 (cond ((null select))
4244 ((and (symbolp select)
4245 (assq select pr-ps-printer-alist))
4246 (pr-menu-set-ps-title select))
4250 (and (>= select 1) (not pr-spool-p)
4251 (setq filename (pr-ps-outfile-preprint
4252 (if pr-print-using-ghostscript
4255 (pr-ps-buffer-ps-print
4257 (min (max n-up 1) 100)
4258 (error "n-up must be an integer greater than zero."))
4263 (defun pr-txt-fast-fire (&optional select-printer)
4264 "Fast fire function for text printing.
4266 If a region is active, the region will be printed instead of the whole buffer.
4267 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4268 `pr-mode-alist' will be used, that is, the current buffer or region will be
4269 printed using `pr-txt-mode'.
4271 Interactively, when you use a prefix argument (C-u), the command prompts the
4272 user for a new active text printer.
4274 Noninteractively, the argument SELECT-PRINTER is treated as follows:
4276 If it's nil, the printing is sent to the current active text printer.
4278 If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new
4279 active printer and printing will immediatelly be done using the new active
4282 If it's non-nil, the command prompts the user for a new active text printer.
4284 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4286 (interactive (list current-prefix-arg))
4287 (cond ((null select-printer))
4288 ((and (symbolp select-printer)
4289 (assq select-printer pr-txt-printer-alist))
4290 (pr-menu-set-txt-title select-printer))
4293 (let ((pr-auto-region t)
4298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4303 "Return the current `printing' setup.
4305 This is *not* an interactive command.
4306 One way to see `printing' setup is to switch to a *Scratch* buffer and type:
4308 M-: (insert (pr-setup)) RET
4310 Or choose the menu option Printing/Show Settings/printing."
4311 (let (ps-prefix-quote)
4315 (concat "\n;;; printing.el version " pr-version "\n")
4317 (ps-comment-string "pr-txt-command " pr-txt-command)
4318 (ps-comment-string "pr-txt-switches "
4319 (pr-switches-string pr-txt-switches "pr-txt-switches"))
4320 (ps-comment-string "pr-txt-printer " pr-txt-printer)
4321 (ps-comment-string "pr-ps-command " pr-ps-command)
4322 (ps-comment-string "pr-ps-switches "
4323 (pr-switches-string pr-ps-switches "pr-ps-switches"))
4324 (ps-comment-string "pr-ps-printer-switch" pr-ps-printer-switch)
4325 (ps-comment-string "pr-ps-printer " pr-ps-printer)
4326 (ps-comment-string "pr-cygwin-system " pr-cygwin-system)
4327 (ps-comment-string "ps-windows-system " ps-windows-system)
4328 (ps-comment-string "ps-lp-system " ps-lp-system)
4330 '(14 . pr-path-style)
4331 '(14 . pr-path-alist)
4334 '(21 . pr-txt-printer-alist)
4337 '(20 . pr-ps-printer-alist)
4340 '(20 . pr-ps-temp-file)
4341 '(20 . pr-delete-temp-file)
4342 '(20 . pr-list-directory)
4344 '(17 . pr-gv-command)
4345 '(17 . pr-gs-command)
4346 '(17 . pr-gs-switches)
4347 '(17 . pr-gs-device)
4348 '(17 . pr-gs-resolution)
4350 '(27 . pr-print-using-ghostscript)
4353 '(27 . pr-file-landscape)
4354 '(27 . pr-file-duplex)
4355 '(27 . pr-file-tumble)
4356 '(27 . pr-auto-region)
4357 '(27 . pr-auto-mode)
4359 '(20 . pr-ps-utility)
4360 '(20 . pr-ps-utility-alist)
4362 '(14 . pr-mode-alist)
4364 '(20 . pr-menu-lock)
4365 '(20 . pr-menu-char-height)
4366 '(20 . pr-menu-char-width)
4368 '(20 . pr-setting-database)
4370 '(22 . pr-visible-entry-list)
4372 '(22 . pr-buffer-verbose)
4373 '(22 . pr-buffer-name)
4374 '(22 . pr-buffer-name-ignore)
4375 ")\n\n;;; printing.el - end of settings\n")
4380 "Return the current `lpr' setup.
4382 This is *not* an interactive command.
4383 One way to see `lpr' setup is to switch to a *Scratch* buffer and type:
4385 M-: (insert (lpr-setup)) RET
4387 Or choose the menu option Printing/Show Settings/lpr."
4388 (let (ps-prefix-quote)
4391 '("\n;;; lpr.el settings\n"
4394 (25 . lpr-add-switches)
4396 (25 . lpr-headers-switches)
4397 (25 . print-region-function)
4398 (25 . lpr-page-header-program)
4399 (25 . lpr-page-header-switches)
4400 ")\n\n;;; lpr.el - end of settings\n")
4404 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4405 ;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>)
4408 (defalias 'pr-mh-get-msg-num 'mh-get-msg-num)
4409 (defalias 'pr-mh-show 'mh-show)
4410 (defalias 'pr-mh-start-of-uncleaned-message 'mh-start-of-uncleaned-message)
4411 (defvar mh-show-buffer nil)
4414 (defun pr-article-date ()
4415 "Find the date of an article or mail message in current buffer.
4416 Return only the dayname, if present, weekday, month, and year."
4418 (goto-char (point-min))
4419 (if (re-search-forward
4420 "^Date:[ \t]+\\(\\([A-Za-z]+, \\)?[0-9]+ [A-Za-z]+ [0-9]+\\)" nil t)
4421 (buffer-substring (match-beginning 1) (match-end 1))
4422 (format-time-string "%Y/%m/%d"))))
4425 (defun pr-mh-current-message ()
4426 "Go to mh-inbox current message."
4427 (let ((msg (or (pr-mh-get-msg-num nil) 0)))
4429 (set-buffer mh-show-buffer)
4430 (goto-char (point-min))
4431 (pr-mh-start-of-uncleaned-message)
4432 (message "Printing message %d" msg)))
4435 (defun pr-mh-print-1 (n-up filename header-list)
4436 "Print mh-inbox current message in PostScript."
4438 (save-window-excursion
4439 (pr-mh-current-message)
4440 (pr-mode-print n-up filename header-list (point)))))
4443 (defun pr-mh-lpr-1 (header-list)
4444 "Print mh-inbox current message in text printer."
4446 (save-window-excursion
4447 (pr-mh-current-message)
4448 (pr-mode-lpr header-list (point)))))
4451 (defalias 'pr-mh-print-2 'pr-mode-print)
4454 (defalias 'pr-mh-lpr-2 'pr-mode-lpr)
4457 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4458 ;; rmail (hacked from ps-print.el)
4461 (defun pr-rmail-lpr (header-list)
4462 "Print RMAIL current message in text printer."
4463 (pr-lpr-message-from-summary header-list
4464 'rmail-buffer 'rmail-summary-buffer))
4467 (defun pr-rmail-print (n-up filename header-list)
4468 "Print RMAIL current message in PostScript."
4469 (pr-ps-message-from-summary n-up filename header-list
4470 'rmail-buffer 'rmail-summary-buffer))
4473 (defun pr-ps-message-from-summary (n-up filename header-list
4474 summary-buffer summary-default)
4475 "Print current message in PostScript."
4476 (let ((buf (or (and (boundp summary-buffer)
4477 (symbol-value summary-buffer))
4478 (symbol-value summary-default))))
4479 (and (get-buffer buf)
4482 (pr-mode-print n-up filename header-list)))))
4485 (defun pr-lpr-message-from-summary (header-list summary-buffer summary-default)
4486 "Print current message in text printer."
4487 (let ((buf (or (and (boundp summary-buffer)
4488 (symbol-value summary-buffer))
4489 (symbol-value summary-default))))
4490 (and (get-buffer buf)
4493 (pr-mode-lpr header-list)))))
4496 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4497 ;; gnus (hacked from ps-print.el)
4500 (defvar pr-gnus-article "*Article*")
4503 (defun pr-gnus-print (n-up filename header-list)
4504 "Print *Article* current message in PostScript."
4505 (pr-ps-message-from-summary n-up filename header-list
4506 'gnus-article-buffer 'pr-gnus-article))
4509 (defun pr-gnus-lpr (header-list)
4510 "Print *Article* current message in text printer."
4511 (pr-lpr-message-from-summary header-list
4512 'gnus-article-buffer 'pr-gnus-article))
4515 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4516 ;; vm (hacked from ps-print.el)
4519 (defvar pr-vm-summary "")
4522 (defun pr-vm-print (n-up filename header-list)
4523 "Print current vm message in PostScript."
4524 (pr-ps-message-from-summary n-up filename header-list
4525 'vm-mail-buffer 'pr-vm-summary))
4528 (defun pr-vm-lpr (header-list)
4529 "Print current vm message in text printer."
4530 (pr-lpr-message-from-summary header-list
4531 'vm-mail-buffer 'pr-vm-summary))
4534 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4538 (defun pr-ps-mode (n-up filename)
4539 "If current major mode is declared, print it in PostScript."
4540 (let ((args (pr-mode-alist-p)))
4542 (let ((fun (cdr args)))
4543 (funcall (car fun) n-up filename (cdr fun))
4546 (message "`%s' major mode not declared." major-mode)
4550 (defmacro pr-local-variable (header-list &rest body)
4552 (let ((ps-header-lines (or (nth 0 ,header-list) ps-header-lines))
4553 (ps-left-header (or (nth 1 ,header-list) ps-left-header))
4554 (ps-right-header (or (nth 2 ,header-list) ps-right-header))
4556 (let ((local-var-list (pr-eval-local-alist (nthcdr 4 ,header-list))))
4558 (and (nth 3 ,header-list)
4559 (pr-kill-local-variable local-var-list))))))
4562 (defun pr-mode-print (n-up filename header-list &optional from to)
4563 "Print current major mode in PostScript."
4566 (let ((file (pr-ps-file filename))
4568 ((pr-region-active-p) (region-beginning))
4571 (pr-text2ps (pr-region-active-symbol start) n-up file start
4573 ((pr-region-active-p) (region-end))
4576 (unless (or pr-spool-p filename)
4577 (pr-ps-file-print file)
4578 (pr-delete-file file)))))
4581 (defun pr-mode-lpr (header-list &optional from to)
4582 "Print current major mode in text printer."
4585 (pr-txt-print (cond (from)
4586 ((pr-region-active-p) (region-beginning))
4589 ((pr-region-active-p) (region-end))
4593 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4597 (defconst pr-menu-entry-alist
4600 (postscript-options . 9)
4601 (postscript-process . 3)
4605 "Alist that associates menu part with number of items per part.
4607 It's used by `pr-menu-index'.
4609 Each element has the form:
4611 (MENU-PART . NUMBER-OF-ITEMS)
4613 See `pr-visible-entry-alist'.")
4616 (defun pr-menu-index (entry index)
4618 (cond ((eq entry 'text)
4620 ((eq entry 'postscript-options)
4622 ((eq entry 'postscript-process)
4623 '(postscript text postscript-options))
4624 ((eq entry 'printing)
4625 '(postscript text postscript-options postscript-process))
4631 (setq key (car base-list)
4632 base-list (cdr base-list))
4633 (and (pr-visible-p key)
4634 (setq index (+ index
4635 (cdr (assq key pr-menu-entry-alist)))))))
4639 (defvar pr-menu-position nil)
4640 (defvar pr-menu-state nil)
4645 ((eq ps-print-emacs-type 'xemacs)
4647 (defvar current-mouse-event nil) ; to avoid compilation gripes
4648 (defun pr-menu-position (entry index horizontal)
4652 'x (- (pr-x-event-x-pixel current-mouse-event) ; X
4653 (* horizontal pr-menu-char-width))
4654 'y (- (pr-x-event-y-pixel current-mouse-event) ; Y
4655 (* (pr-menu-index entry index) pr-menu-char-height)))))
4658 ;; GNU Emacs for Windows 9x/NT
4659 (defun pr-menu-position (entry index horizontal)
4660 (let ((pos (cdr (pr-e-mouse-pixel-position))))
4662 (list (or (car pos) 0) ; X
4663 (- (or (cdr pos) 0) ; Y
4664 (* (pr-menu-index entry index) pr-menu-char-height)))
4665 (selected-frame)))) ; frame
4669 (defun pr-menu-position (entry index horizontal)
4670 (let ((pos (cdr (pr-e-mouse-pixel-position))))
4672 (list (- (or (car pos) 0) ; X
4673 (* horizontal pr-menu-char-width))
4674 (- (or (cdr pos) 0) ; Y
4675 (* (pr-menu-index entry index) pr-menu-char-height)))
4676 (selected-frame)))) ; frame
4680 ((eq ps-print-emacs-type 'emacs)
4682 (defun pr-menu-lookup (path)
4683 (let ((ipath pr-menu-bar))
4684 (lookup-key global-map
4687 (mapcar 'pr-get-symbol
4694 (defun pr-menu-lock (entry index horizontal state path)
4695 (when (and (not (interactive-p)) pr-menu-lock)
4696 (or (and pr-menu-position (eq state pr-menu-state))
4697 (setq pr-menu-position (pr-menu-position entry index horizontal)
4698 pr-menu-state state))
4699 (let* ((menu (pr-menu-lookup path))
4700 (result (x-popup-menu pr-menu-position menu)))
4702 (let ((command (lookup-key menu (vconcat result))))
4703 (if (fboundp command)
4706 (setq pr-menu-position nil))))
4709 ((eq ps-print-emacs-type 'xemacs)
4711 (defvar current-menubar nil) ; to avoid compilation gripes
4712 (defun pr-menu-lookup (path)
4713 (car (pr-x-find-menu-item current-menubar (cons "Printing" path))))
4716 (defun pr-menu-lock (entry index horizontal state path)
4717 (when (and (not (interactive-p)) pr-menu-lock)
4718 (or (and pr-menu-position (eq state pr-menu-state))
4719 (setq pr-menu-position (pr-menu-position entry index horizontal)
4720 pr-menu-state state))
4721 (let* ((menu (pr-menu-lookup path))
4722 (result (pr-x-get-popup-menu-response menu pr-menu-position)))
4723 (and (pr-x-misc-user-event-p result)
4724 (funcall (pr-x-event-function result)
4725 (pr-x-event-object result))))
4726 (setq pr-menu-position nil))))))
4729 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4730 ;; Printer & Utility Selection
4733 (defun pr-update-var (var-sym alist)
4734 (or (assq (symbol-value var-sym) alist)
4735 (set var-sym (car (car alist)))))
4738 (defun pr-update-menus (&optional force)
4739 "Update utility, PostScript and text printer menus.
4741 If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist',
4742 `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not;
4743 otherwise, update PostScript printer menu iff `pr-ps-printer-menu-modified' is
4744 non-nil, update text printer menu iff `pr-txt-printer-menu-modified' is
4745 non-nil, and update PostScript File menus iff `pr-ps-utility-menu-modified' is
4748 (pr-update-var 'pr-ps-name pr-ps-printer-alist)
4749 (pr-update-var 'pr-txt-name pr-txt-printer-alist)
4750 (pr-update-var 'pr-ps-utility pr-ps-utility-alist)
4751 (pr-do-update-menus force))
4754 (defvar pr-ps-printer-menu-modified t
4755 "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.")
4756 (defvar pr-txt-printer-menu-modified t
4757 "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.")
4758 (defvar pr-ps-utility-menu-modified t
4759 "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.")
4762 (defconst pr-even-or-odd-alist
4763 '((nil . "Print All Pages")
4764 (even-page . "Print Even Pages")
4765 (odd-page . "Print Odd Pages")
4766 (even-sheet . "Print Even Sheets")
4767 (odd-sheet . "Print Odd Sheets")))
4770 (defun pr-menu-create (name alist var-sym fun entry index)
4774 (let ((sym (car elt)))
4777 (list fun (list 'quote sym) nil (list 'quote entry) index)
4779 :selected (list 'eq var-sym (list 'quote sym)))))
4785 ((eq ps-print-emacs-type 'emacs)
4787 (defalias 'pr-update-mode-line 'force-mode-line-update)
4790 (defun pr-do-update-menus (&optional force)
4791 (pr-menu-alist pr-ps-printer-alist
4793 'pr-menu-set-ps-title
4794 "PostScript Printers"
4795 'pr-ps-printer-menu-modified
4797 "PostScript Printers"
4799 (pr-menu-alist pr-txt-printer-alist
4801 'pr-menu-set-txt-title
4803 'pr-txt-printer-menu-modified
4807 (let ((save-var pr-ps-utility-menu-modified))
4808 (pr-menu-alist pr-ps-utility-alist
4810 'pr-menu-set-utility-title
4811 '("PostScript Print" "File" "PostScript Utility")
4814 "PostScript Utility"
4816 (pr-menu-alist pr-ps-utility-alist
4818 'pr-menu-set-utility-title
4819 '("PostScript Preview" "File" "PostScript Utility")
4820 'pr-ps-utility-menu-modified
4822 "PostScript Utility"
4824 (pr-even-or-odd-pages ps-even-or-odd-pages force))
4827 (defvar pr-temp-menu nil)
4830 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
4832 (when (and alist (or force (symbol-value modified-sym)))
4833 (easy-menu-define pr-temp-menu nil ""
4834 (pr-menu-create name alist var-sym fun entry index))
4835 (let ((item (pr-menu-get-item menu-path)))
4837 (let* ((binding (nthcdr 3 item))
4838 (key-binding (cdr binding)))
4839 (setcar binding pr-temp-menu)
4840 (and key-binding (listp (car key-binding))
4841 (setcdr binding (cdr key-binding))) ; skip KEY-BINDING
4842 (funcall fun (symbol-value var-sym) item))))
4843 (set modified-sym nil)))
4846 (defun pr-menu-set-ps-title (value &optional item entry index)
4847 (pr-menu-set-item-name (or item
4848 (pr-menu-get-item "PostScript Printers"))
4849 (format "PostScript Printer: %s" value))
4850 (pr-ps-set-printer value)
4852 (pr-menu-lock entry index 12 'toggle nil)))
4855 (defun pr-menu-set-txt-title (value &optional item entry index)
4856 (pr-menu-set-item-name (or item
4857 (pr-menu-get-item "Text Printers"))
4858 (format "Text Printer: %s" value))
4859 (pr-txt-set-printer value)
4861 (pr-menu-lock entry index 12 'toggle nil)))
4864 (defun pr-menu-set-utility-title (value &optional item entry index)
4865 (let ((name (symbol-name value)))
4867 (pr-menu-set-item-name item name)
4868 (pr-menu-set-item-name
4870 '("PostScript Print" "File" "PostScript Utility"))
4872 (pr-menu-set-item-name
4874 '("PostScript Preview" "File" "PostScript Utility"))
4876 (pr-ps-set-utility value)
4878 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
4881 (defun pr-even-or-odd-pages (value &optional no-lock)
4882 (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
4883 (cdr (assq value pr-even-or-odd-alist)))
4884 (setq ps-even-or-odd-pages value)
4886 (pr-menu-lock 'postscript-options 8 12 'toggle nil))))
4889 ((eq ps-print-emacs-type 'xemacs)
4891 (defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
4894 (defvar pr-ps-name-old "PostScript Printers")
4895 (defvar pr-txt-name-old "Text Printers")
4896 (defvar pr-ps-utility-old "PostScript Utility")
4897 (defvar pr-even-or-odd-old "Print All Pages")
4900 (defun pr-do-update-menus (&optional force)
4901 (pr-menu-alist pr-ps-printer-alist
4903 'pr-menu-set-ps-title
4905 'pr-ps-printer-menu-modified
4909 (pr-menu-alist pr-txt-printer-alist
4911 'pr-menu-set-txt-title
4913 'pr-txt-printer-menu-modified
4917 (let ((save-var pr-ps-utility-menu-modified))
4918 (pr-menu-alist pr-ps-utility-alist
4920 'pr-menu-set-utility-title
4921 '("Printing" "PostScript Print" "File")
4926 (pr-menu-alist pr-ps-utility-alist
4928 'pr-menu-set-utility-title
4929 '("Printing" "PostScript Preview" "File")
4930 'pr-ps-utility-menu-modified
4934 (pr-even-or-odd-pages ps-even-or-odd-pages force))
4937 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
4939 (when (and alist (or force (symbol-value modified-sym)))
4940 (pr-xemacs-global-menubar
4941 (pr-x-add-submenu menu-path
4942 (pr-menu-create name alist var-sym
4944 (funcall fun (symbol-value var-sym))
4945 (set modified-sym nil)))
4948 (defun pr-menu-set-ps-title (value &optional item entry index)
4949 (pr-relabel-menu-item (format "PostScript Printer: %s" value)
4951 (pr-ps-set-printer value)
4953 (pr-menu-lock entry index 12 'toggle nil)))
4956 (defun pr-menu-set-txt-title (value &optional item entry index)
4957 (pr-relabel-menu-item (format "Text Printer: %s" value)
4959 (pr-txt-set-printer value)
4961 (pr-menu-lock entry index 12 'toggle nil)))
4964 (defun pr-menu-set-utility-title (value &optional item entry index)
4965 (pr-xemacs-global-menubar
4966 (let ((newname (format "%s" value)))
4967 (pr-x-relabel-menu-item
4968 (list "Printing" "PostScript Print" "File" pr-ps-utility-old)
4970 (pr-x-relabel-menu-item
4971 (list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
4973 (setq pr-ps-utility-old newname)))
4974 (pr-ps-set-utility value)
4976 (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
4979 (defun pr-even-or-odd-pages (value &optional no-lock)
4980 (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
4981 'pr-even-or-odd-old)
4982 (setq ps-even-or-odd-pages value)
4984 (pr-menu-lock 'postscript-options 8 12 'toggle nil))))))
4987 (defun pr-relabel-menu-item (newname var-sym)
4988 (pr-xemacs-global-menubar
4989 (pr-x-relabel-menu-item
4990 (list "Printing" (symbol-value var-sym))
4992 (set var-sym newname)))
4995 (defun pr-menu-set-item-name (item name)
4997 (setcar (nthcdr 2 item) name))) ; ITEM-NAME
5000 (defun pr-menu-get-item (name-list)
5001 ;; NAME-LIST is a string or a list of strings.
5002 (let ((ipath pr-menu-bar)
5003 (len (and (listp name-list) (length name-list))))
5005 (setq name-list (car name-list)))
5011 ;; list and (length list) > 1
5012 (let* ((copy (copy-sequence name-list))
5013 (name (pr-get-symbol (nth (1- len) copy)))
5015 (setcdr (nthcdr (- len 2) copy) nil)
5021 (mapcar 'pr-get-symbol path))
5023 (assq name (nthcdr 2 menu))))
5026 (let ((name (pr-get-symbol name-list))
5027 (menu (lookup-key global-map ipath)))
5028 (assq name (nthcdr 2 menu)))))))
5031 (defun pr-ps-set-utility (value)
5032 (let ((item (cdr (assq value pr-ps-utility-alist))))
5035 "Invalid PostScript utility name `%s' for variable `pr-ps-utility'."
5037 (setq pr-ps-utility value)
5038 (pr-eval-alist (nthcdr 9 item)))
5039 (pr-update-mode-line))
5042 (defun pr-ps-set-printer (value)
5043 (let ((ps (cdr (assq value pr-ps-printer-alist))))
5046 "Invalid PostScript printer name `%s' for variable `pr-ps-name'."
5048 (setq pr-ps-name value
5049 pr-ps-command (pr-dosify-file-name (nth 0 ps))
5050 pr-ps-switches (nth 1 ps)
5051 pr-ps-printer-switch (nth 2 ps)
5052 pr-ps-printer (nth 3 ps))
5053 (or (stringp pr-ps-command)
5055 (cond (ps-windows-system "print")
5059 (or (stringp pr-ps-printer-switch)
5060 (setq pr-ps-printer-switch
5061 (cond (ps-windows-system "/D:")
5065 (pr-eval-alist (nthcdr 4 ps)))
5066 (pr-update-mode-line))
5069 (defun pr-txt-set-printer (value)
5070 (let ((txt (cdr (assq value pr-txt-printer-alist))))
5072 (error "Invalid text printer name `%s' for variable `pr-txt-name'."
5074 (setq pr-txt-name value
5075 pr-txt-command (pr-dosify-file-name (nth 0 txt))
5076 pr-txt-switches (nth 1 txt)
5077 pr-txt-printer (nth 2 txt)))
5078 (or (stringp pr-txt-command)
5079 (setq pr-txt-command
5080 (cond (ps-windows-system "print")
5084 (pr-update-mode-line))
5087 (defun pr-eval-alist (alist)
5088 (mapcar #'(lambda (option)
5089 (let ((var-sym (car option))
5090 (value (cdr option)))
5091 (if (eq var-sym 'inherits-from:)
5092 (pr-eval-setting-alist value 'global)
5093 (set var-sym (eval value)))))
5097 (defun pr-eval-local-alist (alist)
5099 (mapcar #'(lambda (option)
5100 (let ((var-sym (car option))
5101 (value (cdr option)))
5103 (if (eq var-sym 'inherits-from:)
5104 (nconc (pr-eval-setting-alist value) local-list)
5105 (set (make-local-variable var-sym) (eval value))
5106 (cons var-sym local-list)))))
5111 (defun pr-eval-setting-alist (key &optional global old)
5112 (let ((setting (cdr (assq key pr-setting-database))))
5114 (let ((inherits (nth 0 setting))
5115 (local (nth 1 setting))
5116 (kill (nth 2 setting))
5121 (message "There are local buffer settings for `%S'." key)
5124 (if (memq inherits old)
5125 (error "Circular inheritance for `%S'." inherits)
5127 (pr-eval-setting-alist inherits global
5128 (cons inherits old)))))
5130 (cond ((not local) ; global settings
5132 (let ((var-sym (car option)))
5133 (or (eq var-sym 'inherits-from:)
5134 (set var-sym (eval (cdr option)))))))
5135 (kill ; local settings with killing
5137 (let ((var-sym (car option)))
5138 (unless (eq var-sym 'inherits-from:)
5139 (setq local-list (cons var-sym local-list))
5140 (set (make-local-variable var-sym)
5141 (eval (cdr option)))))))
5142 (t ; local settings without killing
5144 (let ((var-sym (car option)))
5145 (or (eq var-sym 'inherits-from:)
5146 (set (make-local-variable var-sym)
5147 (eval (cdr option))))))))
5152 (defun pr-kill-local-variable (local-var-list)
5153 (mapcar 'kill-local-variable local-var-list))
5156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5157 ;; Internal Functions (II)
5160 (defun pr-prompt (str)
5161 (if (pr-auto-mode-p)
5162 (concat str " mode")
5163 (pr-region-active-string str)))
5166 (defun pr-prompt-region (str)
5167 (concat str (if (pr-auto-mode-p)
5172 (defun pr-prompt-gs (str)
5173 (if (pr-using-ghostscript-p)
5178 (defun pr-region-active-symbol (&optional region-p)
5179 (if (or region-p (pr-region-active-p))
5184 (defun pr-region-active-string (prefix)
5186 (if (pr-region-active-p)
5191 (defun pr-show-setup (settings buffer-name)
5192 (with-output-to-temp-buffer buffer-name
5194 (print-help-return-message)))
5197 (defun pr-complete-alist (prompt alist default)
5198 (let ((collection (mapcar #'(lambda (elt)
5199 (setq elt (car elt))
5200 (cons (symbol-name elt) elt))
5202 (cdr (assoc (completing-read (concat prompt ": ")
5204 (symbol-name default) nil
5205 (symbol-name default))
5209 (defun pr-delete-file (file)
5210 (and pr-delete-temp-file (delete-file file)))
5213 (defun pr-expand-file-name (filename)
5214 (pr-dosify-file-name (expand-file-name filename)))
5217 (defun pr-ps-outfile-preprint (&optional mess)
5218 (let* ((prompt (format "%soutput PostScript file name: " (or mess "")))
5219 (res (read-file-name prompt default-directory "" nil)))
5220 (while (cond ((not (file-writable-p res))
5222 (setq prompt "is unwritable"))
5223 ((file-directory-p res)
5225 (setq prompt "is a directory"))
5226 ((file-exists-p res)
5228 (setq prompt "exists")
5229 (not (y-or-n-p (format "File `%s' exists; overwrite? "
5232 (setq res (read-file-name
5233 (format "File %s; PostScript file: " prompt)
5234 (file-name-directory res) nil nil
5235 (file-name-nondirectory res))))
5236 (pr-expand-file-name res)))
5239 (defun pr-ps-infile-preprint (&optional mess)
5240 (let* ((prompt (format "%sinput PostScript file name: " (or mess "")))
5241 (res (read-file-name prompt default-directory "" nil)))
5242 (while (cond ((not (file-exists-p res))
5244 (setq prompt "doesn't exist"))
5245 ((not (file-readable-p res))
5247 (setq prompt "is unreadable"))
5248 ((file-directory-p res)
5250 (setq prompt "is a directory"))
5252 (setq res (read-file-name
5253 (format "File %s; PostScript file: " prompt)
5254 (file-name-directory res) nil nil
5255 (file-name-nondirectory res))))
5256 (pr-expand-file-name res)))
5259 (defun pr-toggle (var-sym mess entry index horizontal state &optional path)
5260 (set var-sym (not (symbol-value var-sym)))
5261 (message "%s is %s" mess (if (symbol-value var-sym) "on" "off"))
5262 (pr-menu-lock entry index horizontal state path))
5265 (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt)
5267 (or (symbol-value n-up-sym)
5268 (set n-up-sym (pr-interactive-n-up prompt)))
5269 (and (eq (symbol-value infile-sym) t)
5270 (set infile-sym (and (not (interactive-p))
5271 (pr-ps-infile-preprint prompt))))
5273 (or (symbol-value infile-sym)
5274 (error "%s: input PostScript file name is missing" prompt))
5275 (set infile-sym (pr-dosify-file-name (symbol-value infile-sym)))
5277 (and (eq (symbol-value outfile-sym) t)
5278 (set outfile-sym (and (not (interactive-p))
5280 (pr-ps-outfile-preprint prompt))))
5281 (and (symbol-value outfile-sym)
5282 (set outfile-sym (pr-dosify-file-name (symbol-value outfile-sym))))
5283 (pr-ps-file (symbol-value outfile-sym)))
5286 (defun pr-ps-utility-process (n-up infile outfile)
5288 (and (stringp infile) (file-exists-p infile)
5289 (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist)))
5290 (pr-call-process (nth 0 item)
5291 (pr-switches-string (nth 1 item)
5292 "pr-ps-utility-alist entry")
5293 (pr-switches-string (nth 8 item)
5294 "pr-ps-utility-alist entry")
5296 (format (nth 2 item) ps-paper-type))
5297 (format (nth 3 item) n-up)
5298 (and pr-file-landscape (nth 4 item))
5299 (and pr-file-duplex (nth 5 item))
5300 (and pr-file-tumble (nth 6 item))
5301 (pr-expand-file-name infile)
5303 (pr-expand-file-name outfile)))))
5306 (defun pr-remove-nil-from-list (lst)
5307 (while (and lst (null (car lst)))
5308 (setq lst (cdr lst)))
5320 (defun pr-call-process (command &rest args)
5321 (let ((buffer (get-buffer-create "*Printing Command Output*"))
5322 (cmd (pr-command command))
5324 (setq args (pr-remove-nil-from-list args))
5327 (goto-char (point-max))
5328 (insert (format "%s %S\n" cmd args)))
5330 (condition-case data
5331 (apply 'call-process cmd nil buffer nil args)
5333 (error-message-string data))))
5336 (goto-char (point-max))
5337 (insert (format "Exit status: %s\n" status)))))
5340 (defun pr-txt-print (from to)
5341 (let ((lpr-command (pr-standard-file-name (pr-command pr-txt-command)))
5342 (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches"))
5343 (printer-name pr-txt-printer))
5344 (lpr-region from to)))
5347 (defun pr-switches-string (switches mess)
5348 (mapconcat 'identity (pr-switches switches mess) " "))
5351 (defun pr-switches (switches mess)
5352 (or (listp switches)
5353 (error "%S should have a list of strings." mess))
5354 (ps-flatten-list ; dynamic evaluation
5355 (mapcar 'ps-eval-switch switches)))
5358 (defun pr-ps-preview (kind n-up filename mess)
5359 (pr-set-n-up-and-filename 'n-up 'filename mess)
5360 (let ((file (pr-ps-file filename)))
5361 (pr-text2ps kind n-up file)
5362 (or pr-spool-p (pr-ps-file-preview file))))
5365 (defun pr-ps-using-ghostscript (kind n-up filename mess)
5366 (pr-set-n-up-and-filename 'n-up 'filename mess)
5367 (let ((file (pr-ps-file filename)))
5368 (pr-text2ps kind n-up file)
5369 (unless (or pr-spool-p filename)
5370 (pr-ps-file-using-ghostscript file)
5371 (pr-delete-file file))))
5374 (defun pr-ps-print (kind n-up filename mess)
5375 (pr-set-n-up-and-filename 'n-up 'filename mess)
5376 (let ((file (pr-ps-file filename)))
5377 (pr-text2ps kind n-up file)
5378 (unless (or pr-spool-p filename)
5379 (pr-ps-file-print file)
5380 (pr-delete-file file))))
5383 (defun pr-ps-file (&optional filename)
5384 (pr-dosify-file-name (or filename
5385 (convert-standard-filename
5386 (expand-file-name pr-ps-temp-file pr-temp-dir)))))
5389 (defun pr-interactive-n-up (mess)
5390 (or (stringp mess) (setq mess "*"))
5392 (let* ((fmt-prompt "%s[%s] N-up printing: (default 1) ")
5394 (str (pr-f-read-string (format fmt-prompt prompt mess) "1" nil "1"))
5396 (while (if (string-match "^\\s *[0-9]+$" str)
5397 (setq int (string-to-int str)
5398 prompt (cond ((< int 1) "Integer below 1; ")
5399 ((> int 100) "Integer above 100; ")
5401 (setq prompt "Invalid integer syntax; "))
5404 (pr-f-read-string (format fmt-prompt prompt mess) str nil "1")))
5408 (defun pr-interactive-dir (mess)
5409 (let* ((dir-name (file-name-directory (or (buffer-file-name)
5410 default-directory)))
5411 (fmt-prompt (concat "%s[" mess "] Directory to print: "))
5412 (dir (read-file-name (format fmt-prompt "")
5413 "" dir-name nil dir-name))
5415 (while (cond ((not (file-directory-p dir))
5417 (setq prompt "It's not a directory! "))
5418 ((not (file-readable-p dir))
5420 (setq prompt "Directory is unreadable! "))
5422 (setq dir-name (file-name-directory dir)
5423 dir (read-file-name (format fmt-prompt prompt)
5424 "" dir-name nil dir-name)))
5425 (file-name-as-directory dir)))
5428 (defun pr-interactive-regexp (mess)
5429 (pr-f-read-string (format "[%s] File regexp to print: " mess) "" nil ""))
5432 (defun pr-interactive-dir-args (mess)
5434 ;; get directory argument
5435 (pr-interactive-dir mess)
5436 ;; get file name regexp
5437 (pr-interactive-regexp mess)))
5440 (defun pr-interactive-ps-dir-args (mess)
5442 ;; get n-up argument
5443 (pr-interactive-n-up mess)
5444 ;; get directory argument
5445 (pr-interactive-dir mess)
5446 ;; get file name regexp
5447 (pr-interactive-regexp mess)
5448 ;; get output file name
5449 (and (not pr-spool-p)
5450 (ps-print-preprint current-prefix-arg))))
5453 (defun pr-interactive-n-up-file (mess)
5455 ;; get n-up argument
5456 (pr-interactive-n-up mess)
5457 ;; get output file name
5458 (and (not pr-spool-p)
5459 (ps-print-preprint current-prefix-arg))))
5462 (defun pr-interactive-n-up-inout (mess)
5464 ;; get n-up argument
5465 (pr-interactive-n-up mess)
5466 ;; get input file name
5467 (pr-ps-infile-preprint (concat mess " "))
5468 ;; get output file name
5469 (ps-print-preprint current-prefix-arg)))
5472 (defun pr-set-outfilename (filename-sym)
5473 (and (not pr-spool-p)
5474 (eq (symbol-value filename-sym) t)
5475 (set filename-sym (and (not (interactive-p))
5477 (ps-print-preprint current-prefix-arg))))
5478 (and (symbol-value filename-sym)
5479 (set filename-sym (pr-dosify-file-name (symbol-value filename-sym)))))
5482 (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess)
5484 (or (symbol-value n-up-sym)
5485 (set n-up-sym (pr-interactive-n-up mess)))
5487 (pr-set-outfilename filename-sym))
5490 (defun pr-set-dir-args (dir-sym regexp-sym mess)
5492 (or (symbol-value dir-sym)
5493 (set dir-sym (pr-interactive-dir mess)))
5495 (or (symbol-value regexp-sym)
5496 (set regexp-sym (pr-interactive-regexp mess))))
5499 (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess)
5501 (or (symbol-value n-up-sym)
5502 (set n-up-sym (pr-interactive-n-up mess)))
5503 ;; directory & file name regexp
5504 (pr-set-dir-args dir-sym regexp-sym mess)
5506 (pr-set-outfilename filename-sym))
5509 (defun pr-find-buffer-visiting (file)
5510 (if (not (file-directory-p file))
5511 (find-buffer-visiting (if ps-windows-system
5514 (let ((truename (file-truename file))
5515 (blist (buffer-list))
5517 (while (and (not found) blist)
5519 (set-buffer (car blist))
5520 (and (eq major-mode 'dired-mode)
5522 (goto-char (point-min))
5523 (string= (buffer-substring-no-properties
5529 (setq found (car blist))))
5530 (setq blist (cdr blist)))
5534 (defun pr-file-list (dir file-regexp fun)
5535 (mapcar #'(lambda (file)
5536 (and (or pr-list-directory
5537 (not (file-directory-p file)))
5538 (let ((buffer (pr-find-buffer-visiting file))
5542 (file-readable-p file))
5544 (set-buffer (or buffer
5545 (find-file-noselect file)))
5548 (kill-buffer (current-buffer))))))))
5549 (directory-files dir t file-regexp)))
5552 (defun pr-delete-file-if-exists (filename)
5553 (and (not pr-spool-p) (stringp filename) (file-exists-p filename)
5554 (delete-file filename)))
5557 (defun pr-ps-file-list (n-up dir file-regexp filename)
5558 (pr-delete-file-if-exists (setq filename (pr-expand-file-name filename)))
5559 (let ((pr-spool-p t))
5560 (pr-file-list dir file-regexp
5562 (if (pr-auto-mode-p)
5563 (pr-ps-mode n-up filename)
5564 (pr-text2ps 'buffer n-up filename)))))
5566 (pr-despool-print filename)))
5569 (defun pr-text2ps (kind n-up filename &optional from to)
5570 (let ((ps-n-up-printing n-up)
5571 (ps-spool-config (and (eq ps-spool-config 'setpagedevice)
5573 (pr-delete-file-if-exists filename)
5576 ;; pr-faces-p and pr-spool-p
5577 ;; here FILENAME arg is ignored
5578 (cond ((eq kind 'buffer)
5579 (ps-spool-buffer-with-faces))
5581 (ps-spool-region-with-faces (or from (point))
5584 ;; pr-faces-p and not pr-spool-p
5586 (ps-print-buffer-with-faces filename))
5588 (ps-print-region-with-faces (or from (point))
5589 (or to (mark)) filename))
5592 ;; not pr-faces-p and pr-spool-p
5593 ;; here FILENAME arg is ignored
5594 (cond ((eq kind 'buffer)
5597 (ps-spool-region (or from (point)) (or to (mark))))
5599 ;; not pr-faces-p and not pr-spool-p
5601 (ps-print-buffer filename))
5603 (ps-print-region (or from (point)) (or to (mark)) filename))
5607 (defun pr-command (command)
5608 "Return absolute file name specification for COMMAND.
5610 If COMMAND is an empty string, return it.
5612 If COMMAND is already an absolute file name specification, return it.
5613 Else it uses `pr-path-alist' to find COMMAND, if find it then return it;
5614 otherwise, gives an error.
5616 When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and
5617 `unix' are used (see `pr-path-alist' for documentation).
5619 If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND,
5620 COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
5621 (if (string= command "")
5623 (pr-dosify-file-name
5624 (or (pr-find-command command)
5625 (pr-path-command (cond (pr-cygwin-system 'cygwin)
5626 (ps-windows-system 'windows)
5628 (file-name-nondirectory command)
5630 (error "Command not found: %s"
5631 (file-name-nondirectory command))))))
5634 (defun pr-path-command (symbol command sym-list)
5635 (let ((lpath (cdr (assq symbol pr-path-alist)))
5638 (and (eq symbol 'PATH) (null lpath)
5639 (setq lpath (parse-colon-path (getenv "PATH"))))
5643 (let ((path (car lpath)))
5647 (and (not (memq path sym-list))
5648 (pr-path-command path command
5649 (cons path sym-list))))
5654 (substitute-in-file-name
5655 (concat (file-name-as-directory path)
5658 (setq lpath (cdr lpath)))
5662 (defun pr-find-command (cmd)
5663 (if ps-windows-system
5665 (let ((ext (cons (file-name-extension cmd t)
5666 (list ".exe" ".bat" ".com")))
5668 (setq cmd (file-name-sans-extension cmd))
5670 (setq found (concat cmd (car ext)))
5671 (not (and (file-regular-p found)
5672 (file-executable-p found))))
5676 ;; non-windows systems
5677 (and (file-regular-p cmd)
5678 (file-executable-p cmd)
5682 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5683 ;; Printing Interface (inspired on ps-print-interface.el)
5691 (defvar pr-i-window-configuration nil)
5693 (defvar pr-i-buffer nil)
5694 (defvar pr-i-region nil)
5695 (defvar pr-i-mode nil)
5696 (defvar pr-i-despool nil)
5697 (defvar pr-i-ps-as-is t)
5698 (defvar pr-i-n-up 1)
5699 (defvar pr-i-directory "./")
5700 (defvar pr-i-regexp "")
5701 (defvar pr-i-ps-file "")
5702 (defvar pr-i-out-file "")
5703 (defvar pr-i-answer-yes nil)
5704 (defvar pr-i-process 'buffer)
5705 (defvar pr-i-ps-send 'printer)
5708 (defvar pr-interface-map nil
5709 "Keymap for pr-interface.")
5711 (if pr-interface-map
5713 (setq pr-interface-map (make-sparse-keymap))
5714 (cond ((eq ps-print-emacs-type 'xemacs) ; XEmacs
5715 (pr-f-set-keymap-parents pr-interface-map (list widget-keymap))
5716 (pr-f-set-keymap-name pr-interface-map 'pr-interface-map))
5717 ((eq ps-print-emacs-type 'emacs) ; GNU Emacs
5718 (pr-f-set-keymap-parents pr-interface-map widget-keymap)))
5719 (define-key pr-interface-map "q" 'pr-interface-quit)
5720 (define-key pr-interface-map "?" 'pr-interface-help))
5723 (defmacro pr-interface-save (&rest body)
5725 (set-buffer pr-i-buffer)
5729 (defun pr-create-interface ()
5730 "Create the front end for printing package."
5731 (setq pr-i-buffer (buffer-name (current-buffer))
5732 pr-i-region (ps-mark-active-p)
5733 pr-i-mode (pr-mode-alist-p)
5734 pr-i-window-configuration (current-window-configuration))
5736 (put 'pr-i-process 'pr-widget-list nil)
5737 (put 'pr-i-ps-send 'pr-widget-list nil)
5739 (delete-other-windows)
5740 (kill-buffer (get-buffer-create pr-buffer-name))
5741 (switch-to-buffer (get-buffer-create pr-buffer-name))
5744 (let ((versions (concat "printing v" pr-version
5745 " ps-print v" ps-print-version)))
5746 (widget-insert (make-string (- 79 (length versions)) ?\ ) versions))
5747 (pr-insert-italic "\nCurrent Directory : " 1)
5748 (pr-insert-italic default-directory)
5750 (pr-insert-section-1) ; 1. Print
5751 (pr-insert-section-2) ; 2. PostScript Printer
5752 (pr-insert-section-3) ; 3. Text Printer
5755 (widget-insert "\n\n " (make-string 77 ?-))
5757 (pr-insert-section-4) ; 4. Settings
5758 (pr-insert-section-5) ; 5. Customize
5759 (pr-insert-section-6) ; 6. Show Settings
5760 (pr-insert-section-7) ; 7. Help
5762 (use-local-map pr-interface-map)
5764 (goto-char (point-min))
5766 (and pr-i-region ; let region activated
5767 (pr-keep-region-active)))
5770 (defun pr-insert-section-1 ()
5772 (pr-insert-italic "\nPrint :" 1)
5775 ;; 1a. Buffer: Buffer List
5776 (pr-insert-radio-button 'pr-i-process 'buffer)
5777 (pr-insert-menu "Buffer List" 'pr-i-buffer
5778 (let ((blist (buffer-list))
5779 case-fold-search choices)
5781 (let ((name (buffer-name (car blist)))
5782 (ignore pr-buffer-name-ignore)
5784 (setq blist (cdr blist))
5785 (while (and ignore (not found))
5786 (setq found (string-match (car ignore) name)
5787 ignore (cdr ignore)))
5799 (setq pr-i-region (ps-mark-active-p)
5800 pr-i-mode (pr-mode-alist-p)))
5801 (pr-update-checkbox 'pr-i-region)
5802 (pr-update-checkbox 'pr-i-mode)))
5803 ;; 1a. Buffer: Region
5804 (put 'pr-i-region 'pr-widget
5808 #'(lambda (widget &rest ignore)
5809 (let ((region-p (pr-interface-save
5810 (ps-mark-active-p))))
5811 (cond ((null (widget-value widget)) ; widget is nil
5812 (setq pr-i-region nil))
5813 (region-p ; widget is true and there is a region
5814 (setq pr-i-region t)
5815 (widget-value-set widget t)
5816 (widget-setup)) ; MUST be called after widget-value-set
5817 (t ; widget is true and there is no region
5819 (message "There is no region active")
5820 (setq pr-i-region nil)
5821 (widget-value-set widget nil)
5822 (widget-setup))))) ; MUST be called after widget-value-set
5825 (put 'pr-i-mode 'pr-widget
5829 #'(lambda (widget &rest ignore)
5830 (let ((mode-p (pr-interface-save
5831 (pr-mode-alist-p))))
5833 ((null (widget-value widget)) ; widget is nil
5834 (setq pr-i-mode nil))
5835 (mode-p ; widget is true and there is a `mode'
5837 (widget-value-set widget t)
5838 (widget-setup)) ; MUST be called after widget-value-set
5839 (t ; widget is true and there is no `mode'
5842 "This buffer isn't in a mode that printing treats specially.")
5843 (setq pr-i-mode nil)
5844 (widget-value-set widget nil)
5845 (widget-setup))))) ; MUST be called after widget-value-set
5849 (pr-insert-radio-button 'pr-i-process 'directory)
5853 :format " Directory : %v"
5854 :notify 'pr-interface-directory
5855 :action (lambda (widget &optional event)
5856 (if (pr-interface-directory widget)
5857 (pr-widget-field-action widget event)
5859 (message "Please specify a readable directory")))
5861 ;; 1b. Directory: File Regexp
5862 (widget-create 'regexp
5864 :format "\n File Regexp : %v\n"
5865 :notify (lambda (widget &rest ignore)
5866 (setq pr-i-regexp (widget-value widget)))
5868 ;; 1b. Directory: List Directory Entry
5870 (pr-insert-toggle 'pr-list-directory " List Directory Entry\n")
5872 ;; 1c. PostScript File:
5873 (pr-insert-radio-button 'pr-i-process 'file)
5877 :format " PostScript File : %v"
5878 :notify 'pr-interface-infile
5879 :action (lambda (widget &rest event)
5880 (if (pr-interface-infile widget)
5881 (pr-widget-field-action widget event)
5883 (message "Please specify a readable PostScript file")))
5885 ;; 1c. PostScript File: PostScript Utility
5886 (pr-insert-menu "PostScript Utility" 'pr-ps-utility
5887 (pr-choice-alist pr-ps-utility-alist)
5888 "\n PostScript Utility : "
5890 ;; 1c. PostScript File: No Preprocessing
5891 (pr-insert-toggle 'pr-i-ps-as-is " No Preprocessing"))
5894 (defun pr-insert-section-2 ()
5895 ;; 2. PostScript Printer:
5896 ;; 2. PostScript Printer: PostScript Printer List
5897 (pr-insert-italic "\n\nPostScript Printer : " 2 20)
5898 (pr-insert-menu "PostScript Printer" 'pr-ps-name
5899 (pr-choice-alist pr-ps-printer-alist))
5900 ;; 2. PostScript Printer: Despool
5901 (put 'pr-i-despool 'pr-widget
5905 #'(lambda (widget &rest ignore)
5907 (setq pr-i-despool (not pr-i-despool))
5909 (message "Can despool only when spooling is actually selected")
5910 (setq pr-i-despool nil))
5911 (widget-value-set widget pr-i-despool)
5912 (widget-setup)) ; MUST be called after widget-value-set
5914 ;; 2. PostScript Printer: Preview Print Quit
5915 (pr-insert-button 'pr-interface-preview "Preview" " ")
5916 (pr-insert-button 'pr-interface-ps-print "Print" " ")
5917 (pr-insert-button 'pr-interface-quit "Quit")
5918 ;; 2. PostScript Printer: Send to Printer/Temporary File
5919 (pr-insert-radio-button 'pr-i-ps-send 'printer)
5920 (widget-insert " Send to Printer/Temporary File")
5921 ;; 2. PostScript Printer: Send to File
5922 (pr-insert-radio-button 'pr-i-ps-send 'file)
5926 :format " Send to File : %v"
5927 :notify 'pr-interface-outfile
5928 :action (lambda (widget &rest event)
5929 (if (and (pr-interface-outfile widget)
5930 (or (not (file-exists-p pr-i-out-file))
5931 (setq pr-i-answer-yes
5932 (y-or-n-p "File exists; overwrite? "))))
5933 (pr-widget-field-action widget event)
5935 (message "Please specify a writable PostScript file")))
5937 ;; 2. PostScript Printer: N-Up
5941 :format "\n N-Up : %v"
5942 :notify (lambda (widget &rest ignore)
5943 (let ((value (if (string= (widget-apply widget :value-get) "")
5945 (widget-value widget))))
5946 (if (and (integerp value)
5947 (<= 1 value) (<= value 100))
5950 (setq pr-i-n-up value))
5952 (message "Please specify an integer between 1 and 100"))))
5956 (defun pr-insert-section-3 ()
5958 (pr-insert-italic "\n\nText Printer : " 2 14)
5959 (pr-insert-menu "Text Printer" 'pr-txt-name
5960 (pr-choice-alist pr-txt-printer-alist)
5962 (pr-insert-button 'pr-interface-printify "Printify" " ")
5963 (pr-insert-button 'pr-interface-txt-print "Print" " ")
5964 (pr-insert-button 'pr-interface-quit "Quit"))
5967 (defun pr-insert-section-4 ()
5969 ;; 4. Settings: Landscape Auto Region Verbose
5970 (pr-insert-checkbox "\n\n " 'ps-landscape-mode
5971 #'(lambda (&rest ignore)
5972 (setq ps-landscape-mode (not ps-landscape-mode)
5973 pr-file-landscape ps-landscape-mode))
5975 (pr-insert-toggle 'pr-auto-region " Auto Region ")
5976 (pr-insert-toggle 'pr-buffer-verbose " Verbose\n ")
5978 ;; 4. Settings: Print Header Auto Mode
5979 (pr-insert-toggle 'ps-print-header " Print Header ")
5980 (pr-insert-toggle 'pr-auto-mode " Auto Mode\n ")
5982 ;; 4. Settings: Print Header Frame Menu Lock
5983 (pr-insert-toggle 'ps-print-header-frame " Print Header Frame ")
5984 (pr-insert-toggle 'pr-menu-lock " Menu Lock\n ")
5986 ;; 4. Settings: Line Number
5987 (pr-insert-toggle 'ps-line-number " Line Number\n ")
5989 ;; 4. Settings: Zebra Stripes Spool Buffer
5990 (pr-insert-toggle 'ps-zebra-stripes " Zebra Stripes")
5991 (pr-insert-checkbox " "
5993 #'(lambda (&rest ignore)
5994 (setq pr-spool-p (not pr-spool-p))
5996 (setq pr-i-despool nil)
5997 (pr-update-checkbox 'pr-i-despool)))
6000 ;; 4. Settings: Duplex Print with faces
6001 (pr-insert-checkbox "\n "
6003 #'(lambda (&rest ignore)
6004 (setq ps-spool-duplex (not ps-spool-duplex)
6005 pr-file-duplex ps-spool-duplex))
6007 (pr-insert-toggle 'pr-faces-p " Print with faces")
6009 ;; 4. Settings: Tumble Print via Ghostscript
6010 (pr-insert-checkbox "\n "
6012 #'(lambda (&rest ignore)
6013 (setq ps-spool-tumble (not ps-spool-tumble)
6014 pr-file-tumble ps-spool-tumble))
6016 (pr-insert-toggle 'pr-print-using-ghostscript " Print via Ghostscript\n ")
6018 ;; 4. Settings: Upside-Down Page Parity
6019 (pr-insert-toggle 'ps-print-upside-down " Upside-Down")
6020 (pr-insert-italic "\n\nSelect Pages : " 2 14)
6021 (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages
6022 (mapcar #'(lambda (alist)
6027 :value (car alist))))
6028 pr-even-or-odd-alist)))
6031 (defun pr-insert-section-5 ()
6033 (pr-insert-italic "\n\nCustomize : " 2 11)
6034 (pr-insert-button 'pr-customize "printing" " ")
6035 (pr-insert-button #'(lambda (&rest ignore) (ps-print-customize))
6037 (pr-insert-button 'lpr-customize "lpr"))
6040 (defun pr-insert-section-6 ()
6041 ;; 6. Show Settings:
6042 (pr-insert-italic "\nShow Settings : " 1 14)
6043 (pr-insert-button 'pr-show-pr-setup "printing" " ")
6044 (pr-insert-button 'pr-show-ps-setup "ps-print" " ")
6045 (pr-insert-button 'pr-show-lpr-setup "lpr"))
6048 (defun pr-insert-section-7 ()
6050 (pr-insert-italic "\nHelp : " 1 5)
6051 (pr-insert-button 'pr-interface-help "Interface Help" " ")
6052 (pr-insert-button 'pr-help "Menu Help" " ")
6053 (pr-insert-button 'pr-interface-quit "Quit" "\n ")
6054 (pr-insert-button 'pr-kill-help "Kill All Printing Help Buffer"))
6057 (defun pr-kill-help (&rest ignore)
6058 "Kill all printing help buffer."
6060 (let ((help '("*Printing Interface Help*" "*Printing Help*"
6061 "*LPR Setup*" "*PR Setup*" "*PS Setup*")))
6063 (let ((buffer (get-buffer (car help))))
6064 (setq help (cdr help))
6066 (delete-windows-on buffer)
6067 (kill-buffer buffer)))))
6068 (recenter (- (window-height) 2)))
6071 (defun pr-interface-quit (&rest ignore)
6072 "Kill the printing buffer interface and quit."
6074 (kill-buffer pr-buffer-name)
6075 (set-window-configuration pr-i-window-configuration))
6078 (defun pr-interface-help (&rest ignore)
6079 "printing buffer interface help."
6081 (pr-show-setup pr-interface-help-message "*Printing Interface Help*"))
6084 (defun pr-interface-txt-print (&rest ignore)
6085 "Print using lpr package."
6087 (condition-case data
6089 ((eq pr-i-process 'directory)
6092 (pr-txt-directory pr-i-directory pr-i-regexp)))
6093 ((eq pr-i-process 'buffer)
6096 (let ((pr-auto-mode pr-i-mode))
6099 (let (pr-auto-region)
6102 (let (pr-auto-mode pr-auto-region)
6105 ((eq pr-i-process 'file)
6106 (error "Please specify a text file"))
6108 (error "Internal error: `pr-i-process' = %S" pr-i-process))
6113 (message (error-message-string data)))))
6116 (defun pr-interface-printify (&rest ignore)
6117 "Printify a buffer."
6119 (condition-case data
6121 ((eq pr-i-process 'directory)
6124 (pr-printify-directory pr-i-directory pr-i-regexp)))
6125 ((eq pr-i-process 'buffer)
6128 (pr-printify-region)
6129 (pr-printify-buffer))))
6130 ((eq pr-i-process 'file)
6131 (error "Cannot printify a PostScript file"))
6133 (error "Internal error: `pr-i-process' = %S" pr-i-process))
6138 (message (error-message-string data)))))
6141 (defun pr-interface-ps-print (&rest ignore)
6142 "Print using ps-print package."
6144 (pr-interface-ps 'pr-despool-ps-print 'pr-ps-directory-ps-print
6145 'pr-ps-file-ps-print 'pr-ps-file-up-ps-print
6146 'pr-ps-region-ps-print 'pr-ps-mode-ps-print
6147 'pr-ps-buffer-ps-print))
6150 (defun pr-interface-preview (&rest ignore)
6151 "Preview a PostScript file."
6153 (pr-interface-ps 'pr-despool-preview 'pr-ps-directory-preview
6154 'pr-ps-file-preview 'pr-ps-file-up-preview
6155 'pr-ps-region-preview 'pr-ps-mode-preview
6156 'pr-ps-buffer-preview))
6159 (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region
6161 (condition-case data
6162 (let ((outfile (or (and (eq pr-i-process 'file) pr-i-ps-as-is)
6165 ((and pr-i-despool pr-spool-p)
6167 (funcall ps-despool outfile))
6168 (setq pr-i-despool nil)
6169 (pr-update-checkbox 'pr-i-despool))
6170 ((eq pr-i-process 'directory)
6173 (funcall ps-directory
6174 pr-i-n-up pr-i-directory pr-i-regexp outfile)))
6175 ((eq pr-i-process 'file)
6176 (cond ((or (file-directory-p pr-i-ps-file)
6177 (not (file-readable-p pr-i-ps-file)))
6178 (error "Please specify a readable PostScript file"))
6181 (funcall ps-file pr-i-ps-file)))
6184 (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile)))
6186 ((eq pr-i-process 'buffer)
6189 (let ((pr-auto-mode pr-i-mode))
6190 (funcall ps-region pr-i-n-up outfile)))
6192 (let (pr-auto-region)
6193 (funcall ps-mode pr-i-n-up outfile)))
6195 (let (pr-auto-mode pr-auto-region)
6196 (funcall ps-buffer pr-i-n-up outfile)))
6199 (error "Internal error: `pr-i-process' = %S" pr-i-process))
6204 (message (error-message-string data)))))
6207 (defun pr-i-ps-send ()
6208 (cond ((eq pr-i-ps-send 'printer)
6210 ((not (eq pr-i-ps-send 'file))
6211 (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send))
6212 ((or (file-directory-p pr-i-out-file)
6213 (not (file-writable-p pr-i-out-file)))
6214 (error "Please specify a writable PostScript file"))
6215 ((or (not (file-exists-p pr-i-out-file))
6217 (setq pr-i-answer-yes
6218 (y-or-n-p (format "File `%s' exists; overwrite? "
6222 (error "File already exists"))))
6225 (defun pr-i-directory ()
6226 (or (and (file-directory-p pr-i-directory)
6227 (file-readable-p pr-i-directory))
6228 (error "Please specify be a readable directory")))
6231 (defun pr-interface-directory (widget &rest ignore)
6232 (and pr-buffer-verbose
6233 (message "You can use M-TAB or ESC TAB for file completion"))
6234 (let ((dir (widget-value widget)))
6235 (and (file-directory-p dir)
6236 (file-readable-p dir)
6237 (setq pr-i-directory dir))))
6240 (defun pr-interface-infile (widget &rest ignore)
6241 (and pr-buffer-verbose
6242 (message "You can use M-TAB or ESC TAB for file completion"))
6243 (let ((file (widget-value widget)))
6244 (and (not (file-directory-p file))
6245 (file-readable-p file)
6246 (setq pr-i-ps-file file))))
6249 (defun pr-interface-outfile (widget &rest ignore)
6250 (setq pr-i-answer-yes nil)
6251 (and pr-buffer-verbose
6252 (message "You can use M-TAB or ESC TAB for file completion"))
6253 (let ((file (widget-value widget)))
6254 (and (not (file-directory-p file))
6255 (file-writable-p file)
6256 (setq pr-i-out-file file))))
6259 (defun pr-widget-field-action (widget event)
6260 (and (get-buffer "*Completions*") ; clean frame window
6261 (delete-windows-on "*Completions*"))
6262 (message " ") ; clean echo area
6263 (widget-field-action widget event))
6266 (defun pr-insert-italic (str &optional from to)
6267 (let ((len (length str)))
6268 (put-text-property (if from (max from 0) 0)
6269 (if to (max to len) len)
6271 (widget-insert str)))
6274 (defun pr-insert-checkbox (before var-sym fun label)
6275 (widget-insert before)
6277 (widget-create 'checkbox
6279 (symbol-value var-sym))
6280 (widget-insert label)))
6283 (defun pr-insert-toggle (var-sym label)
6284 (widget-create 'checkbox
6285 :notify `(lambda (&rest ignore)
6286 (setq ,var-sym (not ,var-sym)))
6287 (symbol-value var-sym))
6288 (widget-insert label))
6291 (defun pr-insert-button (fun label &optional separator)
6292 (widget-create 'push-button
6296 (widget-insert separator)))
6299 (defun pr-insert-menu (tag var-sym choices &optional before after &rest body)
6300 (and before (widget-insert before))
6301 (eval `(widget-create 'menu-choice
6306 :notify (lambda (widget &rest ignore)
6307 (setq ,var-sym (widget-value widget))
6309 :void '(choice-item :format "%[%t%]"
6310 :tag "Can not display value!")
6312 (and after (widget-insert after)))
6315 (defun pr-insert-radio-button (var-sym sym)
6316 (widget-insert "\n")
6317 (let ((wid-list (get var-sym 'pr-widget-list))
6318 (wid (eval `(widget-create
6321 :value (eq ,var-sym (quote ,sym))
6322 :notify (lambda (&rest ignore)
6323 (setq ,var-sym (quote ,sym))
6324 (pr-update-radio-button (quote ,var-sym)))))))
6325 (put var-sym 'pr-widget-list (cons (cons wid sym) wid-list))))
6328 (defun pr-update-radio-button (var-sym)
6329 (let ((wid-list (get var-sym 'pr-widget-list)))
6331 (let ((wid (car (car wid-list)))
6332 (value (cdr (car wid-list))))
6333 (setq wid-list (cdr wid-list))
6334 (widget-value-set wid (eq (symbol-value var-sym) value))))
6338 (defun pr-update-checkbox (var-sym)
6339 (let ((wid (get var-sym 'pr-widget)))
6341 (widget-value-set wid (symbol-value var-sym))
6345 (defun pr-choice-alist (alist)
6346 (let ((max (apply 'max (mapcar #'(lambda (alist)
6347 (length (symbol-name (car alist))))
6349 (mapcar #'(lambda (alist)
6350 (let* ((sym (car alist))
6351 (name (symbol-name sym)))
6358 (make-string (- max (length name)) ?_))
6363 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6372 ;;; arch-tag: 9ce9ac3f-0f60-4370-900b-1943215d9d18
6373 ;;; printing.el ends here