1 ;;; printing.el --- printing utilities
3 ;; Copyright (C) 2000-2001, 2003-2013 Free Software Foundation, Inc.
5 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7 ;; Keywords: wp, print, PostScript
9 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
11 (defconst pr-version
"6.9.3"
12 "printing.el, v 6.9.3 <2007/12/09 vinicius>
14 Please send all bug fixes and enhancements to
15 Vinicius Jose Latorre <viniciusjl@ig.com.br>
18 ;; This file is part of GNU Emacs.
20 ;; GNU Emacs is free software: you can redistribute it and/or modify
21 ;; it under the terms of the GNU General Public License as published by
22 ;; the Free Software Foundation, either version 3 of the License, or
23 ;; (at your option) any later version.
25 ;; GNU Emacs is distributed in the hope that it will be useful,
26 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
27 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ;; GNU General Public License for more details.
30 ;; You should have received a copy of the GNU General Public License
31 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
35 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;; With `printing' you can preview or print a PostScript file. You can also
41 ;; print a text file using PostScript, and preview or print buffers that use
42 ;; certain special modes like mh-folder-mode, rmail-summary-mode,
43 ;; gnus-summary-mode, etc. This package also includes a PostScript/text
46 ;; There are two user interfaces:
49 ;; The `printing' menu replaces the usual print options in the menu bar.
50 ;; This is the default user interface.
52 ;; * Buffer interface:
53 ;; You can use a buffer interface instead of menus. It looks like a
54 ;; customization buffer. Basically, it has the same options found in the
55 ;; menu and some extra options, all this on a buffer.
57 ;; `printing' is prepared to run on GNU, Unix and NT systems.
58 ;; On GNU or Unix system, `printing' depends on gs and gv utilities.
59 ;; On NT system, `printing' depends on gstools (gswin32.exe and gsview32.exe).
60 ;; To obtain ghostscript, ghostview and GSview see the URL
61 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'.
63 ;; `printing' depends on ps-print package to generate PostScript files, to
64 ;; spool and to despool PostScript buffer. So, `printing' provides an
65 ;; interface to ps-print package and it also provides some extra stuff.
67 ;; To download the latest ps-print package see
68 ;; `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'.
69 ;; Please, see README file for ps-print installation instructions.
71 ;; `printing' was inspired by:
73 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr>
74 ;; Special printing functions for Windows NT
76 ;; mh-e-init.el Tom Vogels <tov@ece.cmu.edu>
77 ;; PS-print for mail messages
79 ;; win32-ps-print.el Matthew O. Persico <mpersico@erols.com>
80 ;; PostScript printing with ghostscript
82 ;; ps-print-interface.el Volker Franz <volker.franz@tuebingen.mpg.de>
83 ;; Graphical front end for ps-print and previewing
89 ;; The buffer *Printing Command Output* is where the `printing' log messages
90 ;; are inserted. All program called by `printing' has a log entry in the
91 ;; buffer *Printing Command Output*. A log entry has the following form:
98 ;; PROGRAM is the program activated by `printing',
99 ;; ARG is an argument passed to PROGRAM (it can have more than one argument),
100 ;; MESSAGE is an error message returned by PROGRAM (it can have no message, if
101 ;; PROGRAM is successful),
102 ;; and CODE is a numeric exit status or a signal description string.
104 ;; For example, after previewing a PostScript file, *Printing Command Output*
105 ;; will have the following entry:
107 ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps")
110 ;; In the example above, the previewing was successful. If during previewing,
111 ;; you quit gv execution (by typing C-g during Emacs session), the log entry
114 ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps")
117 ;; So, if something goes wrong, a good place to take a look is the buffer
118 ;; *Printing Command Output*. Don't forget to see also the buffer *Messages*,
122 ;; Novices (First Users)
123 ;; ---------------------
125 ;; First of all, see printing documentation only to get an idea of what
126 ;; `printing' is capable.
128 ;; Then try to set the variables: `pr-ps-name', `pr-ps-printer-alist',
129 ;; `pr-txt-name', `pr-txt-printer-alist' and `pr-path-alist'. These variables
130 ;; are the main variables for printing processing.
132 ;; Now, please, see these variables documentation deeper. You can do this by
133 ;; typing C-h v pr-ps-name RET (for example) if you already loaded printing
134 ;; package, or by browsing printing.el source file.
136 ;; If the documentation isn't clear or if you find a way to improve the
137 ;; documentation, please, send an email to maintainer. All printing users
140 ;; One way to set variables is by calling `pr-customize', customize all
141 ;; variables and save the customization by future sessions (see Options
142 ;; section). Other way is by adding code to your init file; see below
143 ;; for a first setting template that it should be inserted on your
146 ;; * Example of setting for Windows system:
148 ;; (require 'printing) ; load printing package
149 ;; (setq pr-path-alist
150 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
151 ;; (ghostview "c:/gs/gsview-dir")
152 ;; (mpage "c:/mpage-dir")
154 ;; (setq pr-txt-name 'prt_06a)
155 ;; (setq pr-txt-printer-alist
156 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
157 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
158 ;; (PRN "" nil "PRN")
159 ;; (standard "redpr.exe" nil "")
161 ;; (setq pr-ps-name 'lps_06b)
162 ;; (setq pr-ps-printer-alist
163 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
164 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
165 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
166 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
167 ;; (LPT1 "" nil "" "LPT1:")
168 ;; (PRN "" nil "" "PRN")
169 ;; (standard "redpr.exe" nil "" "")
171 ;; (pr-update-menus t) ; update now printer and utility menus
173 ;; * Example of setting for GNU or Unix system:
175 ;; (require 'printing) ; load printing package
176 ;; (setq pr-path-alist
177 ;; '((unix "." "~/bin" ghostview mpage PATH)
178 ;; (ghostview "$HOME/bin/gsview-dir")
179 ;; (mpage "$HOME/bin/mpage-dir")
181 ;; (setq pr-txt-name 'prt_06a)
182 ;; (setq pr-txt-printer-alist
183 ;; '((prt_06a "lpr" nil "prt_06a")
184 ;; (prt_07c nil nil "prt_07c")
186 ;; (setq pr-ps-name 'lps_06b)
187 ;; (setq pr-ps-printer-alist
188 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
189 ;; (lps_07c "lpr" nil nil "lps_07c")
190 ;; (lps_08c nil nil nil "lps_08c")
192 ;; (pr-update-menus t) ; update now printer and utility menus
195 ;; NOTE 1: Don't forget to download and install ghostscript utilities (see
196 ;; Utilities section).
198 ;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be
199 ;; set, as they are implicit set by `pr-ps-printer-alist' and
200 ;; `pr-txt-printer-alist'.
202 ;; NOTE 3: The duplex feature will only work on PostScript printers that
203 ;; support this feature.
204 ;; You can check if your PostScript printer supports duplex feature
205 ;; by checking the printer manual. Or you can try these steps:
206 ;; 1. Open a buffer (or use the *scratch* buffer).
208 ;; First line (on first page)
210 ;; Second line (on second page)
211 ;; 3. Print this buffer with duplex turned on.
212 ;; If it's printed 2 (two) sheets of paper, then your PostScript
213 ;; printer doesn't have duplex feature; otherwise, it's ok, your
214 ;; printer does have duplex feature.
216 ;; NOTE 4: See Tips section.
222 ;; 1. If you have a local printer, that is, a printer which is connected
223 ;; directly to your computer, don't forget to connect the printer to your
224 ;; computer before printing.
226 ;; 2. If you try to print a file and it seems that the file was printed, but
227 ;; there is no paper in the printer, then try to set `pr-delete-temp-file'
228 ;; to nil. Probably `printing' is deleting the temporary file before your
229 ;; local system can get it to send to the printer.
231 ;; 3. Don't try to print a dynamic buffer, that is, a buffer which is
232 ;; modifying while `printing' tries to print. Eventually you got an error
233 ;; message. Instead, save the dynamic buffer to a file or copy it in
234 ;; another buffer and, then, print the file or the new static buffer.
235 ;; An example of dynamic buffer is the *Messages* buffer.
237 ;; 4. When running Emacs on Windows (with or without cygwin), check if your
238 ;; printer is a text printer or not by typing in a DOS window:
240 ;; print /D:\\host\printer somefile.txt
242 ;; Where, `host' is the machine where the printer is directly connected,
243 ;; `printer' is the printer name and `somefile.txt' is a text file.
245 ;; If the printer `\\host\printer' doesn't print the content of
246 ;; `somefile.txt' or, instead, it returns the following message:
248 ;; PostScript Error Handler
249 ;; Offending Command = CCC
252 ;; Where `CCC' is whatever is at the beginning of the text to be printed.
254 ;; Therefore, the printer `\\host\printer' is not a text printer, but a
255 ;; PostScript printer. So, please, don't include this printer in
256 ;; `pr-txt-printer-alist' (which see).
258 ;; 5. You can use gsprint instead of ghostscript to print monochrome PostScript
259 ;; files in Windows. The gsprint utility documentation says that it is more
260 ;; efficient than ghostscript to print monochrome PostScript.
262 ;; To print non-monochrome PostScript file, the efficiency of ghostscript
263 ;; is similar to gsprint.
265 ;; Also the gsprint utility comes together with gsview distribution.
267 ;; For more information about gsprint see
268 ;; `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'.
270 ;; As an example of gsprint declaration:
272 ;; (setq pr-ps-printer-alist
273 ;; '((A "gsprint" ("-all" "-twoup") "-printer " "my-b/w-printer-name")
274 ;; (B "gsprint" ("-all" "-twoup") nil "-printer my-b/w-printer-name")
275 ;; ;; some other printer declaration
278 ;; The example above declares that printer A prints all pages (-all) and two
279 ;; pages per sheet (-twoup). The printer B declaration does the same as the
280 ;; printer A declaration, the only difference is the printer name selection.
282 ;; There are other command line options like:
284 ;; -mono Render in monochrome as 1bit/pixel (only black and white).
285 ;; -grey Render in greyscale as 8bits/pixel.
286 ;; -color Render in color as 24bits/pixel.
288 ;; The default is `-mono'. So, printer A and B in the example above are
289 ;; using implicitly the `-mono' option. Note that in `-mono' no gray tone
290 ;; or color is printed, this includes the zebra stripes, that is, in `-mono'
291 ;; the zebra stripes are not printed.
293 ;; See also documentation for `pr-ps-printer-alist'.
299 ;; To use `printing' insert in your init file:
301 ;; (require 'printing)
302 ;; ;; ...some user settings...
303 ;; (pr-update-menus t)
305 ;; During `pr-update-menus' evaluation:
307 ;; it replaces the Tools/Print menu by Tools/Printing menu.
309 ;; it replaces the File/Print* menu entries by File/Print menu.
310 ;; Please, see section Menu Layout below for menu explanation.
312 ;; To use `printing' utilities you can use the Printing menu options, type M-x
313 ;; followed by one of the commands below, or type a key associated with the
314 ;; command you want (if there is a key binding).
316 ;; `printing' has the following commands:
319 ;; pr-ps-directory-preview
320 ;; pr-ps-directory-using-ghostscript
321 ;; pr-ps-directory-print
322 ;; pr-ps-directory-ps-print
323 ;; pr-ps-buffer-preview
324 ;; pr-ps-buffer-using-ghostscript
325 ;; pr-ps-buffer-print
326 ;; pr-ps-buffer-ps-print
327 ;; pr-ps-region-preview
328 ;; pr-ps-region-using-ghostscript
329 ;; pr-ps-region-print
330 ;; pr-ps-region-ps-print
331 ;; pr-ps-mode-preview
332 ;; pr-ps-mode-using-ghostscript
334 ;; pr-ps-mode-ps-print
335 ;; pr-ps-file-preview
336 ;; pr-ps-file-up-preview
337 ;; pr-ps-file-using-ghostscript
339 ;; pr-ps-file-ps-print
340 ;; pr-ps-file-up-ps-print
342 ;; pr-despool-preview
343 ;; pr-despool-using-ghostscript
345 ;; pr-despool-ps-print
346 ;; pr-printify-directory
347 ;; pr-printify-buffer
348 ;; pr-printify-region
354 ;; pr-toggle-file-duplex
355 ;; pr-toggle-file-tumble
356 ;; pr-toggle-file-landscape
357 ;; pr-toggle-ghostscript
362 ;; pr-toggle-landscape
363 ;; pr-toggle-upside-down
380 ;; The general meanings of above commands are:
383 ;; `pr-interface' buffer interface for printing package.
384 ;; `pr-help' help for printing package.
385 ;; `pr-ps-name' interactively select a PostScript printer.
386 ;; `pr-txt-name' interactively select a text printer.
387 ;; `pr-ps-utility' interactively select a PostScript utility.
388 ;; `pr-show-*-setup' show current settings.
389 ;; `pr-ps-*' deal with PostScript code generation.
390 ;; `pr-txt-*' deal with text generation.
391 ;; `pr-toggle-*' toggle on/off some boolean variable.
392 ;; `pr-despool-*' despool the PostScript spooling buffer.
393 ;; `pr-printify-*' replace nonprintable ASCII by printable ASCII
397 ;; `*-customize' customization.
398 ;; `*-preview' preview a PostScript file.
399 ;; `*-using-ghostscript' use ghostscript to print.
400 ;; `*-fast-fire' fast fire command (see it for documentation).
401 ;; `*-print' send PostScript directly to printer.
402 ;; `*-ps-print' send PostScript directly to printer or use
403 ;; ghostscript to print. It depends on
404 ;; `pr-print-using-ghostscript' option.
407 ;; `*-directory*' process a directory.
408 ;; `*-buffer*' process a buffer.
409 ;; `*-region*' process a region.
410 ;; `*-mode*' process a major mode (see explanation below).
411 ;; `*-file-*' process a PostScript file.
412 ;; `*-file-up-*' process a PostScript file using a filter utility.
414 ;; Here are some examples:
416 ;; `pr-ps-buffer-using-ghostscript'
417 ;; Use ghostscript to print a buffer.
419 ;; `pr-ps-file-print'
420 ;; Print a PostScript file.
423 ;; Toggle spooling buffer.
425 ;; So you can preview through ghostview, use ghostscript to print (if you don't
426 ;; have a PostScript printer) or send directly to printer a PostScript code
427 ;; generated by `ps-print' package.
429 ;; Besides operating one buffer or region each time, you also can postpone
430 ;; previewing or printing by saving the PostScript code generated in a
431 ;; temporary Emacs buffer. This way you can save banner pages between
432 ;; successive printing. You can toggle on/off spooling by invoking
433 ;; `pr-toggle-spool' interactively or through menu bar.
435 ;; If you type, for example:
437 ;; C-u M-x pr-ps-buffer-print RET
439 ;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and
440 ;; a file name, and save the PostScript code generated to the file name instead
441 ;; of sending to printer.
443 ;; This behavior is similar with the commands that deal with PostScript code
444 ;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If
445 ;; spooling is on, only `pr-despool-*' commands prompt for a file name and save
446 ;; the PostScript code spooled in this file.
448 ;; Besides the behavior described above, the `*-directory*' commands also
449 ;; prompt for a directory and a file name regexp. So, it's possible to process
450 ;; all or certain files on a directory at once (see also documentation for
451 ;; `pr-list-directory').
453 ;; `printing' has also a special way to handle some major mode through
454 ;; `*-mode*' commands. So it's possible to customize a major mode printing,
455 ;; it's only needed to declare the customization in `pr-mode-alist' (see
456 ;; section Options) and invoke some of `*-mode*' commands. An example for
457 ;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and
458 ;; you're in the *Summary* buffer, if you forget to switch to the *Article*
459 ;; buffer before printing, you'll get a nicely formatted list of article
460 ;; subjects shows up at the printer. With major mode printing you don't need
461 ;; to switch from gnus *Summary* buffer first.
463 ;; Current global keyboard mapping for GNU Emacs is:
465 ;; (global-set-key [print] 'pr-ps-fast-fire)
466 ;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
467 ;; (global-set-key [S-print] 'pr-ps-mode-using-ghostscript)
468 ;; (global-set-key [C-print] 'pr-txt-fast-fire)
469 ;; (global-set-key [C-M-print] 'pr-txt-fast-fire)
471 ;; And for XEmacs is:
473 ;; (global-set-key 'f22 'pr-ps-fast-fire)
474 ;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
475 ;; (global-set-key '(shift f22) 'pr-ps-mode-using-ghostscript)
476 ;; (global-set-key '(control f22) 'pr-txt-fast-fire)
477 ;; (global-set-key '(control meta f22) 'pr-txt-fast-fire)
479 ;; As a suggestion of global keyboard mapping for some `printing' commands:
481 ;; (global-set-key "\C-ci" 'pr-interface)
482 ;; (global-set-key "\C-cbp" 'pr-ps-buffer-print)
483 ;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview)
484 ;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
485 ;; (global-set-key "\C-crp" 'pr-ps-region-print)
486 ;; (global-set-key "\C-crx" 'pr-ps-region-preview)
487 ;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
493 ;; Below it's shown a brief description of `printing' options, please, see the
494 ;; options declaration in the code for a long documentation.
496 ;; `pr-path-style' Specify which path style to use for external
499 ;; `pr-path-alist' Specify an alist for command paths.
501 ;; `pr-txt-name' Specify a printer for printing a text file.
503 ;; `pr-txt-printer-alist' Specify an alist of all text printers.
505 ;; `pr-ps-name' Specify a printer for printing a PostScript
508 ;; `pr-ps-printer-alist' Specify an alist for all PostScript printers.
510 ;; `pr-temp-dir' Specify a directory for temporary files during
513 ;; `pr-ps-temp-file' Specify PostScript temporary file name prefix.
515 ;; `pr-file-modes' Specify the file permission bits for newly
518 ;; `pr-gv-command' Specify path and name of the gsview/gv
521 ;; `pr-gs-command' Specify path and name of the ghostscript
524 ;; `pr-gs-switches' Specify ghostscript switches.
526 ;; `pr-gs-device' Specify ghostscript device switch value.
528 ;; `pr-gs-resolution' Specify ghostscript resolution switch value.
530 ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript.
532 ;; `pr-faces-p' Non-nil means print with face attributes.
534 ;; `pr-spool-p' Non-nil means spool printing in a buffer.
536 ;; `pr-file-landscape' Non-nil means print PostScript file in
537 ;; landscape orientation.
539 ;; `pr-file-duplex' Non-nil means print PostScript file in duplex
542 ;; `pr-file-tumble' Non-nil means print PostScript file in tumble
545 ;; `pr-auto-region' Non-nil means region is automagically detected.
547 ;; `pr-auto-mode' Non-nil means major-mode specific printing is
548 ;; preferred over normal printing.
550 ;; `pr-mode-alist' Specify an alist for a major-mode and printing
553 ;; `pr-ps-utility' Specify PostScript utility processing.
555 ;; `pr-ps-utility-alist' Specify an alist for PostScript utility
558 ;; `pr-menu-lock' Non-nil means menu is locked while selecting
561 ;; `pr-menu-char-height' Specify menu char height in pixels.
563 ;; `pr-menu-char-width' Specify menu char width in pixels.
565 ;; `pr-setting-database' Specify an alist for settings in general.
567 ;; `pr-visible-entry-list' Specify a list of Printing menu visible
570 ;; `pr-delete-temp-file' Non-nil means delete temporary files.
572 ;; `pr-list-directory' Non-nil means list directory when processing a
575 ;; `pr-buffer-name' Specify the name of the buffer interface for
578 ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be
579 ;; ignored in interface buffer.
581 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a
582 ;; field in interface buffer.
584 ;; To set the above options you may:
586 ;; a) insert the code in your ~/.emacs, like:
588 ;; (setq pr-faces-p t)
590 ;; This way always keep your default settings when you enter a new Emacs
593 ;; b) or use `set-variable' in your Emacs session, like:
595 ;; M-x set-variable RET pr-faces-p RET t RET
597 ;; This way keep your settings only during the current Emacs session.
599 ;; c) or use customization, for example:
600 ;; click on menu-bar *Help* option,
601 ;; then click on *Customize*,
602 ;; then click on *Browse Customization Groups*,
603 ;; expand *PostScript* group,
604 ;; expand *Printing* group
605 ;; and then customize `printing' options.
606 ;; Through this way, you may choose if the settings are kept or not when
607 ;; you leave out the current Emacs session.
609 ;; d) or see the option value:
611 ;; C-h v pr-faces-p RET
613 ;; and click the *customize* hypertext button.
614 ;; Through this way, you may choose if the settings are kept or not when
615 ;; you leave out the current Emacs session.
619 ;; M-x pr-customize RET
621 ;; and then customize `printing' options.
622 ;; Through this way, you may choose if the settings are kept or not when
623 ;; you leave out the current Emacs session.
625 ;; f) or use menu bar, for example:
626 ;; click on menu-bar *File* option,
627 ;; then click on *Printing*,
628 ;; then click on *Customize*,
629 ;; then click on *printing*
630 ;; and then customize `printing' options.
631 ;; Through this way, you may choose if the settings are kept or not when
632 ;; you leave out the current Emacs session.
638 ;; The `printing' menu (Tools/Printing or File/Print) has the following layout:
640 ;; +-----------------------------+
641 ;; A 0 | Printing Interface |
642 ;; +-----------------------------+ +-A---------+ +-B------+
643 ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
644 ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
645 ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
646 ;; +-----------------------------+ |Mode >|-- B |Other...|
647 ;; II 4 | Printify >|-----\ |File >|--\ +--------+
648 ;; 5 | Print >|---\ | |Despool... | |
649 ;; 6 | Text Printer: name >|-\ | | +-----------+ |
650 ;; +-----------------------------+ | | | +---------+ +------------+
651 ;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia
652 ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
653 ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C
654 ;; 10 |[ ]Line Number | | | +---------+ +------------+
655 ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
656 ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... |
657 ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... |
658 ;; 14 |[ ]Upside-Down | | |Region | | Other... |
659 ;; 15 | Print All Pages >|--\ | |Mode | +------------+
660 ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id
661 ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
662 ;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If
663 ;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
664 ;; +-----------------------------+ | |... |
665 ;; V 19 |[ ]Auto Region | | |(*)name |
666 ;; 20 |[ ]Auto Mode | | |... |
667 ;; 21 |[ ]Menu Lock | | +---------+ +--------------+
668 ;; +-----------------------------+ \------------------|(*)All Pages |
669 ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
670 ;; 23 | Show Settings >|-------|printing| |( )Odd Pages |
671 ;; 24 | Help | |ps-print| |( )Even Sheets|
672 ;; +-----------------------------+ |lpr | |( )Odd Sheets |
673 ;; +--------+ +--------------+
675 ;; See `pr-visible-entry-list' for hiding some parts of the menu.
677 ;; The menu has the following sections:
681 ;; 0. You can use a buffer interface instead of menus. It looks like the
682 ;; customization buffer. Basically, it has the same options found in the
683 ;; menu and some extra options, all this on a buffer.
685 ;; I. PostScript printing:
687 ;; 1. You can generate a PostScript file (if you type C-u before activating
688 ;; menu) or PostScript temporary file for a directory, a buffer, a region
689 ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
690 ;; after file generation, ghostview is activated using the file generated
691 ;; as argument. This option is disabled if spooling is on (option 16).
692 ;; Also, if you already have a PostScript file you can preview it.
693 ;; Instead of previewing each buffer, region or major mode at once, you
694 ;; can save temporarily the PostScript code generated in a buffer and
695 ;; preview it later. The option `Despool...' despools the PostScript
696 ;; spooling buffer in a temporary file and uses ghostview to preview it.
697 ;; If you type C-u before choosing this option, the PostScript code
698 ;; generated is saved in a file instead of saving in a temporary file.
699 ;; To spool the PostScript code generated you need to turn on the option
700 ;; 16. The option `Despool...' is enabled if spooling is on (option
703 ;; NOTE 1: It's possible to customize a major mode printing, just declare
704 ;; the customization in `pr-mode-alist' and invoke some of
705 ;; `*-mode*' commands or select Mode option in Printing menu. An
706 ;; example for major mode usage is when you're using gnus (or mh,
707 ;; or rmail, etc.) and you're in the *Summary* buffer, if you
708 ;; forget to switch to the *Article* buffer before printing,
709 ;; you'll get a nicely formatted list of article subjects shows
710 ;; up at the printer. With major mode printing you don't need to
711 ;; switch from gnus *Summary* buffer first.
713 ;; NOTE 2: There are the following options for PostScript file
715 ;; Ia. Print the file *No Preprocessing*, that is, send it
716 ;; directly to PostScript printer.
717 ;; Ib. PostScript utility processing selection.
718 ;; See `pr-ps-utility-alist' and `pr-setting-database' for
720 ;; Ic. Do n-up processing before printing.
721 ;; Id. Toggle on/off landscape for PostScript file processing.
722 ;; Ie. Toggle on/off duplex for PostScript file processing.
723 ;; If. Toggle on/off tumble for PostScript file processing.
725 ;; NOTE 3: Don't forget to download and install the utilities declared on
726 ;; `pr-ps-utility-alist'.
728 ;; 2. Operate the same way as option 1, but it sends directly the PostScript
729 ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to
730 ;; print the PostScript file generated. It depends on option 18, if it's
731 ;; turned on, it uses ghostscript; otherwise, it sends directly to
732 ;; printer. If spooling is on (option 16), the PostScript code is saved
733 ;; temporarily in a buffer instead of printing it or saving it in a file.
734 ;; Also, if you already have a PostScript file you can print it. Instead
735 ;; of printing each buffer, region or major mode at once, you can save
736 ;; temporarily the PostScript code generated in a buffer and print it
737 ;; later. The option `Despool...' despools the PostScript spooling
738 ;; buffer directly on a printer. If you type C-u before choosing this
739 ;; option, the PostScript code generated is saved in a file instead of
740 ;; sending to printer. To spool the PostScript code generated you need
741 ;; to turn on the option 16. This option is enabled if spooling is on
742 ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
744 ;; 3. You can select a new PostScript printer to send PostScript code
745 ;; generated. For selection it's used all PostScript printers defined
746 ;; in `pr-ps-printer-alist' variable (see it for documentation).
747 ;; See also `pr-setting-database'.
749 ;; II. Text printing:
751 ;; 4. If you have control characters (character code from \000 to \037) in a
752 ;; buffer and you want to print them in a text printer, select this
753 ;; option. All control characters in your buffer or region will be
754 ;; replaced by a printable representation. The printable representations
755 ;; use ^ (for ASCII control characters) or hex. The characters tab,
756 ;; linefeed, space, return and formfeed are not affected. You don't need
757 ;; to select this option if you use any option of section I, the
758 ;; PostScript engine treats control characters properly.
760 ;; 5. If you want to print a directory, buffer, region or major mode in a
761 ;; text printer, select this option. See also the NOTE 1 on option 1.
763 ;; 6. You can select a new text printer to send text generated. For
764 ;; selection it's used all text printers defined in
765 ;; `pr-txt-printer-alist' variable (see it for documentation).
766 ;; See also `pr-setting-database'.
768 ;; III. PostScript page toggle options:
770 ;; 7. If you want a PostScript landscape printing, turn on this option.
772 ;; 8. If you want to have a header in each page in your PostScript code,
773 ;; turn on this option.
775 ;; 9. If you want to draw a gaudy frame around the header, turn on this
776 ;; option. This option is enabled if print header is on (option 8).
778 ;; 10. If you want that the line number is printed in your PostScript code,
779 ;; turn on this option.
781 ;; 11. If you want background zebra stripes in your PostScript code, turn on
784 ;; 12. If you want a duplex printing and your PostScript printer has this
785 ;; feature, turn on this option.
787 ;; 13. If you turned on duplex printing, you can choose if you want to have
788 ;; a printing suitable for binding on the left or right (tumble off), or
789 ;; to have a printing suitable for binding at top or bottom (tumble on).
790 ;; This option is enabled if duplex is on (option 12).
792 ;; 14. If you want a PostScript upside-down printing, turn on this option.
794 ;; 15. With this option, you can choose if you want to print all pages, odd
795 ;; pages, even pages, odd sheets or even sheets.
796 ;; See also `ps-even-or-odd-pages'.
798 ;; IV. PostScript processing toggle options:
800 ;; 16. If you want to spool the PostScript code generated, turn on this
801 ;; option. To spool the PostScript code generated use option 2. You
802 ;; can despool later by choosing option 1 or 2, sub-option `Despool...'.
804 ;; 17. If you use colors in your buffers and want to see these colors on
805 ;; your PostScript code generated, turn on this option. If you have a
806 ;; black/white PostScript printer, these colors are displayed in gray
807 ;; scale by PostScript printer interpreter.
809 ;; 18. If you don't have a PostScript printer to send PostScript files, turn
810 ;; on this option. When this option is on, the ghostscript is used to
811 ;; print PostScript files. In GNU or Unix system, if ghostscript is set
812 ;; as a PostScript filter, you don't need to turn on this option.
814 ;; V. Printing customization:
816 ;; 19. If you want that region is automagically detected, turn on this
817 ;; option. Note that this will only work if you're using transient mark
818 ;; mode. When this option is on, the `*-buffer*' commands will behave
819 ;; like `*-region*' commands, that is, `*-buffer*' commands will print
820 ;; only the region marked instead of all buffer.
822 ;; 20. Turn this option on if you want that when current major-mode is
823 ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
824 ;; behave like `*-mode*' commands.
826 ;; 21. If you want that Printing menu stays open while you are setting
827 ;; toggle options, turn on this option. The variables
828 ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
829 ;; menu position, so don't forget to adjust these variables if menu
830 ;; position is not ok.
832 ;; VI. Customization:
834 ;; 22. Besides all options in section III, IV and V, you can customize much
835 ;; more PostScript options in `ps-print' option. Or you can customize
836 ;; some `lpr' options for text printing. Or customize `printing'
839 ;; 23. Show current settings for `printing', `ps-print' or `lpr'.
841 ;; 24. Quick help for printing menu layout.
847 ;; Below it's shown only the main options that affect all `printing' package.
848 ;; Check all the settings below *BEFORE* running `printing' commands.
850 ;; * Example of setting for GNU or Unix system:
852 ;; (require 'printing)
853 ;; (setq pr-path-alist
854 ;; '((unix "." "~/bin" ghostview mpage PATH)
855 ;; (ghostview "$HOME/bin/gsview-dir")
856 ;; (mpage "$HOME/bin/mpage-dir")
858 ;; (setq pr-txt-name 'prt_06a)
859 ;; (setq pr-txt-printer-alist
860 ;; '((prt_06a "lpr" nil "prt_06a")
861 ;; (prt_07c nil nil "prt_07c")
863 ;; (setq pr-ps-name 'lps_06b)
864 ;; (setq pr-ps-printer-alist
865 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
866 ;; (lps_07c "lpr" nil nil "lps_07c")
867 ;; (lps_08c nil nil nil "lps_08c")
869 ;; (setq pr-temp-dir "/tmp/")
870 ;; (setq pr-gv-command "gv")
871 ;; (setq pr-gs-command "gs")
872 ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
873 ;; (setq pr-gs-device "uniprint")
874 ;; (setq pr-gs-resolution 300)
875 ;; (setq pr-ps-utility 'mpage)
876 ;; (setq pr-ps-utility-alist
877 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
878 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
879 ;; (inherits-from: . no-duplex))
881 ;; (setq pr-setting-database
884 ;; (pr-file-duplex . nil)
885 ;; (pr-file-tumble . nil))
887 ;; (pr-update-menus t) ; update now printer and utility menus
889 ;; * Example of setting for Windows system:
891 ;; (require 'printing)
892 ;; (setq pr-path-alist
893 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
894 ;; (ghostview "c:/gs/gsview-dir")
895 ;; (mpage "c:/mpage-dir")
897 ;; (setq pr-txt-name 'prt_06a)
898 ;; (setq pr-txt-printer-alist
899 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
900 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
901 ;; (PRN "" nil "PRN")
902 ;; (standard "redpr.exe" nil "")
904 ;; (setq pr-ps-name 'lps_06b)
905 ;; (setq pr-ps-printer-alist
906 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
907 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
908 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
909 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
910 ;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name")
911 ;; (LPT1 "" nil "" "LPT1:")
912 ;; (PRN "" nil "" "PRN")
913 ;; (standard "redpr.exe" nil "" "")
915 ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/")
916 ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe")
917 ;; (setq pr-gs-command "c:/gs/gswin32.exe")
918 ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts"))
919 ;; (setq pr-gs-device "mswinpr2")
920 ;; (setq pr-gs-resolution 300)
921 ;; (setq pr-ps-utility 'psnup)
922 ;; (setq pr-ps-utility-alist
923 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " "
924 ;; nil (inherits-from: . no-duplex))
926 ;; (setq pr-setting-database
929 ;; (pr-file-duplex . nil)
930 ;; (pr-file-tumble . nil))
932 ;; (pr-update-menus t) ; update now printer and utility menus
934 ;; NOTE: Don't forget to download and install the utilities declared on
935 ;; `pr-ps-utility-alist'.
941 ;; `printing' package has the following utilities:
943 ;; `pr-setup' Return the current `printing' setup.
945 ;; `lpr-setup' Return the current `lpr' setup.
947 ;; `pr-update-menus' Update utility, PostScript and text printer menus.
949 ;; `pr-menu-bind' Install `printing' menu in the menubar.
952 ;; Below are some URL where you can find good utilities.
954 ;; * For `printing' package:
956 ;; printing `http://www.emacswiki.org/cgi-bin/emacs/download/printing.el'
957 ;; ps-print `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'
959 ;; * For GNU or Unix system:
961 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
962 ;; enscript `http://people.ssh.fi/mtr/genscript/'
963 ;; psnup `http://www.knackered.org/angus/psutils/'
964 ;; mpage `http://www.mesa.nl/pub/mpage/'
966 ;; * For Windows system:
969 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'
970 ;; gsprint `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'.
971 ;; enscript `http://people.ssh.fi/mtr/genscript/'
972 ;; psnup `http://gnuwin32.sourceforge.net/packages/psutils.htm'
973 ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/'
979 ;; Thanks to Stefan Monnier <monnier@iro.umontreal.ca> for GNU Emacs and XEmacs
980 ;; printing menu (in `pr-menu-spec') merging suggestion.
982 ;; Thanks to Lennart Borgman <lennart.borgman.073@student.lu.se> for gsprint
983 ;; suggestion (see tip 5 in section Tips).
985 ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions:
986 ;; - directory processing.
987 ;; - `pr-path-alist' variable.
989 ;; - a lot of tests on Windows.
991 ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests.
993 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging
994 ;; and for suggestions:
995 ;; - even/odd pages printing.
996 ;; - ghostscript parameters for `pr-ps-printer-alist'.
997 ;; - default printer name.
998 ;; - completion functions.
999 ;; - automagic region detection.
1000 ;; - menu entry hiding.
1001 ;; - fast fire PostScript printing command.
1002 ;; - `pr-path-style' variable.
1004 ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions:
1005 ;; - PostScript Print and PostScript Print Preview merge.
1006 ;; - Tools/Printing menu.
1007 ;; - replace *-using-preview by *-using-ghostscript.
1008 ;; - printer selection.
1009 ;; - extra parameters for `pr-ps-printer-alist'.
1012 ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el
1013 ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el
1014 ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el
1015 ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el
1016 ;; And to all people who contributed with them.
1019 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1028 (and (string< ps-print-version
"6.6.4")
1029 (error "`printing' requires `ps-print' package version 6.6.4 or later"))
1032 (defconst pr-cygwin-system
1033 (and ps-windows-system
(getenv "OSTYPE")
1034 (string-match "cygwin" (getenv "OSTYPE"))))
1037 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1038 ;; To avoid compilation gripes
1041 (or (fboundp 'subst-char-in-string
) ; hacked from subr.el
1042 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
1043 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
1044 Unless optional argument INPLACE is non-nil, return a new string."
1045 (let ((i (length string
))
1046 (newstr (if inplace string
(copy-sequence string
))))
1047 (while (> (setq i
(1- i
)) 0)
1048 (if (eq (aref newstr i
) fromchar
)
1049 (aset newstr i tochar
)))
1053 (or (fboundp 'make-temp-file
) ; hacked from subr.el
1054 (defun make-temp-file (prefix &optional dir-flag suffix
)
1055 "Create a temporary file.
1056 The returned file name (created by appending some random characters at the end
1057 of PREFIX, and expanding against `temporary-file-directory' if necessary),
1058 is guaranteed to point to a newly created empty file.
1059 You can then use `write-region' to write new data into the file.
1061 If DIR-FLAG is non-nil, create a new empty directory instead of a file.
1063 If SUFFIX is non-nil, add that at the end of the file name."
1064 (let ((umask (default-file-modes))
1068 ;; Create temp files with strict access rights. It's easy to
1069 ;; loosen them later, whereas it's impossible to close the
1070 ;; time-window of loose permissions otherwise.
1071 (set-default-file-modes ?
\700)
1072 (while (condition-case ()
1076 (expand-file-name prefix temporary-file-directory
)))
1078 (setq file
(concat file suffix
)))
1080 (make-directory file
)
1081 (write-region "" nil file nil
'silent nil
'excl
))
1083 (file-already-exists t
))
1084 ;; the file was somehow created by someone else between
1085 ;; `make-temp-name' and `write-region', let's try again.
1089 (set-default-file-modes umask
)))))
1093 ;; User Interface --- declared here to avoid compiler warnings
1094 (defvar pr-path-style
)
1095 (defvar pr-auto-region
)
1096 (defvar pr-menu-char-height
)
1097 (defvar pr-menu-char-width
)
1098 (defvar pr-menu-lock
)
1099 (defvar pr-ps-printer-alist
)
1100 (defvar pr-txt-printer-alist
)
1101 (defvar pr-ps-utility-alist
)
1104 ;; Internal fun alias to avoid compilation gripes
1105 (defalias 'pr-menu-lookup
'ignore
)
1106 (defalias 'pr-menu-lock
'ignore
)
1107 (defalias 'pr-menu-alist
'ignore
)
1108 (defalias 'pr-even-or-odd-pages
'ignore
)
1109 (defalias 'pr-menu-get-item
'ignore
)
1110 (defalias 'pr-menu-set-item-name
'ignore
)
1111 (defalias 'pr-menu-set-utility-title
'ignore
)
1112 (defalias 'pr-menu-set-ps-title
'ignore
)
1113 (defalias 'pr-menu-set-txt-title
'ignore
)
1114 (defalias 'pr-region-active-p
'ignore
)
1115 (defalias 'pr-do-update-menus
'ignore
)
1116 (defalias 'pr-update-mode-line
'ignore
)
1117 (defalias 'pr-read-string
'ignore
)
1118 (defalias 'pr-set-keymap-parents
'ignore
)
1119 (defalias 'pr-keep-region-active
'ignore
))
1122 ;; Internal Vars --- defined here to avoid compiler warnings
1123 (defvar pr-menu-print-item
"print"
1124 "Non-nil means that menu binding was not done.
1126 Used by `pr-menu-bind' and `pr-update-menus'.")
1128 (defvar pr-ps-printer-menu-modified t
1129 "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.")
1131 (defvar pr-txt-printer-menu-modified t
1132 "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.")
1134 (defvar pr-ps-utility-menu-modified t
1135 "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.")
1137 (defconst pr-even-or-odd-alist
1138 '((nil .
"Print All Pages")
1139 (even-page .
"Print Even Pages")
1140 (odd-page .
"Print Odd Pages")
1141 (even-sheet .
"Print Even Sheets")
1142 (odd-sheet .
"Print Odd Sheets")))
1145 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1146 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1147 ;; XEmacs Definitions
1151 ((featurep 'xemacs
) ; XEmacs
1153 (defalias 'pr-set-keymap-parents
'set-keymap-parents
)
1154 (defalias 'pr-set-keymap-name
'set-keymap-name
)
1157 (defun pr-read-string (prompt initial history default
)
1158 (let ((str (read-string prompt initial
)))
1159 (if (and str
(not (string= str
"")))
1164 (defvar zmacs-region-stays nil
)
1167 (defun pr-keep-region-active ()
1168 (setq zmacs-region-stays t
))
1171 (defun pr-region-active-p ()
1172 (and pr-auto-region
(not zmacs-region-stays
) (ps-mark-active-p)))
1175 (defun pr-menu-char-height ()
1176 (font-height (face-font 'default
)))
1179 (defun pr-menu-char-width ()
1180 (font-width (face-font 'default
)))
1183 (defmacro pr-xemacs-global-menubar
(&rest body
)
1185 (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
1186 ;; be sure to access global menubar
1189 (kill-buffer temp
))))
1192 (defun pr-global-menubar (pr-menu-spec)
1194 (pr-xemacs-global-menubar
1195 (add-submenu nil
(cons "Printing" pr-menu-spec
) "Apps"))
1196 (setq pr-menu-print-item nil
))
1199 (defvar current-mouse-event nil
)
1200 (defun pr-menu-position (entry index horizontal
)
1204 'x
(- (event-x-pixel current-mouse-event
) ; X
1205 (* horizontal pr-menu-char-width
))
1206 'y
(- (event-y-pixel current-mouse-event
) ; Y
1207 (* (pr-menu-index entry index
) pr-menu-char-height
)))))
1209 (defvar pr-menu-position nil
)
1210 (defvar pr-menu-state nil
)
1213 (defvar current-menubar nil
) ; to avoid compilation gripes
1214 (defun pr-menu-lookup (path)
1215 (car (find-menu-item current-menubar
(cons "Printing" path
))))
1218 (defun pr-menu-lock (entry index horizontal state path
)
1220 (or (and pr-menu-position
(eq state pr-menu-state
))
1221 (setq pr-menu-position
(pr-menu-position entry index horizontal
)
1222 pr-menu-state state
))
1223 (let* ((menu (pr-menu-lookup path
))
1224 (result (get-popup-menu-response menu pr-menu-position
)))
1225 (and (misc-user-event-p result
)
1226 (funcall (event-function result
)
1227 (event-object result
))))
1228 (setq pr-menu-position nil
)))
1231 (defalias 'pr-update-mode-line
'set-menubar-dirty-flag
)
1234 (defvar pr-ps-name-old
"PostScript Printers")
1235 (defvar pr-txt-name-old
"Text Printers")
1236 (defvar pr-ps-utility-old
"PostScript Utility")
1237 (defvar pr-even-or-odd-old
"Print All Pages")
1240 (defun pr-do-update-menus (&optional force
)
1241 (pr-menu-alist pr-ps-printer-alist
1243 'pr-menu-set-ps-title
1245 'pr-ps-printer-menu-modified
1249 (pr-menu-alist pr-txt-printer-alist
1251 'pr-menu-set-txt-title
1253 'pr-txt-printer-menu-modified
1257 (let ((save-var pr-ps-utility-menu-modified
))
1258 (pr-menu-alist pr-ps-utility-alist
1260 'pr-menu-set-utility-title
1261 '("Printing" "PostScript Print" "File")
1266 (pr-menu-alist pr-ps-utility-alist
1268 'pr-menu-set-utility-title
1269 '("Printing" "PostScript Preview" "File")
1270 'pr-ps-utility-menu-modified
1274 (pr-even-or-odd-pages ps-even-or-odd-pages force
))
1277 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
1279 (when (and alist
(or force
(symbol-value modified-sym
)))
1280 (pr-xemacs-global-menubar
1281 (add-submenu menu-path
1282 (pr-menu-create name alist var-sym
1284 (funcall fun
(symbol-value var-sym
))
1285 (set modified-sym nil
)))
1288 (defun pr-relabel-menu-item (newname var-sym
)
1289 (pr-xemacs-global-menubar
1291 (list "Printing" (symbol-value var-sym
))
1293 (set var-sym newname
)))
1296 (defun pr-menu-set-ps-title (value &optional item entry index
)
1297 (pr-relabel-menu-item (format "PostScript Printer: %s" value
)
1299 (pr-ps-set-printer value
)
1301 (pr-menu-lock entry index
12 'toggle nil
)))
1304 (defun pr-menu-set-txt-title (value &optional item entry index
)
1305 (pr-relabel-menu-item (format "Text Printer: %s" value
)
1307 (pr-txt-set-printer value
)
1309 (pr-menu-lock entry index
12 'toggle nil
)))
1312 (defun pr-menu-set-utility-title (value &optional item entry index
)
1313 (pr-xemacs-global-menubar
1314 (let ((newname (format "%s" value
)))
1316 (list "Printing" "PostScript Print" "File" pr-ps-utility-old
)
1319 (list "Printing" "PostScript Preview" "File" pr-ps-utility-old
)
1321 (setq pr-ps-utility-old newname
)))
1322 (pr-ps-set-utility value
)
1324 (pr-menu-lock entry index
5 nil
'("PostScript Print" "File"))))
1327 (defun pr-even-or-odd-pages (value &optional no-lock
)
1328 (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist
))
1329 'pr-even-or-odd-old
)
1330 (setq ps-even-or-odd-pages value
)
1332 (pr-menu-lock 'postscript-options
8 12 'toggle nil
)))
1337 )) ; end cond featurep
1341 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1342 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1343 ;; GNU Emacs Definitions
1347 ((featurep 'xemacs
) ; XEmacs
1352 (defalias 'pr-set-keymap-parents
'set-keymap-parent
)
1353 (defalias 'pr-set-keymap-name
'ignore
)
1354 (defalias 'pr-read-string
'read-string
)
1357 (defvar deactivate-mark
)
1360 (defun pr-keep-region-active ()
1361 (setq deactivate-mark nil
))
1364 (defun pr-region-active-p ()
1365 (and pr-auto-region transient-mark-mode mark-active
))
1368 (defun pr-menu-char-height ()
1369 (frame-char-height))
1372 (defun pr-menu-char-width ()
1375 (defvar pr-menu-bar nil
1376 "Specify Printing menu-bar entry.")
1380 ;; Replace existing "print" item by "Printing" item.
1381 ;; If you're changing this file, you'll load it a second,
1382 ;; third... time, but "print" item exists only in the first load.
1384 (require 'easymenu
)) ; to avoid compilation gripes
1386 (declare-function easy-menu-add-item
"easymenu"
1387 (map path item
&optional before
))
1388 (declare-function easy-menu-remove-item
"easymenu" (map path name
))
1391 (defun pr-global-menubar (pr-menu-spec)
1393 (let ((menu-file (if (= emacs-major-version
21)
1394 '("menu-bar" "files") ; GNU Emacs 21
1395 '("menu-bar" "file")))) ; GNU Emacs 22 or higher
1398 (easy-menu-add-item global-map menu-file
1399 (easy-menu-create-menu "Print" pr-menu-spec
)
1401 (dolist (item '("print-buffer" "print-region"
1402 "ps-print-buffer-faces" "ps-print-region-faces"
1403 "ps-print-buffer" "ps-print-region"))
1404 (easy-menu-remove-item global-map menu-file item
))
1405 (setq pr-menu-print-item nil
1406 pr-menu-bar
(vector 'menu-bar
1407 (pr-get-symbol (nth 1 menu-file
))
1408 (pr-get-symbol "Print"))))
1410 (easy-menu-add-item global-map menu-file
1411 (easy-menu-create-menu "Print" pr-menu-spec
)))
1417 ;; GNU Emacs for Windows 9x/NT
1418 (defun pr-menu-position (entry index horizontal
)
1419 (let ((pos (cdr (mouse-pixel-position))))
1421 (list (or (car pos
) 0) ; X
1422 (- (or (cdr pos
) 0) ; Y
1423 (* (pr-menu-index entry index
) pr-menu-char-height
)))
1424 (selected-frame)))) ; frame
1428 (defun pr-menu-position (entry index horizontal
)
1429 (let ((pos (cdr (mouse-pixel-position))))
1431 (list (- (or (car pos
) 0) ; X
1432 (* horizontal pr-menu-char-width
))
1433 (- (or (cdr pos
) 0) ; Y
1434 (* (pr-menu-index entry index
) pr-menu-char-height
)))
1435 (selected-frame)))) ; frame
1438 (defvar pr-menu-position nil
)
1439 (defvar pr-menu-state nil
)
1442 (defun pr-menu-lookup (path)
1443 (lookup-key global-map
1445 (vconcat pr-menu-bar
1446 (mapcar 'pr-get-symbol
1453 (defun pr-menu-lock (entry index horizontal state path
)
1455 (or (and pr-menu-position
(eq state pr-menu-state
))
1456 (setq pr-menu-position
(pr-menu-position entry index horizontal
)
1457 pr-menu-state state
))
1458 (let* ((menu (pr-menu-lookup path
))
1459 (result (x-popup-menu pr-menu-position menu
)))
1461 (let ((command (lookup-key menu
(vconcat result
))))
1462 (if (fboundp command
)
1465 (setq pr-menu-position nil
)))
1468 (defalias 'pr-update-mode-line
'force-mode-line-update
)
1471 (defun pr-do-update-menus (&optional force
)
1472 (pr-menu-alist pr-ps-printer-alist
1474 'pr-menu-set-ps-title
1475 "PostScript Printers"
1476 'pr-ps-printer-menu-modified
1478 "PostScript Printers"
1480 (pr-menu-alist pr-txt-printer-alist
1482 'pr-menu-set-txt-title
1484 'pr-txt-printer-menu-modified
1488 (let ((save-var pr-ps-utility-menu-modified
))
1489 (pr-menu-alist pr-ps-utility-alist
1491 'pr-menu-set-utility-title
1492 '("PostScript Print" "File" "PostScript Utility")
1495 "PostScript Utility"
1497 (pr-menu-alist pr-ps-utility-alist
1499 'pr-menu-set-utility-title
1500 '("PostScript Preview" "File" "PostScript Utility")
1501 'pr-ps-utility-menu-modified
1503 "PostScript Utility"
1505 (pr-even-or-odd-pages ps-even-or-odd-pages force
))
1508 (defun pr-menu-get-item (name-list)
1509 ;; NAME-LIST is a string or a list of strings.
1510 (or (listp name-list
)
1511 (setq name-list
(list name-list
)))
1513 (let* ((reversed (reverse name-list
))
1514 (name (pr-get-symbol (car reversed
)))
1515 (path (nreverse (cdr reversed
)))
1518 (vconcat pr-menu-bar
1519 (mapcar 'pr-get-symbol path
)))))
1520 (assq name
(nthcdr 2 menu
)))))
1523 (defvar pr-temp-menu nil
)
1526 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
1528 (when (and alist
(or force
(symbol-value modified-sym
)))
1529 (easy-menu-define pr-temp-menu nil
""
1530 (pr-menu-create name alist var-sym fun entry index
))
1531 (let ((item (pr-menu-get-item menu-path
)))
1533 (let* ((binding (nthcdr 3 item
))
1534 (key-binding (cdr binding
)))
1535 (setcar binding pr-temp-menu
)
1536 (and key-binding
(listp (car key-binding
))
1537 (setcdr binding
(cdr key-binding
))) ; skip KEY-BINDING
1538 (funcall fun
(symbol-value var-sym
) item
))))
1539 (set modified-sym nil
)))
1542 (defun pr-menu-set-item-name (item name
)
1544 (setcar (nthcdr 2 item
) name
))) ; ITEM-NAME
1547 (defun pr-menu-set-ps-title (value &optional item entry index
)
1548 (pr-menu-set-item-name (or item
1549 (pr-menu-get-item "PostScript Printers"))
1550 (format "PostScript Printer: %s" value
))
1551 (pr-ps-set-printer value
)
1553 (pr-menu-lock entry index
12 'toggle nil
)))
1556 (defun pr-menu-set-txt-title (value &optional item entry index
)
1557 (pr-menu-set-item-name (or item
1558 (pr-menu-get-item "Text Printers"))
1559 (format "Text Printer: %s" value
))
1560 (pr-txt-set-printer value
)
1562 (pr-menu-lock entry index
12 'toggle nil
)))
1565 (defun pr-menu-set-utility-title (value &optional item entry index
)
1566 (let ((name (symbol-name value
)))
1568 (pr-menu-set-item-name item name
)
1569 (pr-menu-set-item-name
1571 '("PostScript Print" "File" "PostScript Utility"))
1573 (pr-menu-set-item-name
1575 '("PostScript Preview" "File" "PostScript Utility"))
1577 (pr-ps-set-utility value
)
1579 (pr-menu-lock entry index
5 nil
'("PostScript Print" "File"))))
1582 (defun pr-even-or-odd-pages (value &optional no-lock
)
1583 (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
1584 (cdr (assq value pr-even-or-odd-alist
)))
1585 (setq ps-even-or-odd-pages value
)
1587 (pr-menu-lock 'postscript-options
8 12 'toggle nil
)))
1589 )) ; end cond featurep
1592 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1593 ;; Internal Functions (I)
1596 (defun pr-dosify-file-name (path)
1597 "Replace unix-style directory separator character with dos/windows one."
1598 (interactive "sPath: ")
1599 (if (eq pr-path-style
'windows
)
1600 (subst-char-in-string ?
/ ?
\\ path
)
1604 (defun pr-unixify-file-name (path)
1605 "Replace dos/windows-style directory separator character with unix one."
1606 (interactive "sPath: ")
1607 (if (eq pr-path-style
'windows
)
1608 (subst-char-in-string ?
\\ ?
/ path
)
1612 (defun pr-standard-file-name (path)
1613 "Ensure the proper directory separator depending on the OS.
1614 That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory
1615 separator; otherwise, ensure unix-style directory separator."
1616 (if (or pr-cygwin-system ps-windows-system
)
1617 (subst-char-in-string ?
/ ?
\\ path
)
1618 (subst-char-in-string ?
\\ ?
/ path
)))
1621 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1622 ;; Customization Functions
1625 (defun pr-alist-custom-set (symbol value
)
1626 "Set the value of custom variables for printer & utility selection."
1628 (and (featurep 'printing
) ; update only after printing is loaded
1629 (pr-update-menus t
)))
1632 (defun pr-ps-utility-custom-set (symbol value
)
1633 "Update utility menu entry."
1635 (and (featurep 'printing
) ; update only after printing is loaded
1636 (pr-menu-set-utility-title value
)))
1639 (defun pr-ps-name-custom-set (symbol value
)
1640 "Update `PostScript Printer:' menu entry."
1642 (and (featurep 'printing
) ; update only after printing is loaded
1643 (pr-menu-set-ps-title value
)))
1646 (defun pr-txt-name-custom-set (symbol value
)
1647 "Update `Text Printer:' menu entry."
1649 (and (featurep 'printing
) ; update only after printing is loaded
1650 (pr-menu-set-txt-title value
)))
1653 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1657 (defgroup printing nil
1658 "Printing Utilities group."
1659 :tag
"Printing Utilities"
1660 :link
'(emacs-library-link :tag
"Source Lisp File" "printing.el")
1667 (defcustom pr-path-style
1668 (if (and (not pr-cygwin-system
)
1672 "Specify which path style to use for external commands.
1676 windows Windows 9x/NT style (\\)
1678 unix Unix style (/)"
1679 :type
'(choice :tag
"Path style"
1680 (const :tag
"Windows 9x/NT Style (\\)" :value windows
)
1681 (const :tag
"Unix Style (/)" :value unix
))
1685 (defcustom pr-path-alist
1689 "Specify an alist for command paths.
1691 It's used to find commands used for printing package, like gv, gs, gsview.exe,
1692 mpage, print.exe, etc. See also `pr-command' function.
1694 Each element has the form:
1696 (ENTRY DIRECTORY...)
1700 ENTRY It's a symbol, used to identify this entry.
1701 There must exist at least one of the following entries:
1703 unix this entry is used when Emacs is running on GNU or
1706 cygwin this entry is used when Emacs is running on Windows
1707 95/98/NT/2000 with Cygwin.
1709 windows this entry is used when Emacs is running on Windows
1712 DIRECTORY It should be a string or a symbol. If it's a symbol, it should
1713 exist an equal entry in `pr-path-alist'. If it's a string,
1714 it's considered a directory specification.
1716 The directory specification may contain:
1717 $var environment variable expansion
1719 ./ current directory
1720 ../ previous directory
1722 For example, let's say the home directory is /home/my and the
1723 current directory is /home/my/dir, so:
1725 THE ENTRY IS EXPANDED TO
1726 ~/entry /home/my/entry
1727 ./entry /home/my/dir/entry
1728 ../entry /home/my/entry
1729 $HOME/entry /home/my/entry
1730 $HOME/~/other/../my/entry /home/my/entry
1732 SPECIAL SYMBOL: If the symbol `PATH' is used in the directory
1733 list and there isn't a `PATH' entry in `pr-path-alist' or the
1734 `PATH' entry has a null directory list, the PATH environment
1739 * On GNU or Unix system:
1741 '((unix \".\" \"~/bin\" ghostview mpage PATH)
1742 (ghostview \"$HOME/bin/gsview-dir\")
1743 (mpage \"$HOME/bin/mpage-dir\")
1746 * On Windows system:
1748 '((windows \"c:/applications/executables\" PATH ghostview mpage)
1749 (ghostview \"c:/gs/gsview-dir\")
1750 (mpage \"c:/mpage-dir\")
1754 (symbol :tag
"Identifier ")
1755 (repeat :tag
"Directory List"
1756 (choice :menu-tag
"Directory"
1759 (symbol :value symbol
)))))
1763 (defcustom pr-txt-name
'default
1764 "Specify a printer for printing a text file.
1766 The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
1769 This variable should be modified by customization engine. If this variable is
1770 modified by other means (for example, a lisp function), use `pr-update-menus'
1771 function (see it for documentation) to update text printer menu."
1773 :set
'pr-txt-name-custom-set
1777 (defcustom pr-txt-printer-alist
1778 (list (list 'default lpr-command nil
1779 (cond ((boundp 'printer-name
) printer-name
)
1780 (ps-windows-system "PRN")
1784 ;; * On GNU or Unix system:
1785 ;; '((prt_06a "lpr" nil "prt_06a")
1786 ;; (prt_07c nil nil "prt_07c")
1788 ;; * On Windows system:
1789 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
1790 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
1791 ;; (PRN "" nil "PRN")
1792 ;; (standard "redpr.exe" nil "")
1794 "Specify an alist of all text printers (text printer database).
1796 The alist element has the form:
1798 (SYMBOL COMMAND SWITCHES NAME)
1802 SYMBOL It's a symbol to identify a text printer. It's for
1803 setting option `pr-txt-name' and for menu selection.
1808 COMMAND Name of the program for printing a text file. On MS-DOS and
1809 MS-Windows systems, if the value is an empty string, then Emacs
1810 will write directly to the printer port given by NAME (see text
1811 below), that is, the NAME should be something like \"PRN\" or
1813 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1814 COMMAND shouldn't be an empty string.
1815 The programs `print' and `nprint' (the standard print programs
1816 on Windows NT and Novell Netware respectively) are handled
1817 specially, using NAME as the destination for output; any other
1818 program is treated like `lpr' except that an explicit filename
1819 is given as the last argument.
1820 If COMMAND is nil, it's used the default printing program:
1821 `print' for Windows system, `lp' for lp system and `lpr' for
1822 all other systems. See also `pr-path-alist'.
1828 SWITCHES List of sexp's to pass as extra options for text printer
1829 program. It is recommended to set NAME (see text below)
1830 instead of including an explicit switch on this list.
1836 NAME A string that specifies a text printer name.
1837 On Unix-like systems, a string value should be a name
1838 understood by lpr's -P option (or lp's -d option).
1839 On MS-DOS and MS-Windows systems, it is the name of a printer
1840 device or port. Typical non-default settings would be \"LPT1:\"
1841 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1842 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1843 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1844 printer. You can also set it to a name of a file, in which
1845 case the output gets appended to that file. If you want to
1846 discard the printed output, set this to \"NUL\".
1849 \"/D:\\\\\\\\host\\\\share-name\"
1856 This variable should be modified by customization engine. If this variable is
1857 modified by other means (for example, a lisp function), use `pr-update-menus'
1858 function (see it for documentation) to update text printer menu.
1862 * On GNU or Unix system:
1864 '((prt_06a \"lpr\" nil \"prt_06a\")
1865 (prt_07c nil nil \"prt_07c\")
1868 * On Windows system:
1870 '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\")
1871 (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\")
1872 (PRN \"\" nil \"PRN\")
1873 (standard \"redpr.exe\" nil \"\")
1878 * Information about the print command (print.exe)
1879 `http://www.computerhope.com/printhlp.htm'
1881 * RedMon - Redirection Port Monitor (redpr.exe)
1882 `http://www.cs.wisc.edu/~ghost/redmon/index.htm'
1884 * Redirection Port Monitor (redpr.exe on-line help)
1885 `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm'
1887 * UNIX man pages: lpr (or type `man lpr')
1888 `http://bama.ua.edu/cgi-bin/man-cgi?lpr'
1889 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr'
1891 * UNIX man pages: lp (or type `man lp')
1892 `http://bama.ua.edu/cgi-bin/man-cgi?lp'
1893 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
1896 (list :tag
"Text Printer"
1897 (symbol :tag
"Printer Symbol Name")
1898 (string :tag
"Printer Command")
1899 (repeat :tag
"Printer Switches"
1900 (sexp :tag
"Switch" :value
""))
1901 (choice :menu-tag
"Printer Name"
1903 (const :tag
"None" nil
)
1905 :set
'pr-alist-custom-set
1909 (defcustom pr-ps-name
'default
1910 "Specify a printer for printing a PostScript file.
1912 This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
1915 This variable should be modified by customization engine. If this variable is
1916 modified by other means (for example, a lisp function), use `pr-update-menus'
1917 function (see it for documentation) to update PostScript printer menu."
1919 :set
'pr-ps-name-custom-set
1923 (defcustom pr-ps-printer-alist
1924 (list (list 'default lpr-command nil
1925 (cond (ps-windows-system nil
)
1928 (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name
)))
1930 ;; * On GNU or Unix system:
1931 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
1932 ;; (lps_07c "lpr" nil nil "lps_07c")
1933 ;; (lps_08c nil nil nil "lps_08c")
1935 ;; * On Windows system:
1936 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
1937 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
1938 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
1939 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
1940 ;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name")
1941 ;; (LPT1 "" nil "" "LPT1:")
1942 ;; (PRN "" nil "" "PRN")
1943 ;; (standard "redpr.exe" nil "" "")
1945 "Specify an alist for all PostScript printers (PostScript printer database).
1947 The alist element has the form:
1949 (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...)
1953 SYMBOL It's a symbol to identify a PostScript printer. It's for
1954 setting option `pr-ps-name' and for menu selection.
1959 COMMAND Name of the program for printing a PostScript file. On MS-DOS
1960 and MS-Windows systems, if the value is an empty string then
1961 Emacs will write directly to the printer port given by NAME
1962 (see text below), that is, the NAME should be something like
1963 \"PRN\" or \"LPT1:\".
1964 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1965 COMMAND shouldn't be an empty string.
1966 The programs `print' and `nprint' (the standard print programs
1967 on Windows NT and Novell Netware respectively) are handled
1968 specially, using NAME as the destination for output; any other
1969 program is treated like `lpr' except that an explicit filename
1970 is given as the last argument.
1971 If COMMAND is nil, it's used the default printing program:
1972 `print' for Windows system, `lp' for lp system and `lpr' for
1973 all other systems. See also `pr-path-alist'.
1981 SWITCHES List of sexp's to pass as extra options for PostScript printer
1982 program. It is recommended to set NAME (see text below)
1983 instead of including an explicit switch on this list.
1990 '(\"-all\" \"-twoup\")
1992 PRINTER-SWITCH A string that specifies PostScript printer name switch. If
1993 it's necessary to have a space between PRINTER-SWITCH and NAME,
1994 it should be inserted at the end of PRINTER-SWITCH string.
1995 If PRINTER-SWITCH is nil, it's used the default printer name
1996 switch: `/D:' for Windows system, `-d' for lp system and `-P'
1997 for all other systems.
2011 NAME A string that specifies a PostScript printer name.
2012 On Unix-like systems, a string value should be a name
2013 understood by lpr's -P option (or lp's -d option).
2014 On MS-DOS and MS-Windows systems, it is the name of a printer
2015 device or port. Typical non-default settings would be \"LPT1:\"
2016 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
2017 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
2018 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
2019 printer. You can also set it to a name of a file, in which
2020 case the output gets appended to that file. If you want to
2021 discard the printed output, set this to \"NUL\".
2024 \"\\\\\\\\host\\\\share-name\"
2026 . for print.exe or gsprint.exe
2027 \"/D:\\\\\\\\host\\\\share-name\"
2028 \"\\\\\\\\host\\\\share-name\"
2035 DEFAULT It's a way to set default values when this entry is selected.
2040 Which associates VARIABLE with VALUE. When this entry is
2041 selected, it's executed the following command:
2043 (set VARIABLE (eval VALUE))
2045 Note that VALUE can be any valid lisp expression. So, don't
2046 forget to quote symbols and constant lists.
2047 If VARIABLE is the special keyword `inherits-from:', VALUE must
2048 be a symbol name setting defined in `pr-setting-database' from
2049 which the current setting inherits the context. Take care with
2050 circular inheritance.
2052 '(ps-landscape-mode . nil)
2053 '(ps-spool-duplex . t)
2054 '(pr-gs-device . (my-gs-device t))
2056 This variable should be modified by customization engine. If this variable is
2057 modified by other means (for example, a lisp function), use `pr-update-menus'
2058 function (see it for documentation) to update PostScript printer menu.
2062 * On GNU or Unix system:
2064 '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\")
2065 (lps_07c \"lpr\" nil nil \"lps_07c\")
2066 (lps_08c nil nil nil \"lps_08c\")
2069 * On Windows system:
2071 '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\")
2072 (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\")
2073 (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\")
2074 (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\")
2075 (b/w1 \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"b/w-pr-name\")
2076 (b/w2 \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer \\\\\\\\printers\\\\lps_06a\")
2077 (LPT1 \"\" nil \"\" \"LPT1:\")
2078 (PRN \"\" nil \"\" \"PRN\")
2079 (standard \"redpr.exe\" nil \"\" \"\")
2085 You can use gsprint instead of ghostscript to print monochrome PostScript files
2086 in Windows. The gsprint utility documentation says that it is more efficient
2087 than ghostscript to print monochrome PostScript.
2089 To print non-monochrome PostScript file, the efficiency of ghostscript is
2092 Also the gsprint utility comes together with gsview distribution.
2094 As an example of gsprint declaration:
2096 (setq pr-ps-printer-alist
2097 '((A \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"lps_015\")
2098 (B \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer lps_015\")
2099 ;; some other printer declaration
2102 The example above declares that printer A prints all pages (-all) and two pages
2103 per sheet (-twoup). The printer B declaration does the same as the printer A
2104 declaration, the only difference is the printer name selection.
2106 There are other command line options like:
2108 -mono Render in monochrome as 1bit/pixel (only black and white).
2109 -grey Render in greyscale as 8bits/pixel.
2110 -color Render in color as 24bits/pixel.
2112 The default is `-mono'. So, printer A and B in the example above are using
2113 implicitly the `-mono' option. Note that in `-mono' no gray tone or color is
2114 printed, this includes the zebra stripes, that is, in `-mono' the zebra stripes
2120 * GSPRINT - Ghostscript print to Windows printer
2121 `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'
2123 * Introduction to Ghostscript
2124 `http://www.cs.wisc.edu/~ghost/doc/intro.htm'
2126 * How to use Ghostscript
2127 `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
2129 * Information about the print command (print.exe)
2130 `http://www.computerhope.com/printhlp.htm'
2132 * RedMon - Redirection Port Monitor (redpr.exe)
2133 `http://www.cs.wisc.edu/~ghost/redmon/index.htm'
2135 * Redirection Port Monitor (redpr.exe on-line help)
2136 `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm'
2138 * UNIX man pages: lpr (or type `man lpr')
2139 `http://bama.ua.edu/cgi-bin/man-cgi?lpr'
2140 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr'
2142 * UNIX man pages: lp (or type `man lp')
2143 `http://bama.ua.edu/cgi-bin/man-cgi?lp'
2144 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
2146 * GNU utilities for w32 (cp.exe)
2147 `http://unxutils.sourceforge.net/'
2151 :tag
"PostScript Printer"
2152 (symbol :tag
"Printer Symbol Name")
2153 (string :tag
"Printer Command")
2154 (repeat :tag
"Printer Switches"
2155 (sexp :tag
"Switch" :value
""))
2156 (choice :menu-tag
"Printer Name Switch"
2157 :tag
"Printer Name Switch"
2158 (const :tag
"None" nil
)
2160 (choice :menu-tag
"Printer Name"
2162 (const :tag
"None" nil
)
2165 :tag
"Default Value List"
2170 :menu-tag
"Variable"
2172 (const :tag
"Landscape" ps-landscape-mode
)
2173 (const :tag
"Print Header" ps-print-header
)
2174 (const :tag
"Print Header Frame" ps-print-header-frame
)
2175 (const :tag
"Line Number" ps-line-number
)
2176 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2177 (const :tag
"Duplex" ps-spool-duplex
)
2178 (const :tag
"Tumble" ps-spool-tumble
)
2179 (const :tag
"Upside-Down" ps-print-upside-down
)
2180 (const :tag
"PS File Landscape" pr-file-landscape
)
2181 (const :tag
"PS File Duplex" pr-file-duplex
)
2182 (const :tag
"PS File Tumble" pr-file-tumble
)
2183 (const :tag
"Auto Region" pr-auto-region
)
2184 (const :tag
"Auto Mode" pr-auto-mode
)
2185 (const :tag
"Ghostscript Device" pr-gs-device
)
2186 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2187 (const :tag
"inherits-from:" inherits-from
:)
2188 (variable :tag
"Other"))
2189 (sexp :tag
"Value")))
2191 :set
'pr-alist-custom-set
2195 (defcustom pr-temp-dir
2196 (pr-dosify-file-name
2197 (if (boundp 'temporary-file-directory
)
2198 (symbol-value 'temporary-file-directory
)
2199 ;; hacked from `temporary-file-directory' variable in files.el
2200 (file-name-as-directory
2201 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
2202 (cond (ps-windows-system "c:/temp")
2205 "Specify a directory for temporary files during printing.
2207 See also `pr-ps-temp-file' and `pr-file-modes'."
2208 :type
'(directory :tag
"Temporary Directory")
2212 (defcustom pr-ps-temp-file
"prspool-"
2213 "Specify PostScript temporary file name prefix.
2215 See also `pr-temp-dir' and `pr-file-modes'."
2216 :type
'(file :tag
"PostScript Temporary File Name")
2220 ;; It uses 0600 as default instead of (default-file-modes).
2221 ;; So, by default, only the session owner have permission to deal with files
2222 ;; generated by `printing'.
2223 (defcustom pr-file-modes ?
\600
2224 "Specify the file permission bits for newly created files.
2226 It should be an integer; only the low 9 bits are used.
2228 See also `pr-temp-dir' and `pr-ps-temp-file'."
2229 :type
'(integer :tag
"File Permission Bits")
2233 (defcustom pr-gv-command
2234 (if ps-windows-system
2237 "Specify path and name of the gsview/gv utility.
2239 See also `pr-path-alist'.
2244 `http://www.gnu.org/software/gv/manual/gv.html'
2247 `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm'
2249 * GSview Help - Common Problems
2250 `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm#Common_Problems'
2252 * GSview Readme (compilation & installation)
2253 `http://www.cs.wisc.edu/~ghost/gsview/Readme.htm'
2255 * GSview (main site)
2256 `http://www.cs.wisc.edu/~ghost/gsview/index.htm'
2258 * Ghostscript, Ghostview and GSview
2259 `http://www.cs.wisc.edu/~ghost/'
2262 `http://www.cs.wisc.edu/~ghost/gv/index.htm'
2265 `http://www.cs.wisc.edu/~ghost/gv/gv_doc/gv.html'
2268 `http://www.cs.wisc.edu/~ghost/macos/index.htm'
2270 :type
'(string :tag
"Ghostview Utility")
2274 (defcustom pr-gs-command
2275 (if ps-windows-system
2278 "Specify path and name of the ghostscript utility.
2280 See also `pr-path-alist'.
2284 * Ghostscript, Ghostview and GSview
2285 `http://www.cs.wisc.edu/~ghost/'
2287 * Introduction to Ghostscript
2288 `http://www.cs.wisc.edu/~ghost/doc/intro.htm'
2290 * How to use Ghostscript
2291 `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
2293 * Printer compatibility
2294 `http://www.cs.wisc.edu/~ghost/doc/printer.htm'
2296 :type
'(string :tag
"Ghostscript Utility")
2300 (defcustom pr-gs-switches
2301 (if ps-windows-system
2302 '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")
2303 '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
2304 "Specify ghostscript switches. See the documentation on GS for more info.
2306 It's a list of strings, where each string is one or more ghostscript switches.
2308 A note on the gs switches:
2311 -dNOPAUSE don't wait for user intervention
2312 -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs
2313 -c quit it's added at the end to terminate gs
2315 To see ghostscript documentation for more information:
2317 * On GNU or Unix system:
2318 - for full documentation, type: man gs
2319 - for brief documentation, type: gs -h
2321 * On Windows system:
2322 - for full documentation, see in a browser the file
2323 c:/gstools/gs5.50/index.html, that is, the file index.html which is
2324 located in the same directory as gswin32.exe.
2325 - for brief documentation, type: gswin32.exe -h
2329 * Introduction to Ghostscript
2330 `http://www.cs.wisc.edu/~ghost/doc/intro.htm'
2332 * How to use Ghostscript
2333 `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
2335 * Printer compatibility
2336 `http://www.cs.wisc.edu/~ghost/doc/printer.htm'
2338 :type
'(repeat (string :tag
"Ghostscript Switch"))
2342 (defcustom pr-gs-device
2343 (if ps-windows-system
2346 "Specify the ghostscript device switch value (-sDEVICE=).
2348 A note on the gs switches:
2350 -sDEVICE=djet500 the printer - works with HP DeskJet 540
2352 See `pr-gs-switches' for documentation.
2353 See also `pr-ps-printer-alist'."
2354 :type
'(string :tag
"Ghostscript Device")
2358 (defcustom pr-gs-resolution
300
2359 "Specify ghostscript resolution switch value (-r).
2361 A note on the gs switches:
2363 -r300 resolution 300x300
2365 See `pr-gs-switches' for documentation.
2366 See also `pr-ps-printer-alist'."
2367 :type
'(integer :tag
"Ghostscript Resolution")
2371 (defcustom pr-print-using-ghostscript nil
2372 "Non-nil means print using ghostscript.
2374 This is useful if you don't have a PostScript printer, so you could use the
2375 ghostscript to print a PostScript file.
2377 In GNU or Unix system, if ghostscript is set as a PostScript filter, this
2378 variable should be nil."
2383 (defcustom pr-faces-p nil
2384 "Non-nil means print with face attributes."
2389 (defcustom pr-spool-p nil
2390 "Non-nil means spool printing in a buffer."
2395 (defcustom pr-file-landscape nil
2396 "Non-nil means print PostScript file in landscape orientation."
2401 (defcustom pr-file-duplex nil
2402 "Non-nil means print PostScript file in duplex mode."
2407 (defcustom pr-file-tumble nil
2408 "Non-nil means print PostScript file in tumble mode.
2410 If tumble is off, produces a printing suitable for binding on the left or
2412 If tumble is on, produces a printing suitable for binding at the top or
2418 (defcustom pr-auto-region t
2419 "Non-nil means region is automagically detected.
2421 Note that this will only work if you're using transient mark mode.
2423 When this variable is non-nil, the `*-buffer*' commands will behave like
2424 `*-region*' commands, that is, `*-buffer*' commands will print only the region
2425 marked instead of all buffer."
2430 (defcustom pr-auto-mode t
2431 "Non-nil means major-mode specific printing is preferred over normal printing.
2433 That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
2434 and `*-region*' commands will behave like `*-mode*' commands; otherwise,
2435 `*-buffer*' commands will print the current buffer and `*-region*' commands
2436 will print the current region."
2441 (defcustom pr-mode-alist
2442 '((mh-folder-mode ; mh summary buffer
2443 pr-mh-lpr-1 pr-mh-print-1
2445 (ps-article-author ps-article-subject
)
2446 ("/pagenumberstring load" pr-article-date
)
2449 (mh-letter-mode ; mh letter buffer
2450 pr-mh-lpr-2 pr-mh-print-2
2452 (ps-article-author ps-article-subject
)
2453 ("/pagenumberstring load" pr-article-date
)
2456 (rmail-summary-mode ; rmail summary buffer
2457 pr-rmail-lpr pr-rmail-print
2459 (ps-article-subject ps-article-author buffer-name
)
2463 (rmail-mode ; rmail buffer
2464 pr-rmail-lpr pr-rmail-print
2466 (ps-article-subject ps-article-author buffer-name
)
2470 (gnus-summary-mode ; gnus summary buffer
2471 pr-gnus-lpr pr-gnus-print
2473 (ps-article-subject ps-article-author gnus-newsgroup-name
)
2477 (gnus-article-mode ; gnus article buffer
2478 pr-gnus-lpr pr-gnus-print
2480 (ps-article-subject ps-article-author gnus-newsgroup-name
)
2484 (Info-mode ; Info buffer
2485 pr-mode-lpr pr-mode-print
2487 (ps-info-node ps-info-file
)
2492 pr-vm-lpr pr-vm-print
2494 (ps-article-subject ps-article-author buffer-name
)
2499 "Specify an alist for a major-mode and printing functions.
2501 To customize a major mode printing, just declare the customization in
2502 `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major
2503 mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the
2504 *Summary* buffer, if you forget to switch to the *Article* buffer before
2505 printing, you'll get a nicely formatted list of article subjects shows up at
2506 the printer. With major mode printing you don't need to switch from gnus
2507 *Summary* buffer first.
2509 The elements have the following form:
2521 MAJOR-MODE It's the major mode symbol.
2523 LPR-PRINT It's a symbol function for text printing. It's invoked with
2525 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
2527 Usually LPR-PRINT function prepares the environment or buffer
2528 and then call the function `pr-mode-lpr' which it's used to
2529 process the buffer and send it to text printer.
2531 The `pr-mode-lpr' definition is:
2533 (pr-mode-lpr HEADER-LIST &optional FROM TO)
2535 Where HEADER-LIST is like the argument passed to LPR-PRINT.
2536 FROM and TO are the beginning and end markers, respectively,
2537 for a region. If FROM is nil, it's used (point-min); if TO is
2538 nil, it's used (point-max).
2540 PS-PRINT It's a symbol function for PostScript printing. It's invoked
2541 with three arguments: n-up printing, file name and the list:
2542 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
2544 Usually PS-PRINT function prepares the environment or buffer
2545 and then call the function `pr-mode-print' which it's used to
2546 process the buffer and send it to PostScript printer.
2548 The `pr-mode-print' definition is:
2550 (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO)
2552 Where N-UP, FILENAME and HEADER-LIST are like the arguments
2553 passed to PS-PRINT. FROM and TO are the beginning and end
2554 markers, respectively, for a region. If TO is nil, it's used
2557 HEADER-LINES It's the number of header lines; if is nil, it uses
2558 `ps-header-lines' value.
2560 LEFT-HEADER It's the left header part, it's a list of string, variable
2561 symbol or function symbol (with no argument); if is nil, it
2562 uses `ps-left-header' value.
2564 RIGHT-HEADER It's the right header part, it's a list of string, variable
2565 symbol or function symbol (with no argument); if is nil, it
2566 uses `ps-right-header' value.
2569 Non-nil means to kill all buffer local variable declared in
2570 DEFAULT (see below).
2572 DEFAULT It's a way to set default values when this entry is selected.
2575 (VARIABLE-SYM . VALUE)
2577 Which associates VARIABLE-SYM with VALUE. When this entry is
2578 selected, it's executed the following command:
2580 (set (make-local-variable VARIABLE-SYM) (eval VALUE))
2582 Note that VALUE can be any valid lisp expression. So, don't
2583 forget to quote symbols and constant lists.
2584 If VARIABLE is the special keyword `inherits-from:', VALUE must
2585 be a symbol name setting defined in `pr-setting-database' from
2586 which the current setting inherits the context. Take care with
2587 circular inheritance.
2589 '(ps-landscape-mode . nil)
2590 '(ps-spool-duplex . t)
2591 '(pr-gs-device . (my-gs-device t))"
2595 (symbol :tag
"Major Mode")
2596 (function :tag
"Text Printing Function")
2597 (function :tag
"PS Printing Function")
2598 (choice :menu-tag
"Number of Header Lines"
2599 :tag
"Number of Header Lines"
2600 (integer :tag
"Number")
2601 (const :tag
"Default Number" nil
))
2602 (repeat :tag
"Left Header List"
2603 (choice :menu-tag
"Left Header"
2606 (repeat :tag
"Right Header List"
2607 (choice :menu-tag
"Right Header"
2610 (boolean :tag
"Kill Local Variable At End")
2612 :tag
"Default Value List"
2617 :menu-tag
"Variable"
2619 (const :tag
"Landscape" ps-landscape-mode
)
2620 (const :tag
"Print Header" ps-print-header
)
2621 (const :tag
"Print Header Frame" ps-print-header-frame
)
2622 (const :tag
"Line Number" ps-line-number
)
2623 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2624 (const :tag
"Duplex" ps-spool-duplex
)
2625 (const :tag
"Tumble" ps-spool-tumble
)
2626 (const :tag
"Upside-Down" ps-print-upside-down
)
2627 (const :tag
"PS File Landscape" pr-file-landscape
)
2628 (const :tag
"PS File Duplex" pr-file-duplex
)
2629 (const :tag
"PS File Tumble" pr-file-tumble
)
2630 (const :tag
"Auto Region" pr-auto-region
)
2631 (const :tag
"Auto Mode" pr-auto-mode
)
2632 (const :tag
"Ghostscript Device" pr-gs-device
)
2633 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2634 (const :tag
"inherits-from:" inherits-from
:)
2635 (variable :tag
"Other"))
2636 (sexp :tag
"Value")))
2641 (defcustom pr-ps-utility
'mpage
2642 "Specify PostScript utility symbol.
2644 This utility symbol should be defined on `pr-ps-utility-alist' (see it for
2647 This variable should be modified by customization engine. If this variable is
2648 modified by other means (for example, a lisp function), use `pr-update-menus'
2649 function (see it for documentation) to update PostScript utility menu.
2651 NOTE: Don't forget to download and install the utilities declared on
2652 `pr-ps-utility-alist'."
2653 :type
'(symbol :tag
"PS File Utility")
2654 :set
'pr-ps-utility-custom-set
2658 (defcustom pr-ps-utility-alist
2659 '((mpage "mpage" nil
"-b%s" "-%d" "-l" "-t" "-T" ">" nil
)
2660 (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil
" " nil
2661 (inherits-from: . no-duplex
))
2664 ;; * On GNU or Unix system:
2665 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
2666 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
2667 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
2669 ;; * On Windows system:
2670 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
2671 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
2673 "Specify an alist for PostScript utility processing (PS utility database).
2675 The alist element has the form:
2677 (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT
2678 SWITCHES DEFAULT...)
2682 SYMBOL It's a symbol to identify a PostScript utility. It's for
2683 `pr-ps-utility' variable setting and for menu selection.
2688 UTILITY Name of utility for processing a PostScript file.
2689 See also `pr-path-alist'.
2691 . for GNU or Unix system:
2695 . for Windows system:
2696 \"c:/psutils/psnup -q\"
2698 MUST-SWITCHES List of sexp's to pass as options to the PostScript utility
2699 program. These options are necessary to process the utility
2700 program and must be placed before any other switches.
2705 PAPERSIZE It's a format string to specify paper size switch.
2710 N-UP It's a format string to specify n-up switch.
2715 LANDSCAPE It's a string to specify landscape switch. If the utility
2716 doesn't have landscape switch, set to nil.
2721 DUPLEX It's a string to specify duplex switch. If the utility doesn't
2722 have duplex switch, set to nil.
2727 TUMBLE It's a string to specify tumble switch. If the utility doesn't
2728 have tumble switch, set to nil.
2733 OUTPUT It's a string to specify how to generate an output file. Some
2734 utilities accept an output file option, but some others need
2735 output redirection or some other way to specify an output file.
2738 \" \" ; psnup ... input output
2741 \">\" ; mpage ... input > output
2743 SWITCHES List of sexp's to pass as extra options to the PostScript utility
2750 DEFAULT It's a way to set default values when this entry is selected.
2755 Which associates VARIABLE with VALUE. When this entry is
2756 selected, it's executed the following command:
2758 (set VARIABLE (eval VALUE))
2760 Note that VALUE can be any valid lisp expression. So, don't
2761 forget to quote symbols and constant lists.
2762 If VARIABLE is the special keyword `inherits-from:', VALUE must
2763 be a symbol name setting defined in `pr-setting-database' from
2764 which the current setting inherits the context. Take care with
2765 circular inheritance.
2767 '(pr-file-landscape . nil)
2768 '(pr-file-duplex . t)
2769 '(pr-gs-device . (my-gs-device t))
2771 This variable should be modified by customization engine. If this variable is
2772 modified by other means (for example, a lisp function), use `pr-update-menus'
2773 function (see it for documentation) to update PostScript utility menu.
2775 NOTE: Don't forget to download and install the utilities declared on
2776 `pr-ps-utility-alist'.
2780 * On GNU or Unix system:
2782 '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil)
2783 (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil
2784 (pr-file-duplex . nil) (pr-file-tumble . nil))
2787 * On Windows system:
2789 '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \"
2790 nil (pr-file-duplex . nil) (pr-file-tumble . nil))
2795 * mpage download (GNU or Unix)
2796 `http://www.mesa.nl/pub/mpage/'
2798 * mpage documentation (GNU or Unix - or type `man mpage')
2799 `http://www.cs.umd.edu/faq/guides/manual_unix/node48.html'
2800 `http://www.rt.com/man/mpage.1.html'
2802 * psnup (Windows, GNU or Unix)
2803 `http://www.knackered.org/angus/psutils/'
2804 `http://gershwin.ens.fr/vdaniel/Doc-Locale/Outils-Gnu-Linux/PsUtils/'
2806 * psnup (PsUtils for Windows)
2807 `http://gnuwin32.sourceforge.net/packages/psutils.htm'
2809 * psnup documentation (GNU or Unix - or type `man psnup')
2810 `http://linux.about.com/library/cmd/blcmdl1_psnup.htm'
2811 `http://amath.colorado.edu/computing/software/man/psnup.html'
2813 * GNU Enscript (Windows, GNU or Unix)
2814 `http://people.ssh.com/mtr/genscript/'
2816 * GNU Enscript documentation (Windows, GNU or Unix)
2817 `http://people.ssh.com/mtr/genscript/enscript.man.html'
2818 (on GNU or Unix, type `man enscript')
2821 (list :tag
"PS File Utility"
2822 (symbol :tag
"Utility Symbol")
2823 (string :tag
"Utility Name")
2824 (repeat :tag
"Must Utility Switches"
2825 (sexp :tag
"Switch" :value
""))
2826 (choice :menu-tag
"Paper Size"
2828 (const :tag
"No Paper Size" nil
)
2829 (string :tag
"Paper Size Format"))
2830 (choice :menu-tag
"N-Up"
2832 (const :tag
"No N-Up" nil
)
2833 (string :tag
"N-Up Format"))
2834 (choice :menu-tag
"Landscape"
2836 (const :tag
"No Landscape" nil
)
2837 (string :tag
"Landscape Switch"))
2838 (choice :menu-tag
"Duplex"
2840 (const :tag
"No Duplex" nil
)
2841 (string :tag
"Duplex Switch"))
2842 (choice :menu-tag
"Tumble"
2844 (const :tag
"No Tumble" nil
)
2845 (string :tag
"Tumble Switch"))
2846 (string :tag
"Output Separator")
2847 (repeat :tag
"Utility Switches"
2848 (sexp :tag
"Switch" :value
""))
2850 :tag
"Default Value List"
2855 :menu-tag
"Variable"
2857 (const :tag
"PS File Landscape" pr-file-landscape
)
2858 (const :tag
"PS File Duplex" pr-file-duplex
)
2859 (const :tag
"PS File Tumble" pr-file-tumble
)
2860 (const :tag
"Ghostscript Device" pr-gs-device
)
2861 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2862 (const :tag
"inherits-from:" inherits-from
:)
2863 (variable :tag
"Other"))
2864 (sexp :tag
"Value")))
2866 :set
'pr-alist-custom-set
2870 (defcustom pr-menu-lock t
2871 "Non-nil means menu is locked while selecting toggle options.
2873 See also `pr-menu-char-height' and `pr-menu-char-width'."
2878 (defcustom pr-menu-char-height
(pr-menu-char-height)
2879 "Specify menu char height in pixels.
2881 This variable is used to guess which vertical position should be locked the
2882 menu, so don't forget to adjust it if menu position is not ok.
2884 See also `pr-menu-lock' and `pr-menu-char-width'."
2889 (defcustom pr-menu-char-width
(pr-menu-char-width)
2890 "Specify menu char width in pixels.
2892 This variable is used to guess which horizontal position should be locked the
2893 menu, so don't forget to adjust it if menu position is not ok.
2895 See also `pr-menu-lock' and `pr-menu-char-height'."
2900 (defcustom pr-setting-database
2901 '((no-duplex ; setting symbol name
2902 nil nil nil
; inherits local kill-local
2903 (pr-file-duplex . nil
) ; settings
2904 (pr-file-tumble . nil
))
2906 "Specify an alist for settings in general.
2908 The elements have the following form:
2910 (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...)
2914 SYMBOL It's a symbol to identify the setting group.
2916 INHERITS Specify the inheritance for SYMBOL group. It's a symbol name
2917 setting from which the current setting inherits the context.
2918 If INHERITS is nil, means that there is no inheritance.
2919 This is a simple inheritance mechanism.
2921 Let's see an example to illustrate the inheritance mechanism:
2923 (setq pr-setting-database
2924 '((no-duplex ; setting symbol name
2926 nil nil ; local kill-local
2927 (pr-file-duplex . nil) ; settings
2928 (pr-file-tumble . nil)
2930 (no-duplex-and-landscape ; setting symbol name
2931 no-duplex ; inherits
2932 nil nil ; local kill-local
2933 (pr-file-landscape . nil) ; settings
2936 The example above has two setting groups: no-duplex and
2937 no-duplex-and-landscape. When setting no-duplex is activated
2938 through `inherits-from:' (see option `pr-ps-utility',
2939 `pr-mode-alist' and `pr-ps-printer-alist'), the variables
2940 pr-file-duplex and pr-file-tumble are both set to nil.
2942 Now when setting no-duplex-and-landscape is activated through
2943 `inherits-from:', the variable pr-file-landscape is set to nil
2944 and also the settings for no-duplex are done, because
2945 no-duplex-and-landscape inherits settings from no-duplex.
2947 Take care with circular inheritance. It's an error if circular
2948 inheritance happens.
2950 LOCAL Non-nil means that all settings for SYMBOL group will be
2951 declared local buffer.
2953 KILL-LOCAL Non-nil means that all settings for SYMBOL group will be
2954 killed at end. It has effect only when LOCAL is non-nil.
2956 SETTING It's a cons like:
2960 Which associates VARIABLE with VALUE. When this entry is
2961 selected, it's executed the following command:
2963 * If LOCAL is non-nil:
2964 (set (make-local-variable VARIABLE) (eval VALUE))
2967 (set VARIABLE (eval VALUE))
2969 Note that VALUE can be any valid lisp expression. So, don't
2970 forget to quote symbols and constant lists.
2971 This setting is ignored if VARIABLE is equal to keyword
2974 '(ps-landscape-mode . nil)
2975 '(ps-spool-duplex . t)
2976 '(pr-gs-device . (my-gs-device t))"
2980 (symbol :tag
"Setting Name")
2981 (choice :menu-tag
"Inheritance"
2983 (const :tag
"No Inheritance" nil
)
2984 (symbol :tag
"Inherits From"))
2985 (boolean :tag
"Local Buffer Setting")
2986 (boolean :tag
"Kill Local Variable At End")
2993 :menu-tag
"Variable"
2995 (const :tag
"Landscape" ps-landscape-mode
)
2996 (const :tag
"Print Header" ps-print-header
)
2997 (const :tag
"Print Header Frame" ps-print-header-frame
)
2998 (const :tag
"Line Number" ps-line-number
)
2999 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
3000 (const :tag
"Duplex" ps-spool-duplex
)
3001 (const :tag
"Tumble" ps-spool-tumble
)
3002 (const :tag
"Upside-Down" ps-print-upside-down
)
3003 (const :tag
"PS File Landscape" pr-file-landscape
)
3004 (const :tag
"PS File Duplex" pr-file-duplex
)
3005 (const :tag
"PS File Tumble" pr-file-tumble
)
3006 (const :tag
"Auto Region" pr-auto-region
)
3007 (const :tag
"Auto Mode" pr-auto-mode
)
3008 (const :tag
"Ghostscript Device" pr-gs-device
)
3009 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
3010 (variable :tag
"Other"))
3011 (sexp :tag
"Value")))
3016 (defcustom pr-visible-entry-list
3017 '(postscript text postscript-options postscript-process printing help
)
3018 "Specify a list of Printing menu visible entries.
3020 Valid values with the corresponding menu parts are:
3022 +------------------------------+
3023 | Printing Interface |
3024 +------------------------------+
3025 `postscript' | PostScript Preview >|
3026 | PostScript Print >|
3027 | PostScript Printer: name >|
3028 +------------------------------+
3029 `text' | Printify >|
3031 | Text Printer: name >|
3032 +------------------------------+
3033 `postscript-options' |[ ] Landscape |
3035 |[ ] Print Header Frame |
3037 |[ ] Zebra Stripes |
3041 | Print All Pages >|
3042 +------------------------------+
3043 `postscript-process' |[ ] Spool Buffer |
3044 |[ ] Print with faces |
3045 |[ ] Print via Ghostscript |
3046 +------------------------------+
3047 `printing' |[ ] Auto Region |
3050 +------------------------------+
3051 `help' | Customize >|
3054 +------------------------------+
3056 Any other value is ignored."
3057 :type
'(repeat :tag
"Menu Visible Part"
3058 (choice :menu-tag
"Menu Part"
3062 (const postscript-options
)
3063 (const postscript-process
)
3069 (defcustom pr-delete-temp-file t
3070 "Non-nil means delete temporary files.
3072 Set `pr-delete-temp-file' to nil, if the following message (or a similar)
3073 happens when printing:
3075 Error: could not open \"c:\\temp\\prspool.ps\" for reading."
3080 (defcustom pr-list-directory nil
3081 "Non-nil means list directory when processing a directory.
3083 That is, any subdirectories (and the superdirectory) of the directory (given as
3084 argument of functions below) are also printed (as dired-mode listings).
3086 It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
3087 `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
3088 and `pr-txt-directory'."
3093 (defcustom pr-buffer-name
"*Printing Interface*"
3094 "Specify the name of the buffer interface for printing package.
3096 It's used by `pr-interface'."
3101 (defcustom pr-buffer-name-ignore
3102 (list (regexp-quote pr-buffer-name
) ; ignore printing interface buffer
3103 "^ .*$") ; ignore invisible buffers
3104 "Specify a regexp list for buffer names to be ignored in interface buffer.
3106 NOTE: Case is important for matching, that is, `case-fold-search' is always
3109 It's used by `pr-interface'."
3110 :type
'(repeat (regexp :tag
"Buffer Name Regexp"))
3114 (defcustom pr-buffer-verbose t
3115 "Non-nil means to be verbose when editing a field in interface buffer.
3117 It's used by `pr-interface'."
3122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3123 ;; Internal Variables
3126 (defvar pr-txt-command nil
3127 "Name of program for printing a text file.
3128 See `pr-txt-printer-alist'.")
3131 (defvar pr-txt-switches nil
3132 "List of sexp's to pass as extra options to the text printer program.
3133 See `pr-txt-printer-alist'.")
3136 (defvar pr-txt-printer nil
3137 "Specify text printer name.
3138 See `pr-txt-printer-alist'.")
3141 (defvar pr-ps-command nil
3142 "Name of program for printing a PostScript file.
3143 See `pr-ps-printer-alist'.")
3146 (defvar pr-ps-switches nil
3147 "List of sexp's to pass as extra options to the PostScript printer program.
3148 See `pr-ps-printer-alist'.")
3151 (defvar pr-ps-printer-switch nil
3152 "Specify PostScript printer name switch.
3153 See `pr-ps-printer-alist'.")
3156 (defvar pr-ps-printer nil
3157 "Specify PostScript printer name.
3158 See `pr-ps-printer-alist'.")
3161 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3165 (defmacro pr-save-file-modes
(&rest body
)
3166 "Set temporally file modes to `pr-file-modes'."
3167 `(let ((pr--default-file-modes (default-file-modes))) ; save default
3168 (set-default-file-modes pr-file-modes
)
3170 (set-default-file-modes pr--default-file-modes
))) ; restore default
3173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3177 (defsubst pr-visible-p
(key)
3178 (memq key pr-visible-entry-list
))
3181 (defsubst pr-mode-alist-p
()
3182 (cdr (assq major-mode pr-mode-alist
)))
3185 (defsubst pr-auto-mode-p
()
3186 (and pr-auto-mode
(pr-mode-alist-p)))
3189 (defsubst pr-using-ghostscript-p
()
3190 (and pr-print-using-ghostscript
(not pr-spool-p
)))
3193 (defalias 'pr-get-symbol
3194 (if (fboundp 'easy-menu-intern
) ; hacked from easymenu.el
3196 (lambda (s) (if (stringp s
) (intern s
) s
))))
3199 (defconst pr-menu-spec
3201 ;; unfortunately XEmacs doesn't support :active for submenus,
3203 ;; So, it uses :included instead of :active.
3204 ;; Also, XEmacs doesn't support :help tag.
3205 (let ((pr-:active
(if (featurep 'xemacs
)
3207 :active
)) ; GNU Emacs
3208 (pr-:help
(if (featurep 'xemacs
)
3210 #'(lambda (text) (list :help text
))))) ; GNU Emacs
3212 ["Printing Interface" pr-interface
3214 pr-
:help
"Use buffer interface instead of menu interface")]
3216 ("PostScript Preview" :included
(pr-visible-p 'postscript
)
3218 pr-
:help
"Preview PostScript instead of sending to printer")
3219 ("Directory" ,pr-
:active
(not pr-spool-p
)
3220 ["1-up" (pr-ps-directory-preview 1 nil nil t
) t
]
3221 ["2-up" (pr-ps-directory-preview 2 nil nil t
) t
]
3222 ["4-up" (pr-ps-directory-preview 4 nil nil t
) t
]
3223 ["Other..." (pr-ps-directory-preview nil nil nil t
)
3224 :keys
"\\[pr-ps-buffer-preview]"])
3225 ("Buffer" ,pr-
:active
(not pr-spool-p
)
3226 ["1-up" (pr-ps-buffer-preview 1 t
) t
]
3227 ["2-up" (pr-ps-buffer-preview 2 t
) t
]
3228 ["4-up" (pr-ps-buffer-preview 4 t
) t
]
3229 ["Other..." (pr-ps-buffer-preview nil t
)
3230 :keys
"\\[pr-ps-buffer-preview]"])
3231 ("Region" ,pr-
:active
(and (not pr-spool-p
) (ps-mark-active-p))
3232 ["1-up" (pr-ps-region-preview 1 t
) t
]
3233 ["2-up" (pr-ps-region-preview 2 t
) t
]
3234 ["4-up" (pr-ps-region-preview 4 t
) t
]
3235 ["Other..." (pr-ps-region-preview nil t
)
3236 :keys
"\\[pr-ps-region-preview]"])
3237 ("Mode" ,pr-
:active
(and (not pr-spool-p
) (pr-mode-alist-p))
3238 ["1-up" (pr-ps-mode-preview 1 t
) t
]
3239 ["2-up" (pr-ps-mode-preview 2 t
) t
]
3240 ["4-up" (pr-ps-mode-preview 4 t
) t
]
3241 ["Other..." (pr-ps-mode-preview nil t
)
3242 :keys
"\\[pr-ps-mode-preview]"])
3244 ["No Preprocessing..." (call-interactively 'pr-ps-file-preview
)
3245 :keys
"\\[pr-ps-file-preview]"
3247 pr-
:help
"Preview PostScript file")]
3249 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
3251 pr-
:help
"Select PostScript utility")]
3253 ["1-up..." (pr-ps-file-up-preview 1 t t
) pr-ps-utility-alist
]
3254 ["2-up..." (pr-ps-file-up-preview 2 t t
) pr-ps-utility-alist
]
3255 ["4-up..." (pr-ps-file-up-preview 4 t t
) pr-ps-utility-alist
]
3256 ["Other..." (pr-ps-file-up-preview nil t t
)
3257 :keys
"\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist
]
3259 ["Landscape" pr-toggle-file-landscape-menu
3260 :style toggle
:selected pr-file-landscape
3262 pr-
:help
"Toggle landscape for PostScript file")
3263 :active pr-ps-utility-alist
]
3264 ["Duplex" pr-toggle-file-duplex-menu
3265 :style toggle
:selected pr-file-duplex
3267 pr-
:help
"Toggle duplex for PostScript file")
3268 :active pr-ps-utility-alist
]
3269 ["Tumble" pr-toggle-file-tumble-menu
3270 :style toggle
:selected pr-file-tumble
3272 pr-
:help
"Toggle tumble for PostScript file")
3273 :active
(and pr-file-duplex pr-ps-utility-alist
)])
3274 ["Despool..." (call-interactively 'pr-despool-preview
)
3275 :active pr-spool-p
:keys
"\\[pr-despool-preview]"
3277 pr-
:help
"Despool PostScript buffer to printer or file (C-u)")])
3278 ("PostScript Print" :included
(pr-visible-p 'postscript
)
3280 pr-
:help
"Send PostScript to printer or file (C-u)")
3282 ["1-up" (pr-ps-directory-ps-print 1 nil nil t
) t
]
3283 ["2-up" (pr-ps-directory-ps-print 2 nil nil t
) t
]
3284 ["4-up" (pr-ps-directory-ps-print 4 nil nil t
) t
]
3285 ["Other..." (pr-ps-directory-ps-print nil nil nil t
)
3286 :keys
"\\[pr-ps-buffer-ps-print]"])
3288 ["1-up" (pr-ps-buffer-ps-print 1 t
) t
]
3289 ["2-up" (pr-ps-buffer-ps-print 2 t
) t
]
3290 ["4-up" (pr-ps-buffer-ps-print 4 t
) t
]
3291 ["Other..." (pr-ps-buffer-ps-print nil t
)
3292 :keys
"\\[pr-ps-buffer-ps-print]"])
3293 ("Region" ,pr-
:active
(ps-mark-active-p)
3294 ["1-up" (pr-ps-region-ps-print 1 t
) t
]
3295 ["2-up" (pr-ps-region-ps-print 2 t
) t
]
3296 ["4-up" (pr-ps-region-ps-print 4 t
) t
]
3297 ["Other..." (pr-ps-region-ps-print nil t
)
3298 :keys
"\\[pr-ps-region-ps-print]"])
3299 ("Mode" ,pr-
:active
(pr-mode-alist-p)
3300 ["1-up" (pr-ps-mode-ps-print 1 t
) t
]
3301 ["2-up" (pr-ps-mode-ps-print 2 t
) t
]
3302 ["4-up" (pr-ps-mode-ps-print 4 t
) t
]
3303 ["Other..." (pr-ps-mode-ps-print nil t
)
3304 :keys
"\\[pr-ps-mode-ps-print]"])
3306 ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print
)
3307 :keys
"\\[pr-ps-file-ps-print]"
3309 pr-
:help
"Send PostScript file to printer")]
3311 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
3313 pr-
:help
"Select PostScript utility")]
3315 ["1-up..." (pr-ps-file-up-ps-print 1 t t
) pr-ps-utility-alist
]
3316 ["2-up..." (pr-ps-file-up-ps-print 2 t t
) pr-ps-utility-alist
]
3317 ["4-up..." (pr-ps-file-up-ps-print 4 t t
) pr-ps-utility-alist
]
3318 ["Other..." (pr-ps-file-up-ps-print nil t t
)
3319 :keys
"\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist
]
3321 ["Landscape" pr-toggle-file-landscape-menu
3322 :style toggle
:selected pr-file-landscape
3324 pr-
:help
"Toggle landscape for PostScript file")
3325 :active pr-ps-utility-alist
]
3326 ["Duplex" pr-toggle-file-duplex-menu
3327 :style toggle
:selected pr-file-duplex
3329 pr-
:help
"Toggle duplex for PostScript file")
3330 :active pr-ps-utility-alist
]
3331 ["Tumble" pr-toggle-file-tumble-menu
3332 :style toggle
:selected pr-file-tumble
3334 pr-
:help
"Toggle tumble for PostScript file")
3335 :active
(and pr-file-duplex pr-ps-utility-alist
)])
3336 ["Despool..." (call-interactively 'pr-despool-ps-print
)
3337 :active pr-spool-p
:keys
"\\[pr-despool-ps-print]"
3339 pr-
:help
"Despool PostScript buffer to printer or file (C-u)")])
3340 ["PostScript Printers" pr-update-menus
3341 :active pr-ps-printer-alist
:included
(pr-visible-p 'postscript
)
3343 pr-
:help
"Select PostScript printer")]
3345 ("Printify" :included
(pr-visible-p 'text
)
3348 "Replace non-printing chars with printable representations.")
3349 ["Directory" pr-printify-directory t
]
3350 ["Buffer" pr-printify-buffer t
]
3351 ["Region" pr-printify-region
(ps-mark-active-p)])
3352 ("Print" :included
(pr-visible-p 'text
)
3354 pr-
:help
"Send text to printer")
3355 ["Directory" pr-txt-directory t
]
3356 ["Buffer" pr-txt-buffer t
]
3357 ["Region" pr-txt-region
(ps-mark-active-p)]
3358 ["Mode" pr-txt-mode
(pr-mode-alist-p)])
3359 ["Text Printers" pr-update-menus
3360 :active pr-txt-printer-alist
:included
(pr-visible-p 'text
)
3362 pr-
:help
"Select text printer")]
3364 ["Landscape" pr-toggle-landscape-menu
3365 :style toggle
:selected ps-landscape-mode
3366 :included
(pr-visible-p 'postscript-options
)]
3367 ["Print Header" pr-toggle-header-menu
3368 :style toggle
:selected ps-print-header
3369 :included
(pr-visible-p 'postscript-options
)]
3370 ["Print Header Frame" pr-toggle-header-frame-menu
3371 :style toggle
:selected ps-print-header-frame
:active ps-print-header
3372 :included
(pr-visible-p 'postscript-options
)]
3373 ["Line Number" pr-toggle-line-menu
3374 :style toggle
:selected ps-line-number
3375 :included
(pr-visible-p 'postscript-options
)]
3376 ["Zebra Stripes" pr-toggle-zebra-menu
3377 :style toggle
:selected ps-zebra-stripes
3378 :included
(pr-visible-p 'postscript-options
)]
3379 ["Duplex" pr-toggle-duplex-menu
3380 :style toggle
:selected ps-spool-duplex
3381 :included
(pr-visible-p 'postscript-options
)]
3382 ["Tumble" pr-toggle-tumble-menu
3383 :style toggle
:selected ps-spool-tumble
:active ps-spool-duplex
3384 :included
(pr-visible-p 'postscript-options
)]
3385 ["Upside-Down" pr-toggle-upside-down-menu
3386 :style toggle
:selected ps-print-upside-down
3387 :included
(pr-visible-p 'postscript-options
)]
3388 ("Print All Pages" :included
(pr-visible-p 'postscript-options
)
3390 pr-
:help
"Select odd/even pages/sheets to print")
3391 ["All Pages" (pr-even-or-odd-pages nil
)
3392 :style radio
:selected
(eq ps-even-or-odd-pages nil
)]
3393 ["Even Pages" (pr-even-or-odd-pages 'even-page
)
3394 :style radio
:selected
(eq ps-even-or-odd-pages
'even-page
)]
3395 ["Odd Pages" (pr-even-or-odd-pages 'odd-page
)
3396 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-page
)]
3397 ["Even Sheets" (pr-even-or-odd-pages 'even-sheet
)
3398 :style radio
:selected
(eq ps-even-or-odd-pages
'even-sheet
)]
3399 ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet
)
3400 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-sheet
)])
3402 ["Spool Buffer" pr-toggle-spool-menu
3403 :style toggle
:selected pr-spool-p
3404 :included
(pr-visible-p 'postscript-process
)
3406 pr-
:help
"Toggle PostScript spooling")]
3407 ["Print with faces" pr-toggle-faces-menu
3408 :style toggle
:selected pr-faces-p
3409 :included
(pr-visible-p 'postscript-process
)
3411 pr-
:help
"Toggle PostScript printing with faces")]
3412 ["Print via Ghostscript" pr-toggle-ghostscript-menu
3413 :style toggle
:selected pr-print-using-ghostscript
3414 :included
(pr-visible-p 'postscript-process
)
3416 pr-
:help
"Toggle PostScript generation using ghostscript")]
3418 ["Auto Region" pr-toggle-region-menu
3419 :style toggle
:selected pr-auto-region
3420 :included
(pr-visible-p 'printing
)]
3421 ["Auto Mode" pr-toggle-mode-menu
3422 :style toggle
:selected pr-auto-mode
3423 :included
(pr-visible-p 'printing
)]
3424 ["Menu Lock" pr-toggle-lock-menu
3425 :style toggle
:selected pr-menu-lock
3426 :included
(pr-visible-p 'printing
)]
3428 ("Customize" :included
(pr-visible-p 'help
)
3429 ["printing" pr-customize t
]
3430 ["ps-print" ps-print-customize t
]
3431 ["lpr" lpr-customize t
])
3432 ("Show Settings" :included
(pr-visible-p 'help
)
3433 ["printing" pr-show-pr-setup t
]
3434 ["ps-print" pr-show-ps-setup t
]
3435 ["lpr" pr-show-lpr-setup t
])
3436 ["Help" pr-help
:active t
:included
(pr-visible-p 'help
)]
3440 (defun pr-menu-bind ()
3441 "Install `printing' menu in the menubar.
3442 This replaces the File/Print* menu entries with a File/Print sub-menu.
3443 Calls `pr-update-menus' to adjust menus."
3445 (pr-global-menubar pr-menu-spec
)
3446 (pr-update-menus t
))
3450 (let ((pr-print-key (if (featurep 'xemacs
)
3452 'print
))) ; GNU Emacs
3453 (global-set-key `[,pr-print-key
] 'pr-ps-fast-fire
)
3454 ;; Well, M-print and S-print are used because in my keyboard S-print works
3455 ;; and M-print doesn't. But M-print can work in other keyboard.
3456 (global-set-key `[(meta ,pr-print-key
)] 'pr-ps-mode-using-ghostscript
)
3457 (global-set-key `[(shift ,pr-print-key
)] 'pr-ps-mode-using-ghostscript
)
3458 ;; Well, C-print and C-M-print are used because in my keyboard C-M-print works
3459 ;; and C-print doesn't. But C-print can work in other keyboard.
3460 (global-set-key `[(control ,pr-print-key
)] 'pr-txt-fast-fire
)
3461 (global-set-key `[(control meta
,pr-print-key
)] 'pr-txt-fast-fire
))
3464 ;;; You can also use something like:
3465 ;;;(global-set-key "\C-ci" 'pr-interface)
3466 ;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print)
3467 ;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview)
3468 ;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
3469 ;;;(global-set-key "\C-crp" 'pr-ps-region-print)
3470 ;;;(global-set-key "\C-crx" 'pr-ps-region-preview)
3471 ;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
3474 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3478 (defconst pr-help-message
3479 (concat "printing.el version " pr-version
3480 " ps-print.el version " ps-print-version
3485 The `printing' menu (Tools/Printing or File/Print) has the following layout:
3487 +-----------------------------+
3488 A 0 | Printing Interface |
3489 +-----------------------------+ +-A---------+ +-B------+
3490 I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
3491 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
3492 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
3493 +-----------------------------+ |Mode >|-- B |Other...|
3494 II 4 | Printify >|-----\\ |File >|--\\ +--------+
3495 5 | Print >|---\\ | |Despool... | |
3496 6 | Text Printer: name >|-\\ | | +-----------+ |
3497 +-----------------------------+ | | | +---------+ +------------+
3498 III 7 |[ ]Landscape | | | \\-|Directory| | No Prep... | Ia
3499 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
3500 9 |[ ]Print Header Frame | | | |Region | | name >|- C
3501 10 |[ ]Line Number | | | +---------+ +------------+
3502 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
3503 12 |[ ]Duplex | | \\---|Directory| | 2-up... |
3504 13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... |
3505 14 |[ ]Upside-Down | | |Region | | Other... |
3506 15 | Print All Pages >|--\\ | |Mode | +------------+
3507 +-----------------------------+ | | +---------+ |[ ]Landscape| Id
3508 IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
3509 17 |[ ]Print with faces | | \\--|( )name A| |[ ]Tumble | If
3510 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
3511 +-----------------------------+ | |... |
3512 V 19 |[ ]Auto Region | | |(*)name |
3513 20 |[ ]Auto Mode | | |... |
3514 21 |[ ]Menu Lock | | +---------+ +--------------+
3515 +-----------------------------+ \\------------------|(*)All Pages |
3516 VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
3517 23 | Show Settings >|-------|printing| |( )Odd Pages |
3518 24 | Help | |ps-print| |( )Even Sheets|
3519 +-----------------------------+ |lpr | |( )Odd Sheets |
3520 +--------+ +--------------+
3522 See `pr-visible-entry-list' for hiding some parts of the menu.
3524 The menu has the following sections:
3528 0. You can use a buffer interface instead of menus. It looks like the
3529 customization buffer. Basically, it has the same options found in the
3530 menu and some extra options, all this on a buffer.
3532 I. PostScript printing:
3534 1. You can generate a PostScript file (if you type C-u before activating
3535 menu) or PostScript temporary file for a directory, a buffer, a region
3536 or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
3537 after file generation, ghostview is activated using the file generated
3538 as argument. This option is disabled if spooling is on (option 16).
3539 Also, if you already have a PostScript file you can preview it.
3540 Instead of previewing each buffer, region or major mode at once, you
3541 can save temporarily the PostScript code generated in a buffer and
3542 preview it later. The option `Despool...' despools the PostScript
3543 spooling buffer in a temporary file and uses ghostview to preview it.
3544 If you type C-u before choosing this option, the PostScript code
3545 generated is saved in a file instead of saving in a temporary file. To
3546 spool the PostScript code generated you need to turn on the option 16.
3547 The option `Despool...' is enabled if spooling is on (option 16).
3549 NOTE 1: It's possible to customize a major mode printing, just declare
3550 the customization in `pr-mode-alist' and invoke some of
3551 `*-mode*' commands or select Mode option in Printing menu. An
3552 example for major mode usage is when you're using gnus (or mh,
3553 or rmail, etc.) and you're in the *Summary* buffer, if you
3554 forget to switch to the *Article* buffer before printing,
3555 you'll get a nicely formatted list of article subjects shows
3556 up at the printer. With major mode printing you don't need to
3557 switch from gnus *Summary* buffer first.
3559 NOTE 2: There are the following options for PostScript file processing:
3560 Ia. Print the file *No Preprocessing*, that is, send it
3561 directly to PostScript printer.
3562 Ib. PostScript utility processing selection.
3563 See `pr-ps-utility-alist' and `pr-setting-database' for
3565 Ic. Do n-up processing before printing.
3566 Id. Toggle on/off landscape for PostScript file processing.
3567 Ie. Toggle on/off duplex for PostScript file processing.
3568 If. Toggle on/off tumble for PostScript file processing.
3570 NOTE 3: Don't forget to download and install the utilities declared on
3571 `pr-ps-utility-alist'.
3573 2. Operate the same way as option 1, but it sends directly the PostScript
3574 code (or put in a file, if you've typed C-u) or it uses ghostscript to
3575 print the PostScript file generated. It depends on option 18, if it's
3576 turned on, it uses ghostscript; otherwise, it sends directly to
3577 printer. If spooling is on (option 16), the PostScript code is saved
3578 temporarily in a buffer instead of printing it or saving it in a file.
3579 Also, if you already have a PostScript file you can print it.
3580 Instead of printing each buffer, region or major mode at once, you can
3581 save temporarily the PostScript code generated in a buffer and print it
3582 later. The option `Despool...' despools the PostScript spooling buffer
3583 directly on a printer. If you type C-u before choosing this option,
3584 the PostScript code generated is saved in a file instead of sending it to
3585 the printer. To spool the PostScript code generated you need to turn on
3586 option 16. This option is enabled if spooling is on (option 16).
3587 See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
3589 3. You can select a new PostScript printer to send PostScript code
3590 generated. For selection it's used all PostScript printers defined
3591 in `pr-ps-printer-alist' variable (see it for documentation).
3592 See also `pr-setting-database'.
3596 4. If you have control characters (character code from \\000 to \\037) in a
3597 buffer and you want to print them in a text printer, select this
3598 option. All control characters in your buffer or region will be
3599 replaced by a printable representation. The printable representations
3600 use ^ (for ASCII control characters) or hex. The characters tab,
3601 linefeed, space, return and formfeed are not affected.
3602 You don't need to select this option if you use any option of section
3603 I, the PostScript engine treats control characters properly.
3605 5. If you want to print a directory, buffer, region or major mode in a
3606 text printer, select this option. See also the NOTE 1 on option 1.
3608 6. You can select a new text printer to send text generated. For
3609 selection it's used all text printers defined in `pr-txt-printer-alist'
3610 variable (see it for documentation).
3611 See also `pr-setting-database'.
3613 III. PostScript page toggle options:
3615 7. If you want a PostScript landscape printing, turn on this option.
3617 8. If you want to have a header in each page in your PostScript code,
3618 turn on this option.
3620 9. If you want to draw a gaudy frame around the header, turn on this
3621 option. This option is enabled if print header is on (option 8).
3623 10. If you want that the line number is printed in your PostScript code,
3624 turn on this option.
3626 11. If you want background zebra stripes in your PostScript code, turn on
3629 12. If you want a duplex printing and your PostScript printer has this
3630 feature, turn on this option.
3632 13. If you turned on duplex printing, you can choose if you want to have a
3633 printing suitable for binding on the left or right (tumble off), or to
3634 have a printing suitable for binding at top or bottom (tumble on).
3635 This option is enabled if duplex is on (option 12).
3637 14. If you want a PostScript upside-down printing, turn on this option.
3639 15. With this option, you can choose if you want to print all pages, odd
3640 pages, even pages, odd sheets or even sheets.
3641 See also `ps-even-or-odd-pages'.
3643 IV. PostScript processing toggle options:
3645 16. If you want to spool the PostScript code generated, turn on this
3646 option. To spool the PostScript code generated use option 2. You can
3647 despool later by choosing option 1 or 2, sub-option `Despool...'.
3649 17. If you use colors in your buffers and want to see these colors on your
3650 PostScript code generated, turn on this option. If you have a
3651 black/white PostScript printer, these colors are displayed in gray
3652 scale by PostScript printer interpreter.
3654 18. If you don't have a PostScript printer to send PostScript files, turn
3655 on this option. When this option is on, the ghostscript is used to
3656 print PostScript files. In GNU or Unix system, if ghostscript is set
3657 as a PostScript filter, you don't need to turn on this option.
3659 V. Printing customization:
3661 19. If you want that region is automagically detected, turn on this
3662 option. Note that this will only work if you're using transient mark
3663 mode. When this option is on, the `*-buffer*' commands will behave
3664 like `*-region*' commands, that is, `*-buffer*' commands will print
3665 only the region marked instead of all buffer.
3667 20. Turn this option on if you want that when current major-mode is
3668 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3669 behave like `*-mode*' commands.
3671 21. If you want that Printing menu stays open while you are setting
3672 toggle options, turn on this option. The variables
3673 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3674 menu position, so don't forget to adjust these variables if menu
3679 22. Besides all options in section III, IV and V, you can customize much
3680 more PostScript options in `ps-print' option. Or you can customize
3681 some `lpr' options for text printing. Or customize `printing'
3684 23. Show current settings for `printing', `ps-print' or `lpr'.
3686 24. Quick help for printing menu layout.
3688 "Printing help message.")
3691 (defconst pr-interface-help-message
3692 (concat "printing.el version " pr-version
3693 " ps-print.el version " ps-print-version
3695 The printing interface buffer has the same functionality as the printing menu.
3696 The major difference is that the states (like sending PostScript generated to a
3697 file, n-up printing, etc.) are set and saved between printing buffer
3698 activation. Also, the landscape, duplex and tumble values are the same for
3699 PostScript file and directory/buffer/region/mode processing; using menu, there
3700 are different value sets for PostScript file and directory/buffer/region/mode
3703 The printing interface buffer has the following sections:
3707 Here you can choose to print/preview a buffer, a directory or a PostScript
3713 Select a buffer from the current buffer list.
3716 If it's on, this means that the selected buffer has an active region,
3717 so you can turn on/off, as you wish.
3718 If it's off when a buffer is selected, this means that the selected
3719 buffer has no active region, so it'll not be possible to turn it on.
3720 If you want to process the region, let this option on.
3721 If you want to process the whole buffer, let this option off.
3724 If it's on, this means that the selected buffer major mode is declared
3725 for major mode processing, so you can turn on/off, as you wish.
3726 If it's off when a buffer is selected, this means that the selected
3727 buffer major mode isn't declared for major mode processing, so it'll
3728 not be possible to turn it on.
3729 If you want the major mode processing, let this option on.
3730 If you don't want the major mode processing, let this option off.
3732 NOTE 1: It's possible to customize a major mode printing, just declare
3733 the customization in `pr-mode-alist' and invoke some of
3734 `*-mode*' commands or select Mode option in Printing menu. An
3735 example for major mode usage is when you're using gnus (or mh,
3736 or rmail, etc.) and you're in the *Summary* buffer, if you
3737 forget to switch to the *Article* buffer before printing,
3738 you'll get a nicely formatted list of article subjects shows
3739 up at the printer. With major mode printing you don't need to
3740 switch from gnus *Summary* buffer first.
3745 Specify a valid directory path.
3748 Specify a file name regexp. All file names in the directory that
3749 match with regexp will be printed/previewed. An empty file name
3750 regexp means to print/preview all files in the directory.
3752 * List Directory Entry:
3753 If it's turned on, list directory entries besides file entries.
3755 1c. PostScript file:
3758 Specify an existent PostScript file to print/preview.
3760 * PostScript Utility:
3761 Select a PostScript utility.
3762 See `pr-ps-utility-alist' and `pr-setting-database' for documentation.
3764 NOTE 2: Don't forget to download and install the utilities declared on
3765 `pr-ps-utility-alist'.
3768 If it's turned on, don't use the PostScript utility to preprocess the
3769 PostScript file before printing/previewing.
3771 2. PostScript printer:
3773 * PostScript Printer:
3774 You can select a new PostScript printer to send PostScript code
3775 generated. For selection it's used all PostScript printers defined
3776 in `pr-ps-printer-alist' variable (see it for documentation).
3777 See also `pr-setting-database'.
3780 If spooling is on, you can turn it on/off, as you wish.
3781 If spooling is off, it'll not be possible to turn it on.
3782 If it's turned on, specify to despools the PostScript spooling buffer in
3783 a temporary file or in the selected PostScript file when
3784 printing/previewing.
3787 Preview the PostScript generated.
3790 Print the PostScript generated.
3793 Quit from printing interface buffer.
3795 * Send to Printer/Temporary File:
3796 If it's turned on, the PostScript generated is sent directly to
3797 PostScript printer or, for previewing, to a temporary file.
3800 Specify a file name to send the PostScript generated.
3803 Specify n-up printing.
3808 Select a new text printer to send text generated. For selection it's used
3809 all text printers defined in `pr-txt-printer-alist' variable (see it for
3810 documentation). See also `pr-setting-database'.
3813 If you have control characters (character code from \\000 to \\037) in a
3814 buffer and you want to print them in a text printer, select this
3815 option. All control characters in your buffer or region will be
3816 replaced by a printable representation. The printable representations
3817 use ^ (for ASCII control characters) or hex. The characters tab,
3818 linefeed, space, return and formfeed are not affected.
3819 You don't need to select this option if you use any option of section
3820 I, the PostScript engine treats control characters properly.
3823 To print a directory, buffer, region or major mode in a
3824 text printer, select this option. See also the NOTE 1 on section 1.
3827 Quit from printing interface buffer.
3831 There are 3 setting columns:
3833 4a. First column (left column):
3836 PostScript landscape printing.
3839 To have a header in each page in your PostScript code.
3841 * Print Header Frame:
3842 To draw a gaudy frame around the header.
3845 The line number is printed in your PostScript code.
3848 Background zebra stripes in your PostScript code.
3851 Duplex printing (if your PostScript printer has this feature).
3854 If duplex printing is on, you can choose if you want to have a
3855 printing suitable for binding on the left or right (tumble off), or to
3856 have a printing suitable for binding at top or bottom (tumble on).
3859 PostScript upside-down printing.
3861 4b. Second column (middle column):
3864 If you want that region is automagically detected, turn on this
3865 option. Note that this will only work if you're using transient mark
3866 mode. When this option is on, the `*-buffer*' commands will behave
3867 like `*-region*' commands, that is, `*-buffer*' commands will print
3868 only the region marked instead of all buffer.
3871 Turn this option on if you want that when current major-mode is
3872 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3873 behave like `*-mode*' commands.
3876 If you want that Printing menu stays open while you are setting
3877 toggle options, turn on this option. The variables
3878 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3879 menu position, so don't forget to adjust these variables if menu
3883 To spool the PostScript code generated. You can despool later by
3884 setting Despool option on PostScript printer section.
3887 If you use colors in your buffers and want to see these colors on your
3888 PostScript code generated, turn on this option. If you have a
3889 black/white PostScript printer, these colors are displayed in gray
3890 scale by PostScript printer interpreter.
3892 * Print via Ghostscript:
3893 If you don't have a PostScript printer to send PostScript files, turn
3894 on this option. When this option is on, the ghostscript is used to
3895 print PostScript files. In GNU or Unix system, if ghostscript is set
3896 as a PostScript filter, you don't need to turn on this option.
3899 To print all pages, odd pages, even pages, odd sheets or even sheets.
3900 See also `ps-even-or-odd-pages'.
3902 4c. Third column (right column):
3905 That is, to be verbose when editing a field in interface buffer.
3909 Besides all options in section 4, you can customize much more PostScript
3910 options in `ps-print' option. Or you can customize some `lpr' options for
3911 text printing. Or customize `printing' options.
3915 Show current settings for `printing', `ps-print' or `lpr'.
3919 Quick help for printing interface buffer and printing menu layout. You can
3920 also quit the printing interface buffer or kill all printing help buffer.
3922 "Printing buffer interface help message.")
3925 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3930 (defun pr-interface (&optional buffer
)
3931 "Activate the printing interface buffer.
3933 If BUFFER is nil, the current buffer is used for printing.
3935 For more information, type \\[pr-interface-help]."
3937 (with-current-buffer (or buffer
(current-buffer))
3938 (pr-create-interface)))
3942 (defun pr-ps-directory-preview (n-up dir file-regexp
&optional filename
)
3943 "Preview directory using ghostview.
3945 Interactively, the command prompts for N-UP printing number, a directory, a
3946 file name regexp for matching and, when you use a prefix argument (C-u), the
3947 command prompts the user for a file name, and saves the PostScript image in
3948 that file instead of saving it in a temporary file.
3950 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3951 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3952 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3953 save the image in a temporary file. If FILENAME is a string, save the
3954 PostScript image in a file with that name. If FILENAME is t, prompts for a
3957 See also documentation for `pr-list-directory'."
3958 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir")))
3959 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
3960 (pr-prompt "PS preview dir"))
3961 (setq filename
(pr-ps-file filename
))
3962 (pr-ps-file-list n-up dir file-regexp filename
)
3964 (pr-ps-file-preview filename
)))
3968 (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp
&optional filename
)
3969 "Print directory using PostScript through ghostscript.
3971 Interactively, the command prompts for N-UP printing number, a directory, a
3972 file name regexp for matching and, when you use a prefix argument (C-u), the
3973 command prompts the user for a file name, and saves the PostScript image in
3974 that file instead of saving it in a temporary file.
3976 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3977 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3978 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3979 save the image in a temporary file. If FILENAME is a string, save the
3980 PostScript image in a file with that name. If FILENAME is t, prompts for a
3983 See also documentation for `pr-list-directory'."
3984 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS")))
3985 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
3986 (pr-prompt "PS print dir GS"))
3987 (let ((file (pr-ps-file filename
)))
3988 (pr-ps-file-list n-up dir file-regexp file
)
3989 (pr-ps-file-using-ghostscript file
)
3990 (or filename
(pr-delete-file file
))))
3994 (defun pr-ps-directory-print (n-up dir file-regexp
&optional filename
)
3995 "Print directory using PostScript printer.
3997 Interactively, the command prompts for N-UP printing number, a directory, a
3998 file name regexp for matching and, when you use a prefix argument (C-u), the
3999 command prompts the user for a file name, and saves the PostScript image in
4000 that file instead of saving it in a temporary file.
4002 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
4003 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
4004 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
4005 save the image in a temporary file. If FILENAME is a string, save the
4006 PostScript image in a file with that name. If FILENAME is t, prompts for a
4009 See also documentation for `pr-list-directory'."
4010 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir")))
4011 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
4012 (pr-prompt "PS print dir"))
4013 (let ((file (pr-ps-file filename
)))
4014 (pr-ps-file-list n-up dir file-regexp file
)
4015 (pr-ps-file-print file
)
4016 (or filename
(pr-delete-file file
))))
4020 (defun pr-ps-directory-ps-print (n-up dir file-regexp
&optional filename
)
4021 "Print directory using PostScript printer or through ghostscript.
4023 It depends on `pr-print-using-ghostscript'.
4025 Interactively, the command prompts for N-UP printing number, a directory, a
4026 file name regexp for matching and, when you use a prefix argument (C-u), the
4027 command prompts the user for a file name, and saves the PostScript image in
4028 that file instead of saving it in a temporary file.
4030 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
4031 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
4032 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
4033 save the image in a temporary file. If FILENAME is a string, save the
4034 PostScript image in a file with that name. If FILENAME is t, prompts for a
4037 See also documentation for `pr-list-directory'."
4038 (interactive (pr-interactive-ps-dir-args
4039 (pr-prompt (pr-prompt-gs "PS print dir"))))
4040 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
4041 (pr-prompt (pr-prompt-gs "PS print dir")))
4042 (if (pr-using-ghostscript-p)
4043 (pr-ps-directory-using-ghostscript n-up dir file-regexp filename
)
4044 (pr-ps-directory-print n-up dir file-regexp filename
)))
4048 (defun pr-ps-buffer-preview (n-up &optional filename
)
4049 "Preview buffer using ghostview.
4051 Interactively, the command prompts for N-UP printing number and, when you use a
4052 prefix argument (C-u), the command prompts the user for a file name, and saves
4053 the PostScript image in that file instead of saving it in a temporary file.
4055 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4056 argument FILENAME is treated as follows: if it's nil, save the image in a
4057 temporary file. If FILENAME is a string, save the PostScript image in a file
4058 with that name. If FILENAME is t, prompts for a file name."
4059 (interactive (pr-interactive-n-up-file (pr-prompt "PS preview")))
4060 (if (pr-auto-mode-p)
4061 (pr-ps-mode-preview n-up filename
)
4062 (pr-ps-preview (pr-region-active-symbol) n-up filename
4063 (pr-region-active-string "PS preview"))))
4067 (defun pr-ps-buffer-using-ghostscript (n-up &optional filename
)
4068 "Print buffer using PostScript through ghostscript.
4070 Interactively, the command prompts for N-UP printing number and, when you use a
4071 prefix argument (C-u), the command prompts the user for a file name, and saves
4072 the PostScript image in that file instead of sending it to the printer.
4074 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4075 argument FILENAME is treated as follows: if it's nil, send the image to the
4076 printer. If FILENAME is a string, save the PostScript image in a file with
4077 that name. If FILENAME is t, prompts for a file name."
4078 (interactive (pr-interactive-n-up-file (pr-prompt "PS print GS")))
4079 (if (pr-auto-mode-p)
4080 (pr-ps-mode-using-ghostscript n-up filename
)
4081 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
4082 (pr-region-active-string "PS print GS"))))
4086 (defun pr-ps-buffer-print (n-up &optional filename
)
4087 "Print buffer using PostScript printer.
4089 Interactively, the command prompts for N-UP printing number and, when you use a
4090 prefix argument (C-u), the command prompts the user for a file name, and saves
4091 the PostScript image in that file instead of sending it to the printer.
4093 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4094 argument FILENAME is treated as follows: if it's nil, send the image to the
4095 printer. If FILENAME is a string, save the PostScript image in a file with
4096 that name. If FILENAME is t, prompts for a file name."
4097 (interactive (pr-interactive-n-up-file (pr-prompt "PS print")))
4098 (if (pr-auto-mode-p)
4099 (pr-ps-mode-print n-up filename
)
4100 (pr-ps-print (pr-region-active-symbol) n-up filename
4101 (pr-region-active-string "PS print"))))
4105 (defun pr-ps-buffer-ps-print (n-up &optional filename
)
4106 "Print buffer using PostScript printer or through ghostscript.
4108 It depends on `pr-print-using-ghostscript'.
4110 Interactively, the command prompts for N-UP printing number and, when you use a
4111 prefix argument (C-u), the command prompts the user for a file name, and saves
4112 the PostScript image in that file instead of sending it to the printer.
4114 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4115 argument FILENAME is treated as follows: if it's nil, send the image to the
4116 printer. If FILENAME is a string, save the PostScript image in a file with
4117 that name. If FILENAME is t, prompts for a file name."
4118 (interactive (pr-interactive-n-up-file
4119 (pr-prompt (pr-prompt-gs "PS print"))))
4120 (cond ((pr-auto-mode-p)
4121 (pr-ps-mode-ps-print n-up filename
))
4122 ((pr-using-ghostscript-p)
4123 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
4124 (pr-region-active-string "PS print GS")))
4126 (pr-ps-print (pr-region-active-symbol) n-up filename
4127 (pr-region-active-string "PS print")))))
4131 (defun pr-ps-region-preview (n-up &optional filename
)
4132 "Preview region using ghostview.
4134 See also `pr-ps-buffer-preview'."
4135 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS preview")))
4136 (if (pr-auto-mode-p)
4137 (let ((pr-auto-region t
))
4138 (pr-ps-mode-preview n-up filename
))
4139 (pr-ps-preview 'region n-up filename
"PS preview region")))
4143 (defun pr-ps-region-using-ghostscript (n-up &optional filename
)
4144 "Print region using PostScript through ghostscript.
4146 See also `pr-ps-buffer-using-ghostscript'."
4147 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print GS")))
4148 (if (pr-auto-mode-p)
4149 (let ((pr-auto-region t
))
4150 (pr-ps-mode-using-ghostscript n-up filename
))
4151 (pr-ps-using-ghostscript 'region n-up filename
"PS print GS region")))
4155 (defun pr-ps-region-print (n-up &optional filename
)
4156 "Print region using PostScript printer.
4158 See also `pr-ps-buffer-print'."
4159 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print")))
4160 (if (pr-auto-mode-p)
4161 (let ((pr-auto-region t
))
4162 (pr-ps-mode-print n-up filename
))
4163 (pr-ps-print 'region n-up filename
"PS print region")))
4167 (defun pr-ps-region-ps-print (n-up &optional filename
)
4168 "Print region using PostScript printer or through ghostscript.
4170 See also `pr-ps-buffer-ps-print'."
4171 (interactive (pr-interactive-n-up-file
4172 (pr-prompt-region (pr-prompt-gs "PS print"))))
4173 (cond ((pr-auto-mode-p)
4174 (let ((pr-auto-region t
))
4175 (pr-ps-mode-ps-print n-up filename
)))
4176 ((pr-using-ghostscript-p)
4177 (pr-ps-using-ghostscript 'region n-up filename
"PS print GS region"))
4179 (pr-ps-print 'region n-up filename
"PS print region"))))
4183 (defun pr-ps-mode-preview (n-up &optional filename
)
4184 "Preview major mode using ghostview.
4186 See also `pr-ps-buffer-preview'."
4187 (interactive (pr-interactive-n-up-file "PS preview mode"))
4188 (pr-set-n-up-and-filename 'n-up
'filename
"PS preview mode")
4189 (let ((file (pr-ps-file filename
)))
4190 (and (pr-ps-mode n-up file
)
4192 (pr-ps-file-preview file
))))
4196 (defun pr-ps-mode-using-ghostscript (n-up &optional filename
)
4197 "Print major mode using PostScript through ghostscript.
4199 See also `pr-ps-buffer-using-ghostscript'."
4200 (interactive (pr-interactive-n-up-file "PS print GS mode"))
4201 (pr-set-n-up-and-filename 'n-up
'filename
"PS print GS mode")
4202 (let ((file (pr-ps-file filename
)))
4203 (when (and (pr-ps-mode n-up file
)
4205 (pr-ps-file-using-ghostscript file
)
4206 (or filename
(pr-delete-file file
)))))
4210 (defun pr-ps-mode-print (n-up &optional filename
)
4211 "Print major mode using PostScript printer.
4213 See also `pr-ps-buffer-print'."
4214 (interactive (pr-interactive-n-up-file "PS print mode"))
4215 (pr-set-n-up-and-filename 'n-up
'filename
"PS print mode")
4216 (pr-ps-mode n-up filename
))
4220 (defun pr-ps-mode-ps-print (n-up &optional filename
)
4221 "Print major mode using PostScript or through ghostscript.
4223 See also `pr-ps-buffer-ps-print'."
4224 (interactive (pr-interactive-n-up-file (pr-prompt-gs "PS print mode")))
4225 (if (pr-using-ghostscript-p)
4226 (pr-ps-mode-using-ghostscript n-up filename
)
4227 (pr-ps-mode-print n-up filename
)))
4231 (defun pr-printify-directory (&optional dir file-regexp
)
4232 "Replace nonprinting characters in directory with printable representations.
4233 The printable representations use ^ (for ASCII control characters) or hex.
4234 The characters tab, linefeed, space, return and formfeed are not affected.
4236 Interactively, the command prompts for a directory and a file name regexp for
4239 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
4240 prompts for FILE(name)-REGEXP.
4242 See also documentation for `pr-list-directory'."
4243 (interactive (pr-interactive-dir-args "Printify dir"))
4244 (pr-set-dir-args 'dir
'file-regexp
"Printify dir")
4245 (pr-file-list dir file-regexp
'pr-printify-buffer
))
4249 (defun pr-printify-buffer ()
4250 "Replace nonprinting characters in buffer with printable representations.
4251 The printable representations use ^ (for ASCII control characters) or hex.
4252 The characters tab, linefeed, space, return and formfeed are not affected."
4254 (if (pr-region-active-p)
4255 (pr-printify-region)
4256 (printify-region (point-min) (point-max))))
4260 (defun pr-printify-region ()
4261 "Replace nonprinting characters in region with printable representations.
4262 The printable representations use ^ (for ASCII control characters) or hex.
4263 The characters tab, linefeed, space, return and formfeed are not affected."
4265 (printify-region (point) (mark)))
4269 (defun pr-txt-directory (&optional dir file-regexp
)
4270 "Print directory using text printer.
4272 Interactively, the command prompts for a directory and a file name regexp for
4275 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
4276 prompts for FILE(name)-REGEXP.
4278 See also documentation for `pr-list-directory'."
4279 (interactive (pr-interactive-dir-args "Print dir"))
4280 (pr-set-dir-args 'dir
'file-regexp
"Print dir")
4281 (pr-file-list dir file-regexp
'pr-txt-buffer
))
4285 (defun pr-txt-buffer ()
4286 "Print buffer using text printer."
4288 (cond ((pr-auto-mode-p)
4290 ((pr-region-active-p)
4293 (pr-txt-print (point-min) (point-max)))))
4297 (defun pr-txt-region ()
4298 "Print region using text printer."
4300 (if (pr-auto-mode-p)
4301 (let ((pr-auto-region t
))
4303 (pr-txt-print (point) (mark))))
4307 (defun pr-txt-mode ()
4308 "Print major mode using text printer."
4310 (let ((args (pr-mode-alist-p)))
4312 (funcall (car args
) (nthcdr 2 args
))
4314 (message "`%s' major mode not declared." major-mode
))))
4318 (defun pr-despool-preview (&optional filename
)
4319 "Preview spooled PostScript.
4321 Interactively, when you use a prefix argument (C-u), the command prompts the
4322 user for a file name, and saves the spooled PostScript image in that file
4323 instead of saving it in a temporary file.
4325 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4326 save the image in a temporary file. If FILENAME is a string, save the
4327 PostScript image in a file with that name."
4328 (interactive (list (ps-print-preprint current-prefix-arg
)))
4329 (let ((file (pr-ps-file filename
)))
4330 (when (stringp file
)
4331 (pr-despool-print file
)
4332 (pr-ps-file-preview file
))))
4336 (defun pr-despool-using-ghostscript (&optional filename
)
4337 "Print spooled PostScript using ghostscript.
4339 Interactively, when you use a prefix argument (C-u), the command prompts the
4340 user for a file name, and saves the spooled PostScript image in that file
4341 instead of sending it to the printer.
4343 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4344 send the image to the printer. If FILENAME is a string, save the PostScript
4345 image in a file with that name."
4346 (interactive (list (ps-print-preprint current-prefix-arg
)))
4347 (let ((file (pr-ps-file filename
)))
4348 (when (stringp file
)
4349 (pr-despool-print file
)
4350 (pr-ps-file-using-ghostscript file
)
4351 (or filename
(pr-delete-file file
)))))
4355 (defun pr-despool-print (&optional filename
)
4356 "Send the spooled PostScript to the printer.
4358 Interactively, when you use a prefix argument (C-u), the command prompts the
4359 user for a file name, and saves the spooled PostScript image in that file
4360 instead of sending it to the printer.
4362 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4363 send the image to the printer. If FILENAME is a string, save the PostScript
4364 image in a file with that name."
4365 (interactive (list (ps-print-preprint current-prefix-arg
)))
4367 (let ((ps-lpr-command (pr-command pr-ps-command
))
4368 (ps-lpr-switches pr-ps-switches
)
4369 (ps-printer-name-option pr-ps-printer-switch
)
4370 (ps-printer-name pr-ps-printer
))
4371 (ps-despool filename
))))
4375 (defun pr-despool-ps-print (&optional filename
)
4376 "Send the spooled PostScript to the printer or use ghostscript to print it.
4378 Interactively, when you use a prefix argument (C-u), the command prompts the
4379 user for a file name, and saves the spooled PostScript image in that file
4380 instead of sending it to the printer.
4382 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4383 send the image to the printer. If FILENAME is a string, save the PostScript
4384 image in a file with that name."
4385 (interactive (list (ps-print-preprint current-prefix-arg
)))
4386 (if pr-print-using-ghostscript
4387 (pr-despool-using-ghostscript filename
)
4388 (pr-despool-print filename
)))
4392 (defun pr-ps-file-preview (filename)
4393 "Preview PostScript file FILENAME."
4394 (interactive (list (pr-ps-infile-preprint "Preview ")))
4395 (and (stringp filename
) (file-exists-p filename
)
4396 (pr-call-process pr-gv-command filename
)))
4400 (defun pr-ps-file-up-preview (n-up ifilename
&optional ofilename
)
4401 "Preview PostScript file FILENAME."
4402 (interactive (pr-interactive-n-up-inout "PS preview"))
4403 (let ((outfile (pr-ps-utility-args 'n-up
'ifilename
'ofilename
4405 (pr-ps-utility-process n-up ifilename outfile
)
4406 (pr-ps-file-preview outfile
)))
4410 (defun pr-ps-file-using-ghostscript (filename)
4411 "Print PostScript file FILENAME using ghostscript."
4412 (interactive (list (pr-ps-infile-preprint "Print preview ")))
4413 (and (stringp filename
) (file-exists-p filename
)
4414 (let* ((file (pr-expand-file-name filename
))
4415 (tempfile (pr-dosify-file-name (make-temp-file file
))))
4417 (pr-call-process pr-gs-command
4418 (format "-sDEVICE=%s" pr-gs-device
)
4419 (format "-r%d" pr-gs-resolution
)
4420 (pr-switches-string pr-gs-switches
"pr-gs-switches")
4421 (format "-sOutputFile=\"%s\"" tempfile
)
4425 (pr-ps-file-print tempfile
)
4427 (pr-delete-file tempfile
))))
4431 (defun pr-ps-file-print (filename)
4432 "Print PostScript file FILENAME."
4433 (interactive (list (pr-ps-infile-preprint "Print ")))
4434 (and (stringp filename
) (file-exists-p filename
)
4436 (let ((file (pr-expand-file-name filename
)))
4437 (if (string= pr-ps-command
"")
4439 (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name
)))
4440 (with-current-buffer ps-spool-buffer
4442 (insert-file-contents-literally file
))
4444 ;; use `pr-ps-command' to print
4445 (apply 'pr-call-process
4447 (pr-switches-string pr-ps-switches
"pr-ps-switches")
4448 (if (string-match "cp" pr-ps-command
)
4449 ;; for "cp" (cmd in out)
4451 (concat pr-ps-printer-switch pr-ps-printer
))
4452 ;; else, for others (cmd out in)
4453 (list (concat pr-ps-printer-switch pr-ps-printer
)
4458 (defun pr-ps-file-ps-print (filename)
4459 "Send PostScript file FILENAME to printer or use ghostscript to print it."
4460 (interactive (list (pr-ps-infile-preprint
4461 (if pr-print-using-ghostscript
4464 (if pr-print-using-ghostscript
4465 (pr-ps-file-using-ghostscript filename
)
4466 (pr-ps-file-print filename
)))
4470 (defun pr-ps-file-up-ps-print (n-up ifilename
&optional ofilename
)
4471 "Process a PostScript file IFILENAME and send it to printer.
4473 Interactively, the command prompts for N-UP printing number, for an input
4474 PostScript file IFILENAME and, when you use a prefix argument (C-u), the
4475 command prompts the user for an output PostScript file name OFILENAME, and
4476 saves the PostScript image in that file instead of sending it to the printer.
4478 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4479 argument IFILENAME is treated as follows: if it's t, prompts for an input
4480 PostScript file name; otherwise, it *must* be a string that it's an input
4481 PostScript file name. The argument OFILENAME is treated as follows: if it's
4482 nil, send the image to the printer. If OFILENAME is a string, save the
4483 PostScript image in a file with that name. If OFILENAME is t, prompts for a
4485 (interactive (pr-interactive-n-up-inout
4486 (if pr-print-using-ghostscript
4489 (let ((outfile (pr-ps-utility-args 'n-up
'ifilename
'ofilename
4490 (if pr-print-using-ghostscript
4493 (pr-ps-utility-process n-up ifilename outfile
)
4495 (pr-ps-file-ps-print outfile
)
4496 (pr-delete-file outfile
))))
4500 (defun pr-toggle-file-duplex ()
4501 "Toggle duplex for PostScript file."
4503 (pr-toggle-file-duplex-menu t
))
4507 (defun pr-toggle-file-tumble ()
4508 "Toggle tumble for PostScript file.
4510 If tumble is off, produces a printing suitable for binding on the left or
4512 If tumble is on, produces a printing suitable for binding at the top or
4515 (pr-toggle-file-tumble-menu t
))
4519 (defun pr-toggle-file-landscape ()
4520 "Toggle landscape for PostScript file."
4522 (pr-toggle-file-landscape-menu t
))
4526 (defun pr-toggle-ghostscript ()
4527 "Toggle printing using ghostscript."
4529 (pr-toggle-ghostscript-menu t
))
4533 (defun pr-toggle-faces ()
4534 "Toggle printing with faces."
4536 (pr-toggle-faces-menu t
))
4540 (defun pr-toggle-spool ()
4543 (pr-toggle-spool-menu t
))
4547 (defun pr-toggle-duplex ()
4550 (pr-toggle-duplex-menu t
))
4554 (defun pr-toggle-tumble ()
4557 If tumble is off, produces a printing suitable for binding on the left or
4559 If tumble is on, produces a printing suitable for binding at the top or
4562 (pr-toggle-tumble-menu t
))
4566 (defun pr-toggle-landscape ()
4569 (pr-toggle-landscape-menu t
))
4573 (defun pr-toggle-upside-down ()
4574 "Toggle upside-down."
4576 (pr-toggle-upside-down-menu t
))
4580 (defun pr-toggle-line ()
4581 "Toggle line number."
4583 (pr-toggle-line-menu t
))
4587 (defun pr-toggle-zebra ()
4588 "Toggle zebra stripes."
4590 (pr-toggle-zebra-menu t
))
4594 (defun pr-toggle-header ()
4595 "Toggle printing header."
4597 (pr-toggle-header-menu t
))
4601 (defun pr-toggle-header-frame ()
4602 "Toggle printing header frame."
4604 (pr-toggle-header-frame-menu t
))
4608 (defun pr-toggle-lock ()
4611 (pr-toggle-lock-menu t
))
4615 (defun pr-toggle-region ()
4616 "Toggle whether the region is automagically detected."
4618 (pr-toggle-region-menu t
))
4622 (defun pr-toggle-mode ()
4625 (pr-toggle-mode-menu t
))
4629 (defun pr-customize (&rest ignore
)
4630 "Customization of the `printing' group."
4632 (customize-group 'printing
))
4636 (defun lpr-customize (&rest ignore
)
4637 "Customization of the `lpr' group."
4639 (customize-group 'lpr
))
4643 (defun pr-help (&rest ignore
)
4644 "Help for the printing package."
4646 (pr-show-setup pr-help-message
"*Printing Help*"))
4650 (defun pr-ps-name ()
4651 "Interactively select a PostScript printer."
4653 (pr-menu-set-ps-title
4654 (pr-complete-alist "PostScript printer"
4655 pr-ps-printer-alist pr-ps-name
)))
4659 (defun pr-txt-name ()
4660 "Interactively select a text printer."
4662 (pr-menu-set-txt-title
4663 (pr-complete-alist "Text printer"
4664 pr-txt-printer-alist pr-txt-name
)))
4668 (defun pr-ps-utility ()
4669 "Interactively select a PostScript utility."
4671 (pr-menu-set-utility-title
4672 (pr-complete-alist "PostScript utility"
4673 pr-ps-utility-alist pr-ps-utility
)))
4677 (defun pr-show-ps-setup (&rest ignore
)
4678 "Show current ps-print settings."
4680 (pr-show-setup (ps-setup) "*PS Setup*"))
4684 (defun pr-show-pr-setup (&rest ignore
)
4685 "Show current printing settings."
4687 (pr-show-setup (pr-setup) "*PR Setup*"))
4691 (defun pr-show-lpr-setup (&rest ignore
)
4692 "Show current lpr settings."
4694 (pr-show-setup (lpr-setup) "*LPR Setup*"))
4697 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4702 (defun pr-ps-fast-fire (n-up &optional select
)
4703 "Fast fire function for PostScript printing.
4705 If a region is active, the region will be printed instead of the whole buffer.
4706 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4707 `pr-mode-alist' will be used, that is, the current buffer or region will be
4708 printed using `pr-ps-mode-ps-print'.
4711 Interactively, you have the following situations:
4713 M-x pr-ps-fast-fire RET
4714 The command prompts the user for a N-UP value and printing will
4715 immediately be done using the current active printer.
4717 C-u M-x pr-ps-fast-fire RET
4718 C-u 0 M-x pr-ps-fast-fire RET
4719 The command prompts the user for a N-UP value and also for a current
4720 PostScript printer, then printing will immediately be done using the new
4721 current active printer.
4723 C-u 1 M-x pr-ps-fast-fire RET
4724 The command prompts the user for a N-UP value and also for a file name,
4725 and saves the PostScript image in that file instead of sending it to the
4728 C-u 2 M-x pr-ps-fast-fire RET
4729 The command prompts the user for a N-UP value, then for a current
4730 PostScript printer and, finally, for a file name. Then change the active
4731 printer to that chosen by user and saves the PostScript image in
4732 that file instead of sending it to the printer.
4735 Noninteractively, the argument N-UP should be a positive integer greater than
4736 zero and the argument SELECT is treated as follows:
4738 If it's nil, send the image to the printer.
4740 If it's a list or an integer lesser or equal to zero, the command prompts
4741 the user for a current PostScript printer, then printing will immediately
4742 be done using the new current active printer.
4744 If it's an integer equal to 1, the command prompts the user for a file name
4745 and saves the PostScript image in that file instead of sending it to the
4748 If it's an integer greater or equal to 2, the command prompts the user for a
4749 current PostScript printer and for a file name. Then change the active
4750 printer to that chosen by user and saves the PostScript image in that file
4751 instead of sending it to the printer.
4753 If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new
4754 active printer and printing will immediately be done using the new active
4757 Otherwise, send the image to the printer.
4760 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4762 (interactive (list (pr-interactive-n-up (pr-prompt-gs "PS print fast"))
4763 current-prefix-arg
))
4764 (let ((pr-auto-region t
)
4767 (cond ((null select
))
4770 ((and (symbolp select
)
4771 (assq select pr-ps-printer-alist
))
4772 (pr-menu-set-ps-title select
))
4776 (and (>= select
1) (not pr-spool-p
)
4777 (setq filename
(pr-ps-outfile-preprint
4778 (if pr-print-using-ghostscript
4781 (pr-ps-buffer-ps-print
4783 (min (max n-up
1) 100)
4784 (error "n-up must be an integer greater than zero"))
4789 (defun pr-txt-fast-fire (&optional select-printer
)
4790 "Fast fire function for text printing.
4792 If a region is active, the region will be printed instead of the whole buffer.
4793 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4794 `pr-mode-alist' will be used, that is, the current buffer or region will be
4795 printed using `pr-txt-mode'.
4797 Interactively, when you use a prefix argument (C-u), the command prompts the
4798 user for a new active text printer.
4800 Noninteractively, the argument SELECT-PRINTER is treated as follows:
4802 If it's nil, the printing is sent to the current active text printer.
4804 If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new
4805 active printer and printing will immediately be done using the new active
4808 If it's non-nil, the command prompts the user for a new active text printer.
4810 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4812 (interactive (list current-prefix-arg
))
4813 (cond ((null select-printer
))
4814 ((and (symbolp select-printer
)
4815 (assq select-printer pr-txt-printer-alist
))
4816 (pr-menu-set-txt-title select-printer
))
4819 (let ((pr-auto-region t
)
4824 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4829 "Return the current `printing' setup.
4831 This is *not* an interactive command.
4832 One way to see `printing' setup is to switch to a *Scratch* buffer and type:
4834 M-: (insert (pr-setup)) RET
4836 Or choose the menu option Printing/Show Settings/printing."
4837 (let (ps-prefix-quote)
4841 (concat "\n;;; printing.el version " pr-version
"\n")
4843 (ps-comment-string "emacs-version " emacs-version
)
4844 (ps-comment-string "pr-txt-command " pr-txt-command
)
4845 (ps-comment-string "pr-txt-switches "
4846 (pr-switches-string pr-txt-switches
"pr-txt-switches"))
4847 (ps-comment-string "pr-txt-printer " pr-txt-printer
)
4848 (ps-comment-string "pr-ps-command " pr-ps-command
)
4849 (ps-comment-string "pr-ps-switches "
4850 (pr-switches-string pr-ps-switches
"pr-ps-switches"))
4851 (ps-comment-string "pr-ps-printer-switch" pr-ps-printer-switch
)
4852 (ps-comment-string "pr-ps-printer " pr-ps-printer
)
4853 (ps-comment-string "pr-cygwin-system " pr-cygwin-system
)
4854 (ps-comment-string "ps-windows-system " ps-windows-system
)
4855 (ps-comment-string "ps-lp-system " ps-lp-system
)
4857 '(14 . pr-path-style
)
4858 '(14 . pr-path-alist
)
4861 '(21 . pr-txt-printer-alist
)
4864 '(20 . pr-ps-printer-alist
)
4867 '(20 . pr-ps-temp-file
)
4868 '(20 . pr-file-modes
)
4869 '(20 . pr-delete-temp-file
)
4870 '(20 . pr-list-directory
)
4872 '(17 . pr-gv-command
)
4873 '(17 . pr-gs-command
)
4874 '(17 . pr-gs-switches
)
4875 '(17 . pr-gs-device
)
4876 '(17 . pr-gs-resolution
)
4878 '(27 . pr-print-using-ghostscript
)
4881 '(27 . pr-file-landscape
)
4882 '(27 . pr-file-duplex
)
4883 '(27 . pr-file-tumble
)
4884 '(27 . pr-auto-region
)
4885 '(27 . pr-auto-mode
)
4887 '(20 . pr-ps-utility
)
4888 '(20 . pr-ps-utility-alist
)
4890 '(14 . pr-mode-alist
)
4892 '(20 . pr-menu-lock
)
4893 '(20 . pr-menu-char-height
)
4894 '(20 . pr-menu-char-width
)
4896 '(20 . pr-setting-database
)
4898 '(22 . pr-visible-entry-list
)
4900 '(22 . pr-buffer-verbose
)
4901 '(22 . pr-buffer-name
)
4902 '(22 . pr-buffer-name-ignore
)
4903 ")\n\n;;; printing.el - end of settings\n")
4908 "Return the current `lpr' setup.
4910 This is *not* an interactive command.
4911 One way to see `lpr' setup is to switch to a *Scratch* buffer and type:
4913 M-: (insert (lpr-setup)) RET
4915 Or choose the menu option Printing/Show Settings/lpr."
4916 (let (ps-prefix-quote)
4920 "\n;;; lpr.el settings\n"
4921 (ps-comment-string "emacs-version" emacs-version
)
4923 '(25 . printer-name
)
4924 '(25 . lpr-switches
)
4925 '(25 . lpr-add-switches
)
4927 '(25 . lpr-headers-switches
)
4928 '(25 . print-region-function
)
4929 '(25 . lpr-page-header-program
)
4930 '(25 . lpr-page-header-switches
)
4931 ")\n\n;;; lpr.el - end of settings\n")
4935 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4936 ;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>)
4938 (declare-function mh-get-msg-num
"mh-utils" (error-if-no-message))
4939 (declare-function mh-show
"mh-show" (&optional message redisplay-flag
))
4940 (declare-function mh-start-of-uncleaned-message
"mh-show" ())
4941 (defvar mh-show-buffer
)
4944 (defun pr-article-date ()
4945 "Find the date of an article or mail message in current buffer.
4946 Return only the dayname, if present, weekday, month, and year."
4948 (goto-char (point-min))
4949 (if (re-search-forward
4950 "^Date:[ \t]+\\(\\([A-Za-z]+, \\)?[0-9]+ [A-Za-z]+ [0-9]+\\)" nil t
)
4951 (buffer-substring (match-beginning 1) (match-end 1))
4952 (format-time-string "%Y/%m/%d"))))
4955 (defun pr-mh-current-message ()
4956 "Go to mh-inbox current message."
4957 (let ((msg (or (mh-get-msg-num nil
) 0)))
4959 (set-buffer mh-show-buffer
)
4960 (goto-char (point-min))
4961 (mh-start-of-uncleaned-message)
4962 (message "Printing message %d" msg
)))
4965 (defun pr-mh-print-1 (n-up filename header-list
)
4966 "Print mh-inbox current message in PostScript."
4968 (save-window-excursion
4969 (pr-mh-current-message)
4970 (pr-mode-print n-up filename header-list
(point)))))
4973 (defun pr-mh-lpr-1 (header-list)
4974 "Print mh-inbox current message in text printer."
4976 (save-window-excursion
4977 (pr-mh-current-message)
4978 (pr-mode-lpr header-list
(point)))))
4981 (defalias 'pr-mh-print-2
'pr-mode-print
)
4984 (defalias 'pr-mh-lpr-2
'pr-mode-lpr
)
4987 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4988 ;; rmail (hacked from ps-print.el)
4991 (defun pr-rmail-lpr (header-list)
4992 "Print RMAIL current message in text printer."
4993 (pr-lpr-message-from-summary header-list
4994 'rmail-buffer
'rmail-summary-buffer
))
4997 (defun pr-rmail-print (n-up filename header-list
)
4998 "Print RMAIL current message in PostScript."
4999 (pr-ps-message-from-summary n-up filename header-list
5000 'rmail-buffer
'rmail-summary-buffer
))
5003 (defun pr-ps-message-from-summary (n-up filename header-list
5004 summary-buffer summary-default
)
5005 "Print current message in PostScript."
5006 (let ((buf (or (and (boundp summary-buffer
)
5007 (symbol-value summary-buffer
))
5008 (symbol-value summary-default
))))
5009 (and (get-buffer buf
)
5010 (with-current-buffer buf
5011 (pr-mode-print n-up filename header-list
)))))
5014 (defun pr-lpr-message-from-summary (header-list summary-buffer summary-default
)
5015 "Print current message in text printer."
5016 (let ((buf (or (and (boundp summary-buffer
)
5017 (symbol-value summary-buffer
))
5018 (symbol-value summary-default
))))
5019 (and (get-buffer buf
)
5020 (with-current-buffer buf
5021 (pr-mode-lpr header-list
)))))
5024 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5025 ;; gnus (hacked from ps-print.el)
5028 (defvar pr-gnus-article
"*Article*")
5031 (defun pr-gnus-print (n-up filename header-list
)
5032 "Print *Article* current message in PostScript."
5033 (pr-ps-message-from-summary n-up filename header-list
5034 'gnus-article-buffer
'pr-gnus-article
))
5037 (defun pr-gnus-lpr (header-list)
5038 "Print *Article* current message in text printer."
5039 (pr-lpr-message-from-summary header-list
5040 'gnus-article-buffer
'pr-gnus-article
))
5043 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5044 ;; vm (hacked from ps-print.el)
5047 (defvar pr-vm-summary
"")
5050 (defun pr-vm-print (n-up filename header-list
)
5051 "Print current vm message in PostScript."
5052 (pr-ps-message-from-summary n-up filename header-list
5053 'vm-mail-buffer
'pr-vm-summary
))
5056 (defun pr-vm-lpr (header-list)
5057 "Print current vm message in text printer."
5058 (pr-lpr-message-from-summary header-list
5059 'vm-mail-buffer
'pr-vm-summary
))
5062 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5066 (defun pr-ps-mode (n-up filename
)
5067 "If current major mode is declared, print it in PostScript."
5068 (let ((args (pr-mode-alist-p)))
5070 (let ((fun (cdr args
)))
5071 (funcall (car fun
) n-up filename
(cdr fun
))
5074 (message "`%s' major mode not declared." major-mode
)
5078 (defmacro pr-local-variable
(header-list &rest body
)
5080 (let ((ps-header-lines (or (nth 0 ,header-list
) ps-header-lines
))
5081 (ps-left-header (or (nth 1 ,header-list
) ps-left-header
))
5082 (ps-right-header (or (nth 2 ,header-list
) ps-right-header
))
5084 (let ((local-var-list (pr-eval-local-alist (nthcdr 4 ,header-list
))))
5086 (and (nth 3 ,header-list
)
5087 (pr-kill-local-variable local-var-list
))))))
5090 (defun pr-mode-print (n-up filename header-list
&optional from to
)
5091 "Print current major mode in PostScript."
5094 (let ((file (pr-ps-file filename
))
5096 ((pr-region-active-p) (region-beginning))
5099 (pr-text2ps (pr-region-active-symbol start
) n-up file start
5101 ((pr-region-active-p) (region-end))
5104 (unless (or pr-spool-p filename
)
5105 (pr-ps-file-print file
)
5106 (pr-delete-file file
)))))
5109 (defun pr-mode-lpr (header-list &optional from to
)
5110 "Print current major mode in text printer."
5113 (pr-txt-print (cond (from)
5114 ((pr-region-active-p) (region-beginning))
5117 ((pr-region-active-p) (region-end))
5121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5125 (defconst pr-menu-entry-alist
5128 (postscript-options .
9)
5129 (postscript-process .
3)
5133 "Alist that associates menu part with number of items per part.
5135 It's used by `pr-menu-index'.
5137 Each element has the form:
5139 (MENU-PART . NUMBER-OF-ITEMS)
5141 See `pr-visible-entry-alist'.")
5144 (defun pr-menu-index (entry index
)
5146 (cond ((eq entry
'text
)
5148 ((eq entry
'postscript-options
)
5150 ((eq entry
'postscript-process
)
5151 '(postscript text postscript-options
))
5152 ((eq entry
'printing
)
5153 '(postscript text postscript-options postscript-process
))
5159 (setq key
(car base-list
)
5160 base-list
(cdr base-list
))
5161 (and (pr-visible-p key
)
5162 (setq index
(+ index
5163 (cdr (assq key pr-menu-entry-alist
)))))))
5167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5168 ;; Printer & Utility Selection
5171 (defun pr-update-var (var-sym alist
)
5172 (or (assq (symbol-value var-sym
) alist
)
5173 (set var-sym
(car (car alist
)))))
5176 (defun pr-update-menus (&optional force
)
5177 "Update utility, PostScript and text printer menus.
5179 If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist',
5180 `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not;
5181 otherwise, update PostScript printer menu if `pr-ps-printer-menu-modified' is
5182 non-nil, update text printer menu if `pr-txt-printer-menu-modified' is
5183 non-nil, and update PostScript File menus if `pr-ps-utility-menu-modified' is
5186 If menu binding was not done, calls `pr-menu-bind'."
5188 (if pr-menu-print-item
; since v6.8.4
5189 ;; There was no menu binding yet, so do it now!
5190 ;; This is a hack to be compatible with old versions of printing.
5191 ;; So, user does not need to change printing calling in init files.
5193 ;; Here menu binding is ok.
5194 (pr-update-var 'pr-ps-name pr-ps-printer-alist
)
5195 (pr-update-var 'pr-txt-name pr-txt-printer-alist
)
5196 (pr-update-var 'pr-ps-utility pr-ps-utility-alist
)
5197 (pr-do-update-menus force
)))
5200 (defun pr-menu-create (name alist var-sym fun entry index
)
5204 (let ((sym (car elt
)))
5207 (list fun
(list 'quote sym
) nil
(list 'quote entry
) index
)
5209 :selected
(list 'eq var-sym
(list 'quote sym
)))))
5213 (defun pr-ps-set-utility (value)
5214 (let ((item (cdr (assq value pr-ps-utility-alist
))))
5217 "Invalid PostScript utility name `%s' for variable `pr-ps-utility'"
5219 (setq pr-ps-utility value
)
5220 (pr-eval-alist (nthcdr 9 item
)))
5221 (pr-update-mode-line))
5224 (defun pr-ps-set-printer (value)
5225 (let ((ps (cdr (assq value pr-ps-printer-alist
))))
5228 "Invalid PostScript printer name `%s' for variable `pr-ps-name'"
5230 (setq pr-ps-name value
5231 pr-ps-command
(pr-dosify-file-name (nth 0 ps
))
5232 pr-ps-switches
(nth 1 ps
)
5233 pr-ps-printer-switch
(nth 2 ps
)
5234 pr-ps-printer
(nth 3 ps
))
5235 (or (stringp pr-ps-command
)
5237 (cond (ps-windows-system "print")
5241 (or (stringp pr-ps-printer-switch
)
5242 (setq pr-ps-printer-switch
5243 (cond (ps-windows-system "/D:")
5247 (pr-eval-alist (nthcdr 4 ps
)))
5248 (pr-update-mode-line))
5251 (defun pr-txt-set-printer (value)
5252 (let ((txt (cdr (assq value pr-txt-printer-alist
))))
5254 (error "Invalid text printer name `%s' for variable `pr-txt-name'"
5256 (setq pr-txt-name value
5257 pr-txt-command
(pr-dosify-file-name (nth 0 txt
))
5258 pr-txt-switches
(nth 1 txt
)
5259 pr-txt-printer
(nth 2 txt
)))
5260 (or (stringp pr-txt-command
)
5261 (setq pr-txt-command
5262 (cond (ps-windows-system "print")
5266 (pr-update-mode-line))
5269 (defun pr-eval-alist (alist)
5270 (mapcar #'(lambda (option)
5271 (let ((var-sym (car option
))
5272 (value (cdr option
)))
5273 (if (eq var-sym
'inherits-from
:)
5274 (pr-eval-setting-alist value
'global
)
5275 (set var-sym
(eval value
)))))
5279 (defun pr-eval-local-alist (alist)
5281 (mapc #'(lambda (option)
5282 (let ((var-sym (car option
))
5283 (value (cdr option
)))
5285 (if (eq var-sym
'inherits-from
:)
5286 (nconc (pr-eval-setting-alist value
) local-list
)
5287 (set (make-local-variable var-sym
) (eval value
))
5288 (cons var-sym local-list
)))))
5293 (defun pr-eval-setting-alist (key &optional global old
)
5294 (let ((setting (cdr (assq key pr-setting-database
))))
5296 (let ((inherits (nth 0 setting
))
5297 (local (nth 1 setting
))
5298 (kill (nth 2 setting
))
5303 (message "There are local buffer settings for `%S'." key
)
5306 (if (memq inherits old
)
5307 (error "Circular inheritance for `%S'" inherits
)
5309 (pr-eval-setting-alist inherits global
5310 (cons inherits old
)))))
5312 (cond ((not local
) ; global settings
5314 (let ((var-sym (car option
)))
5315 (or (eq var-sym
'inherits-from
:)
5316 (set var-sym
(eval (cdr option
)))))))
5317 (kill ; local settings with killing
5319 (let ((var-sym (car option
)))
5320 (unless (eq var-sym
'inherits-from
:)
5321 (setq local-list
(cons var-sym local-list
))
5322 (set (make-local-variable var-sym
)
5323 (eval (cdr option
)))))))
5324 (t ; local settings without killing
5326 (let ((var-sym (car option
)))
5327 (or (eq var-sym
'inherits-from
:)
5328 (set (make-local-variable var-sym
)
5329 (eval (cdr option
))))))))
5334 (defun pr-kill-local-variable (local-var-list)
5335 (mapcar 'kill-local-variable local-var-list
))
5338 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5339 ;; Internal Functions (II)
5342 (defun pr-toggle (var-sym mess entry index horizontal state
5343 &optional path no-menu
)
5344 (set var-sym
(not (symbol-value var-sym
)))
5345 (message "%s is %s" mess
(if (symbol-value var-sym
) "on" "off"))
5347 (pr-menu-lock entry index horizontal state path
)))
5350 (defun pr-toggle-file-duplex-menu (&optional no-menu
)
5351 "Toggle whether to print PostScript files in duplex mode."
5353 (pr-toggle 'pr-file-duplex
"PS file duplex" nil
7 5 nil
5354 '("PostScript Print" "File") no-menu
))
5357 (defun pr-toggle-file-tumble-menu (&optional no-menu
)
5358 "Toggle whether to print PostScript files in tumble mode."
5360 (pr-toggle 'pr-file-tumble
"PS file tumble" nil
8 5 nil
5361 '("PostScript Print" "File") no-menu
))
5364 (defun pr-toggle-file-landscape-menu (&optional no-menu
)
5365 "Toggle whether to print PostScript files in landscape orientation."
5367 (pr-toggle 'pr-file-landscape
"PS file landscape" nil
6 5 nil
5368 '("PostScript Print" "File") no-menu
))
5371 (defun pr-toggle-ghostscript-menu (&optional no-menu
)
5372 "Toggle whether to print using ghostscript."
5374 (pr-toggle 'pr-print-using-ghostscript
"Printing using ghostscript"
5375 'postscript-process
2 12 'toggle nil no-menu
))
5378 (defun pr-toggle-faces-menu (&optional no-menu
)
5379 "Toggle whether to print with face attributes."
5381 (pr-toggle 'pr-faces-p
"Printing with faces"
5382 'postscript-process
1 12 'toggle nil no-menu
))
5385 (defun pr-toggle-spool-menu (&optional no-menu
)
5386 "Toggle whether to spool printing in a buffer."
5388 (pr-toggle 'pr-spool-p
"Spooling printing"
5389 'postscript-process
0 12 'toggle nil no-menu
))
5392 (defun pr-toggle-duplex-menu (&optional no-menu
)
5393 "Toggle whether to generate PostScript for a two-sided printer."
5395 (pr-toggle 'ps-spool-duplex
"Printing duplex"
5396 'postscript-options
5 12 'toggle nil no-menu
))
5399 (defun pr-toggle-tumble-menu (&optional no-menu
)
5400 "Toggle how pages on opposite sides of a sheet are oriented."
5402 (pr-toggle 'ps-spool-tumble
"Tumble"
5403 'postscript-options
6 12 'toggle nil no-menu
))
5406 (defun pr-toggle-landscape-menu (&optional no-menu
)
5407 "Toggle whether to print in landscape mode."
5409 (pr-toggle 'ps-landscape-mode
"Landscape"
5410 'postscript-options
0 12 'toggle nil no-menu
))
5413 (defun pr-toggle-upside-down-menu (&optional no-menu
)
5414 "Toggle whether to print upside-down (that is, rotated by 180 degrees)."
5416 (pr-toggle 'ps-print-upside-down
"Upside-Down"
5417 'postscript-options
7 12 'toggle nil no-menu
))
5420 (defun pr-toggle-line-menu (&optional no-menu
)
5421 "Toggle whether to means print line numbers."
5423 (pr-toggle 'ps-line-number
"Line number"
5424 'postscript-options
3 12 'toggle nil no-menu
))
5427 (defun pr-toggle-zebra-menu (&optional no-menu
)
5428 "Toggle whether to print zebra stripes."
5430 (pr-toggle 'ps-zebra-stripes
"Zebra stripe"
5431 'postscript-options
4 12 'toggle nil no-menu
))
5434 (defun pr-toggle-header-menu (&optional no-menu
)
5435 "Toggle whether to print a header at the top of each page."
5437 (pr-toggle 'ps-print-header
"Print header"
5438 'postscript-options
1 12 'toggle nil no-menu
))
5441 (defun pr-toggle-header-frame-menu (&optional no-menu
)
5442 "Toggle whether to draw a gaudy frame around the header."
5444 (pr-toggle 'ps-print-header-frame
"Print header frame"
5445 'postscript-options
2 12 'toggle nil no-menu
))
5448 (defun pr-toggle-lock-menu (&optional no-menu
)
5449 "Toggle whether the menu is locked while selecting toggle options."
5451 (pr-toggle 'pr-menu-lock
"Menu lock"
5452 'printing
2 12 'toggle nil no-menu
))
5455 (defun pr-toggle-region-menu (&optional no-menu
)
5456 "Toggle whether the region is automagically detected."
5458 (pr-toggle 'pr-auto-region
"Auto region"
5459 'printing
0 12 'toggle nil no-menu
))
5462 (defun pr-toggle-mode-menu (&optional no-menu
)
5463 "Toggle whether major-mode specific printing is preferred over normal printing."
5465 (pr-toggle 'pr-auto-mode
"Auto mode"
5466 'printing
1 12 'toggle nil no-menu
))
5469 (defun pr-prompt (str)
5470 (if (pr-auto-mode-p)
5471 (concat str
" mode")
5472 (pr-region-active-string str
)))
5475 (defun pr-prompt-region (str)
5476 (concat str
(if (pr-auto-mode-p)
5481 (defun pr-prompt-gs (str)
5482 (if (pr-using-ghostscript-p)
5487 (defun pr-region-active-symbol (&optional region-p
)
5488 (if (or region-p
(pr-region-active-p))
5493 (defun pr-region-active-string (prefix)
5495 (if (pr-region-active-p)
5500 (defun pr-show-setup (settings buffer-name
)
5501 (with-output-to-temp-buffer buffer-name
5503 (help-print-return-message)))
5506 (defun pr-complete-alist (prompt alist default
)
5507 (let ((collection (mapcar #'(lambda (elt)
5508 (setq elt
(car elt
))
5509 (cons (symbol-name elt
) elt
))
5511 (cdr (assoc (completing-read (concat prompt
": ")
5513 (symbol-name default
) nil
5514 (symbol-name default
))
5518 (defun pr-delete-file (file)
5519 (and pr-delete-temp-file
(file-exists-p file
)
5520 (delete-file file
)))
5523 (defun pr-expand-file-name (filename)
5524 (pr-dosify-file-name (expand-file-name filename
)))
5527 (defun pr-ps-outfile-preprint (&optional mess
)
5528 (let* ((prompt (format "%soutput PostScript file name: " (or mess
"")))
5529 (res (read-file-name prompt default-directory
"" nil
)))
5530 (while (cond ((not (file-writable-p res
))
5532 (setq prompt
"is unwritable"))
5533 ((file-directory-p res
)
5535 (setq prompt
"is a directory"))
5536 ((file-exists-p res
)
5538 (setq prompt
"exists")
5539 (not (y-or-n-p (format "File `%s' exists; overwrite? "
5542 (setq res
(read-file-name
5543 (format "File %s; PostScript file: " prompt
)
5544 (file-name-directory res
) nil nil
5545 (file-name-nondirectory res
))))
5546 (pr-expand-file-name res
)))
5549 (defun pr-ps-infile-preprint (&optional mess
)
5550 (let* ((prompt (format "%sinput PostScript file name: " (or mess
"")))
5551 (res (read-file-name prompt default-directory
"" nil
)))
5552 (while (cond ((not (file-exists-p res
))
5554 (setq prompt
"doesn't exist"))
5555 ((not (file-readable-p res
))
5557 (setq prompt
"is unreadable"))
5558 ((file-directory-p res
)
5560 (setq prompt
"is a directory"))
5562 (setq res
(read-file-name
5563 (format "File %s; PostScript file: " prompt
)
5564 (file-name-directory res
) nil nil
5565 (file-name-nondirectory res
))))
5566 (pr-expand-file-name res
)))
5569 (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt
)
5570 ;; check arguments for PostScript file processing.
5572 (or (symbol-value n-up-sym
)
5573 (set n-up-sym
(pr-interactive-n-up prompt
)))
5575 (and (eq (symbol-value infile-sym
) t
)
5576 (set infile-sym
(pr-ps-infile-preprint prompt
)))
5577 (or (symbol-value infile-sym
)
5578 (error "%s: input PostScript file name is missing" prompt
))
5579 (set infile-sym
(pr-dosify-file-name (symbol-value infile-sym
)))
5581 (and (eq (symbol-value outfile-sym
) t
)
5582 (set outfile-sym
(and current-prefix-arg
5583 (pr-ps-outfile-preprint prompt
))))
5584 (and (symbol-value outfile-sym
)
5585 (set outfile-sym
(pr-dosify-file-name (symbol-value outfile-sym
))))
5586 (pr-ps-file (symbol-value outfile-sym
)))
5589 (defun pr-ps-utility-process (n-up infile outfile
)
5590 ;; activate utility to process a PostScript file.
5592 (and (stringp infile
) (file-exists-p infile
)
5593 (setq item
(cdr (assq pr-ps-utility pr-ps-utility-alist
)))
5594 (pr-call-process (nth 0 item
)
5595 (pr-switches-string (nth 1 item
)
5596 "pr-ps-utility-alist entry")
5597 (pr-switches-string (nth 8 item
)
5598 "pr-ps-utility-alist entry")
5600 (format (nth 2 item
) ps-paper-type
))
5601 (format (nth 3 item
) n-up
)
5602 (and pr-file-landscape
(nth 4 item
))
5603 (and pr-file-duplex
(nth 5 item
))
5604 (and pr-file-tumble
(nth 6 item
))
5605 (pr-expand-file-name infile
)
5607 (pr-expand-file-name outfile
)))))
5610 (defun pr-remove-nil-from-list (lst)
5611 (while (and lst
(null (car lst
)))
5612 (setq lst
(cdr lst
)))
5624 (defun pr-call-process (command &rest args
)
5625 (let ((buffer (get-buffer-create "*Printing Command Output*"))
5626 (cmd (pr-command command
))
5628 (setq args
(pr-remove-nil-from-list args
))
5629 ;; *Printing Command Output* == show command & args
5630 (with-current-buffer buffer
5631 (goto-char (point-max))
5632 (insert (format "%s %S\n" cmd args
)))
5633 ;; *Printing Command Output* == show any return message from command
5636 (condition-case data
5637 (apply 'call-process cmd nil buffer nil args
)
5639 (error-message-string data
)))))
5640 ;; *Printing Command Output* == show exit status
5641 (with-current-buffer buffer
5642 (goto-char (point-max))
5643 (insert (format "Exit status: %s\n\n" status
)))
5644 ;; message if error status
5645 (if (or (stringp status
)
5646 (and (integerp status
) (/= status
0)))
5648 "Printing error status: %s (see *Printing Command Output* buffer)"
5652 (defun pr-txt-print (from to
)
5653 (let ((lpr-command (pr-standard-file-name (pr-command pr-txt-command
)))
5654 (lpr-switches (pr-switches pr-txt-switches
"pr-txt-switches"))
5655 (printer-name pr-txt-printer
))
5656 (lpr-region from to
)))
5659 (defun pr-switches-string (switches mess
)
5660 ;; If SWITCHES is nil, return nil.
5661 ;; Otherwise, return the list of string in a string.
5663 (mapconcat 'identity
(pr-switches switches mess
) " ")))
5666 (defun pr-switches (switches mess
)
5667 (or (listp switches
)
5668 (error "%S should have a list of strings" mess
))
5669 (ps-flatten-list ; dynamic evaluation
5670 (mapcar 'ps-eval-switch switches
)))
5673 (defun pr-ps-preview (kind n-up filename mess
)
5674 (pr-set-n-up-and-filename 'n-up
'filename mess
)
5675 (let ((file (pr-ps-file filename
)))
5676 (pr-text2ps kind n-up file
)
5677 (or pr-spool-p
(pr-ps-file-preview file
))))
5680 (defun pr-ps-using-ghostscript (kind n-up filename mess
)
5681 (pr-set-n-up-and-filename 'n-up
'filename mess
)
5682 (let ((file (pr-ps-file filename
)))
5683 (pr-text2ps kind n-up file
)
5684 (unless (or pr-spool-p filename
)
5685 (pr-ps-file-using-ghostscript file
)
5686 (pr-delete-file file
))))
5689 (defun pr-ps-print (kind n-up filename mess
)
5690 (pr-set-n-up-and-filename 'n-up
'filename mess
)
5691 (let ((file (pr-ps-file filename
)))
5692 (pr-text2ps kind n-up file
)
5693 (unless (or pr-spool-p filename
)
5694 (pr-ps-file-print file
)
5695 (pr-delete-file file
))))
5698 (defun pr-ps-file (&optional filename
)
5699 (pr-dosify-file-name (or filename
5701 (convert-standard-filename
5702 (expand-file-name pr-ps-temp-file pr-temp-dir
))
5706 (defun pr-interactive-n-up (mess)
5707 (or (stringp mess
) (setq mess
"*"))
5709 (let* ((fmt-prompt "%s[%s] N-up printing (default 1): ")
5711 (str (pr-read-string (format fmt-prompt prompt mess
) "1" nil
"1"))
5713 (while (if (string-match "^\\s *[0-9]+$" str
)
5714 (setq int
(string-to-number str
)
5715 prompt
(cond ((< int
1) "Integer below 1; ")
5716 ((> int
100) "Integer above 100; ")
5718 (setq prompt
"Invalid integer syntax; "))
5721 (pr-read-string (format fmt-prompt prompt mess
) str nil
"1")))
5725 (defun pr-interactive-dir (mess)
5726 (let* ((dir-name (file-name-directory (or (buffer-file-name)
5727 default-directory
)))
5728 (fmt-prompt (concat "%s[" mess
"] Directory to print: "))
5729 (dir (read-directory-name (format fmt-prompt
"")
5730 "" dir-name nil dir-name
))
5732 (while (cond ((not (file-directory-p dir
))
5734 (setq prompt
"It's not a directory! "))
5735 ((not (file-readable-p dir
))
5737 (setq prompt
"Directory is unreadable! "))
5739 (setq dir-name
(file-name-directory dir
)
5740 dir
(read-directory-name (format fmt-prompt prompt
)
5741 "" dir-name nil dir-name
)))
5742 (file-name-as-directory dir
)))
5745 (defun pr-interactive-regexp (mess)
5746 (pr-read-string (format "[%s] File regexp to print: " mess
) "" nil
""))
5749 (defun pr-interactive-dir-args (mess)
5751 ;; get directory argument
5752 (pr-interactive-dir mess
)
5753 ;; get file name regexp
5754 (pr-interactive-regexp mess
)))
5757 (defun pr-interactive-ps-dir-args (mess)
5759 ;; get n-up argument
5760 (pr-interactive-n-up mess
)
5761 ;; get directory argument
5762 (pr-interactive-dir mess
)
5763 ;; get file name regexp
5764 (pr-interactive-regexp mess
)
5765 ;; get output file name
5766 (and (not pr-spool-p
)
5767 (ps-print-preprint current-prefix-arg
))))
5770 (defun pr-interactive-n-up-file (mess)
5772 ;; get n-up argument
5773 (pr-interactive-n-up mess
)
5774 ;; get output file name
5775 (and (not pr-spool-p
)
5776 (ps-print-preprint current-prefix-arg
))))
5779 (defun pr-interactive-n-up-inout (mess)
5781 ;; get n-up argument
5782 (pr-interactive-n-up mess
)
5783 ;; get input file name
5784 (pr-ps-infile-preprint (concat mess
" "))
5785 ;; get output file name
5786 (ps-print-preprint current-prefix-arg
)))
5789 (defun pr-set-outfilename (filename-sym)
5790 (and (not pr-spool-p
)
5791 (eq (symbol-value filename-sym
) t
)
5792 (set filename-sym
(and current-prefix-arg
5793 (ps-print-preprint current-prefix-arg
))))
5794 (and (symbol-value filename-sym
)
5795 (set filename-sym
(pr-dosify-file-name (symbol-value filename-sym
)))))
5798 (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess
)
5800 (or (symbol-value n-up-sym
)
5801 (set n-up-sym
(pr-interactive-n-up mess
)))
5803 (pr-set-outfilename filename-sym
))
5806 (defun pr-set-dir-args (dir-sym regexp-sym mess
)
5808 (or (symbol-value dir-sym
)
5809 (set dir-sym
(pr-interactive-dir mess
)))
5811 (or (symbol-value regexp-sym
)
5812 (set regexp-sym
(pr-interactive-regexp mess
))))
5815 (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess
)
5817 (or (symbol-value n-up-sym
)
5818 (set n-up-sym
(pr-interactive-n-up mess
)))
5819 ;; directory & file name regexp
5820 (pr-set-dir-args dir-sym regexp-sym mess
)
5822 (pr-set-outfilename filename-sym
))
5825 (defun pr-find-buffer-visiting (file)
5826 (if (not (file-directory-p file
))
5827 (find-buffer-visiting (if ps-windows-system
5830 (let ((truename (file-truename file
))
5831 (blist (buffer-list))
5833 (while (and (not found
) blist
)
5834 (with-current-buffer (car blist
)
5835 (and (eq major-mode
'dired-mode
)
5837 (goto-char (point-min))
5838 (string= (buffer-substring-no-properties
5844 (setq found
(car blist
))))
5845 (setq blist
(cdr blist
)))
5849 (defun pr-file-list (dir file-regexp fun
)
5850 (mapcar #'(lambda (file)
5851 (and (or pr-list-directory
5852 (not (file-directory-p file
)))
5853 (let ((buffer (pr-find-buffer-visiting file
))
5857 (file-readable-p file
))
5858 (with-current-buffer (or buffer
5859 (find-file-noselect file
))
5862 (kill-buffer (current-buffer))))))))
5863 (directory-files dir t file-regexp
)))
5866 (defun pr-delete-file-if-exists (filename)
5867 (and (not pr-spool-p
) (stringp filename
) (file-exists-p filename
)
5868 (delete-file filename
)))
5871 (defun pr-ps-file-list (n-up dir file-regexp filename
)
5872 (pr-delete-file-if-exists (setq filename
(pr-expand-file-name filename
)))
5873 (let ((pr-spool-p t
))
5874 (pr-file-list dir file-regexp
5876 (if (pr-auto-mode-p)
5877 (pr-ps-mode n-up filename
)
5878 (pr-text2ps 'buffer n-up filename
)))))
5880 (pr-despool-print filename
)))
5883 (defun pr-text2ps (kind n-up filename
&optional from to
)
5885 (let ((ps-n-up-printing n-up
)
5886 (ps-spool-config (and (eq ps-spool-config
'setpagedevice
)
5888 (pr-delete-file-if-exists filename
)
5891 ;; pr-faces-p and pr-spool-p
5892 ;; here FILENAME arg is ignored
5893 (cond ((eq kind
'buffer
)
5894 (ps-spool-buffer-with-faces))
5896 (ps-spool-region-with-faces (or from
(point))
5899 ;; pr-faces-p and not pr-spool-p
5901 (ps-print-buffer-with-faces filename
))
5903 (ps-print-region-with-faces (or from
(point))
5904 (or to
(mark)) filename
))
5907 ;; not pr-faces-p and pr-spool-p
5908 ;; here FILENAME arg is ignored
5909 (cond ((eq kind
'buffer
)
5912 (ps-spool-region (or from
(point)) (or to
(mark))))
5914 ;; not pr-faces-p and not pr-spool-p
5916 (ps-print-buffer filename
))
5918 (ps-print-region (or from
(point)) (or to
(mark)) filename
))
5922 (defun pr-command (command)
5923 "Return absolute file name specification for COMMAND.
5925 If COMMAND is an empty string, return it.
5927 If COMMAND is already an absolute file name specification, return it.
5928 Else it uses `pr-path-alist' to find COMMAND, if find it then return it;
5929 otherwise, gives an error.
5931 When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and
5932 `unix' are used (see `pr-path-alist' for documentation).
5934 If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND,
5935 COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
5936 (if (string= command
"")
5938 (pr-dosify-file-name
5939 (or (pr-find-command command
)
5940 (pr-path-command (cond (pr-cygwin-system 'cygwin
)
5941 (ps-windows-system 'windows
)
5943 (file-name-nondirectory command
)
5945 (error "Command not found: %s"
5946 (file-name-nondirectory command
))))))
5949 (defun pr-path-command (symbol command sym-list
)
5950 (let ((lpath (cdr (assq symbol pr-path-alist
)))
5953 (and (eq symbol
'PATH
) (null lpath
)
5954 (setq lpath
(parse-colon-path (getenv "PATH"))))
5958 (let ((path (car lpath
)))
5962 (and (not (memq path sym-list
))
5963 (pr-path-command path command
5964 (cons path sym-list
))))
5969 (substitute-in-file-name
5970 (concat (file-name-as-directory path
)
5973 (setq lpath
(cdr lpath
)))
5977 (defun pr-find-command (cmd)
5978 (if ps-windows-system
5980 (let ((ext (cons (file-name-extension cmd t
)
5981 (list ".exe" ".bat" ".com")))
5983 (setq cmd
(file-name-sans-extension cmd
))
5985 (setq found
(concat cmd
(car ext
)))
5986 (not (and (file-regular-p found
)
5987 (file-executable-p found
))))
5991 ;; non-windows systems
5992 (and (file-regular-p cmd
)
5993 (file-executable-p cmd
)
5997 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5998 ;; Printing Interface (inspired by ps-print-interface.el)
6007 (defvar pr-i-window-configuration nil
)
6009 (defvar pr-i-buffer nil
)
6010 (defvar pr-i-region nil
)
6011 (defvar pr-i-mode nil
)
6012 (defvar pr-i-despool nil
)
6013 (defvar pr-i-ps-as-is t
)
6014 (defvar pr-i-n-up
1)
6015 (defvar pr-i-directory
"./")
6016 (defvar pr-i-regexp
"")
6017 (defvar pr-i-ps-file
"")
6018 (defvar pr-i-out-file
"")
6019 (defvar pr-i-answer-yes nil
)
6020 (defvar pr-i-process
'buffer
)
6021 (defvar pr-i-ps-send
'printer
)
6024 (defvar pr-interface-map nil
6025 "Keymap for pr-interface.")
6027 (unless pr-interface-map
6028 (let ((map (make-sparse-keymap)))
6029 (cond ((featurep 'xemacs
) ; XEmacs
6030 (pr-set-keymap-parents map
(list widget-keymap
))
6031 (pr-set-keymap-name map
'pr-interface-map
))
6033 (pr-set-keymap-parents map widget-keymap
)))
6034 (define-key map
"q" 'pr-interface-quit
)
6035 (define-key map
"?" 'pr-interface-help
)
6036 (setq pr-interface-map map
)))
6039 (defmacro pr-interface-save
(&rest body
)
6040 `(with-current-buffer pr-i-buffer
6044 (defun pr-create-interface ()
6045 "Create the front end for printing package."
6046 (setq pr-i-buffer
(buffer-name (current-buffer))
6047 pr-i-region
(ps-mark-active-p)
6048 pr-i-mode
(pr-mode-alist-p)
6049 pr-i-window-configuration
(current-window-configuration))
6051 (put 'pr-i-process
'pr-widget-list nil
)
6052 (put 'pr-i-ps-send
'pr-widget-list nil
)
6054 (delete-other-windows)
6055 (kill-buffer (get-buffer-create pr-buffer-name
))
6056 (switch-to-buffer (get-buffer-create pr-buffer-name
))
6059 (let ((versions (concat "printing v" pr-version
6060 " ps-print v" ps-print-version
)))
6061 ;; to keep compatibility with Emacs 20 & 21:
6062 ;; DO NOT REPLACE `?\ ' BY `?\s'
6063 (widget-insert (make-string (- 79 (length versions
)) ?\
) versions
))
6064 (pr-insert-italic "\nCurrent Directory : " 1)
6065 (pr-insert-italic default-directory
)
6067 (pr-insert-section-1) ; 1. Print
6068 (pr-insert-section-2) ; 2. PostScript Printer
6069 (pr-insert-section-3) ; 3. Text Printer
6072 (widget-insert "\n\n " (make-string 77 ?-
))
6074 (pr-insert-section-4) ; 4. Settings
6075 (pr-insert-section-5) ; 5. Customize
6076 (pr-insert-section-6) ; 6. Show Settings
6077 (pr-insert-section-7) ; 7. Help
6079 (use-local-map pr-interface-map
)
6081 (goto-char (point-min))
6083 (and pr-i-region
; let region activated
6084 (pr-keep-region-active)))
6086 (declare-function widget-field-action
"wid-edit" (widget &optional _event
))
6087 (declare-function widget-value-set
"wid-edit" (widget value
))
6089 (defun pr-insert-section-1 ()
6091 (pr-insert-italic "\nPrint :" 1)
6094 ;; 1a. Buffer: Buffer List
6095 (pr-insert-radio-button 'pr-i-process
'buffer
)
6096 (pr-insert-menu "Buffer List" 'pr-i-buffer
6097 (let ((blist (buffer-list))
6098 case-fold-search choices
)
6100 (let ((name (buffer-name (car blist
)))
6101 (ignore pr-buffer-name-ignore
)
6103 (setq blist
(cdr blist
))
6104 (while (and ignore
(not found
))
6105 (setq found
(string-match (car ignore
) name
)
6106 ignore
(cdr ignore
)))
6118 (setq pr-i-region
(ps-mark-active-p)
6119 pr-i-mode
(pr-mode-alist-p)))
6120 (pr-update-checkbox 'pr-i-region
)
6121 (pr-update-checkbox 'pr-i-mode
)))
6122 ;; 1a. Buffer: Region
6123 (put 'pr-i-region
'pr-widget
6127 #'(lambda (widget &rest ignore
)
6128 (let ((region-p (pr-interface-save
6129 (ps-mark-active-p))))
6130 (cond ((null (widget-value widget
)) ; widget is nil
6131 (setq pr-i-region nil
))
6132 (region-p ; widget is true and there is a region
6133 (setq pr-i-region t
)
6134 (widget-value-set widget t
)
6135 (widget-setup)) ; MUST be called after widget-value-set
6136 (t ; widget is true and there is no region
6138 (message "There is no region active")
6139 (setq pr-i-region nil
)
6140 (widget-value-set widget nil
)
6141 (widget-setup))))) ; MUST be called after widget-value-set
6144 (put 'pr-i-mode
'pr-widget
6148 #'(lambda (widget &rest ignore
)
6149 (let ((mode-p (pr-interface-save
6150 (pr-mode-alist-p))))
6152 ((null (widget-value widget
)) ; widget is nil
6153 (setq pr-i-mode nil
))
6154 (mode-p ; widget is true and there is a `mode'
6156 (widget-value-set widget t
)
6157 (widget-setup)) ; MUST be called after widget-value-set
6158 (t ; widget is true and there is no `mode'
6161 "This buffer isn't in a mode that printing treats specially.")
6162 (setq pr-i-mode nil
)
6163 (widget-value-set widget nil
)
6164 (widget-setup))))) ; MUST be called after widget-value-set
6168 (pr-insert-radio-button 'pr-i-process
'directory
)
6172 :format
" Directory : %v"
6173 :notify
'pr-interface-directory
6174 :action
(lambda (widget &optional event
)
6175 (if (pr-interface-directory widget
)
6176 (pr-widget-field-action widget event
)
6178 (message "Please specify a readable directory")))
6180 ;; 1b. Directory: File Regexp
6181 (widget-create 'regexp
6183 :format
"\n File Regexp : %v\n"
6184 :notify
(lambda (widget &rest ignore
)
6185 (setq pr-i-regexp
(widget-value widget
)))
6187 ;; 1b. Directory: List Directory Entry
6189 (pr-insert-toggle 'pr-list-directory
" List Directory Entry\n")
6191 ;; 1c. PostScript File:
6192 (pr-insert-radio-button 'pr-i-process
'file
)
6196 :format
" PostScript File : %v"
6197 :notify
'pr-interface-infile
6198 :action
(lambda (widget &rest event
)
6199 (if (pr-interface-infile widget
)
6200 (pr-widget-field-action widget event
)
6202 (message "Please specify a readable PostScript file")))
6204 ;; 1c. PostScript File: PostScript Utility
6205 (pr-insert-menu "PostScript Utility" 'pr-ps-utility
6206 (pr-choice-alist pr-ps-utility-alist
)
6207 "\n PostScript Utility : "
6209 ;; 1c. PostScript File: No Preprocessing
6210 (pr-insert-toggle 'pr-i-ps-as-is
" No Preprocessing"))
6213 (defun pr-insert-section-2 ()
6214 ;; 2. PostScript Printer:
6215 ;; 2. PostScript Printer: PostScript Printer List
6216 (pr-insert-italic "\n\nPostScript Printer : " 2 20)
6217 (pr-insert-menu "PostScript Printer" 'pr-ps-name
6218 (pr-choice-alist pr-ps-printer-alist
))
6219 ;; 2. PostScript Printer: Despool
6220 (put 'pr-i-despool
'pr-widget
6224 #'(lambda (widget &rest ignore
)
6226 (setq pr-i-despool
(not pr-i-despool
))
6228 (message "Can despool only when spooling is actually selected")
6229 (setq pr-i-despool nil
))
6230 (widget-value-set widget pr-i-despool
)
6231 (widget-setup)) ; MUST be called after widget-value-set
6233 ;; 2. PostScript Printer: Preview Print Quit
6234 (pr-insert-button 'pr-interface-preview
"Preview" " ")
6235 (pr-insert-button 'pr-interface-ps-print
"Print" " ")
6236 (pr-insert-button 'pr-interface-quit
"Quit")
6237 ;; 2. PostScript Printer: Send to Printer/Temporary File
6238 (pr-insert-radio-button 'pr-i-ps-send
'printer
)
6239 (widget-insert " Send to Printer/Temporary File")
6240 ;; 2. PostScript Printer: Send to File
6241 (pr-insert-radio-button 'pr-i-ps-send
'file
)
6245 :format
" Send to File : %v"
6246 :notify
'pr-interface-outfile
6247 :action
(lambda (widget &rest event
)
6248 (if (and (pr-interface-outfile widget
)
6249 (or (not (file-exists-p pr-i-out-file
))
6250 (setq pr-i-answer-yes
6251 (y-or-n-p "File exists; overwrite? "))))
6252 (pr-widget-field-action widget event
)
6254 (message "Please specify a writable PostScript file")))
6256 ;; 2. PostScript Printer: N-Up
6260 :format
"\n N-Up : %v"
6261 :notify
(lambda (widget &rest ignore
)
6262 (let ((value (if (string= (widget-apply widget
:value-get
) "")
6264 (widget-value widget
))))
6265 (if (and (integerp value
)
6266 (<= 1 value
) (<= value
100))
6269 (setq pr-i-n-up value
))
6271 (message "Please specify an integer between 1 and 100"))))
6275 (defun pr-insert-section-3 ()
6277 (pr-insert-italic "\n\nText Printer : " 2 14)
6278 (pr-insert-menu "Text Printer" 'pr-txt-name
6279 (pr-choice-alist pr-txt-printer-alist
)
6281 (pr-insert-button 'pr-interface-printify
"Printify" " ")
6282 (pr-insert-button 'pr-interface-txt-print
"Print" " ")
6283 (pr-insert-button 'pr-interface-quit
"Quit"))
6286 (defun pr-insert-section-4 ()
6288 ;; 4. Settings: Landscape Auto Region Verbose
6289 (pr-insert-checkbox "\n\n " 'ps-landscape-mode
6290 #'(lambda (&rest ignore
)
6291 (setq ps-landscape-mode
(not ps-landscape-mode
)
6292 pr-file-landscape ps-landscape-mode
))
6294 (pr-insert-toggle 'pr-auto-region
" Auto Region ")
6295 (pr-insert-toggle 'pr-buffer-verbose
" Verbose\n ")
6297 ;; 4. Settings: Print Header Auto Mode
6298 (pr-insert-toggle 'ps-print-header
" Print Header ")
6299 (pr-insert-toggle 'pr-auto-mode
" Auto Mode\n ")
6301 ;; 4. Settings: Print Header Frame Menu Lock
6302 (pr-insert-toggle 'ps-print-header-frame
" Print Header Frame ")
6303 (pr-insert-toggle 'pr-menu-lock
" Menu Lock\n ")
6305 ;; 4. Settings: Line Number
6306 (pr-insert-toggle 'ps-line-number
" Line Number\n ")
6308 ;; 4. Settings: Zebra Stripes Spool Buffer
6309 (pr-insert-toggle 'ps-zebra-stripes
" Zebra Stripes")
6310 (pr-insert-checkbox " "
6312 #'(lambda (&rest ignore
)
6313 (setq pr-spool-p
(not pr-spool-p
))
6315 (setq pr-i-despool nil
)
6316 (pr-update-checkbox 'pr-i-despool
)))
6319 ;; 4. Settings: Duplex Print with faces
6320 (pr-insert-checkbox "\n "
6322 #'(lambda (&rest ignore
)
6323 (setq ps-spool-duplex
(not ps-spool-duplex
)
6324 pr-file-duplex ps-spool-duplex
))
6326 (pr-insert-toggle 'pr-faces-p
" Print with faces")
6328 ;; 4. Settings: Tumble Print via Ghostscript
6329 (pr-insert-checkbox "\n "
6331 #'(lambda (&rest ignore
)
6332 (setq ps-spool-tumble
(not ps-spool-tumble
)
6333 pr-file-tumble ps-spool-tumble
))
6335 (pr-insert-toggle 'pr-print-using-ghostscript
" Print via Ghostscript\n ")
6337 ;; 4. Settings: Upside-Down Page Parity
6338 (pr-insert-toggle 'ps-print-upside-down
" Upside-Down")
6339 (pr-insert-italic "\n\nSelect Pages : " 2 14)
6340 (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages
6341 (mapcar #'(lambda (alist)
6346 :value
(car alist
))))
6347 pr-even-or-odd-alist
)))
6350 (defun pr-insert-section-5 ()
6352 (pr-insert-italic "\n\nCustomize : " 2 11)
6353 (pr-insert-button 'pr-customize
"printing" " ")
6354 (pr-insert-button #'(lambda (&rest ignore
) (ps-print-customize))
6356 (pr-insert-button 'lpr-customize
"lpr"))
6359 (defun pr-insert-section-6 ()
6360 ;; 6. Show Settings:
6361 (pr-insert-italic "\nShow Settings : " 1 14)
6362 (pr-insert-button 'pr-show-pr-setup
"printing" " ")
6363 (pr-insert-button 'pr-show-ps-setup
"ps-print" " ")
6364 (pr-insert-button 'pr-show-lpr-setup
"lpr"))
6367 (defun pr-insert-section-7 ()
6369 (pr-insert-italic "\nHelp : " 1 5)
6370 (pr-insert-button 'pr-interface-help
"Interface Help" " ")
6371 (pr-insert-button 'pr-help
"Menu Help" " ")
6372 (pr-insert-button 'pr-interface-quit
"Quit" "\n ")
6373 (pr-insert-button 'pr-kill-help
"Kill All Printing Help Buffer"))
6376 (defun pr-kill-help (&rest ignore
)
6377 "Kill all printing help buffer."
6379 (let ((help '("*Printing Interface Help*" "*Printing Help*"
6380 "*LPR Setup*" "*PR Setup*" "*PS Setup*")))
6382 (let ((buffer (get-buffer (car help
))))
6383 (setq help
(cdr help
))
6385 (delete-windows-on buffer
)
6386 (kill-buffer buffer
)))))
6387 (recenter (- (window-height) 2)))
6390 (defun pr-interface-quit (&rest ignore
)
6391 "Kill the printing buffer interface and quit."
6393 (kill-buffer pr-buffer-name
)
6394 (set-window-configuration pr-i-window-configuration
))
6397 (defun pr-interface-help (&rest ignore
)
6398 "printing buffer interface help."
6400 (pr-show-setup pr-interface-help-message
"*Printing Interface Help*"))
6403 (defun pr-interface-txt-print (&rest ignore
)
6404 "Print using lpr package."
6406 (condition-case data
6408 ((eq pr-i-process
'directory
)
6411 (pr-txt-directory pr-i-directory pr-i-regexp
)))
6412 ((eq pr-i-process
'buffer
)
6415 (let ((pr-auto-mode pr-i-mode
))
6418 (let (pr-auto-region)
6421 (let (pr-auto-mode pr-auto-region
)
6424 ((eq pr-i-process
'file
)
6425 (error "Please specify a text file"))
6427 (error "Internal error: `pr-i-process' = %S" pr-i-process
))
6432 (message "%s" (error-message-string data
)))))
6435 (defun pr-interface-printify (&rest ignore
)
6436 "Printify a buffer."
6438 (condition-case data
6440 ((eq pr-i-process
'directory
)
6443 (pr-printify-directory pr-i-directory pr-i-regexp
)))
6444 ((eq pr-i-process
'buffer
)
6447 (pr-printify-region)
6448 (pr-printify-buffer))))
6449 ((eq pr-i-process
'file
)
6450 (error "Cannot printify a PostScript file"))
6452 (error "Internal error: `pr-i-process' = %S" pr-i-process
))
6457 (message "%s" (error-message-string data
)))))
6460 (defun pr-interface-ps-print (&rest ignore
)
6461 "Print using ps-print package."
6463 (pr-interface-ps 'pr-despool-ps-print
'pr-ps-directory-ps-print
6464 'pr-ps-file-ps-print
'pr-ps-file-up-ps-print
6465 'pr-ps-region-ps-print
'pr-ps-mode-ps-print
6466 'pr-ps-buffer-ps-print
))
6469 (defun pr-interface-preview (&rest ignore
)
6470 "Preview a PostScript file."
6472 (pr-interface-ps 'pr-despool-preview
'pr-ps-directory-preview
6473 'pr-ps-file-preview
'pr-ps-file-up-preview
6474 'pr-ps-region-preview
'pr-ps-mode-preview
6475 'pr-ps-buffer-preview
))
6478 (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region
6480 (condition-case data
6481 (let ((outfile (or (and (eq pr-i-process
'file
) pr-i-ps-as-is
)
6484 ((and pr-i-despool pr-spool-p
)
6486 (funcall ps-despool outfile
))
6487 (setq pr-i-despool nil
)
6488 (pr-update-checkbox 'pr-i-despool
))
6489 ((eq pr-i-process
'directory
)
6492 (funcall ps-directory
6493 pr-i-n-up pr-i-directory pr-i-regexp outfile
)))
6494 ((eq pr-i-process
'file
)
6495 (cond ((or (file-directory-p pr-i-ps-file
)
6496 (not (file-readable-p pr-i-ps-file
)))
6497 (error "Please specify a readable PostScript file"))
6500 (funcall ps-file pr-i-ps-file
)))
6503 (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile
)))
6505 ((eq pr-i-process
'buffer
)
6508 (let ((pr-auto-mode pr-i-mode
))
6509 (funcall ps-region pr-i-n-up outfile
)))
6511 (let (pr-auto-region)
6512 (funcall ps-mode pr-i-n-up outfile
)))
6514 (let (pr-auto-mode pr-auto-region
)
6515 (funcall ps-buffer pr-i-n-up outfile
)))
6518 (error "Internal error: `pr-i-process' = %S" pr-i-process
))
6523 (message "%s" (error-message-string data
)))))
6526 (defun pr-i-ps-send ()
6527 (cond ((eq pr-i-ps-send
'printer
)
6529 ((not (eq pr-i-ps-send
'file
))
6530 (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send
))
6531 ((or (file-directory-p pr-i-out-file
)
6532 (not (file-writable-p pr-i-out-file
)))
6533 (error "Please specify a writable PostScript file"))
6534 ((or (not (file-exists-p pr-i-out-file
))
6536 (setq pr-i-answer-yes
6537 (y-or-n-p (format "File `%s' exists; overwrite? "
6541 (error "File already exists"))))
6544 (defun pr-i-directory ()
6545 (or (and (file-directory-p pr-i-directory
)
6546 (file-readable-p pr-i-directory
))
6547 (error "Please specify be a readable directory")))
6550 (defun pr-interface-directory (widget &rest ignore
)
6551 (and pr-buffer-verbose
6552 (message "You can use M-TAB or ESC TAB for file completion"))
6553 (let ((dir (widget-value widget
)))
6554 (and (file-directory-p dir
)
6555 (file-readable-p dir
)
6556 (setq pr-i-directory dir
))))
6559 (defun pr-interface-infile (widget &rest ignore
)
6560 (and pr-buffer-verbose
6561 (message "You can use M-TAB or ESC TAB for file completion"))
6562 (let ((file (widget-value widget
)))
6563 (and (not (file-directory-p file
))
6564 (file-readable-p file
)
6565 (setq pr-i-ps-file file
))))
6568 (defun pr-interface-outfile (widget &rest ignore
)
6569 (setq pr-i-answer-yes nil
)
6570 (and pr-buffer-verbose
6571 (message "You can use M-TAB or ESC TAB for file completion"))
6572 (let ((file (widget-value widget
)))
6573 (and (not (file-directory-p file
))
6574 (file-writable-p file
)
6575 (setq pr-i-out-file file
))))
6578 (defun pr-widget-field-action (widget event
)
6579 (and (get-buffer "*Completions*") ; clean frame window
6580 (delete-windows-on "*Completions*"))
6581 (message " ") ; clean echo area
6582 (widget-field-action widget event
))
6585 (defun pr-insert-italic (str &optional from to
)
6586 (let ((len (length str
)))
6587 (put-text-property (if from
(max from
0) 0)
6588 (if to
(max to len
) len
)
6590 (widget-insert str
)))
6593 (defun pr-insert-checkbox (before var-sym fun label
)
6594 (widget-insert before
)
6596 (widget-create 'checkbox
6598 (symbol-value var-sym
))
6599 (widget-insert label
)))
6602 (defun pr-insert-toggle (var-sym label
)
6603 (widget-create 'checkbox
6604 :notify
`(lambda (&rest ignore
)
6605 (setq ,var-sym
(not ,var-sym
)))
6606 (symbol-value var-sym
))
6607 (widget-insert label
))
6610 (defun pr-insert-button (fun label
&optional separator
)
6611 (widget-create 'push-button
6615 (widget-insert separator
)))
6618 (defun pr-insert-menu (tag var-sym choices
&optional before after
&rest body
)
6619 (and before
(widget-insert before
))
6620 (eval `(widget-create 'menu-choice
6625 :notify
(lambda (widget &rest ignore
)
6626 (setq ,var-sym
(widget-value widget
))
6628 :void
'(choice-item :format
"%[%t%]"
6629 :tag
"Can not display value!")
6631 (and after
(widget-insert after
)))
6634 (defun pr-insert-radio-button (var-sym sym
)
6635 (widget-insert "\n")
6636 (let ((wid-list (get var-sym
'pr-widget-list
))
6637 (wid (eval `(widget-create
6640 :value
(eq ,var-sym
(quote ,sym
))
6641 :notify
(lambda (&rest ignore
)
6642 (setq ,var-sym
(quote ,sym
))
6643 (pr-update-radio-button (quote ,var-sym
)))))))
6644 (put var-sym
'pr-widget-list
(cons (cons wid sym
) wid-list
))))
6647 (defun pr-update-radio-button (var-sym)
6648 (let ((wid-list (get var-sym
'pr-widget-list
)))
6650 (let ((wid (car (car wid-list
)))
6651 (value (cdr (car wid-list
))))
6652 (setq wid-list
(cdr wid-list
))
6653 (widget-value-set wid
(eq (symbol-value var-sym
) value
))))
6657 (defun pr-update-checkbox (var-sym)
6658 (let ((wid (get var-sym
'pr-widget
)))
6660 (widget-value-set wid
(symbol-value var-sym
))
6664 (defun pr-choice-alist (alist)
6665 (let ((max (apply 'max
(mapcar #'(lambda (alist)
6666 (length (symbol-name (car alist
))))
6668 (mapcar #'(lambda (alist)
6669 (let* ((sym (car alist
))
6670 (name (symbol-name sym
)))
6677 (make-string (- max
(length name
)) ?_
))
6682 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6688 ;;; printing.el ends here