1 ;;; printing.el --- printing utilities
3 ;; Copyright (C) 2000-2001, 2003-2012 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 coding your settings on Emacs init file (that is,
143 ;; ~/.emacs file), see below for a first setting template that it should be
144 ;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT
147 ;; * Example of setting for Windows system:
149 ;; (require 'printing) ; load printing package
150 ;; (setq pr-path-alist
151 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
152 ;; (ghostview "c:/gs/gsview-dir")
153 ;; (mpage "c:/mpage-dir")
155 ;; (setq pr-txt-name 'prt_06a)
156 ;; (setq pr-txt-printer-alist
157 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
158 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
159 ;; (PRN "" nil "PRN")
160 ;; (standard "redpr.exe" nil "")
162 ;; (setq pr-ps-name 'lps_06b)
163 ;; (setq pr-ps-printer-alist
164 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
165 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
166 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
167 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
168 ;; (LPT1 "" nil "" "LPT1:")
169 ;; (PRN "" nil "" "PRN")
170 ;; (standard "redpr.exe" nil "" "")
172 ;; (pr-update-menus t) ; update now printer and utility menus
174 ;; * Example of setting for GNU or Unix system:
176 ;; (require 'printing) ; load printing package
177 ;; (setq pr-path-alist
178 ;; '((unix "." "~/bin" ghostview mpage PATH)
179 ;; (ghostview "$HOME/bin/gsview-dir")
180 ;; (mpage "$HOME/bin/mpage-dir")
182 ;; (setq pr-txt-name 'prt_06a)
183 ;; (setq pr-txt-printer-alist
184 ;; '((prt_06a "lpr" nil "prt_06a")
185 ;; (prt_07c nil nil "prt_07c")
187 ;; (setq pr-ps-name 'lps_06b)
188 ;; (setq pr-ps-printer-alist
189 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
190 ;; (lps_07c "lpr" nil nil "lps_07c")
191 ;; (lps_08c nil nil nil "lps_08c")
193 ;; (pr-update-menus t) ; update now printer and utility menus
196 ;; NOTE 1: Don't forget to download and install ghostscript utilities (see
197 ;; Utilities section).
199 ;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be
200 ;; set, as they are implicit set by `pr-ps-printer-alist' and
201 ;; `pr-txt-printer-alist'.
203 ;; NOTE 3: The duplex feature will only work on PostScript printers that
204 ;; support this feature.
205 ;; You can check if your PostScript printer supports duplex feature
206 ;; by checking the printer manual. Or you can try these steps:
207 ;; 1. Open a buffer (or use the *scratch* buffer).
209 ;; First line (on first page)
211 ;; Second line (on second page)
212 ;; 3. Print this buffer with duplex turned on.
213 ;; If it's printed 2 (two) sheets of paper, then your PostScript
214 ;; printer doesn't have duplex feature; otherwise, it's ok, your
215 ;; printer does have duplex feature.
217 ;; NOTE 4: See Tips section.
223 ;; 1. If you have a local printer, that is, a printer which is connected
224 ;; directly to your computer, don't forget to connect the printer to your
225 ;; computer before printing.
227 ;; 2. If you try to print a file and it seems that the file was printed, but
228 ;; there is no paper in the printer, then try to set `pr-delete-temp-file'
229 ;; to nil. Probably `printing' is deleting the temporary file before your
230 ;; local system can get it to send to the printer.
232 ;; 3. Don't try to print a dynamic buffer, that is, a buffer which is
233 ;; modifying while `printing' tries to print. Eventually you got an error
234 ;; message. Instead, save the dynamic buffer to a file or copy it in
235 ;; another buffer and, then, print the file or the new static buffer.
236 ;; An example of dynamic buffer is the *Messages* buffer.
238 ;; 4. When running Emacs on Windows (with or without cygwin), check if your
239 ;; printer is a text printer or not by typing in a DOS window:
241 ;; print /D:\\host\printer somefile.txt
243 ;; Where, `host' is the machine where the printer is directly connected,
244 ;; `printer' is the printer name and `somefile.txt' is a text file.
246 ;; If the printer `\\host\printer' doesn't print the content of
247 ;; `somefile.txt' or, instead, it returns the following message:
249 ;; PostScript Error Handler
250 ;; Offending Command = CCC
253 ;; Where `CCC' is whatever is at the beginning of the text to be printed.
255 ;; Therefore, the printer `\\host\printer' is not a text printer, but a
256 ;; PostScript printer. So, please, don't include this printer in
257 ;; `pr-txt-printer-alist' (which see).
259 ;; 5. You can use gsprint instead of ghostscript to print monochrome PostScript
260 ;; files in Windows. The gsprint utility documentation says that it is more
261 ;; efficient than ghostscript to print monochrome PostScript.
263 ;; To print non-monochrome PostScript file, the efficiency of ghostscript
264 ;; is similar to gsprint.
266 ;; Also the gsprint utility comes together with gsview distribution.
268 ;; For more information about gsprint see
269 ;; `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'.
271 ;; As an example of gsprint declaration:
273 ;; (setq pr-ps-printer-alist
274 ;; '((A "gsprint" ("-all" "-twoup") "-printer " "my-b/w-printer-name")
275 ;; (B "gsprint" ("-all" "-twoup") nil "-printer my-b/w-printer-name")
276 ;; ;; some other printer declaration
279 ;; The example above declares that printer A prints all pages (-all) and two
280 ;; pages per sheet (-twoup). The printer B declaration does the same as the
281 ;; printer A declaration, the only difference is the printer name selection.
283 ;; There are other command line options like:
285 ;; -mono Render in monochrome as 1bit/pixel (only black and white).
286 ;; -grey Render in greyscale as 8bits/pixel.
287 ;; -color Render in color as 24bits/pixel.
289 ;; The default is `-mono'. So, printer A and B in the example above are
290 ;; using implicitly the `-mono' option. Note that in `-mono' no gray tone
291 ;; or color is printed, this includes the zebra stripes, that is, in `-mono'
292 ;; the zebra stripes are not printed.
294 ;; See also documentation for `pr-ps-printer-alist'.
300 ;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're
301 ;; using Windows 9x/NT or MS-DOS):
303 ;; (require 'printing)
304 ;; ;; ...some user settings...
305 ;; (pr-update-menus t)
307 ;; During `pr-update-menus' evaluation:
309 ;; it replaces the Tools/Print menu by Tools/Printing menu.
311 ;; it replaces the File/Print* menu entries by File/Print menu.
312 ;; Please, see section Menu Layout below for menu explanation.
314 ;; To use `printing' utilities you can use the Printing menu options, type M-x
315 ;; followed by one of the commands below, or type a key associated with the
316 ;; command you want (if there is a key binding).
318 ;; `printing' has the following commands:
321 ;; pr-ps-directory-preview
322 ;; pr-ps-directory-using-ghostscript
323 ;; pr-ps-directory-print
324 ;; pr-ps-directory-ps-print
325 ;; pr-ps-buffer-preview
326 ;; pr-ps-buffer-using-ghostscript
327 ;; pr-ps-buffer-print
328 ;; pr-ps-buffer-ps-print
329 ;; pr-ps-region-preview
330 ;; pr-ps-region-using-ghostscript
331 ;; pr-ps-region-print
332 ;; pr-ps-region-ps-print
333 ;; pr-ps-mode-preview
334 ;; pr-ps-mode-using-ghostscript
336 ;; pr-ps-mode-ps-print
337 ;; pr-ps-file-preview
338 ;; pr-ps-file-up-preview
339 ;; pr-ps-file-using-ghostscript
341 ;; pr-ps-file-ps-print
342 ;; pr-ps-file-up-ps-print
344 ;; pr-despool-preview
345 ;; pr-despool-using-ghostscript
347 ;; pr-despool-ps-print
348 ;; pr-printify-directory
349 ;; pr-printify-buffer
350 ;; pr-printify-region
356 ;; pr-toggle-file-duplex
357 ;; pr-toggle-file-tumble
358 ;; pr-toggle-file-landscape
359 ;; pr-toggle-ghostscript
364 ;; pr-toggle-landscape
365 ;; pr-toggle-upside-down
382 ;; The general meanings of above commands are:
385 ;; `pr-interface' buffer interface for printing package.
386 ;; `pr-help' help for printing package.
387 ;; `pr-ps-name' interactively select a PostScript printer.
388 ;; `pr-txt-name' interactively select a text printer.
389 ;; `pr-ps-utility' interactively select a PostScript utility.
390 ;; `pr-show-*-setup' show current settings.
391 ;; `pr-ps-*' deal with PostScript code generation.
392 ;; `pr-txt-*' deal with text generation.
393 ;; `pr-toggle-*' toggle on/off some boolean variable.
394 ;; `pr-despool-*' despool the PostScript spooling buffer.
395 ;; `pr-printify-*' replace nonprintable ASCII by printable ASCII
399 ;; `*-customize' customization.
400 ;; `*-preview' preview a PostScript file.
401 ;; `*-using-ghostscript' use ghostscript to print.
402 ;; `*-fast-fire' fast fire command (see it for documentation).
403 ;; `*-print' send PostScript directly to printer.
404 ;; `*-ps-print' send PostScript directly to printer or use
405 ;; ghostscript to print. It depends on
406 ;; `pr-print-using-ghostscript' option.
409 ;; `*-directory*' process a directory.
410 ;; `*-buffer*' process a buffer.
411 ;; `*-region*' process a region.
412 ;; `*-mode*' process a major mode (see explanation below).
413 ;; `*-file-*' process a PostScript file.
414 ;; `*-file-up-*' process a PostScript file using a filter utility.
416 ;; Here are some examples:
418 ;; `pr-ps-buffer-using-ghostscript'
419 ;; Use ghostscript to print a buffer.
421 ;; `pr-ps-file-print'
422 ;; Print a PostScript file.
425 ;; Toggle spooling buffer.
427 ;; So you can preview through ghostview, use ghostscript to print (if you don't
428 ;; have a PostScript printer) or send directly to printer a PostScript code
429 ;; generated by `ps-print' package.
431 ;; Besides operating one buffer or region each time, you also can postpone
432 ;; previewing or printing by saving the PostScript code generated in a
433 ;; temporary Emacs buffer. This way you can save banner pages between
434 ;; successive printing. You can toggle on/off spooling by invoking
435 ;; `pr-toggle-spool' interactively or through menu bar.
437 ;; If you type, for example:
439 ;; C-u M-x pr-ps-buffer-print RET
441 ;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and
442 ;; a file name, and save the PostScript code generated to the file name instead
443 ;; of sending to printer.
445 ;; This behavior is similar with the commands that deal with PostScript code
446 ;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If
447 ;; spooling is on, only `pr-despool-*' commands prompt for a file name and save
448 ;; the PostScript code spooled in this file.
450 ;; Besides the behavior described above, the `*-directory*' commands also
451 ;; prompt for a directory and a file name regexp. So, it's possible to process
452 ;; all or certain files on a directory at once (see also documentation for
453 ;; `pr-list-directory').
455 ;; `printing' has also a special way to handle some major mode through
456 ;; `*-mode*' commands. So it's possible to customize a major mode printing,
457 ;; it's only needed to declare the customization in `pr-mode-alist' (see
458 ;; section Options) and invoke some of `*-mode*' commands. An example for
459 ;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and
460 ;; you're in the *Summary* buffer, if you forget to switch to the *Article*
461 ;; buffer before printing, you'll get a nicely formatted list of article
462 ;; subjects shows up at the printer. With major mode printing you don't need
463 ;; to switch from gnus *Summary* buffer first.
465 ;; Current global keyboard mapping for GNU Emacs is:
467 ;; (global-set-key [print] 'pr-ps-fast-fire)
468 ;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
469 ;; (global-set-key [S-print] 'pr-ps-mode-using-ghostscript)
470 ;; (global-set-key [C-print] 'pr-txt-fast-fire)
471 ;; (global-set-key [C-M-print] 'pr-txt-fast-fire)
473 ;; And for XEmacs is:
475 ;; (global-set-key 'f22 'pr-ps-fast-fire)
476 ;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
477 ;; (global-set-key '(shift f22) 'pr-ps-mode-using-ghostscript)
478 ;; (global-set-key '(control f22) 'pr-txt-fast-fire)
479 ;; (global-set-key '(control meta f22) 'pr-txt-fast-fire)
481 ;; As a suggestion of global keyboard mapping for some `printing' commands:
483 ;; (global-set-key "\C-ci" 'pr-interface)
484 ;; (global-set-key "\C-cbp" 'pr-ps-buffer-print)
485 ;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview)
486 ;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
487 ;; (global-set-key "\C-crp" 'pr-ps-region-print)
488 ;; (global-set-key "\C-crx" 'pr-ps-region-preview)
489 ;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
495 ;; Below it's shown a brief description of `printing' options, please, see the
496 ;; options declaration in the code for a long documentation.
498 ;; `pr-path-style' Specify which path style to use for external
501 ;; `pr-path-alist' Specify an alist for command paths.
503 ;; `pr-txt-name' Specify a printer for printing a text file.
505 ;; `pr-txt-printer-alist' Specify an alist of all text printers.
507 ;; `pr-ps-name' Specify a printer for printing a PostScript
510 ;; `pr-ps-printer-alist' Specify an alist for all PostScript printers.
512 ;; `pr-temp-dir' Specify a directory for temporary files during
515 ;; `pr-ps-temp-file' Specify PostScript temporary file name prefix.
517 ;; `pr-file-modes' Specify the file permission bits for newly
520 ;; `pr-gv-command' Specify path and name of the gsview/gv
523 ;; `pr-gs-command' Specify path and name of the ghostscript
526 ;; `pr-gs-switches' Specify ghostscript switches.
528 ;; `pr-gs-device' Specify ghostscript device switch value.
530 ;; `pr-gs-resolution' Specify ghostscript resolution switch value.
532 ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript.
534 ;; `pr-faces-p' Non-nil means print with face attributes.
536 ;; `pr-spool-p' Non-nil means spool printing in a buffer.
538 ;; `pr-file-landscape' Non-nil means print PostScript file in
539 ;; landscape orientation.
541 ;; `pr-file-duplex' Non-nil means print PostScript file in duplex
544 ;; `pr-file-tumble' Non-nil means print PostScript file in tumble
547 ;; `pr-auto-region' Non-nil means region is automagically detected.
549 ;; `pr-auto-mode' Non-nil means major-mode specific printing is
550 ;; preferred over normal printing.
552 ;; `pr-mode-alist' Specify an alist for a major-mode and printing
555 ;; `pr-ps-utility' Specify PostScript utility processing.
557 ;; `pr-ps-utility-alist' Specify an alist for PostScript utility
560 ;; `pr-menu-lock' Non-nil means menu is locked while selecting
563 ;; `pr-menu-char-height' Specify menu char height in pixels.
565 ;; `pr-menu-char-width' Specify menu char width in pixels.
567 ;; `pr-setting-database' Specify an alist for settings in general.
569 ;; `pr-visible-entry-list' Specify a list of Printing menu visible
572 ;; `pr-delete-temp-file' Non-nil means delete temporary files.
574 ;; `pr-list-directory' Non-nil means list directory when processing a
577 ;; `pr-buffer-name' Specify the name of the buffer interface for
580 ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be
581 ;; ignored in interface buffer.
583 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a
584 ;; field in interface buffer.
586 ;; To set the above options you may:
588 ;; a) insert the code in your ~/.emacs, like:
590 ;; (setq pr-faces-p t)
592 ;; This way always keep your default settings when you enter a new Emacs
595 ;; b) or use `set-variable' in your Emacs session, like:
597 ;; M-x set-variable RET pr-faces-p RET t RET
599 ;; This way keep your settings only during the current Emacs session.
601 ;; c) or use customization, for example:
602 ;; click on menu-bar *Help* option,
603 ;; then click on *Customize*,
604 ;; then click on *Browse Customization Groups*,
605 ;; expand *PostScript* group,
606 ;; expand *Printing* group
607 ;; and then customize `printing' options.
608 ;; Through this way, you may choose if the settings are kept or not when
609 ;; you leave out the current Emacs session.
611 ;; d) or see the option value:
613 ;; C-h v pr-faces-p RET
615 ;; and click the *customize* hypertext button.
616 ;; Through this way, you may choose if the settings are kept or not when
617 ;; you leave out the current Emacs session.
621 ;; M-x pr-customize RET
623 ;; and then customize `printing' options.
624 ;; Through this way, you may choose if the settings are kept or not when
625 ;; you leave out the current Emacs session.
627 ;; f) or use menu bar, for example:
628 ;; click on menu-bar *File* option,
629 ;; then click on *Printing*,
630 ;; then click on *Customize*,
631 ;; then click on *printing*
632 ;; and then customize `printing' options.
633 ;; Through this way, you may choose if the settings are kept or not when
634 ;; you leave out the current Emacs session.
640 ;; The `printing' menu (Tools/Printing or File/Print) has the following layout:
642 ;; +-----------------------------+
643 ;; A 0 | Printing Interface |
644 ;; +-----------------------------+ +-A---------+ +-B------+
645 ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
646 ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
647 ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
648 ;; +-----------------------------+ |Mode >|-- B |Other...|
649 ;; II 4 | Printify >|-----\ |File >|--\ +--------+
650 ;; 5 | Print >|---\ | |Despool... | |
651 ;; 6 | Text Printer: name >|-\ | | +-----------+ |
652 ;; +-----------------------------+ | | | +---------+ +------------+
653 ;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia
654 ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
655 ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C
656 ;; 10 |[ ]Line Number | | | +---------+ +------------+
657 ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
658 ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... |
659 ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... |
660 ;; 14 |[ ]Upside-Down | | |Region | | Other... |
661 ;; 15 | Print All Pages >|--\ | |Mode | +------------+
662 ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id
663 ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
664 ;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If
665 ;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
666 ;; +-----------------------------+ | |... |
667 ;; V 19 |[ ]Auto Region | | |(*)name |
668 ;; 20 |[ ]Auto Mode | | |... |
669 ;; 21 |[ ]Menu Lock | | +---------+ +--------------+
670 ;; +-----------------------------+ \------------------|(*)All Pages |
671 ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
672 ;; 23 | Show Settings >|-------|printing| |( )Odd Pages |
673 ;; 24 | Help | |ps-print| |( )Even Sheets|
674 ;; +-----------------------------+ |lpr | |( )Odd Sheets |
675 ;; +--------+ +--------------+
677 ;; See `pr-visible-entry-list' for hiding some parts of the menu.
679 ;; The menu has the following sections:
683 ;; 0. You can use a buffer interface instead of menus. It looks like the
684 ;; customization buffer. Basically, it has the same options found in the
685 ;; menu and some extra options, all this on a buffer.
687 ;; I. PostScript printing:
689 ;; 1. You can generate a PostScript file (if you type C-u before activating
690 ;; menu) or PostScript temporary file for a directory, a buffer, a region
691 ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
692 ;; after file generation, ghostview is activated using the file generated
693 ;; as argument. This option is disabled if spooling is on (option 16).
694 ;; Also, if you already have a PostScript file you can preview it.
695 ;; Instead of previewing each buffer, region or major mode at once, you
696 ;; can save temporarily the PostScript code generated in a buffer and
697 ;; preview it later. The option `Despool...' despools the PostScript
698 ;; spooling buffer in a temporary file and uses ghostview to preview it.
699 ;; If you type C-u before choosing this option, the PostScript code
700 ;; generated is saved in a file instead of saving in a temporary file.
701 ;; To spool the PostScript code generated you need to turn on the option
702 ;; 16. The option `Despool...' is enabled if spooling is on (option
705 ;; NOTE 1: It's possible to customize a major mode printing, just declare
706 ;; the customization in `pr-mode-alist' and invoke some of
707 ;; `*-mode*' commands or select Mode option in Printing menu. An
708 ;; example for major mode usage is when you're using gnus (or mh,
709 ;; or rmail, etc.) and you're in the *Summary* buffer, if you
710 ;; forget to switch to the *Article* buffer before printing,
711 ;; you'll get a nicely formatted list of article subjects shows
712 ;; up at the printer. With major mode printing you don't need to
713 ;; switch from gnus *Summary* buffer first.
715 ;; NOTE 2: There are the following options for PostScript file
717 ;; Ia. Print the file *No Preprocessing*, that is, send it
718 ;; directly to PostScript printer.
719 ;; Ib. PostScript utility processing selection.
720 ;; See `pr-ps-utility-alist' and `pr-setting-database' for
722 ;; Ic. Do n-up processing before printing.
723 ;; Id. Toggle on/off landscape for PostScript file processing.
724 ;; Ie. Toggle on/off duplex for PostScript file processing.
725 ;; If. Toggle on/off tumble for PostScript file processing.
727 ;; NOTE 3: Don't forget to download and install the utilities declared on
728 ;; `pr-ps-utility-alist'.
730 ;; 2. Operate the same way as option 1, but it sends directly the PostScript
731 ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to
732 ;; print the PostScript file generated. It depends on option 18, if it's
733 ;; turned on, it uses ghostscript; otherwise, it sends directly to
734 ;; printer. If spooling is on (option 16), the PostScript code is saved
735 ;; temporarily in a buffer instead of printing it or saving it in a file.
736 ;; Also, if you already have a PostScript file you can print it. Instead
737 ;; of printing each buffer, region or major mode at once, you can save
738 ;; temporarily the PostScript code generated in a buffer and print it
739 ;; later. The option `Despool...' despools the PostScript spooling
740 ;; buffer directly on a printer. If you type C-u before choosing this
741 ;; option, the PostScript code generated is saved in a file instead of
742 ;; sending to printer. To spool the PostScript code generated you need
743 ;; to turn on the option 16. This option is enabled if spooling is on
744 ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
746 ;; 3. You can select a new PostScript printer to send PostScript code
747 ;; generated. For selection it's used all PostScript printers defined
748 ;; in `pr-ps-printer-alist' variable (see it for documentation).
749 ;; See also `pr-setting-database'.
751 ;; II. Text printing:
753 ;; 4. If you have control characters (character code from \000 to \037) in a
754 ;; buffer and you want to print them in a text printer, select this
755 ;; option. All control characters in your buffer or region will be
756 ;; replaced by a printable representation. The printable representations
757 ;; use ^ (for ASCII control characters) or hex. The characters tab,
758 ;; linefeed, space, return and formfeed are not affected. You don't need
759 ;; to select this option if you use any option of section I, the
760 ;; PostScript engine treats control characters properly.
762 ;; 5. If you want to print a directory, buffer, region or major mode in a
763 ;; text printer, select this option. See also the NOTE 1 on option 1.
765 ;; 6. You can select a new text printer to send text generated. For
766 ;; selection it's used all text printers defined in
767 ;; `pr-txt-printer-alist' variable (see it for documentation).
768 ;; See also `pr-setting-database'.
770 ;; III. PostScript page toggle options:
772 ;; 7. If you want a PostScript landscape printing, turn on this option.
774 ;; 8. If you want to have a header in each page in your PostScript code,
775 ;; turn on this option.
777 ;; 9. If you want to draw a gaudy frame around the header, turn on this
778 ;; option. This option is enabled if print header is on (option 8).
780 ;; 10. If you want that the line number is printed in your PostScript code,
781 ;; turn on this option.
783 ;; 11. If you want background zebra stripes in your PostScript code, turn on
786 ;; 12. If you want a duplex printing and your PostScript printer has this
787 ;; feature, turn on this option.
789 ;; 13. If you turned on duplex printing, you can choose if you want to have
790 ;; a printing suitable for binding on the left or right (tumble off), or
791 ;; to have a printing suitable for binding at top or bottom (tumble on).
792 ;; This option is enabled if duplex is on (option 12).
794 ;; 14. If you want a PostScript upside-down printing, turn on this option.
796 ;; 15. With this option, you can choose if you want to print all pages, odd
797 ;; pages, even pages, odd sheets or even sheets.
798 ;; See also `ps-even-or-odd-pages'.
800 ;; IV. PostScript processing toggle options:
802 ;; 16. If you want to spool the PostScript code generated, turn on this
803 ;; option. To spool the PostScript code generated use option 2. You
804 ;; can despool later by choosing option 1 or 2, sub-option `Despool...'.
806 ;; 17. If you use colors in your buffers and want to see these colors on
807 ;; your PostScript code generated, turn on this option. If you have a
808 ;; black/white PostScript printer, these colors are displayed in gray
809 ;; scale by PostScript printer interpreter.
811 ;; 18. If you don't have a PostScript printer to send PostScript files, turn
812 ;; on this option. When this option is on, the ghostscript is used to
813 ;; print PostScript files. In GNU or Unix system, if ghostscript is set
814 ;; as a PostScript filter, you don't need to turn on this option.
816 ;; V. Printing customization:
818 ;; 19. If you want that region is automagically detected, turn on this
819 ;; option. Note that this will only work if you're using transient mark
820 ;; mode. When this option is on, the `*-buffer*' commands will behave
821 ;; like `*-region*' commands, that is, `*-buffer*' commands will print
822 ;; only the region marked instead of all buffer.
824 ;; 20. Turn this option on if you want that when current major-mode is
825 ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
826 ;; behave like `*-mode*' commands.
828 ;; 21. If you want that Printing menu stays open while you are setting
829 ;; toggle options, turn on this option. The variables
830 ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
831 ;; menu position, so don't forget to adjust these variables if menu
832 ;; position is not ok.
834 ;; VI. Customization:
836 ;; 22. Besides all options in section III, IV and V, you can customize much
837 ;; more PostScript options in `ps-print' option. Or you can customize
838 ;; some `lpr' options for text printing. Or customize `printing'
841 ;; 23. Show current settings for `printing', `ps-print' or `lpr'.
843 ;; 24. Quick help for printing menu layout.
849 ;; Below it's shown only the main options that affect all `printing' package.
850 ;; Check all the settings below *BEFORE* running `printing' commands.
852 ;; * Example of setting for GNU or Unix system:
854 ;; (require 'printing)
855 ;; (setq pr-path-alist
856 ;; '((unix "." "~/bin" ghostview mpage PATH)
857 ;; (ghostview "$HOME/bin/gsview-dir")
858 ;; (mpage "$HOME/bin/mpage-dir")
860 ;; (setq pr-txt-name 'prt_06a)
861 ;; (setq pr-txt-printer-alist
862 ;; '((prt_06a "lpr" nil "prt_06a")
863 ;; (prt_07c nil nil "prt_07c")
865 ;; (setq pr-ps-name 'lps_06b)
866 ;; (setq pr-ps-printer-alist
867 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
868 ;; (lps_07c "lpr" nil nil "lps_07c")
869 ;; (lps_08c nil nil nil "lps_08c")
871 ;; (setq pr-temp-dir "/tmp/")
872 ;; (setq pr-gv-command "gv")
873 ;; (setq pr-gs-command "gs")
874 ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
875 ;; (setq pr-gs-device "uniprint")
876 ;; (setq pr-gs-resolution 300)
877 ;; (setq pr-ps-utility 'mpage)
878 ;; (setq pr-ps-utility-alist
879 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
880 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
881 ;; (inherits-from: . no-duplex))
883 ;; (setq pr-setting-database
886 ;; (pr-file-duplex . nil)
887 ;; (pr-file-tumble . nil))
889 ;; (pr-update-menus t) ; update now printer and utility menus
891 ;; * Example of setting for Windows system:
893 ;; (require 'printing)
894 ;; (setq pr-path-alist
895 ;; '((windows "c:/applications/executables" PATH ghostview mpage)
896 ;; (ghostview "c:/gs/gsview-dir")
897 ;; (mpage "c:/mpage-dir")
899 ;; (setq pr-txt-name 'prt_06a)
900 ;; (setq pr-txt-printer-alist
901 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
902 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
903 ;; (PRN "" nil "PRN")
904 ;; (standard "redpr.exe" nil "")
906 ;; (setq pr-ps-name 'lps_06b)
907 ;; (setq pr-ps-printer-alist
908 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
909 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
910 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
911 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
912 ;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name")
913 ;; (LPT1 "" nil "" "LPT1:")
914 ;; (PRN "" nil "" "PRN")
915 ;; (standard "redpr.exe" nil "" "")
917 ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/")
918 ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe")
919 ;; (setq pr-gs-command "c:/gs/gswin32.exe")
920 ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts"))
921 ;; (setq pr-gs-device "mswinpr2")
922 ;; (setq pr-gs-resolution 300)
923 ;; (setq pr-ps-utility 'psnup)
924 ;; (setq pr-ps-utility-alist
925 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " "
926 ;; nil (inherits-from: . no-duplex))
928 ;; (setq pr-setting-database
931 ;; (pr-file-duplex . nil)
932 ;; (pr-file-tumble . nil))
934 ;; (pr-update-menus t) ; update now printer and utility menus
936 ;; NOTE: Don't forget to download and install the utilities declared on
937 ;; `pr-ps-utility-alist'.
943 ;; `printing' package has the following utilities:
945 ;; `pr-setup' Return the current `printing' setup.
947 ;; `lpr-setup' Return the current `lpr' setup.
949 ;; `pr-update-menus' Update utility, PostScript and text printer menus.
951 ;; `pr-menu-bind' Install `printing' menu in the menubar.
954 ;; Below are some URL where you can find good utilities.
956 ;; * For `printing' package:
958 ;; printing `http://www.emacswiki.org/cgi-bin/emacs/download/printing.el'
959 ;; ps-print `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'
961 ;; * For GNU or Unix system:
963 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
964 ;; enscript `http://people.ssh.fi/mtr/genscript/'
965 ;; psnup `http://www.knackered.org/angus/psutils/'
966 ;; mpage `http://www.mesa.nl/pub/mpage/'
968 ;; * For Windows system:
971 ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'
972 ;; gsprint `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'.
973 ;; enscript `http://people.ssh.fi/mtr/genscript/'
974 ;; psnup `http://gnuwin32.sourceforge.net/packages/psutils.htm'
975 ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/'
981 ;; Thanks to Stefan Monnier <monnier@iro.umontreal.ca> for GNU Emacs and XEmacs
982 ;; printing menu (in `pr-menu-spec') merging suggestion.
984 ;; Thanks to Lennart Borgman <lennart.borgman.073@student.lu.se> for gsprint
985 ;; suggestion (see tip 5 in section Tips).
987 ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions:
988 ;; - directory processing.
989 ;; - `pr-path-alist' variable.
991 ;; - a lot of tests on Windows.
993 ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests.
995 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging
996 ;; and for suggestions:
997 ;; - even/odd pages printing.
998 ;; - ghostscript parameters for `pr-ps-printer-alist'.
999 ;; - default printer name.
1000 ;; - completion functions.
1001 ;; - automagic region detection.
1002 ;; - menu entry hiding.
1003 ;; - fast fire PostScript printing command.
1004 ;; - `pr-path-style' variable.
1006 ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions:
1007 ;; - PostScript Print and PostScript Print Preview merge.
1008 ;; - Tools/Printing menu.
1009 ;; - replace *-using-preview by *-using-ghostscript.
1010 ;; - printer selection.
1011 ;; - extra parameters for `pr-ps-printer-alist'.
1014 ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el
1015 ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el
1016 ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el
1017 ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el
1018 ;; And to all people who contributed with them.
1021 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1030 (and (string< ps-print-version
"6.6.4")
1031 (error "`printing' requires `ps-print' package version 6.6.4 or later"))
1034 (defconst pr-cygwin-system
1035 (and ps-windows-system
(getenv "OSTYPE")
1036 (string-match "cygwin" (getenv "OSTYPE"))))
1039 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1040 ;; To avoid compilation gripes
1043 (or (fboundp 'subst-char-in-string
) ; hacked from subr.el
1044 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
1045 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
1046 Unless optional argument INPLACE is non-nil, return a new string."
1047 (let ((i (length string
))
1048 (newstr (if inplace string
(copy-sequence string
))))
1049 (while (> (setq i
(1- i
)) 0)
1050 (if (eq (aref newstr i
) fromchar
)
1051 (aset newstr i tochar
)))
1055 (or (fboundp 'make-temp-file
) ; hacked from subr.el
1056 (defun make-temp-file (prefix &optional dir-flag suffix
)
1057 "Create a temporary file.
1058 The returned file name (created by appending some random characters at the end
1059 of PREFIX, and expanding against `temporary-file-directory' if necessary),
1060 is guaranteed to point to a newly created empty file.
1061 You can then use `write-region' to write new data into the file.
1063 If DIR-FLAG is non-nil, create a new empty directory instead of a file.
1065 If SUFFIX is non-nil, add that at the end of the file name."
1066 (let ((umask (default-file-modes))
1070 ;; Create temp files with strict access rights. It's easy to
1071 ;; loosen them later, whereas it's impossible to close the
1072 ;; time-window of loose permissions otherwise.
1073 (set-default-file-modes ?
\700)
1074 (while (condition-case ()
1078 (expand-file-name prefix temporary-file-directory
)))
1080 (setq file
(concat file suffix
)))
1082 (make-directory file
)
1083 (write-region "" nil file nil
'silent nil
'excl
))
1085 (file-already-exists t
))
1086 ;; the file was somehow created by someone else between
1087 ;; `make-temp-name' and `write-region', let's try again.
1091 (set-default-file-modes umask
)))))
1095 ;; User Interface --- declared here to avoid compiler warnings
1096 (defvar pr-path-style
)
1097 (defvar pr-auto-region
)
1098 (defvar pr-menu-char-height
)
1099 (defvar pr-menu-char-width
)
1100 (defvar pr-menu-lock
)
1101 (defvar pr-ps-printer-alist
)
1102 (defvar pr-txt-printer-alist
)
1103 (defvar pr-ps-utility-alist
)
1106 ;; Internal fun alias to avoid compilation gripes
1107 (defalias 'pr-menu-lookup
'ignore
)
1108 (defalias 'pr-menu-lock
'ignore
)
1109 (defalias 'pr-menu-alist
'ignore
)
1110 (defalias 'pr-even-or-odd-pages
'ignore
)
1111 (defalias 'pr-menu-get-item
'ignore
)
1112 (defalias 'pr-menu-set-item-name
'ignore
)
1113 (defalias 'pr-menu-set-utility-title
'ignore
)
1114 (defalias 'pr-menu-set-ps-title
'ignore
)
1115 (defalias 'pr-menu-set-txt-title
'ignore
)
1116 (defalias 'pr-region-active-p
'ignore
)
1117 (defalias 'pr-do-update-menus
'ignore
)
1118 (defalias 'pr-update-mode-line
'ignore
)
1119 (defalias 'pr-read-string
'ignore
)
1120 (defalias 'pr-set-keymap-parents
'ignore
)
1121 (defalias 'pr-keep-region-active
'ignore
))
1124 ;; Internal Vars --- defined here to avoid compiler warnings
1125 (defvar pr-menu-print-item
"print"
1126 "Non-nil means that menu binding was not done.
1128 Used by `pr-menu-bind' and `pr-update-menus'.")
1130 (defvar pr-ps-printer-menu-modified t
1131 "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.")
1133 (defvar pr-txt-printer-menu-modified t
1134 "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.")
1136 (defvar pr-ps-utility-menu-modified t
1137 "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.")
1139 (defconst pr-even-or-odd-alist
1140 '((nil .
"Print All Pages")
1141 (even-page .
"Print Even Pages")
1142 (odd-page .
"Print Odd Pages")
1143 (even-sheet .
"Print Even Sheets")
1144 (odd-sheet .
"Print Odd Sheets")))
1147 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1148 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1149 ;; XEmacs Definitions
1153 ((featurep 'xemacs
) ; XEmacs
1155 (defalias 'pr-set-keymap-parents
'set-keymap-parents
)
1156 (defalias 'pr-set-keymap-name
'set-keymap-name
)
1159 (defun pr-read-string (prompt initial history default
)
1160 (let ((str (read-string prompt initial
)))
1161 (if (and str
(not (string= str
"")))
1166 (defvar zmacs-region-stays nil
)
1169 (defun pr-keep-region-active ()
1170 (setq zmacs-region-stays t
))
1173 (defun pr-region-active-p ()
1174 (and pr-auto-region
(not zmacs-region-stays
) (ps-mark-active-p)))
1177 (defun pr-menu-char-height ()
1178 (font-height (face-font 'default
)))
1181 (defun pr-menu-char-width ()
1182 (font-width (face-font 'default
)))
1185 (defmacro pr-xemacs-global-menubar
(&rest body
)
1187 (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
1188 ;; be sure to access global menubar
1191 (kill-buffer temp
))))
1194 (defun pr-global-menubar (pr-menu-spec)
1196 (pr-xemacs-global-menubar
1197 (add-submenu nil
(cons "Printing" pr-menu-spec
) "Apps"))
1198 (setq pr-menu-print-item nil
))
1201 (defvar current-mouse-event nil
)
1202 (defun pr-menu-position (entry index horizontal
)
1206 'x
(- (event-x-pixel current-mouse-event
) ; X
1207 (* horizontal pr-menu-char-width
))
1208 'y
(- (event-y-pixel current-mouse-event
) ; Y
1209 (* (pr-menu-index entry index
) pr-menu-char-height
)))))
1211 (defvar pr-menu-position nil
)
1212 (defvar pr-menu-state nil
)
1215 (defvar current-menubar nil
) ; to avoid compilation gripes
1216 (defun pr-menu-lookup (path)
1217 (car (find-menu-item current-menubar
(cons "Printing" path
))))
1220 (defun pr-menu-lock (entry index horizontal state path
)
1222 (or (and pr-menu-position
(eq state pr-menu-state
))
1223 (setq pr-menu-position
(pr-menu-position entry index horizontal
)
1224 pr-menu-state state
))
1225 (let* ((menu (pr-menu-lookup path
))
1226 (result (get-popup-menu-response menu pr-menu-position
)))
1227 (and (misc-user-event-p result
)
1228 (funcall (event-function result
)
1229 (event-object result
))))
1230 (setq pr-menu-position nil
)))
1233 (defalias 'pr-update-mode-line
'set-menubar-dirty-flag
)
1236 (defvar pr-ps-name-old
"PostScript Printers")
1237 (defvar pr-txt-name-old
"Text Printers")
1238 (defvar pr-ps-utility-old
"PostScript Utility")
1239 (defvar pr-even-or-odd-old
"Print All Pages")
1242 (defun pr-do-update-menus (&optional force
)
1243 (pr-menu-alist pr-ps-printer-alist
1245 'pr-menu-set-ps-title
1247 'pr-ps-printer-menu-modified
1251 (pr-menu-alist pr-txt-printer-alist
1253 'pr-menu-set-txt-title
1255 'pr-txt-printer-menu-modified
1259 (let ((save-var pr-ps-utility-menu-modified
))
1260 (pr-menu-alist pr-ps-utility-alist
1262 'pr-menu-set-utility-title
1263 '("Printing" "PostScript Print" "File")
1268 (pr-menu-alist pr-ps-utility-alist
1270 'pr-menu-set-utility-title
1271 '("Printing" "PostScript Preview" "File")
1272 'pr-ps-utility-menu-modified
1276 (pr-even-or-odd-pages ps-even-or-odd-pages force
))
1279 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
1281 (when (and alist
(or force
(symbol-value modified-sym
)))
1282 (pr-xemacs-global-menubar
1283 (add-submenu menu-path
1284 (pr-menu-create name alist var-sym
1286 (funcall fun
(symbol-value var-sym
))
1287 (set modified-sym nil
)))
1290 (defun pr-relabel-menu-item (newname var-sym
)
1291 (pr-xemacs-global-menubar
1293 (list "Printing" (symbol-value var-sym
))
1295 (set var-sym newname
)))
1298 (defun pr-menu-set-ps-title (value &optional item entry index
)
1299 (pr-relabel-menu-item (format "PostScript Printer: %s" value
)
1301 (pr-ps-set-printer value
)
1303 (pr-menu-lock entry index
12 'toggle nil
)))
1306 (defun pr-menu-set-txt-title (value &optional item entry index
)
1307 (pr-relabel-menu-item (format "Text Printer: %s" value
)
1309 (pr-txt-set-printer value
)
1311 (pr-menu-lock entry index
12 'toggle nil
)))
1314 (defun pr-menu-set-utility-title (value &optional item entry index
)
1315 (pr-xemacs-global-menubar
1316 (let ((newname (format "%s" value
)))
1318 (list "Printing" "PostScript Print" "File" pr-ps-utility-old
)
1321 (list "Printing" "PostScript Preview" "File" pr-ps-utility-old
)
1323 (setq pr-ps-utility-old newname
)))
1324 (pr-ps-set-utility value
)
1326 (pr-menu-lock entry index
5 nil
'("PostScript Print" "File"))))
1329 (defun pr-even-or-odd-pages (value &optional no-lock
)
1330 (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist
))
1331 'pr-even-or-odd-old
)
1332 (setq ps-even-or-odd-pages value
)
1334 (pr-menu-lock 'postscript-options
8 12 'toggle nil
)))
1339 )) ; end cond featurep
1343 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1344 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1345 ;; GNU Emacs Definitions
1349 ((featurep 'xemacs
) ; XEmacs
1354 (defalias 'pr-set-keymap-parents
'set-keymap-parent
)
1355 (defalias 'pr-set-keymap-name
'ignore
)
1356 (defalias 'pr-read-string
'read-string
)
1359 (defvar deactivate-mark
)
1362 (defun pr-keep-region-active ()
1363 (setq deactivate-mark nil
))
1366 (defun pr-region-active-p ()
1367 (and pr-auto-region transient-mark-mode mark-active
))
1370 (defun pr-menu-char-height ()
1371 (frame-char-height))
1374 (defun pr-menu-char-width ()
1377 (defvar pr-menu-bar nil
1378 "Specify Printing menu-bar entry.")
1382 ;; Replace existing "print" item by "Printing" item.
1383 ;; If you're changing this file, you'll load it a second,
1384 ;; third... time, but "print" item exists only in the first load.
1386 (require 'easymenu
)) ; to avoid compilation gripes
1389 (defun pr-global-menubar (pr-menu-spec)
1391 (let ((menu-file (if (= emacs-major-version
21)
1392 '("menu-bar" "files") ; GNU Emacs 21
1393 '("menu-bar" "file")))) ; GNU Emacs 22 or higher
1396 (easy-menu-add-item global-map menu-file
1397 (easy-menu-create-menu "Print" pr-menu-spec
)
1399 (dolist (item '("print-buffer" "print-region"
1400 "ps-print-buffer-faces" "ps-print-region-faces"
1401 "ps-print-buffer" "ps-print-region"))
1402 (easy-menu-remove-item global-map menu-file item
))
1403 (setq pr-menu-print-item nil
1404 pr-menu-bar
(vector 'menu-bar
1405 (pr-get-symbol (nth 1 menu-file
))
1406 (pr-get-symbol "Print"))))
1408 (easy-menu-add-item global-map menu-file
1409 (easy-menu-create-menu "Print" pr-menu-spec
)))
1415 ;; GNU Emacs for Windows 9x/NT
1416 (defun pr-menu-position (entry index horizontal
)
1417 (let ((pos (cdr (mouse-pixel-position))))
1419 (list (or (car pos
) 0) ; X
1420 (- (or (cdr pos
) 0) ; Y
1421 (* (pr-menu-index entry index
) pr-menu-char-height
)))
1422 (selected-frame)))) ; frame
1426 (defun pr-menu-position (entry index horizontal
)
1427 (let ((pos (cdr (mouse-pixel-position))))
1429 (list (- (or (car pos
) 0) ; X
1430 (* horizontal pr-menu-char-width
))
1431 (- (or (cdr pos
) 0) ; Y
1432 (* (pr-menu-index entry index
) pr-menu-char-height
)))
1433 (selected-frame)))) ; frame
1436 (defvar pr-menu-position nil
)
1437 (defvar pr-menu-state nil
)
1440 (defun pr-menu-lookup (path)
1441 (lookup-key global-map
1443 (vconcat pr-menu-bar
1444 (mapcar 'pr-get-symbol
1451 (defun pr-menu-lock (entry index horizontal state path
)
1453 (or (and pr-menu-position
(eq state pr-menu-state
))
1454 (setq pr-menu-position
(pr-menu-position entry index horizontal
)
1455 pr-menu-state state
))
1456 (let* ((menu (pr-menu-lookup path
))
1457 (result (x-popup-menu pr-menu-position menu
)))
1459 (let ((command (lookup-key menu
(vconcat result
))))
1460 (if (fboundp command
)
1463 (setq pr-menu-position nil
)))
1466 (defalias 'pr-update-mode-line
'force-mode-line-update
)
1469 (defun pr-do-update-menus (&optional force
)
1470 (pr-menu-alist pr-ps-printer-alist
1472 'pr-menu-set-ps-title
1473 "PostScript Printers"
1474 'pr-ps-printer-menu-modified
1476 "PostScript Printers"
1478 (pr-menu-alist pr-txt-printer-alist
1480 'pr-menu-set-txt-title
1482 'pr-txt-printer-menu-modified
1486 (let ((save-var pr-ps-utility-menu-modified
))
1487 (pr-menu-alist pr-ps-utility-alist
1489 'pr-menu-set-utility-title
1490 '("PostScript Print" "File" "PostScript Utility")
1493 "PostScript Utility"
1495 (pr-menu-alist pr-ps-utility-alist
1497 'pr-menu-set-utility-title
1498 '("PostScript Preview" "File" "PostScript Utility")
1499 'pr-ps-utility-menu-modified
1501 "PostScript Utility"
1503 (pr-even-or-odd-pages ps-even-or-odd-pages force
))
1506 (defun pr-menu-get-item (name-list)
1507 ;; NAME-LIST is a string or a list of strings.
1508 (or (listp name-list
)
1509 (setq name-list
(list name-list
)))
1511 (let* ((reversed (reverse name-list
))
1512 (name (pr-get-symbol (car reversed
)))
1513 (path (nreverse (cdr reversed
)))
1516 (vconcat pr-menu-bar
1517 (mapcar 'pr-get-symbol path
)))))
1518 (assq name
(nthcdr 2 menu
)))))
1521 (defvar pr-temp-menu nil
)
1524 (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
1526 (when (and alist
(or force
(symbol-value modified-sym
)))
1527 (easy-menu-define pr-temp-menu nil
""
1528 (pr-menu-create name alist var-sym fun entry index
))
1529 (let ((item (pr-menu-get-item menu-path
)))
1531 (let* ((binding (nthcdr 3 item
))
1532 (key-binding (cdr binding
)))
1533 (setcar binding pr-temp-menu
)
1534 (and key-binding
(listp (car key-binding
))
1535 (setcdr binding
(cdr key-binding
))) ; skip KEY-BINDING
1536 (funcall fun
(symbol-value var-sym
) item
))))
1537 (set modified-sym nil
)))
1540 (defun pr-menu-set-item-name (item name
)
1542 (setcar (nthcdr 2 item
) name
))) ; ITEM-NAME
1545 (defun pr-menu-set-ps-title (value &optional item entry index
)
1546 (pr-menu-set-item-name (or item
1547 (pr-menu-get-item "PostScript Printers"))
1548 (format "PostScript Printer: %s" value
))
1549 (pr-ps-set-printer value
)
1551 (pr-menu-lock entry index
12 'toggle nil
)))
1554 (defun pr-menu-set-txt-title (value &optional item entry index
)
1555 (pr-menu-set-item-name (or item
1556 (pr-menu-get-item "Text Printers"))
1557 (format "Text Printer: %s" value
))
1558 (pr-txt-set-printer value
)
1560 (pr-menu-lock entry index
12 'toggle nil
)))
1563 (defun pr-menu-set-utility-title (value &optional item entry index
)
1564 (let ((name (symbol-name value
)))
1566 (pr-menu-set-item-name item name
)
1567 (pr-menu-set-item-name
1569 '("PostScript Print" "File" "PostScript Utility"))
1571 (pr-menu-set-item-name
1573 '("PostScript Preview" "File" "PostScript Utility"))
1575 (pr-ps-set-utility value
)
1577 (pr-menu-lock entry index
5 nil
'("PostScript Print" "File"))))
1580 (defun pr-even-or-odd-pages (value &optional no-lock
)
1581 (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
1582 (cdr (assq value pr-even-or-odd-alist
)))
1583 (setq ps-even-or-odd-pages value
)
1585 (pr-menu-lock 'postscript-options
8 12 'toggle nil
)))
1587 )) ; end cond featurep
1590 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1591 ;; Internal Functions (I)
1594 (defun pr-dosify-file-name (path)
1595 "Replace unix-style directory separator character with dos/windows one."
1596 (interactive "sPath: ")
1597 (if (eq pr-path-style
'windows
)
1598 (subst-char-in-string ?
/ ?
\\ path
)
1602 (defun pr-unixify-file-name (path)
1603 "Replace dos/windows-style directory separator character with unix one."
1604 (interactive "sPath: ")
1605 (if (eq pr-path-style
'windows
)
1606 (subst-char-in-string ?
\\ ?
/ path
)
1610 (defun pr-standard-file-name (path)
1611 "Ensure the proper directory separator depending on the OS.
1612 That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory
1613 separator; otherwise, ensure unix-style directory separator."
1614 (if (or pr-cygwin-system ps-windows-system
)
1615 (subst-char-in-string ?
/ ?
\\ path
)
1616 (subst-char-in-string ?
\\ ?
/ path
)))
1619 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1620 ;; Customization Functions
1623 (defun pr-alist-custom-set (symbol value
)
1624 "Set the value of custom variables for printer & utility selection."
1626 (and (featurep 'printing
) ; update only after printing is loaded
1627 (pr-update-menus t
)))
1630 (defun pr-ps-utility-custom-set (symbol value
)
1631 "Update utility menu entry."
1633 (and (featurep 'printing
) ; update only after printing is loaded
1634 (pr-menu-set-utility-title value
)))
1637 (defun pr-ps-name-custom-set (symbol value
)
1638 "Update `PostScript Printer:' menu entry."
1640 (and (featurep 'printing
) ; update only after printing is loaded
1641 (pr-menu-set-ps-title value
)))
1644 (defun pr-txt-name-custom-set (symbol value
)
1645 "Update `Text Printer:' menu entry."
1647 (and (featurep 'printing
) ; update only after printing is loaded
1648 (pr-menu-set-txt-title value
)))
1651 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1655 (defgroup printing nil
1656 "Printing Utilities group."
1657 :tag
"Printing Utilities"
1658 :link
'(emacs-library-link :tag
"Source Lisp File" "printing.el")
1665 (defcustom pr-path-style
1666 (if (and (not pr-cygwin-system
)
1670 "Specify which path style to use for external commands.
1674 windows Windows 9x/NT style (\\)
1676 unix Unix style (/)"
1677 :type
'(choice :tag
"Path style"
1678 (const :tag
"Windows 9x/NT Style (\\)" :value windows
)
1679 (const :tag
"Unix Style (/)" :value unix
))
1683 (defcustom pr-path-alist
1687 "Specify an alist for command paths.
1689 It's used to find commands used for printing package, like gv, gs, gsview.exe,
1690 mpage, print.exe, etc. See also `pr-command' function.
1692 Each element has the form:
1694 (ENTRY DIRECTORY...)
1698 ENTRY It's a symbol, used to identify this entry.
1699 There must exist at least one of the following entries:
1701 unix this entry is used when Emacs is running on GNU or
1704 cygwin this entry is used when Emacs is running on Windows
1705 95/98/NT/2000 with Cygwin.
1707 windows this entry is used when Emacs is running on Windows
1710 DIRECTORY It should be a string or a symbol. If it's a symbol, it should
1711 exist an equal entry in `pr-path-alist'. If it's a string,
1712 it's considered a directory specification.
1714 The directory specification may contain:
1715 $var environment variable expansion
1717 ./ current directory
1718 ../ previous directory
1720 For example, let's say the home directory is /home/my and the
1721 current directory is /home/my/dir, so:
1723 THE ENTRY IS EXPANDED TO
1724 ~/entry /home/my/entry
1725 ./entry /home/my/dir/entry
1726 ../entry /home/my/entry
1727 $HOME/entry /home/my/entry
1728 $HOME/~/other/../my/entry /home/my/entry
1730 SPECIAL SYMBOL: If the symbol `PATH' is used in the directory
1731 list and there isn't a `PATH' entry in `pr-path-alist' or the
1732 `PATH' entry has a null directory list, the PATH environment
1737 * On GNU or Unix system:
1739 '((unix \".\" \"~/bin\" ghostview mpage PATH)
1740 (ghostview \"$HOME/bin/gsview-dir\")
1741 (mpage \"$HOME/bin/mpage-dir\")
1744 * On Windows system:
1746 '((windows \"c:/applications/executables\" PATH ghostview mpage)
1747 (ghostview \"c:/gs/gsview-dir\")
1748 (mpage \"c:/mpage-dir\")
1752 (symbol :tag
"Identifier ")
1753 (repeat :tag
"Directory List"
1754 (choice :menu-tag
"Directory"
1757 (symbol :value symbol
)))))
1761 (defcustom pr-txt-name
'default
1762 "Specify a printer for printing a text file.
1764 The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
1767 This variable should be modified by customization engine. If this variable is
1768 modified by other means (for example, a lisp function), use `pr-update-menus'
1769 function (see it for documentation) to update text printer menu."
1771 :set
'pr-txt-name-custom-set
1775 (defcustom pr-txt-printer-alist
1776 (list (list 'default lpr-command nil
1777 (cond ((boundp 'printer-name
) printer-name
)
1778 (ps-windows-system "PRN")
1782 ;; * On GNU or Unix system:
1783 ;; '((prt_06a "lpr" nil "prt_06a")
1784 ;; (prt_07c nil nil "prt_07c")
1786 ;; * On Windows system:
1787 ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
1788 ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
1789 ;; (PRN "" nil "PRN")
1790 ;; (standard "redpr.exe" nil "")
1792 "Specify an alist of all text printers (text printer database).
1794 The alist element has the form:
1796 (SYMBOL COMMAND SWITCHES NAME)
1800 SYMBOL It's a symbol to identify a text printer. It's for
1801 `pr-txt-name' variable setting and for menu selection.
1806 COMMAND Name of the program for printing a text file. On MS-DOS and
1807 MS-Windows systems, if the value is an empty string, then Emacs
1808 will write directly to the printer port given by NAME (see text
1809 below), that is, the NAME should be something like \"PRN\" or
1811 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1812 COMMAND shouldn't be an empty string.
1813 The programs `print' and `nprint' (the standard print programs
1814 on Windows NT and Novell Netware respectively) are handled
1815 specially, using NAME as the destination for output; any other
1816 program is treated like `lpr' except that an explicit filename
1817 is given as the last argument.
1818 If COMMAND is nil, it's used the default printing program:
1819 `print' for Windows system, `lp' for lp system and `lpr' for
1820 all other systems. See also `pr-path-alist'.
1826 SWITCHES List of sexp's to pass as extra options for text printer
1827 program. It is recommended to set NAME (see text below)
1828 instead of including an explicit switch on this list.
1834 NAME A string that specifies a text printer name.
1835 On Unix-like systems, a string value should be a name
1836 understood by lpr's -P option (or lp's -d option).
1837 On MS-DOS and MS-Windows systems, it is the name of a printer
1838 device or port. Typical non-default settings would be \"LPT1:\"
1839 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
1840 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
1841 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
1842 printer. You can also set it to a name of a file, in which
1843 case the output gets appended to that file. If you want to
1844 discard the printed output, set this to \"NUL\".
1847 \"/D:\\\\\\\\host\\\\share-name\"
1854 This variable should be modified by customization engine. If this variable is
1855 modified by other means (for example, a lisp function), use `pr-update-menus'
1856 function (see it for documentation) to update text printer menu.
1860 * On GNU or Unix system:
1862 '((prt_06a \"lpr\" nil \"prt_06a\")
1863 (prt_07c nil nil \"prt_07c\")
1866 * On Windows system:
1868 '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\")
1869 (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\")
1870 (PRN \"\" nil \"PRN\")
1871 (standard \"redpr.exe\" nil \"\")
1876 * Information about the print command (print.exe)
1877 `http://www.computerhope.com/printhlp.htm'
1879 * RedMon - Redirection Port Monitor (redpr.exe)
1880 `http://www.cs.wisc.edu/~ghost/redmon/index.htm'
1882 * Redirection Port Monitor (redpr.exe on-line help)
1883 `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm'
1885 * UNIX man pages: lpr (or type `man lpr')
1886 `http://bama.ua.edu/cgi-bin/man-cgi?lpr'
1887 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr'
1889 * UNIX man pages: lp (or type `man lp')
1890 `http://bama.ua.edu/cgi-bin/man-cgi?lp'
1891 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
1894 (list :tag
"Text Printer"
1895 (symbol :tag
"Printer Symbol Name")
1896 (string :tag
"Printer Command")
1897 (repeat :tag
"Printer Switches"
1898 (sexp :tag
"Switch" :value
""))
1899 (choice :menu-tag
"Printer Name"
1901 (const :tag
"None" nil
)
1903 :set
'pr-alist-custom-set
1907 (defcustom pr-ps-name
'default
1908 "Specify a printer for printing a PostScript file.
1910 This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
1913 This variable should be modified by customization engine. If this variable is
1914 modified by other means (for example, a lisp function), use `pr-update-menus'
1915 function (see it for documentation) to update PostScript printer menu."
1917 :set
'pr-ps-name-custom-set
1921 (defcustom pr-ps-printer-alist
1922 (list (list 'default lpr-command nil
1923 (cond (ps-windows-system nil
)
1926 (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name
)))
1928 ;; * On GNU or Unix system:
1929 ;; '((lps_06b "lpr" nil "-P" "lps_06b")
1930 ;; (lps_07c "lpr" nil nil "lps_07c")
1931 ;; (lps_08c nil nil nil "lps_08c")
1933 ;; * On Windows system:
1934 ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
1935 ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
1936 ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
1937 ;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
1938 ;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name")
1939 ;; (LPT1 "" nil "" "LPT1:")
1940 ;; (PRN "" nil "" "PRN")
1941 ;; (standard "redpr.exe" nil "" "")
1943 "Specify an alist for all PostScript printers (PostScript printer database).
1945 The alist element has the form:
1947 (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...)
1951 SYMBOL It's a symbol to identify a PostScript printer. It's for
1952 `pr-ps-name' variable setting and for menu selection.
1957 COMMAND Name of the program for printing a PostScript file. On MS-DOS
1958 and MS-Windows systems, if the value is an empty string then
1959 Emacs will write directly to the printer port given by NAME
1960 (see text below), that is, the NAME should be something like
1961 \"PRN\" or \"LPT1:\".
1962 If NAME is something like \"\\\\\\\\host\\\\share-name\" then
1963 COMMAND shouldn't be an empty string.
1964 The programs `print' and `nprint' (the standard print programs
1965 on Windows NT and Novell Netware respectively) are handled
1966 specially, using NAME as the destination for output; any other
1967 program is treated like `lpr' except that an explicit filename
1968 is given as the last argument.
1969 If COMMAND is nil, it's used the default printing program:
1970 `print' for Windows system, `lp' for lp system and `lpr' for
1971 all other systems. See also `pr-path-alist'.
1979 SWITCHES List of sexp's to pass as extra options for PostScript printer
1980 program. It is recommended to set NAME (see text below)
1981 instead of including an explicit switch on this list.
1988 '(\"-all\" \"-twoup\")
1990 PRINTER-SWITCH A string that specifies PostScript printer name switch. If
1991 it's necessary to have a space between PRINTER-SWITCH and NAME,
1992 it should be inserted at the end of PRINTER-SWITCH string.
1993 If PRINTER-SWITCH is nil, it's used the default printer name
1994 switch: `/D:' for Windows system, `-d' for lp system and `-P'
1995 for all other systems.
2009 NAME A string that specifies a PostScript printer name.
2010 On Unix-like systems, a string value should be a name
2011 understood by lpr's -P option (or lp's -d option).
2012 On MS-DOS and MS-Windows systems, it is the name of a printer
2013 device or port. Typical non-default settings would be \"LPT1:\"
2014 to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
2015 \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
2016 (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
2017 printer. You can also set it to a name of a file, in which
2018 case the output gets appended to that file. If you want to
2019 discard the printed output, set this to \"NUL\".
2022 \"\\\\\\\\host\\\\share-name\"
2024 . for print.exe or gsprint.exe
2025 \"/D:\\\\\\\\host\\\\share-name\"
2026 \"\\\\\\\\host\\\\share-name\"
2033 DEFAULT It's a way to set default values when this entry is selected.
2038 Which associates VARIABLE with VALUE. When this entry is
2039 selected, it's executed the following command:
2041 (set VARIABLE (eval VALUE))
2043 Note that VALUE can be any valid lisp expression. So, don't
2044 forget to quote symbols and constant lists.
2045 If VARIABLE is the special keyword `inherits-from:', VALUE must
2046 be a symbol name setting defined in `pr-setting-database' from
2047 which the current setting inherits the context. Take care with
2048 circular inheritance.
2050 '(ps-landscape-mode . nil)
2051 '(ps-spool-duplex . t)
2052 '(pr-gs-device . (my-gs-device t))
2054 This variable should be modified by customization engine. If this variable is
2055 modified by other means (for example, a lisp function), use `pr-update-menus'
2056 function (see it for documentation) to update PostScript printer menu.
2060 * On GNU or Unix system:
2062 '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\")
2063 (lps_07c \"lpr\" nil nil \"lps_07c\")
2064 (lps_08c nil nil nil \"lps_08c\")
2067 * On Windows system:
2069 '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\")
2070 (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\")
2071 (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\")
2072 (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\")
2073 (b/w1 \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"b/w-pr-name\")
2074 (b/w2 \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer \\\\\\\\printers\\\\lps_06a\")
2075 (LPT1 \"\" nil \"\" \"LPT1:\")
2076 (PRN \"\" nil \"\" \"PRN\")
2077 (standard \"redpr.exe\" nil \"\" \"\")
2083 You can use gsprint instead of ghostscript to print monochrome PostScript files
2084 in Windows. The gsprint utility documentation says that it is more efficient
2085 than ghostscript to print monochrome PostScript.
2087 To print non-monochrome PostScript file, the efficiency of ghostscript is
2090 Also the gsprint utility comes together with gsview distribution.
2092 As an example of gsprint declaration:
2094 (setq pr-ps-printer-alist
2095 '((A \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"lps_015\")
2096 (B \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer lps_015\")
2097 ;; some other printer declaration
2100 The example above declares that printer A prints all pages (-all) and two pages
2101 per sheet (-twoup). The printer B declaration does the same as the printer A
2102 declaration, the only difference is the printer name selection.
2104 There are other command line options like:
2106 -mono Render in monochrome as 1bit/pixel (only black and white).
2107 -grey Render in greyscale as 8bits/pixel.
2108 -color Render in color as 24bits/pixel.
2110 The default is `-mono'. So, printer A and B in the example above are using
2111 implicitly the `-mono' option. Note that in `-mono' no gray tone or color is
2112 printed, this includes the zebra stripes, that is, in `-mono' the zebra stripes
2118 * GSPRINT - Ghostscript print to Windows printer
2119 `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'
2121 * Introduction to Ghostscript
2122 `http://www.cs.wisc.edu/~ghost/doc/intro.htm'
2124 * How to use Ghostscript
2125 `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
2127 * Information about the print command (print.exe)
2128 `http://www.computerhope.com/printhlp.htm'
2130 * RedMon - Redirection Port Monitor (redpr.exe)
2131 `http://www.cs.wisc.edu/~ghost/redmon/index.htm'
2133 * Redirection Port Monitor (redpr.exe on-line help)
2134 `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm'
2136 * UNIX man pages: lpr (or type `man lpr')
2137 `http://bama.ua.edu/cgi-bin/man-cgi?lpr'
2138 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr'
2140 * UNIX man pages: lp (or type `man lp')
2141 `http://bama.ua.edu/cgi-bin/man-cgi?lp'
2142 `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
2144 * GNU utilities for w32 (cp.exe)
2145 `http://unxutils.sourceforge.net/'
2149 :tag
"PostScript Printer"
2150 (symbol :tag
"Printer Symbol Name")
2151 (string :tag
"Printer Command")
2152 (repeat :tag
"Printer Switches"
2153 (sexp :tag
"Switch" :value
""))
2154 (choice :menu-tag
"Printer Name Switch"
2155 :tag
"Printer Name Switch"
2156 (const :tag
"None" nil
)
2158 (choice :menu-tag
"Printer Name"
2160 (const :tag
"None" nil
)
2163 :tag
"Default Value List"
2168 :menu-tag
"Variable"
2170 (const :tag
"Landscape" ps-landscape-mode
)
2171 (const :tag
"Print Header" ps-print-header
)
2172 (const :tag
"Print Header Frame" ps-print-header-frame
)
2173 (const :tag
"Line Number" ps-line-number
)
2174 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2175 (const :tag
"Duplex" ps-spool-duplex
)
2176 (const :tag
"Tumble" ps-spool-tumble
)
2177 (const :tag
"Upside-Down" ps-print-upside-down
)
2178 (const :tag
"PS File Landscape" pr-file-landscape
)
2179 (const :tag
"PS File Duplex" pr-file-duplex
)
2180 (const :tag
"PS File Tumble" pr-file-tumble
)
2181 (const :tag
"Auto Region" pr-auto-region
)
2182 (const :tag
"Auto Mode" pr-auto-mode
)
2183 (const :tag
"Ghostscript Device" pr-gs-device
)
2184 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2185 (const :tag
"inherits-from:" inherits-from
:)
2186 (variable :tag
"Other"))
2187 (sexp :tag
"Value")))
2189 :set
'pr-alist-custom-set
2193 (defcustom pr-temp-dir
2194 (pr-dosify-file-name
2195 (if (boundp 'temporary-file-directory
)
2196 (symbol-value 'temporary-file-directory
)
2197 ;; hacked from `temporary-file-directory' variable in files.el
2198 (file-name-as-directory
2199 (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
2200 (cond (ps-windows-system "c:/temp")
2203 "Specify a directory for temporary files during printing.
2205 See also `pr-ps-temp-file' and `pr-file-modes'."
2206 :type
'(directory :tag
"Temporary Directory")
2210 (defcustom pr-ps-temp-file
"prspool-"
2211 "Specify PostScript temporary file name prefix.
2213 See also `pr-temp-dir' and `pr-file-modes'."
2214 :type
'(file :tag
"PostScript Temporary File Name")
2218 ;; It uses 0600 as default instead of (default-file-modes).
2219 ;; So, by default, only the session owner have permission to deal with files
2220 ;; generated by `printing'.
2221 (defcustom pr-file-modes ?
\600
2222 "Specify the file permission bits for newly created files.
2224 It should be an integer; only the low 9 bits are used.
2226 See also `pr-temp-dir' and `pr-ps-temp-file'."
2227 :type
'(integer :tag
"File Permission Bits")
2231 (defcustom pr-gv-command
2232 (if ps-windows-system
2235 "Specify path and name of the gsview/gv utility.
2237 See also `pr-path-alist'.
2242 `http://www.gnu.org/software/gv/manual/gv.html'
2245 `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm'
2247 * GSview Help - Common Problems
2248 `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm#Common_Problems'
2250 * GSview Readme (compilation & installation)
2251 `http://www.cs.wisc.edu/~ghost/gsview/Readme.htm'
2253 * GSview (main site)
2254 `http://www.cs.wisc.edu/~ghost/gsview/index.htm'
2256 * Ghostscript, Ghostview and GSview
2257 `http://www.cs.wisc.edu/~ghost/'
2260 `http://www.cs.wisc.edu/~ghost/gv/index.htm'
2263 `http://www.cs.wisc.edu/~ghost/gv/gv_doc/gv.html'
2266 `http://www.cs.wisc.edu/~ghost/macos/index.htm'
2268 :type
'(string :tag
"Ghostview Utility")
2272 (defcustom pr-gs-command
2273 (if ps-windows-system
2276 "Specify path and name of the ghostscript utility.
2278 See also `pr-path-alist'.
2282 * Ghostscript, Ghostview and GSview
2283 `http://www.cs.wisc.edu/~ghost/'
2285 * Introduction to Ghostscript
2286 `http://www.cs.wisc.edu/~ghost/doc/intro.htm'
2288 * How to use Ghostscript
2289 `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
2291 * Printer compatibility
2292 `http://www.cs.wisc.edu/~ghost/doc/printer.htm'
2294 :type
'(string :tag
"Ghostscript Utility")
2298 (defcustom pr-gs-switches
2299 (if ps-windows-system
2300 '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")
2301 '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
2302 "Specify ghostscript switches. See the documentation on GS for more info.
2304 It's a list of strings, where each string is one or more ghostscript switches.
2306 A note on the gs switches:
2309 -dNOPAUSE don't wait for user intervention
2310 -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs
2311 -c quit it's added at the end to terminate gs
2313 To see ghostscript documentation for more information:
2315 * On GNU or Unix system:
2316 - for full documentation, type: man gs
2317 - for brief documentation, type: gs -h
2319 * On Windows system:
2320 - for full documentation, see in a browser the file
2321 c:/gstools/gs5.50/index.html, that is, the file index.html which is
2322 located in the same directory as gswin32.exe.
2323 - for brief documentation, type: gswin32.exe -h
2327 * Introduction to Ghostscript
2328 `http://www.cs.wisc.edu/~ghost/doc/intro.htm'
2330 * How to use Ghostscript
2331 `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
2333 * Printer compatibility
2334 `http://www.cs.wisc.edu/~ghost/doc/printer.htm'
2336 :type
'(repeat (string :tag
"Ghostscript Switch"))
2340 (defcustom pr-gs-device
2341 (if ps-windows-system
2344 "Specify the ghostscript device switch value (-sDEVICE=).
2346 A note on the gs switches:
2348 -sDEVICE=djet500 the printer - works with HP DeskJet 540
2350 See `pr-gs-switches' for documentation.
2351 See also `pr-ps-printer-alist'."
2352 :type
'(string :tag
"Ghostscript Device")
2356 (defcustom pr-gs-resolution
300
2357 "Specify ghostscript resolution switch value (-r).
2359 A note on the gs switches:
2361 -r300 resolution 300x300
2363 See `pr-gs-switches' for documentation.
2364 See also `pr-ps-printer-alist'."
2365 :type
'(integer :tag
"Ghostscript Resolution")
2369 (defcustom pr-print-using-ghostscript nil
2370 "Non-nil means print using ghostscript.
2372 This is useful if you don't have a PostScript printer, so you could use the
2373 ghostscript to print a PostScript file.
2375 In GNU or Unix system, if ghostscript is set as a PostScript filter, this
2376 variable should be nil."
2381 (defcustom pr-faces-p nil
2382 "Non-nil means print with face attributes."
2387 (defcustom pr-spool-p nil
2388 "Non-nil means spool printing in a buffer."
2393 (defcustom pr-file-landscape nil
2394 "Non-nil means print PostScript file in landscape orientation."
2399 (defcustom pr-file-duplex nil
2400 "Non-nil means print PostScript file in duplex mode."
2405 (defcustom pr-file-tumble nil
2406 "Non-nil means print PostScript file in tumble mode.
2408 If tumble is off, produces a printing suitable for binding on the left or
2410 If tumble is on, produces a printing suitable for binding at the top or
2416 (defcustom pr-auto-region t
2417 "Non-nil means region is automagically detected.
2419 Note that this will only work if you're using transient mark mode.
2421 When this variable is non-nil, the `*-buffer*' commands will behave like
2422 `*-region*' commands, that is, `*-buffer*' commands will print only the region
2423 marked instead of all buffer."
2428 (defcustom pr-auto-mode t
2429 "Non-nil means major-mode specific printing is preferred over normal printing.
2431 That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
2432 and `*-region*' commands will behave like `*-mode*' commands; otherwise,
2433 `*-buffer*' commands will print the current buffer and `*-region*' commands
2434 will print the current region."
2439 (defcustom pr-mode-alist
2440 '((mh-folder-mode ; mh summary buffer
2441 pr-mh-lpr-1 pr-mh-print-1
2443 (ps-article-author ps-article-subject
)
2444 ("/pagenumberstring load" pr-article-date
)
2447 (mh-letter-mode ; mh letter buffer
2448 pr-mh-lpr-2 pr-mh-print-2
2450 (ps-article-author ps-article-subject
)
2451 ("/pagenumberstring load" pr-article-date
)
2454 (rmail-summary-mode ; rmail summary buffer
2455 pr-rmail-lpr pr-rmail-print
2457 (ps-article-subject ps-article-author buffer-name
)
2461 (rmail-mode ; rmail buffer
2462 pr-rmail-lpr pr-rmail-print
2464 (ps-article-subject ps-article-author buffer-name
)
2468 (gnus-summary-mode ; gnus summary buffer
2469 pr-gnus-lpr pr-gnus-print
2471 (ps-article-subject ps-article-author gnus-newsgroup-name
)
2475 (gnus-article-mode ; gnus article buffer
2476 pr-gnus-lpr pr-gnus-print
2478 (ps-article-subject ps-article-author gnus-newsgroup-name
)
2482 (Info-mode ; Info buffer
2483 pr-mode-lpr pr-mode-print
2485 (ps-info-node ps-info-file
)
2490 pr-vm-lpr pr-vm-print
2492 (ps-article-subject ps-article-author buffer-name
)
2497 "Specify an alist for a major-mode and printing functions.
2499 To customize a major mode printing, just declare the customization in
2500 `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major
2501 mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the
2502 *Summary* buffer, if you forget to switch to the *Article* buffer before
2503 printing, you'll get a nicely formatted list of article subjects shows up at
2504 the printer. With major mode printing you don't need to switch from gnus
2505 *Summary* buffer first.
2507 The elements have the following form:
2519 MAJOR-MODE It's the major mode symbol.
2521 LPR-PRINT It's a symbol function for text printing. It's invoked with
2523 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
2525 Usually LPR-PRINT function prepares the environment or buffer
2526 and then call the function `pr-mode-lpr' which it's used to
2527 process the buffer and send it to text printer.
2529 The `pr-mode-lpr' definition is:
2531 (pr-mode-lpr HEADER-LIST &optional FROM TO)
2533 Where HEADER-LIST is like the argument passed to LPR-PRINT.
2534 FROM and TO are the beginning and end markers, respectively,
2535 for a region. If FROM is nil, it's used (point-min); if TO is
2536 nil, it's used (point-max).
2538 PS-PRINT It's a symbol function for PostScript printing. It's invoked
2539 with three arguments: n-up printing, file name and the list:
2540 (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
2542 Usually PS-PRINT function prepares the environment or buffer
2543 and then call the function `pr-mode-print' which it's used to
2544 process the buffer and send it to PostScript printer.
2546 The `pr-mode-print' definition is:
2548 (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO)
2550 Where N-UP, FILENAME and HEADER-LIST are like the arguments
2551 passed to PS-PRINT. FROM and TO are the beginning and end
2552 markers, respectively, for a region. If TO is nil, it's used
2555 HEADER-LINES It's the number of header lines; if is nil, it uses
2556 `ps-header-lines' value.
2558 LEFT-HEADER It's the left header part, it's a list of string, variable
2559 symbol or function symbol (with no argument); if is nil, it
2560 uses `ps-left-header' value.
2562 RIGHT-HEADER It's the right header part, it's a list of string, variable
2563 symbol or function symbol (with no argument); if is nil, it
2564 uses `ps-right-header' value.
2567 Non-nil means to kill all buffer local variable declared in
2568 DEFAULT (see below).
2570 DEFAULT It's a way to set default values when this entry is selected.
2573 (VARIABLE-SYM . VALUE)
2575 Which associates VARIABLE-SYM with VALUE. When this entry is
2576 selected, it's executed the following command:
2578 (set (make-local-variable VARIABLE-SYM) (eval VALUE))
2580 Note that VALUE can be any valid lisp expression. So, don't
2581 forget to quote symbols and constant lists.
2582 If VARIABLE is the special keyword `inherits-from:', VALUE must
2583 be a symbol name setting defined in `pr-setting-database' from
2584 which the current setting inherits the context. Take care with
2585 circular inheritance.
2587 '(ps-landscape-mode . nil)
2588 '(ps-spool-duplex . t)
2589 '(pr-gs-device . (my-gs-device t))"
2593 (symbol :tag
"Major Mode")
2594 (function :tag
"Text Printing Function")
2595 (function :tag
"PS Printing Function")
2596 (choice :menu-tag
"Number of Header Lines"
2597 :tag
"Number of Header Lines"
2598 (integer :tag
"Number")
2599 (const :tag
"Default Number" nil
))
2600 (repeat :tag
"Left Header List"
2601 (choice :menu-tag
"Left Header"
2604 (repeat :tag
"Right Header List"
2605 (choice :menu-tag
"Right Header"
2608 (boolean :tag
"Kill Local Variable At End")
2610 :tag
"Default Value List"
2615 :menu-tag
"Variable"
2617 (const :tag
"Landscape" ps-landscape-mode
)
2618 (const :tag
"Print Header" ps-print-header
)
2619 (const :tag
"Print Header Frame" ps-print-header-frame
)
2620 (const :tag
"Line Number" ps-line-number
)
2621 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2622 (const :tag
"Duplex" ps-spool-duplex
)
2623 (const :tag
"Tumble" ps-spool-tumble
)
2624 (const :tag
"Upside-Down" ps-print-upside-down
)
2625 (const :tag
"PS File Landscape" pr-file-landscape
)
2626 (const :tag
"PS File Duplex" pr-file-duplex
)
2627 (const :tag
"PS File Tumble" pr-file-tumble
)
2628 (const :tag
"Auto Region" pr-auto-region
)
2629 (const :tag
"Auto Mode" pr-auto-mode
)
2630 (const :tag
"Ghostscript Device" pr-gs-device
)
2631 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2632 (const :tag
"inherits-from:" inherits-from
:)
2633 (variable :tag
"Other"))
2634 (sexp :tag
"Value")))
2639 (defcustom pr-ps-utility
'mpage
2640 "Specify PostScript utility symbol.
2642 This utility symbol should be defined on `pr-ps-utility-alist' (see it for
2645 This variable should be modified by customization engine. If this variable is
2646 modified by other means (for example, a lisp function), use `pr-update-menus'
2647 function (see it for documentation) to update PostScript utility menu.
2649 NOTE: Don't forget to download and install the utilities declared on
2650 `pr-ps-utility-alist'."
2651 :type
'(symbol :tag
"PS File Utility")
2652 :set
'pr-ps-utility-custom-set
2656 (defcustom pr-ps-utility-alist
2657 '((mpage "mpage" nil
"-b%s" "-%d" "-l" "-t" "-T" ">" nil
)
2658 (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil
" " nil
2659 (inherits-from: . no-duplex
))
2662 ;; * On GNU or Unix system:
2663 ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
2664 ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
2665 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
2667 ;; * On Windows system:
2668 ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
2669 ;; (pr-file-duplex . nil) (pr-file-tumble . nil))
2671 "Specify an alist for PostScript utility processing (PS utility database).
2673 The alist element has the form:
2675 (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT
2676 SWITCHES DEFAULT...)
2680 SYMBOL It's a symbol to identify a PostScript utility. It's for
2681 `pr-ps-utility' variable setting and for menu selection.
2686 UTILITY Name of utility for processing a PostScript file.
2687 See also `pr-path-alist'.
2689 . for GNU or Unix system:
2693 . for Windows system:
2694 \"c:/psutils/psnup -q\"
2696 MUST-SWITCHES List of sexp's to pass as options to the PostScript utility
2697 program. These options are necessary to process the utility
2698 program and must be placed before any other switches.
2703 PAPERSIZE It's a format string to specify paper size switch.
2708 N-UP It's a format string to specify n-up switch.
2713 LANDSCAPE It's a string to specify landscape switch. If the utility
2714 doesn't have landscape switch, set to nil.
2719 DUPLEX It's a string to specify duplex switch. If the utility doesn't
2720 have duplex switch, set to nil.
2725 TUMBLE It's a string to specify tumble switch. If the utility doesn't
2726 have tumble switch, set to nil.
2731 OUTPUT It's a string to specify how to generate an output file. Some
2732 utilities accept an output file option, but some others need
2733 output redirection or some other way to specify an output file.
2736 \" \" ; psnup ... input output
2739 \">\" ; mpage ... input > output
2741 SWITCHES List of sexp's to pass as extra options to the PostScript utility
2748 DEFAULT It's a way to set default values when this entry is selected.
2753 Which associates VARIABLE with VALUE. When this entry is
2754 selected, it's executed the following command:
2756 (set VARIABLE (eval VALUE))
2758 Note that VALUE can be any valid lisp expression. So, don't
2759 forget to quote symbols and constant lists.
2760 If VARIABLE is the special keyword `inherits-from:', VALUE must
2761 be a symbol name setting defined in `pr-setting-database' from
2762 which the current setting inherits the context. Take care with
2763 circular inheritance.
2765 '(pr-file-landscape . nil)
2766 '(pr-file-duplex . t)
2767 '(pr-gs-device . (my-gs-device t))
2769 This variable should be modified by customization engine. If this variable is
2770 modified by other means (for example, a lisp function), use `pr-update-menus'
2771 function (see it for documentation) to update PostScript utility menu.
2773 NOTE: Don't forget to download and install the utilities declared on
2774 `pr-ps-utility-alist'.
2778 * On GNU or Unix system:
2780 '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil)
2781 (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil
2782 (pr-file-duplex . nil) (pr-file-tumble . nil))
2785 * On Windows system:
2787 '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \"
2788 nil (pr-file-duplex . nil) (pr-file-tumble . nil))
2793 * mpage download (GNU or Unix)
2794 `http://www.mesa.nl/pub/mpage/'
2796 * mpage documentation (GNU or Unix - or type `man mpage')
2797 `http://www.cs.umd.edu/faq/guides/manual_unix/node48.html'
2798 `http://www.rt.com/man/mpage.1.html'
2800 * psnup (Windows, GNU or Unix)
2801 `http://www.knackered.org/angus/psutils/'
2802 `http://gershwin.ens.fr/vdaniel/Doc-Locale/Outils-Gnu-Linux/PsUtils/'
2804 * psnup (PsUtils for Windows)
2805 `http://gnuwin32.sourceforge.net/packages/psutils.htm'
2807 * psnup documentation (GNU or Unix - or type `man psnup')
2808 `http://linux.about.com/library/cmd/blcmdl1_psnup.htm'
2809 `http://amath.colorado.edu/computing/software/man/psnup.html'
2811 * GNU Enscript (Windows, GNU or Unix)
2812 `http://people.ssh.com/mtr/genscript/'
2814 * GNU Enscript documentation (Windows, GNU or Unix)
2815 `http://people.ssh.com/mtr/genscript/enscript.man.html'
2816 (on GNU or Unix, type `man enscript')
2819 (list :tag
"PS File Utility"
2820 (symbol :tag
"Utility Symbol")
2821 (string :tag
"Utility Name")
2822 (repeat :tag
"Must Utility Switches"
2823 (sexp :tag
"Switch" :value
""))
2824 (choice :menu-tag
"Paper Size"
2826 (const :tag
"No Paper Size" nil
)
2827 (string :tag
"Paper Size Format"))
2828 (choice :menu-tag
"N-Up"
2830 (const :tag
"No N-Up" nil
)
2831 (string :tag
"N-Up Format"))
2832 (choice :menu-tag
"Landscape"
2834 (const :tag
"No Landscape" nil
)
2835 (string :tag
"Landscape Switch"))
2836 (choice :menu-tag
"Duplex"
2838 (const :tag
"No Duplex" nil
)
2839 (string :tag
"Duplex Switch"))
2840 (choice :menu-tag
"Tumble"
2842 (const :tag
"No Tumble" nil
)
2843 (string :tag
"Tumble Switch"))
2844 (string :tag
"Output Separator")
2845 (repeat :tag
"Utility Switches"
2846 (sexp :tag
"Switch" :value
""))
2848 :tag
"Default Value List"
2853 :menu-tag
"Variable"
2855 (const :tag
"PS File Landscape" pr-file-landscape
)
2856 (const :tag
"PS File Duplex" pr-file-duplex
)
2857 (const :tag
"PS File Tumble" pr-file-tumble
)
2858 (const :tag
"Ghostscript Device" pr-gs-device
)
2859 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
2860 (const :tag
"inherits-from:" inherits-from
:)
2861 (variable :tag
"Other"))
2862 (sexp :tag
"Value")))
2864 :set
'pr-alist-custom-set
2868 (defcustom pr-menu-lock t
2869 "Non-nil means menu is locked while selecting toggle options.
2871 See also `pr-menu-char-height' and `pr-menu-char-width'."
2876 (defcustom pr-menu-char-height
(pr-menu-char-height)
2877 "Specify menu char height in pixels.
2879 This variable is used to guess which vertical position should be locked the
2880 menu, so don't forget to adjust it if menu position is not ok.
2882 See also `pr-menu-lock' and `pr-menu-char-width'."
2887 (defcustom pr-menu-char-width
(pr-menu-char-width)
2888 "Specify menu char width in pixels.
2890 This variable is used to guess which horizontal position should be locked the
2891 menu, so don't forget to adjust it if menu position is not ok.
2893 See also `pr-menu-lock' and `pr-menu-char-height'."
2898 (defcustom pr-setting-database
2899 '((no-duplex ; setting symbol name
2900 nil nil nil
; inherits local kill-local
2901 (pr-file-duplex . nil
) ; settings
2902 (pr-file-tumble . nil
))
2904 "Specify an alist for settings in general.
2906 The elements have the following form:
2908 (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...)
2912 SYMBOL It's a symbol to identify the setting group.
2914 INHERITS Specify the inheritance for SYMBOL group. It's a symbol name
2915 setting from which the current setting inherits the context.
2916 If INHERITS is nil, means that there is no inheritance.
2917 This is a simple inheritance mechanism.
2919 Let's see an example to illustrate the inheritance mechanism:
2921 (setq pr-setting-database
2922 '((no-duplex ; setting symbol name
2924 nil nil ; local kill-local
2925 (pr-file-duplex . nil) ; settings
2926 (pr-file-tumble . nil)
2928 (no-duplex-and-landscape ; setting symbol name
2929 no-duplex ; inherits
2930 nil nil ; local kill-local
2931 (pr-file-landscape . nil) ; settings
2934 The example above has two setting groups: no-duplex and
2935 no-duplex-and-landscape. When setting no-duplex is activated
2936 through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist'
2937 and `pr-ps-printer-alist'), the variables pr-file-duplex and
2938 pr-file-tumble are both set to nil.
2940 Now when setting no-duplex-and-landscape is activated through
2941 `inherits-from:', the variable pr-file-landscape is set to nil
2942 and also the settings for no-duplex are done, because
2943 no-duplex-and-landscape inherits settings from no-duplex.
2945 Take care with circular inheritance. It's an error if circular
2946 inheritance happens.
2948 LOCAL Non-nil means that all settings for SYMBOL group will be
2949 declared local buffer.
2951 KILL-LOCAL Non-nil means that all settings for SYMBOL group will be
2952 killed at end. It has effect only when LOCAL is non-nil.
2954 SETTING It's a cons like:
2958 Which associates VARIABLE with VALUE. When this entry is
2959 selected, it's executed the following command:
2961 * If LOCAL is non-nil:
2962 (set (make-local-variable VARIABLE) (eval VALUE))
2965 (set VARIABLE (eval VALUE))
2967 Note that VALUE can be any valid lisp expression. So, don't
2968 forget to quote symbols and constant lists.
2969 This setting is ignored if VARIABLE is equal to keyword
2972 '(ps-landscape-mode . nil)
2973 '(ps-spool-duplex . t)
2974 '(pr-gs-device . (my-gs-device t))"
2978 (symbol :tag
"Setting Name")
2979 (choice :menu-tag
"Inheritance"
2981 (const :tag
"No Inheritance" nil
)
2982 (symbol :tag
"Inherits From"))
2983 (boolean :tag
"Local Buffer Setting")
2984 (boolean :tag
"Kill Local Variable At End")
2991 :menu-tag
"Variable"
2993 (const :tag
"Landscape" ps-landscape-mode
)
2994 (const :tag
"Print Header" ps-print-header
)
2995 (const :tag
"Print Header Frame" ps-print-header-frame
)
2996 (const :tag
"Line Number" ps-line-number
)
2997 (const :tag
"Zebra Stripes" ps-zebra-stripes
)
2998 (const :tag
"Duplex" ps-spool-duplex
)
2999 (const :tag
"Tumble" ps-spool-tumble
)
3000 (const :tag
"Upside-Down" ps-print-upside-down
)
3001 (const :tag
"PS File Landscape" pr-file-landscape
)
3002 (const :tag
"PS File Duplex" pr-file-duplex
)
3003 (const :tag
"PS File Tumble" pr-file-tumble
)
3004 (const :tag
"Auto Region" pr-auto-region
)
3005 (const :tag
"Auto Mode" pr-auto-mode
)
3006 (const :tag
"Ghostscript Device" pr-gs-device
)
3007 (const :tag
"Ghostscript Resolution" pr-gs-resolution
)
3008 (variable :tag
"Other"))
3009 (sexp :tag
"Value")))
3014 (defcustom pr-visible-entry-list
3015 '(postscript text postscript-options postscript-process printing help
)
3016 "Specify a list of Printing menu visible entries.
3018 Valid values with the corresponding menu parts are:
3020 +------------------------------+
3021 | Printing Interface |
3022 +------------------------------+
3023 `postscript' | PostScript Preview >|
3024 | PostScript Print >|
3025 | PostScript Printer: name >|
3026 +------------------------------+
3027 `text' | Printify >|
3029 | Text Printer: name >|
3030 +------------------------------+
3031 `postscript-options' |[ ] Landscape |
3033 |[ ] Print Header Frame |
3035 |[ ] Zebra Stripes |
3039 | Print All Pages >|
3040 +------------------------------+
3041 `postscript-process' |[ ] Spool Buffer |
3042 |[ ] Print with faces |
3043 |[ ] Print via Ghostscript |
3044 +------------------------------+
3045 `printing' |[ ] Auto Region |
3048 +------------------------------+
3049 `help' | Customize >|
3052 +------------------------------+
3054 Any other value is ignored."
3055 :type
'(repeat :tag
"Menu Visible Part"
3056 (choice :menu-tag
"Menu Part"
3060 (const postscript-options
)
3061 (const postscript-process
)
3067 (defcustom pr-delete-temp-file t
3068 "Non-nil means delete temporary files.
3070 Set `pr-delete-temp-file' to nil, if the following message (or a similar)
3071 happens when printing:
3073 Error: could not open \"c:\\temp\\prspool.ps\" for reading."
3078 (defcustom pr-list-directory nil
3079 "Non-nil means list directory when processing a directory.
3081 That is, any subdirectories (and the superdirectory) of the directory (given as
3082 argument of functions below) are also printed (as dired-mode listings).
3084 It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
3085 `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
3086 and `pr-txt-directory'."
3091 (defcustom pr-buffer-name
"*Printing Interface*"
3092 "Specify the name of the buffer interface for printing package.
3094 It's used by `pr-interface'."
3099 (defcustom pr-buffer-name-ignore
3100 (list (regexp-quote pr-buffer-name
) ; ignore printing interface buffer
3101 "^ .*$") ; ignore invisible buffers
3102 "Specify a regexp list for buffer names to be ignored in interface buffer.
3104 NOTE: Case is important for matching, that is, `case-fold-search' is always
3107 It's used by `pr-interface'."
3108 :type
'(repeat (regexp :tag
"Buffer Name Regexp"))
3112 (defcustom pr-buffer-verbose t
3113 "Non-nil means to be verbose when editing a field in interface buffer.
3115 It's used by `pr-interface'."
3120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3121 ;; Internal Variables
3124 (defvar pr-txt-command nil
3125 "Name of program for printing a text file.
3126 See `pr-txt-printer-alist'.")
3129 (defvar pr-txt-switches nil
3130 "List of sexp's to pass as extra options to the text printer program.
3131 See `pr-txt-printer-alist'.")
3134 (defvar pr-txt-printer nil
3135 "Specify text printer name.
3136 See `pr-txt-printer-alist'.")
3139 (defvar pr-ps-command nil
3140 "Name of program for printing a PostScript file.
3141 See `pr-ps-printer-alist'.")
3144 (defvar pr-ps-switches nil
3145 "List of sexp's to pass as extra options to the PostScript printer program.
3146 See `pr-ps-printer-alist'.")
3149 (defvar pr-ps-printer-switch nil
3150 "Specify PostScript printer name switch.
3151 See `pr-ps-printer-alist'.")
3154 (defvar pr-ps-printer nil
3155 "Specify PostScript printer name.
3156 See `pr-ps-printer-alist'.")
3159 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3163 (defmacro pr-save-file-modes
(&rest body
)
3164 "Set temporally file modes to `pr-file-modes'."
3165 `(let ((pr--default-file-modes (default-file-modes))) ; save default
3166 (set-default-file-modes pr-file-modes
)
3168 (set-default-file-modes pr--default-file-modes
))) ; restore default
3171 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3175 (defsubst pr-visible-p
(key)
3176 (memq key pr-visible-entry-list
))
3179 (defsubst pr-mode-alist-p
()
3180 (cdr (assq major-mode pr-mode-alist
)))
3183 (defsubst pr-auto-mode-p
()
3184 (and pr-auto-mode
(pr-mode-alist-p)))
3187 (defsubst pr-using-ghostscript-p
()
3188 (and pr-print-using-ghostscript
(not pr-spool-p
)))
3191 (defalias 'pr-get-symbol
3192 (if (fboundp 'easy-menu-intern
) ; hacked from easymenu.el
3194 (lambda (s) (if (stringp s
) (intern s
) s
))))
3197 (defconst pr-menu-spec
3199 ;; unfortunately XEmacs doesn't support :active for submenus,
3201 ;; So, it uses :included instead of :active.
3202 ;; Also, XEmacs doesn't support :help tag.
3203 (let ((pr-:active
(if (featurep 'xemacs
)
3205 :active
)) ; GNU Emacs
3206 (pr-:help
(if (featurep 'xemacs
)
3208 #'(lambda (text) (list :help text
))))) ; GNU Emacs
3210 ["Printing Interface" pr-interface
3212 pr-
:help
"Use buffer interface instead of menu interface")]
3214 ("PostScript Preview" :included
(pr-visible-p 'postscript
)
3216 pr-
:help
"Preview PostScript instead of sending to printer")
3217 ("Directory" ,pr-
:active
(not pr-spool-p
)
3218 ["1-up" (pr-ps-directory-preview 1 nil nil t
) t
]
3219 ["2-up" (pr-ps-directory-preview 2 nil nil t
) t
]
3220 ["4-up" (pr-ps-directory-preview 4 nil nil t
) t
]
3221 ["Other..." (pr-ps-directory-preview nil nil nil t
)
3222 :keys
"\\[pr-ps-buffer-preview]"])
3223 ("Buffer" ,pr-
:active
(not pr-spool-p
)
3224 ["1-up" (pr-ps-buffer-preview 1 t
) t
]
3225 ["2-up" (pr-ps-buffer-preview 2 t
) t
]
3226 ["4-up" (pr-ps-buffer-preview 4 t
) t
]
3227 ["Other..." (pr-ps-buffer-preview nil t
)
3228 :keys
"\\[pr-ps-buffer-preview]"])
3229 ("Region" ,pr-
:active
(and (not pr-spool-p
) (ps-mark-active-p))
3230 ["1-up" (pr-ps-region-preview 1 t
) t
]
3231 ["2-up" (pr-ps-region-preview 2 t
) t
]
3232 ["4-up" (pr-ps-region-preview 4 t
) t
]
3233 ["Other..." (pr-ps-region-preview nil t
)
3234 :keys
"\\[pr-ps-region-preview]"])
3235 ("Mode" ,pr-
:active
(and (not pr-spool-p
) (pr-mode-alist-p))
3236 ["1-up" (pr-ps-mode-preview 1 t
) t
]
3237 ["2-up" (pr-ps-mode-preview 2 t
) t
]
3238 ["4-up" (pr-ps-mode-preview 4 t
) t
]
3239 ["Other..." (pr-ps-mode-preview nil t
)
3240 :keys
"\\[pr-ps-mode-preview]"])
3242 ["No Preprocessing..." (call-interactively 'pr-ps-file-preview
)
3243 :keys
"\\[pr-ps-file-preview]"
3245 pr-
:help
"Preview PostScript file")]
3247 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
3249 pr-
:help
"Select PostScript utility")]
3251 ["1-up..." (pr-ps-file-up-preview 1 t t
) pr-ps-utility-alist
]
3252 ["2-up..." (pr-ps-file-up-preview 2 t t
) pr-ps-utility-alist
]
3253 ["4-up..." (pr-ps-file-up-preview 4 t t
) pr-ps-utility-alist
]
3254 ["Other..." (pr-ps-file-up-preview nil t t
)
3255 :keys
"\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist
]
3257 ["Landscape" pr-toggle-file-landscape-menu
3258 :style toggle
:selected pr-file-landscape
3260 pr-
:help
"Toggle landscape for PostScript file")
3261 :active pr-ps-utility-alist
]
3262 ["Duplex" pr-toggle-file-duplex-menu
3263 :style toggle
:selected pr-file-duplex
3265 pr-
:help
"Toggle duplex for PostScript file")
3266 :active pr-ps-utility-alist
]
3267 ["Tumble" pr-toggle-file-tumble-menu
3268 :style toggle
:selected pr-file-tumble
3270 pr-
:help
"Toggle tumble for PostScript file")
3271 :active
(and pr-file-duplex pr-ps-utility-alist
)])
3272 ["Despool..." (call-interactively 'pr-despool-preview
)
3273 :active pr-spool-p
:keys
"\\[pr-despool-preview]"
3275 pr-
:help
"Despool PostScript buffer to printer or file (C-u)")])
3276 ("PostScript Print" :included
(pr-visible-p 'postscript
)
3278 pr-
:help
"Send PostScript to printer or file (C-u)")
3280 ["1-up" (pr-ps-directory-ps-print 1 nil nil t
) t
]
3281 ["2-up" (pr-ps-directory-ps-print 2 nil nil t
) t
]
3282 ["4-up" (pr-ps-directory-ps-print 4 nil nil t
) t
]
3283 ["Other..." (pr-ps-directory-ps-print nil nil nil t
)
3284 :keys
"\\[pr-ps-buffer-ps-print]"])
3286 ["1-up" (pr-ps-buffer-ps-print 1 t
) t
]
3287 ["2-up" (pr-ps-buffer-ps-print 2 t
) t
]
3288 ["4-up" (pr-ps-buffer-ps-print 4 t
) t
]
3289 ["Other..." (pr-ps-buffer-ps-print nil t
)
3290 :keys
"\\[pr-ps-buffer-ps-print]"])
3291 ("Region" ,pr-
:active
(ps-mark-active-p)
3292 ["1-up" (pr-ps-region-ps-print 1 t
) t
]
3293 ["2-up" (pr-ps-region-ps-print 2 t
) t
]
3294 ["4-up" (pr-ps-region-ps-print 4 t
) t
]
3295 ["Other..." (pr-ps-region-ps-print nil t
)
3296 :keys
"\\[pr-ps-region-ps-print]"])
3297 ("Mode" ,pr-
:active
(pr-mode-alist-p)
3298 ["1-up" (pr-ps-mode-ps-print 1 t
) t
]
3299 ["2-up" (pr-ps-mode-ps-print 2 t
) t
]
3300 ["4-up" (pr-ps-mode-ps-print 4 t
) t
]
3301 ["Other..." (pr-ps-mode-ps-print nil t
)
3302 :keys
"\\[pr-ps-mode-ps-print]"])
3304 ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print
)
3305 :keys
"\\[pr-ps-file-ps-print]"
3307 pr-
:help
"Send PostScript file to printer")]
3309 ["PostScript Utility" pr-update-menus
:active pr-ps-utility-alist
3311 pr-
:help
"Select PostScript utility")]
3313 ["1-up..." (pr-ps-file-up-ps-print 1 t t
) pr-ps-utility-alist
]
3314 ["2-up..." (pr-ps-file-up-ps-print 2 t t
) pr-ps-utility-alist
]
3315 ["4-up..." (pr-ps-file-up-ps-print 4 t t
) pr-ps-utility-alist
]
3316 ["Other..." (pr-ps-file-up-ps-print nil t t
)
3317 :keys
"\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist
]
3319 ["Landscape" pr-toggle-file-landscape-menu
3320 :style toggle
:selected pr-file-landscape
3322 pr-
:help
"Toggle landscape for PostScript file")
3323 :active pr-ps-utility-alist
]
3324 ["Duplex" pr-toggle-file-duplex-menu
3325 :style toggle
:selected pr-file-duplex
3327 pr-
:help
"Toggle duplex for PostScript file")
3328 :active pr-ps-utility-alist
]
3329 ["Tumble" pr-toggle-file-tumble-menu
3330 :style toggle
:selected pr-file-tumble
3332 pr-
:help
"Toggle tumble for PostScript file")
3333 :active
(and pr-file-duplex pr-ps-utility-alist
)])
3334 ["Despool..." (call-interactively 'pr-despool-ps-print
)
3335 :active pr-spool-p
:keys
"\\[pr-despool-ps-print]"
3337 pr-
:help
"Despool PostScript buffer to printer or file (C-u)")])
3338 ["PostScript Printers" pr-update-menus
3339 :active pr-ps-printer-alist
:included
(pr-visible-p 'postscript
)
3341 pr-
:help
"Select PostScript printer")]
3343 ("Printify" :included
(pr-visible-p 'text
)
3346 "Replace non-printing chars with printable representations.")
3347 ["Directory" pr-printify-directory t
]
3348 ["Buffer" pr-printify-buffer t
]
3349 ["Region" pr-printify-region
(ps-mark-active-p)])
3350 ("Print" :included
(pr-visible-p 'text
)
3352 pr-
:help
"Send text to printer")
3353 ["Directory" pr-txt-directory t
]
3354 ["Buffer" pr-txt-buffer t
]
3355 ["Region" pr-txt-region
(ps-mark-active-p)]
3356 ["Mode" pr-txt-mode
(pr-mode-alist-p)])
3357 ["Text Printers" pr-update-menus
3358 :active pr-txt-printer-alist
:included
(pr-visible-p 'text
)
3360 pr-
:help
"Select text printer")]
3362 ["Landscape" pr-toggle-landscape-menu
3363 :style toggle
:selected ps-landscape-mode
3364 :included
(pr-visible-p 'postscript-options
)]
3365 ["Print Header" pr-toggle-header-menu
3366 :style toggle
:selected ps-print-header
3367 :included
(pr-visible-p 'postscript-options
)]
3368 ["Print Header Frame" pr-toggle-header-frame-menu
3369 :style toggle
:selected ps-print-header-frame
:active ps-print-header
3370 :included
(pr-visible-p 'postscript-options
)]
3371 ["Line Number" pr-toggle-line-menu
3372 :style toggle
:selected ps-line-number
3373 :included
(pr-visible-p 'postscript-options
)]
3374 ["Zebra Stripes" pr-toggle-zebra-menu
3375 :style toggle
:selected ps-zebra-stripes
3376 :included
(pr-visible-p 'postscript-options
)]
3377 ["Duplex" pr-toggle-duplex-menu
3378 :style toggle
:selected ps-spool-duplex
3379 :included
(pr-visible-p 'postscript-options
)]
3380 ["Tumble" pr-toggle-tumble-menu
3381 :style toggle
:selected ps-spool-tumble
:active ps-spool-duplex
3382 :included
(pr-visible-p 'postscript-options
)]
3383 ["Upside-Down" pr-toggle-upside-down-menu
3384 :style toggle
:selected ps-print-upside-down
3385 :included
(pr-visible-p 'postscript-options
)]
3386 ("Print All Pages" :included
(pr-visible-p 'postscript-options
)
3388 pr-
:help
"Select odd/even pages/sheets to print")
3389 ["All Pages" (pr-even-or-odd-pages nil
)
3390 :style radio
:selected
(eq ps-even-or-odd-pages nil
)]
3391 ["Even Pages" (pr-even-or-odd-pages 'even-page
)
3392 :style radio
:selected
(eq ps-even-or-odd-pages
'even-page
)]
3393 ["Odd Pages" (pr-even-or-odd-pages 'odd-page
)
3394 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-page
)]
3395 ["Even Sheets" (pr-even-or-odd-pages 'even-sheet
)
3396 :style radio
:selected
(eq ps-even-or-odd-pages
'even-sheet
)]
3397 ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet
)
3398 :style radio
:selected
(eq ps-even-or-odd-pages
'odd-sheet
)])
3400 ["Spool Buffer" pr-toggle-spool-menu
3401 :style toggle
:selected pr-spool-p
3402 :included
(pr-visible-p 'postscript-process
)
3404 pr-
:help
"Toggle PostScript spooling")]
3405 ["Print with faces" pr-toggle-faces-menu
3406 :style toggle
:selected pr-faces-p
3407 :included
(pr-visible-p 'postscript-process
)
3409 pr-
:help
"Toggle PostScript printing with faces")]
3410 ["Print via Ghostscript" pr-toggle-ghostscript-menu
3411 :style toggle
:selected pr-print-using-ghostscript
3412 :included
(pr-visible-p 'postscript-process
)
3414 pr-
:help
"Toggle PostScript generation using ghostscript")]
3416 ["Auto Region" pr-toggle-region-menu
3417 :style toggle
:selected pr-auto-region
3418 :included
(pr-visible-p 'printing
)]
3419 ["Auto Mode" pr-toggle-mode-menu
3420 :style toggle
:selected pr-auto-mode
3421 :included
(pr-visible-p 'printing
)]
3422 ["Menu Lock" pr-toggle-lock-menu
3423 :style toggle
:selected pr-menu-lock
3424 :included
(pr-visible-p 'printing
)]
3426 ("Customize" :included
(pr-visible-p 'help
)
3427 ["printing" pr-customize t
]
3428 ["ps-print" ps-print-customize t
]
3429 ["lpr" lpr-customize t
])
3430 ("Show Settings" :included
(pr-visible-p 'help
)
3431 ["printing" pr-show-pr-setup t
]
3432 ["ps-print" pr-show-ps-setup t
]
3433 ["lpr" pr-show-lpr-setup t
])
3434 ["Help" pr-help
:active t
:included
(pr-visible-p 'help
)]
3438 (defun pr-menu-bind ()
3439 "Install `printing' menu in the menubar.
3440 This replaces the File/Print* menu entries with a File/Print sub-menu.
3441 Calls `pr-update-menus' to adjust menus."
3443 (pr-global-menubar pr-menu-spec
)
3444 (pr-update-menus t
))
3448 (let ((pr-print-key (if (featurep 'xemacs
)
3450 'print
))) ; GNU Emacs
3451 (global-set-key `[,pr-print-key
] 'pr-ps-fast-fire
)
3452 ;; Well, M-print and S-print are used because in my keyboard S-print works
3453 ;; and M-print doesn't. But M-print can work in other keyboard.
3454 (global-set-key `[(meta ,pr-print-key
)] 'pr-ps-mode-using-ghostscript
)
3455 (global-set-key `[(shift ,pr-print-key
)] 'pr-ps-mode-using-ghostscript
)
3456 ;; Well, C-print and C-M-print are used because in my keyboard C-M-print works
3457 ;; and C-print doesn't. But C-print can work in other keyboard.
3458 (global-set-key `[(control ,pr-print-key
)] 'pr-txt-fast-fire
)
3459 (global-set-key `[(control meta
,pr-print-key
)] 'pr-txt-fast-fire
))
3462 ;;; You can also use something like:
3463 ;;;(global-set-key "\C-ci" 'pr-interface)
3464 ;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print)
3465 ;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview)
3466 ;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
3467 ;;;(global-set-key "\C-crp" 'pr-ps-region-print)
3468 ;;;(global-set-key "\C-crx" 'pr-ps-region-preview)
3469 ;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
3472 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3476 (defconst pr-help-message
3477 (concat "printing.el version " pr-version
3478 " ps-print.el version " ps-print-version
3483 The `printing' menu (Tools/Printing or File/Print) has the following layout:
3485 +-----------------------------+
3486 A 0 | Printing Interface |
3487 +-----------------------------+ +-A---------+ +-B------+
3488 I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
3489 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
3490 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
3491 +-----------------------------+ |Mode >|-- B |Other...|
3492 II 4 | Printify >|-----\\ |File >|--\\ +--------+
3493 5 | Print >|---\\ | |Despool... | |
3494 6 | Text Printer: name >|-\\ | | +-----------+ |
3495 +-----------------------------+ | | | +---------+ +------------+
3496 III 7 |[ ]Landscape | | | \\-|Directory| | No Prep... | Ia
3497 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
3498 9 |[ ]Print Header Frame | | | |Region | | name >|- C
3499 10 |[ ]Line Number | | | +---------+ +------------+
3500 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
3501 12 |[ ]Duplex | | \\---|Directory| | 2-up... |
3502 13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... |
3503 14 |[ ]Upside-Down | | |Region | | Other... |
3504 15 | Print All Pages >|--\\ | |Mode | +------------+
3505 +-----------------------------+ | | +---------+ |[ ]Landscape| Id
3506 IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
3507 17 |[ ]Print with faces | | \\--|( )name A| |[ ]Tumble | If
3508 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
3509 +-----------------------------+ | |... |
3510 V 19 |[ ]Auto Region | | |(*)name |
3511 20 |[ ]Auto Mode | | |... |
3512 21 |[ ]Menu Lock | | +---------+ +--------------+
3513 +-----------------------------+ \\------------------|(*)All Pages |
3514 VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
3515 23 | Show Settings >|-------|printing| |( )Odd Pages |
3516 24 | Help | |ps-print| |( )Even Sheets|
3517 +-----------------------------+ |lpr | |( )Odd Sheets |
3518 +--------+ +--------------+
3520 See `pr-visible-entry-list' for hiding some parts of the menu.
3522 The menu has the following sections:
3526 0. You can use a buffer interface instead of menus. It looks like the
3527 customization buffer. Basically, it has the same options found in the
3528 menu and some extra options, all this on a buffer.
3530 I. PostScript printing:
3532 1. You can generate a PostScript file (if you type C-u before activating
3533 menu) or PostScript temporary file for a directory, a buffer, a region
3534 or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
3535 after file generation, ghostview is activated using the file generated
3536 as argument. This option is disabled if spooling is on (option 16).
3537 Also, if you already have a PostScript file you can preview it.
3538 Instead of previewing each buffer, region or major mode at once, you
3539 can save temporarily the PostScript code generated in a buffer and
3540 preview it later. The option `Despool...' despools the PostScript
3541 spooling buffer in a temporary file and uses ghostview to preview it.
3542 If you type C-u before choosing this option, the PostScript code
3543 generated is saved in a file instead of saving in a temporary file. To
3544 spool the PostScript code generated you need to turn on the option 16.
3545 The option `Despool...' is enabled if spooling is on (option 16).
3547 NOTE 1: It's possible to customize a major mode printing, just declare
3548 the customization in `pr-mode-alist' and invoke some of
3549 `*-mode*' commands or select Mode option in Printing menu. An
3550 example for major mode usage is when you're using gnus (or mh,
3551 or rmail, etc.) and you're in the *Summary* buffer, if you
3552 forget to switch to the *Article* buffer before printing,
3553 you'll get a nicely formatted list of article subjects shows
3554 up at the printer. With major mode printing you don't need to
3555 switch from gnus *Summary* buffer first.
3557 NOTE 2: There are the following options for PostScript file processing:
3558 Ia. Print the file *No Preprocessing*, that is, send it
3559 directly to PostScript printer.
3560 Ib. PostScript utility processing selection.
3561 See `pr-ps-utility-alist' and `pr-setting-database' for
3563 Ic. Do n-up processing before printing.
3564 Id. Toggle on/off landscape for PostScript file processing.
3565 Ie. Toggle on/off duplex for PostScript file processing.
3566 If. Toggle on/off tumble for PostScript file processing.
3568 NOTE 3: Don't forget to download and install the utilities declared on
3569 `pr-ps-utility-alist'.
3571 2. Operate the same way as option 1, but it sends directly the PostScript
3572 code (or put in a file, if you've typed C-u) or it uses ghostscript to
3573 print the PostScript file generated. It depends on option 18, if it's
3574 turned on, it uses ghostscript; otherwise, it sends directly to
3575 printer. If spooling is on (option 16), the PostScript code is saved
3576 temporarily in a buffer instead of printing it or saving it in a file.
3577 Also, if you already have a PostScript file you can print it.
3578 Instead of printing each buffer, region or major mode at once, you can
3579 save temporarily the PostScript code generated in a buffer and print it
3580 later. The option `Despool...' despools the PostScript spooling buffer
3581 directly on a printer. If you type C-u before choosing this option,
3582 the PostScript code generated is saved in a file instead of sending it to
3583 the printer. To spool the PostScript code generated you need to turn on
3584 option 16. This option is enabled if spooling is on (option 16).
3585 See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
3587 3. You can select a new PostScript printer to send PostScript code
3588 generated. For selection it's used all PostScript printers defined
3589 in `pr-ps-printer-alist' variable (see it for documentation).
3590 See also `pr-setting-database'.
3594 4. If you have control characters (character code from \\000 to \\037) in a
3595 buffer and you want to print them in a text printer, select this
3596 option. All control characters in your buffer or region will be
3597 replaced by a printable representation. The printable representations
3598 use ^ (for ASCII control characters) or hex. The characters tab,
3599 linefeed, space, return and formfeed are not affected.
3600 You don't need to select this option if you use any option of section
3601 I, the PostScript engine treats control characters properly.
3603 5. If you want to print a directory, buffer, region or major mode in a
3604 text printer, select this option. See also the NOTE 1 on option 1.
3606 6. You can select a new text printer to send text generated. For
3607 selection it's used all text printers defined in `pr-txt-printer-alist'
3608 variable (see it for documentation).
3609 See also `pr-setting-database'.
3611 III. PostScript page toggle options:
3613 7. If you want a PostScript landscape printing, turn on this option.
3615 8. If you want to have a header in each page in your PostScript code,
3616 turn on this option.
3618 9. If you want to draw a gaudy frame around the header, turn on this
3619 option. This option is enabled if print header is on (option 8).
3621 10. If you want that the line number is printed in your PostScript code,
3622 turn on this option.
3624 11. If you want background zebra stripes in your PostScript code, turn on
3627 12. If you want a duplex printing and your PostScript printer has this
3628 feature, turn on this option.
3630 13. If you turned on duplex printing, you can choose if you want to have a
3631 printing suitable for binding on the left or right (tumble off), or to
3632 have a printing suitable for binding at top or bottom (tumble on).
3633 This option is enabled if duplex is on (option 12).
3635 14. If you want a PostScript upside-down printing, turn on this option.
3637 15. With this option, you can choose if you want to print all pages, odd
3638 pages, even pages, odd sheets or even sheets.
3639 See also `ps-even-or-odd-pages'.
3641 IV. PostScript processing toggle options:
3643 16. If you want to spool the PostScript code generated, turn on this
3644 option. To spool the PostScript code generated use option 2. You can
3645 despool later by choosing option 1 or 2, sub-option `Despool...'.
3647 17. If you use colors in your buffers and want to see these colors on your
3648 PostScript code generated, turn on this option. If you have a
3649 black/white PostScript printer, these colors are displayed in gray
3650 scale by PostScript printer interpreter.
3652 18. If you don't have a PostScript printer to send PostScript files, turn
3653 on this option. When this option is on, the ghostscript is used to
3654 print PostScript files. In GNU or Unix system, if ghostscript is set
3655 as a PostScript filter, you don't need to turn on this option.
3657 V. Printing customization:
3659 19. If you want that region is automagically detected, turn on this
3660 option. Note that this will only work if you're using transient mark
3661 mode. When this option is on, the `*-buffer*' commands will behave
3662 like `*-region*' commands, that is, `*-buffer*' commands will print
3663 only the region marked instead of all buffer.
3665 20. Turn this option on if you want that when current major-mode is
3666 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3667 behave like `*-mode*' commands.
3669 21. If you want that Printing menu stays open while you are setting
3670 toggle options, turn on this option. The variables
3671 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3672 menu position, so don't forget to adjust these variables if menu
3677 22. Besides all options in section III, IV and V, you can customize much
3678 more PostScript options in `ps-print' option. Or you can customize
3679 some `lpr' options for text printing. Or customize `printing'
3682 23. Show current settings for `printing', `ps-print' or `lpr'.
3684 24. Quick help for printing menu layout.
3686 "Printing help message.")
3689 (defconst pr-interface-help-message
3690 (concat "printing.el version " pr-version
3691 " ps-print.el version " ps-print-version
3693 The printing interface buffer has the same functionality as the printing menu.
3694 The major difference is that the states (like sending PostScript generated to a
3695 file, n-up printing, etc.) are set and saved between printing buffer
3696 activation. Also, the landscape, duplex and tumble values are the same for
3697 PostScript file and directory/buffer/region/mode processing; using menu, there
3698 are different value sets for PostScript file and directory/buffer/region/mode
3701 The printing interface buffer has the following sections:
3705 Here you can choose to print/preview a buffer, a directory or a PostScript
3711 Select a buffer from the current buffer list.
3714 If it's on, this means that the selected buffer has an active region,
3715 so you can turn on/off, as you wish.
3716 If it's off when a buffer is selected, this means that the selected
3717 buffer has no active region, so it'll not be possible to turn it on.
3718 If you want to process the region, let this option on.
3719 If you want to process the whole buffer, let this option off.
3722 If it's on, this means that the selected buffer major mode is declared
3723 for major mode processing, so you can turn on/off, as you wish.
3724 If it's off when a buffer is selected, this means that the selected
3725 buffer major mode isn't declared for major mode processing, so it'll
3726 not be possible to turn it on.
3727 If you want the major mode processing, let this option on.
3728 If you don't want the major mode processing, let this option off.
3730 NOTE 1: It's possible to customize a major mode printing, just declare
3731 the customization in `pr-mode-alist' and invoke some of
3732 `*-mode*' commands or select Mode option in Printing menu. An
3733 example for major mode usage is when you're using gnus (or mh,
3734 or rmail, etc.) and you're in the *Summary* buffer, if you
3735 forget to switch to the *Article* buffer before printing,
3736 you'll get a nicely formatted list of article subjects shows
3737 up at the printer. With major mode printing you don't need to
3738 switch from gnus *Summary* buffer first.
3743 Specify a valid directory path.
3746 Specify a file name regexp. All file names in the directory that
3747 match with regexp will be printed/previewed. An empty file name
3748 regexp means to print/preview all files in the directory.
3750 * List Directory Entry:
3751 If it's turned on, list directory entries besides file entries.
3753 1c. PostScript file:
3756 Specify an existent PostScript file to print/preview.
3758 * PostScript Utility:
3759 Select a PostScript utility.
3760 See `pr-ps-utility-alist' and `pr-setting-database' for documentation.
3762 NOTE 2: Don't forget to download and install the utilities declared on
3763 `pr-ps-utility-alist'.
3766 If it's turned on, don't use the PostScript utility to preprocess the
3767 PostScript file before printing/previewing.
3769 2. PostScript printer:
3771 * PostScript Printer:
3772 You can select a new PostScript printer to send PostScript code
3773 generated. For selection it's used all PostScript printers defined
3774 in `pr-ps-printer-alist' variable (see it for documentation).
3775 See also `pr-setting-database'.
3778 If spooling is on, you can turn it on/off, as you wish.
3779 If spooling is off, it'll not be possible to turn it on.
3780 If it's turned on, specify to despools the PostScript spooling buffer in
3781 a temporary file or in the selected PostScript file when
3782 printing/previewing.
3785 Preview the PostScript generated.
3788 Print the PostScript generated.
3791 Quit from printing interface buffer.
3793 * Send to Printer/Temporary File:
3794 If it's turned on, the PostScript generated is sent directly to
3795 PostScript printer or, for previewing, to a temporary file.
3798 Specify a file name to send the PostScript generated.
3801 Specify n-up printing.
3806 Select a new text printer to send text generated. For selection it's used
3807 all text printers defined in `pr-txt-printer-alist' variable (see it for
3808 documentation). See also `pr-setting-database'.
3811 If you have control characters (character code from \\000 to \\037) in a
3812 buffer and you want to print them in a text printer, select this
3813 option. All control characters in your buffer or region will be
3814 replaced by a printable representation. The printable representations
3815 use ^ (for ASCII control characters) or hex. The characters tab,
3816 linefeed, space, return and formfeed are not affected.
3817 You don't need to select this option if you use any option of section
3818 I, the PostScript engine treats control characters properly.
3821 To print a directory, buffer, region or major mode in a
3822 text printer, select this option. See also the NOTE 1 on section 1.
3825 Quit from printing interface buffer.
3829 There are 3 setting columns:
3831 4a. First column (left column):
3834 PostScript landscape printing.
3837 To have a header in each page in your PostScript code.
3839 * Print Header Frame:
3840 To draw a gaudy frame around the header.
3843 The line number is printed in your PostScript code.
3846 Background zebra stripes in your PostScript code.
3849 Duplex printing (if your PostScript printer has this feature).
3852 If duplex printing is on, you can choose if you want to have a
3853 printing suitable for binding on the left or right (tumble off), or to
3854 have a printing suitable for binding at top or bottom (tumble on).
3857 PostScript upside-down printing.
3859 4b. Second column (middle column):
3862 If you want that region is automagically detected, turn on this
3863 option. Note that this will only work if you're using transient mark
3864 mode. When this option is on, the `*-buffer*' commands will behave
3865 like `*-region*' commands, that is, `*-buffer*' commands will print
3866 only the region marked instead of all buffer.
3869 Turn this option on if you want that when current major-mode is
3870 declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
3871 behave like `*-mode*' commands.
3874 If you want that Printing menu stays open while you are setting
3875 toggle options, turn on this option. The variables
3876 `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
3877 menu position, so don't forget to adjust these variables if menu
3881 To spool the PostScript code generated. You can despool later by
3882 setting Despool option on PostScript printer section.
3885 If you use colors in your buffers and want to see these colors on your
3886 PostScript code generated, turn on this option. If you have a
3887 black/white PostScript printer, these colors are displayed in gray
3888 scale by PostScript printer interpreter.
3890 * Print via Ghostscript:
3891 If you don't have a PostScript printer to send PostScript files, turn
3892 on this option. When this option is on, the ghostscript is used to
3893 print PostScript files. In GNU or Unix system, if ghostscript is set
3894 as a PostScript filter, you don't need to turn on this option.
3897 To print all pages, odd pages, even pages, odd sheets or even sheets.
3898 See also `ps-even-or-odd-pages'.
3900 4c. Third column (right column):
3903 That is, to be verbose when editing a field in interface buffer.
3907 Besides all options in section 4, you can customize much more PostScript
3908 options in `ps-print' option. Or you can customize some `lpr' options for
3909 text printing. Or customize `printing' options.
3913 Show current settings for `printing', `ps-print' or `lpr'.
3917 Quick help for printing interface buffer and printing menu layout. You can
3918 also quit the printing interface buffer or kill all printing help buffer.
3920 "Printing buffer interface help message.")
3923 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3928 (defun pr-interface (&optional buffer
)
3929 "Activate the printing interface buffer.
3931 If BUFFER is nil, the current buffer is used for printing.
3933 For more information, type \\[pr-interface-help]."
3935 (with-current-buffer (or buffer
(current-buffer))
3936 (pr-create-interface)))
3940 (defun pr-ps-directory-preview (n-up dir file-regexp
&optional filename
)
3941 "Preview directory using ghostview.
3943 Interactively, the command prompts for N-UP printing number, a directory, a
3944 file name regexp for matching and, when you use a prefix argument (C-u), the
3945 command prompts the user for a file name, and saves the PostScript image in
3946 that file instead of saving it in a temporary file.
3948 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3949 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3950 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3951 save the image in a temporary file. If FILENAME is a string, save the
3952 PostScript image in a file with that name. If FILENAME is t, prompts for a
3955 See also documentation for `pr-list-directory'."
3956 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir")))
3957 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
3958 (pr-prompt "PS preview dir"))
3959 (setq filename
(pr-ps-file filename
))
3960 (pr-ps-file-list n-up dir file-regexp filename
)
3962 (pr-ps-file-preview filename
)))
3966 (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp
&optional filename
)
3967 "Print directory using PostScript through ghostscript.
3969 Interactively, the command prompts for N-UP printing number, a directory, a
3970 file name regexp for matching and, when you use a prefix argument (C-u), the
3971 command prompts the user for a file name, and saves the PostScript image in
3972 that file instead of saving it in a temporary file.
3974 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
3975 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
3976 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
3977 save the image in a temporary file. If FILENAME is a string, save the
3978 PostScript image in a file with that name. If FILENAME is t, prompts for a
3981 See also documentation for `pr-list-directory'."
3982 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS")))
3983 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
3984 (pr-prompt "PS print dir GS"))
3985 (let ((file (pr-ps-file filename
)))
3986 (pr-ps-file-list n-up dir file-regexp file
)
3987 (pr-ps-file-using-ghostscript file
)
3988 (or filename
(pr-delete-file file
))))
3992 (defun pr-ps-directory-print (n-up dir file-regexp
&optional filename
)
3993 "Print directory using PostScript printer.
3995 Interactively, the command prompts for N-UP printing number, a directory, a
3996 file name regexp for matching and, when you use a prefix argument (C-u), the
3997 command prompts the user for a file name, and saves the PostScript image in
3998 that file instead of saving it in a temporary file.
4000 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
4001 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
4002 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
4003 save the image in a temporary file. If FILENAME is a string, save the
4004 PostScript image in a file with that name. If FILENAME is t, prompts for a
4007 See also documentation for `pr-list-directory'."
4008 (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir")))
4009 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
4010 (pr-prompt "PS print dir"))
4011 (let ((file (pr-ps-file filename
)))
4012 (pr-ps-file-list n-up dir file-regexp file
)
4013 (pr-ps-file-print file
)
4014 (or filename
(pr-delete-file file
))))
4018 (defun pr-ps-directory-ps-print (n-up dir file-regexp
&optional filename
)
4019 "Print directory using PostScript printer or through ghostscript.
4021 It depends on `pr-print-using-ghostscript'.
4023 Interactively, the command prompts for N-UP printing number, a directory, a
4024 file name regexp for matching and, when you use a prefix argument (C-u), the
4025 command prompts the user for a file name, and saves the PostScript image in
4026 that file instead of saving it in a temporary file.
4028 Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is
4029 nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for
4030 FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil,
4031 save the image in a temporary file. If FILENAME is a string, save the
4032 PostScript image in a file with that name. If FILENAME is t, prompts for a
4035 See also documentation for `pr-list-directory'."
4036 (interactive (pr-interactive-ps-dir-args
4037 (pr-prompt (pr-prompt-gs "PS print dir"))))
4038 (pr-set-ps-dir-args 'n-up
'dir
'file-regexp
'filename
4039 (pr-prompt (pr-prompt-gs "PS print dir")))
4040 (if (pr-using-ghostscript-p)
4041 (pr-ps-directory-using-ghostscript n-up dir file-regexp filename
)
4042 (pr-ps-directory-print n-up dir file-regexp filename
)))
4046 (defun pr-ps-buffer-preview (n-up &optional filename
)
4047 "Preview buffer using ghostview.
4049 Interactively, the command prompts for N-UP printing number and, when you use a
4050 prefix argument (C-u), the command prompts the user for a file name, and saves
4051 the PostScript image in that file instead of saving it in a temporary file.
4053 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4054 argument FILENAME is treated as follows: if it's nil, save the image in a
4055 temporary file. If FILENAME is a string, save the PostScript image in a file
4056 with that name. If FILENAME is t, prompts for a file name."
4057 (interactive (pr-interactive-n-up-file (pr-prompt "PS preview")))
4058 (if (pr-auto-mode-p)
4059 (pr-ps-mode-preview n-up filename
)
4060 (pr-ps-preview (pr-region-active-symbol) n-up filename
4061 (pr-region-active-string "PS preview"))))
4065 (defun pr-ps-buffer-using-ghostscript (n-up &optional filename
)
4066 "Print buffer using PostScript through ghostscript.
4068 Interactively, the command prompts for N-UP printing number and, when you use a
4069 prefix argument (C-u), the command prompts the user for a file name, and saves
4070 the PostScript image in that file instead of sending it to the printer.
4072 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4073 argument FILENAME is treated as follows: if it's nil, send the image to the
4074 printer. If FILENAME is a string, save the PostScript image in a file with
4075 that name. If FILENAME is t, prompts for a file name."
4076 (interactive (pr-interactive-n-up-file (pr-prompt "PS print GS")))
4077 (if (pr-auto-mode-p)
4078 (pr-ps-mode-using-ghostscript n-up filename
)
4079 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
4080 (pr-region-active-string "PS print GS"))))
4084 (defun pr-ps-buffer-print (n-up &optional filename
)
4085 "Print buffer using PostScript printer.
4087 Interactively, the command prompts for N-UP printing number and, when you use a
4088 prefix argument (C-u), the command prompts the user for a file name, and saves
4089 the PostScript image in that file instead of sending it to the printer.
4091 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4092 argument FILENAME is treated as follows: if it's nil, send the image to the
4093 printer. If FILENAME is a string, save the PostScript image in a file with
4094 that name. If FILENAME is t, prompts for a file name."
4095 (interactive (pr-interactive-n-up-file (pr-prompt "PS print")))
4096 (if (pr-auto-mode-p)
4097 (pr-ps-mode-print n-up filename
)
4098 (pr-ps-print (pr-region-active-symbol) n-up filename
4099 (pr-region-active-string "PS print"))))
4103 (defun pr-ps-buffer-ps-print (n-up &optional filename
)
4104 "Print buffer using PostScript printer or through ghostscript.
4106 It depends on `pr-print-using-ghostscript'.
4108 Interactively, the command prompts for N-UP printing number and, when you use a
4109 prefix argument (C-u), the command prompts the user for a file name, and saves
4110 the PostScript image in that file instead of sending it to the printer.
4112 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4113 argument FILENAME is treated as follows: if it's nil, send the image to the
4114 printer. If FILENAME is a string, save the PostScript image in a file with
4115 that name. If FILENAME is t, prompts for a file name."
4116 (interactive (pr-interactive-n-up-file
4117 (pr-prompt (pr-prompt-gs "PS print"))))
4118 (cond ((pr-auto-mode-p)
4119 (pr-ps-mode-ps-print n-up filename
))
4120 ((pr-using-ghostscript-p)
4121 (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename
4122 (pr-region-active-string "PS print GS")))
4124 (pr-ps-print (pr-region-active-symbol) n-up filename
4125 (pr-region-active-string "PS print")))))
4129 (defun pr-ps-region-preview (n-up &optional filename
)
4130 "Preview region using ghostview.
4132 See also `pr-ps-buffer-preview'."
4133 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS preview")))
4134 (if (pr-auto-mode-p)
4135 (let ((pr-auto-region t
))
4136 (pr-ps-mode-preview n-up filename
))
4137 (pr-ps-preview 'region n-up filename
"PS preview region")))
4141 (defun pr-ps-region-using-ghostscript (n-up &optional filename
)
4142 "Print region using PostScript through ghostscript.
4144 See also `pr-ps-buffer-using-ghostscript'."
4145 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print GS")))
4146 (if (pr-auto-mode-p)
4147 (let ((pr-auto-region t
))
4148 (pr-ps-mode-using-ghostscript n-up filename
))
4149 (pr-ps-using-ghostscript 'region n-up filename
"PS print GS region")))
4153 (defun pr-ps-region-print (n-up &optional filename
)
4154 "Print region using PostScript printer.
4156 See also `pr-ps-buffer-print'."
4157 (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print")))
4158 (if (pr-auto-mode-p)
4159 (let ((pr-auto-region t
))
4160 (pr-ps-mode-print n-up filename
))
4161 (pr-ps-print 'region n-up filename
"PS print region")))
4165 (defun pr-ps-region-ps-print (n-up &optional filename
)
4166 "Print region using PostScript printer or through ghostscript.
4168 See also `pr-ps-buffer-ps-print'."
4169 (interactive (pr-interactive-n-up-file
4170 (pr-prompt-region (pr-prompt-gs "PS print"))))
4171 (cond ((pr-auto-mode-p)
4172 (let ((pr-auto-region t
))
4173 (pr-ps-mode-ps-print n-up filename
)))
4174 ((pr-using-ghostscript-p)
4175 (pr-ps-using-ghostscript 'region n-up filename
"PS print GS region"))
4177 (pr-ps-print 'region n-up filename
"PS print region"))))
4181 (defun pr-ps-mode-preview (n-up &optional filename
)
4182 "Preview major mode using ghostview.
4184 See also `pr-ps-buffer-preview'."
4185 (interactive (pr-interactive-n-up-file "PS preview mode"))
4186 (pr-set-n-up-and-filename 'n-up
'filename
"PS preview mode")
4187 (let ((file (pr-ps-file filename
)))
4188 (and (pr-ps-mode n-up file
)
4190 (pr-ps-file-preview file
))))
4194 (defun pr-ps-mode-using-ghostscript (n-up &optional filename
)
4195 "Print major mode using PostScript through ghostscript.
4197 See also `pr-ps-buffer-using-ghostscript'."
4198 (interactive (pr-interactive-n-up-file "PS print GS mode"))
4199 (pr-set-n-up-and-filename 'n-up
'filename
"PS print GS mode")
4200 (let ((file (pr-ps-file filename
)))
4201 (when (and (pr-ps-mode n-up file
)
4203 (pr-ps-file-using-ghostscript file
)
4204 (or filename
(pr-delete-file file
)))))
4208 (defun pr-ps-mode-print (n-up &optional filename
)
4209 "Print major mode using PostScript printer.
4211 See also `pr-ps-buffer-print'."
4212 (interactive (pr-interactive-n-up-file "PS print mode"))
4213 (pr-set-n-up-and-filename 'n-up
'filename
"PS print mode")
4214 (pr-ps-mode n-up filename
))
4218 (defun pr-ps-mode-ps-print (n-up &optional filename
)
4219 "Print major mode using PostScript or through ghostscript.
4221 See also `pr-ps-buffer-ps-print'."
4222 (interactive (pr-interactive-n-up-file (pr-prompt-gs "PS print mode")))
4223 (if (pr-using-ghostscript-p)
4224 (pr-ps-mode-using-ghostscript n-up filename
)
4225 (pr-ps-mode-print n-up filename
)))
4229 (defun pr-printify-directory (&optional dir file-regexp
)
4230 "Replace nonprinting characters in directory with printable representations.
4231 The printable representations use ^ (for ASCII control characters) or hex.
4232 The characters tab, linefeed, space, return and formfeed are not affected.
4234 Interactively, the command prompts for a directory and a file name regexp for
4237 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
4238 prompts for FILE(name)-REGEXP.
4240 See also documentation for `pr-list-directory'."
4241 (interactive (pr-interactive-dir-args "Printify dir"))
4242 (pr-set-dir-args 'dir
'file-regexp
"Printify dir")
4243 (pr-file-list dir file-regexp
'pr-printify-buffer
))
4247 (defun pr-printify-buffer ()
4248 "Replace nonprinting characters in buffer with printable representations.
4249 The printable representations use ^ (for ASCII control characters) or hex.
4250 The characters tab, linefeed, space, return and formfeed are not affected."
4252 (if (pr-region-active-p)
4253 (pr-printify-region)
4254 (printify-region (point-min) (point-max))))
4258 (defun pr-printify-region ()
4259 "Replace nonprinting characters in region with printable representations.
4260 The printable representations use ^ (for ASCII control characters) or hex.
4261 The characters tab, linefeed, space, return and formfeed are not affected."
4263 (printify-region (point) (mark)))
4267 (defun pr-txt-directory (&optional dir file-regexp
)
4268 "Print directory using text printer.
4270 Interactively, the command prompts for a directory and a file name regexp for
4273 Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil,
4274 prompts for FILE(name)-REGEXP.
4276 See also documentation for `pr-list-directory'."
4277 (interactive (pr-interactive-dir-args "Print dir"))
4278 (pr-set-dir-args 'dir
'file-regexp
"Print dir")
4279 (pr-file-list dir file-regexp
'pr-txt-buffer
))
4283 (defun pr-txt-buffer ()
4284 "Print buffer using text printer."
4286 (cond ((pr-auto-mode-p)
4288 ((pr-region-active-p)
4291 (pr-txt-print (point-min) (point-max)))))
4295 (defun pr-txt-region ()
4296 "Print region using text printer."
4298 (if (pr-auto-mode-p)
4299 (let ((pr-auto-region t
))
4301 (pr-txt-print (point) (mark))))
4305 (defun pr-txt-mode ()
4306 "Print major mode using text printer."
4308 (let ((args (pr-mode-alist-p)))
4310 (funcall (car args
) (nthcdr 2 args
))
4312 (message "`%s' major mode not declared." major-mode
))))
4316 (defun pr-despool-preview (&optional filename
)
4317 "Preview spooled PostScript.
4319 Interactively, when you use a prefix argument (C-u), the command prompts the
4320 user for a file name, and saves the spooled PostScript image in that file
4321 instead of saving it in a temporary file.
4323 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4324 save the image in a temporary file. If FILENAME is a string, save the
4325 PostScript image in a file with that name."
4326 (interactive (list (ps-print-preprint current-prefix-arg
)))
4327 (let ((file (pr-ps-file filename
)))
4328 (when (stringp file
)
4329 (pr-despool-print file
)
4330 (pr-ps-file-preview file
))))
4334 (defun pr-despool-using-ghostscript (&optional filename
)
4335 "Print spooled PostScript using ghostscript.
4337 Interactively, when you use a prefix argument (C-u), the command prompts the
4338 user for a file name, and saves the spooled PostScript image in that file
4339 instead of sending it to the printer.
4341 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4342 send the image to the printer. If FILENAME is a string, save the PostScript
4343 image in a file with that name."
4344 (interactive (list (ps-print-preprint current-prefix-arg
)))
4345 (let ((file (pr-ps-file filename
)))
4346 (when (stringp file
)
4347 (pr-despool-print file
)
4348 (pr-ps-file-using-ghostscript file
)
4349 (or filename
(pr-delete-file file
)))))
4353 (defun pr-despool-print (&optional filename
)
4354 "Send the spooled PostScript to the printer.
4356 Interactively, when you use a prefix argument (C-u), the command prompts the
4357 user for a file name, and saves the spooled PostScript image in that file
4358 instead of sending it to the printer.
4360 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4361 send the image to the printer. If FILENAME is a string, save the PostScript
4362 image in a file with that name."
4363 (interactive (list (ps-print-preprint current-prefix-arg
)))
4365 (let ((ps-lpr-command (pr-command pr-ps-command
))
4366 (ps-lpr-switches pr-ps-switches
)
4367 (ps-printer-name-option pr-ps-printer-switch
)
4368 (ps-printer-name pr-ps-printer
))
4369 (ps-despool filename
))))
4373 (defun pr-despool-ps-print (&optional filename
)
4374 "Send the spooled PostScript to the printer or use ghostscript to print it.
4376 Interactively, when you use a prefix argument (C-u), the command prompts the
4377 user for a file name, and saves the spooled PostScript image in that file
4378 instead of sending it to the printer.
4380 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
4381 send the image to the printer. If FILENAME is a string, save the PostScript
4382 image in a file with that name."
4383 (interactive (list (ps-print-preprint current-prefix-arg
)))
4384 (if pr-print-using-ghostscript
4385 (pr-despool-using-ghostscript filename
)
4386 (pr-despool-print filename
)))
4390 (defun pr-ps-file-preview (filename)
4391 "Preview PostScript file FILENAME."
4392 (interactive (list (pr-ps-infile-preprint "Preview ")))
4393 (and (stringp filename
) (file-exists-p filename
)
4394 (pr-call-process pr-gv-command filename
)))
4398 (defun pr-ps-file-up-preview (n-up ifilename
&optional ofilename
)
4399 "Preview PostScript file FILENAME."
4400 (interactive (pr-interactive-n-up-inout "PS preview"))
4401 (let ((outfile (pr-ps-utility-args 'n-up
'ifilename
'ofilename
4403 (pr-ps-utility-process n-up ifilename outfile
)
4404 (pr-ps-file-preview outfile
)))
4408 (defun pr-ps-file-using-ghostscript (filename)
4409 "Print PostScript file FILENAME using ghostscript."
4410 (interactive (list (pr-ps-infile-preprint "Print preview ")))
4411 (and (stringp filename
) (file-exists-p filename
)
4412 (let* ((file (pr-expand-file-name filename
))
4413 (tempfile (pr-dosify-file-name (make-temp-file file
))))
4415 (pr-call-process pr-gs-command
4416 (format "-sDEVICE=%s" pr-gs-device
)
4417 (format "-r%d" pr-gs-resolution
)
4418 (pr-switches-string pr-gs-switches
"pr-gs-switches")
4419 (format "-sOutputFile=\"%s\"" tempfile
)
4423 (pr-ps-file-print tempfile
)
4425 (pr-delete-file tempfile
))))
4429 (defun pr-ps-file-print (filename)
4430 "Print PostScript file FILENAME."
4431 (interactive (list (pr-ps-infile-preprint "Print ")))
4432 (and (stringp filename
) (file-exists-p filename
)
4434 (let ((file (pr-expand-file-name filename
)))
4435 (if (string= pr-ps-command
"")
4437 (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name
)))
4438 (with-current-buffer ps-spool-buffer
4440 (insert-file-contents-literally file
))
4442 ;; use `pr-ps-command' to print
4443 (apply 'pr-call-process
4445 (pr-switches-string pr-ps-switches
"pr-ps-switches")
4446 (if (string-match "cp" pr-ps-command
)
4447 ;; for "cp" (cmd in out)
4449 (concat pr-ps-printer-switch pr-ps-printer
))
4450 ;; else, for others (cmd out in)
4451 (list (concat pr-ps-printer-switch pr-ps-printer
)
4456 (defun pr-ps-file-ps-print (filename)
4457 "Send PostScript file FILENAME to printer or use ghostscript to print it."
4458 (interactive (list (pr-ps-infile-preprint
4459 (if pr-print-using-ghostscript
4462 (if pr-print-using-ghostscript
4463 (pr-ps-file-using-ghostscript filename
)
4464 (pr-ps-file-print filename
)))
4468 (defun pr-ps-file-up-ps-print (n-up ifilename
&optional ofilename
)
4469 "Process a PostScript file IFILENAME and send it to printer.
4471 Interactively, the command prompts for N-UP printing number, for an input
4472 PostScript file IFILENAME and, when you use a prefix argument (C-u), the
4473 command prompts the user for an output PostScript file name OFILENAME, and
4474 saves the PostScript image in that file instead of sending it to the printer.
4476 Noninteractively, if N-UP is nil, prompts for N-UP printing number. The
4477 argument IFILENAME is treated as follows: if it's t, prompts for an input
4478 PostScript file name; otherwise, it *must* be a string that it's an input
4479 PostScript file name. The argument OFILENAME is treated as follows: if it's
4480 nil, send the image to the printer. If OFILENAME is a string, save the
4481 PostScript image in a file with that name. If OFILENAME is t, prompts for a
4483 (interactive (pr-interactive-n-up-inout
4484 (if pr-print-using-ghostscript
4487 (let ((outfile (pr-ps-utility-args 'n-up
'ifilename
'ofilename
4488 (if pr-print-using-ghostscript
4491 (pr-ps-utility-process n-up ifilename outfile
)
4493 (pr-ps-file-ps-print outfile
)
4494 (pr-delete-file outfile
))))
4498 (defun pr-toggle-file-duplex ()
4499 "Toggle duplex for PostScript file."
4501 (pr-toggle-file-duplex-menu t
))
4505 (defun pr-toggle-file-tumble ()
4506 "Toggle tumble for PostScript file.
4508 If tumble is off, produces a printing suitable for binding on the left or
4510 If tumble is on, produces a printing suitable for binding at the top or
4513 (pr-toggle-file-tumble-menu t
))
4517 (defun pr-toggle-file-landscape ()
4518 "Toggle landscape for PostScript file."
4520 (pr-toggle-file-landscape-menu t
))
4524 (defun pr-toggle-ghostscript ()
4525 "Toggle printing using ghostscript."
4527 (pr-toggle-ghostscript-menu t
))
4531 (defun pr-toggle-faces ()
4532 "Toggle printing with faces."
4534 (pr-toggle-faces-menu t
))
4538 (defun pr-toggle-spool ()
4541 (pr-toggle-spool-menu t
))
4545 (defun pr-toggle-duplex ()
4548 (pr-toggle-duplex-menu t
))
4552 (defun pr-toggle-tumble ()
4555 If tumble is off, produces a printing suitable for binding on the left or
4557 If tumble is on, produces a printing suitable for binding at the top or
4560 (pr-toggle-tumble-menu t
))
4564 (defun pr-toggle-landscape ()
4567 (pr-toggle-landscape-menu t
))
4571 (defun pr-toggle-upside-down ()
4572 "Toggle upside-down."
4574 (pr-toggle-upside-down-menu t
))
4578 (defun pr-toggle-line ()
4579 "Toggle line number."
4581 (pr-toggle-line-menu t
))
4585 (defun pr-toggle-zebra ()
4586 "Toggle zebra stripes."
4588 (pr-toggle-zebra-menu t
))
4592 (defun pr-toggle-header ()
4593 "Toggle printing header."
4595 (pr-toggle-header-menu t
))
4599 (defun pr-toggle-header-frame ()
4600 "Toggle printing header frame."
4602 (pr-toggle-header-frame-menu t
))
4606 (defun pr-toggle-lock ()
4609 (pr-toggle-lock-menu t
))
4613 (defun pr-toggle-region ()
4614 "Toggle whether the region is automagically detected."
4616 (pr-toggle-region-menu t
))
4620 (defun pr-toggle-mode ()
4623 (pr-toggle-mode-menu t
))
4627 (defun pr-customize (&rest ignore
)
4628 "Customization of the `printing' group."
4630 (customize-group 'printing
))
4634 (defun lpr-customize (&rest ignore
)
4635 "Customization of the `lpr' group."
4637 (customize-group 'lpr
))
4641 (defun pr-help (&rest ignore
)
4642 "Help for the printing package."
4644 (pr-show-setup pr-help-message
"*Printing Help*"))
4648 (defun pr-ps-name ()
4649 "Interactively select a PostScript printer."
4651 (pr-menu-set-ps-title
4652 (pr-complete-alist "PostScript printer"
4653 pr-ps-printer-alist pr-ps-name
)))
4657 (defun pr-txt-name ()
4658 "Interactively select a text printer."
4660 (pr-menu-set-txt-title
4661 (pr-complete-alist "Text printer"
4662 pr-txt-printer-alist pr-txt-name
)))
4666 (defun pr-ps-utility ()
4667 "Interactively select a PostScript utility."
4669 (pr-menu-set-utility-title
4670 (pr-complete-alist "PostScript utility"
4671 pr-ps-utility-alist pr-ps-utility
)))
4675 (defun pr-show-ps-setup (&rest ignore
)
4676 "Show current ps-print settings."
4678 (pr-show-setup (ps-setup) "*PS Setup*"))
4682 (defun pr-show-pr-setup (&rest ignore
)
4683 "Show current printing settings."
4685 (pr-show-setup (pr-setup) "*PR Setup*"))
4689 (defun pr-show-lpr-setup (&rest ignore
)
4690 "Show current lpr settings."
4692 (pr-show-setup (lpr-setup) "*LPR Setup*"))
4695 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4700 (defun pr-ps-fast-fire (n-up &optional select
)
4701 "Fast fire function for PostScript printing.
4703 If a region is active, the region will be printed instead of the whole buffer.
4704 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4705 `pr-mode-alist' will be used, that is, the current buffer or region will be
4706 printed using `pr-ps-mode-ps-print'.
4709 Interactively, you have the following situations:
4711 M-x pr-ps-fast-fire RET
4712 The command prompts the user for a N-UP value and printing will
4713 immediately be done using the current active printer.
4715 C-u M-x pr-ps-fast-fire RET
4716 C-u 0 M-x pr-ps-fast-fire RET
4717 The command prompts the user for a N-UP value and also for a current
4718 PostScript printer, then printing will immediately be done using the new
4719 current active printer.
4721 C-u 1 M-x pr-ps-fast-fire RET
4722 The command prompts the user for a N-UP value and also for a file name,
4723 and saves the PostScript image in that file instead of sending it to the
4726 C-u 2 M-x pr-ps-fast-fire RET
4727 The command prompts the user for a N-UP value, then for a current
4728 PostScript printer and, finally, for a file name. Then change the active
4729 printer to that chosen by user and saves the PostScript image in
4730 that file instead of sending it to the printer.
4733 Noninteractively, the argument N-UP should be a positive integer greater than
4734 zero and the argument SELECT is treated as follows:
4736 If it's nil, send the image to the printer.
4738 If it's a list or an integer lesser or equal to zero, the command prompts
4739 the user for a current PostScript printer, then printing will immediately
4740 be done using the new current active printer.
4742 If it's an integer equal to 1, the command prompts the user for a file name
4743 and saves the PostScript image in that file instead of sending it to the
4746 If it's an integer greater or equal to 2, the command prompts the user for a
4747 current PostScript printer and for a file name. Then change the active
4748 printer to that chosen by user and saves the PostScript image in that file
4749 instead of sending it to the printer.
4751 If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new
4752 active printer and printing will immediately be done using the new active
4755 Otherwise, send the image to the printer.
4758 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4760 (interactive (list (pr-interactive-n-up (pr-prompt-gs "PS print fast"))
4761 current-prefix-arg
))
4762 (let ((pr-auto-region t
)
4765 (cond ((null select
))
4768 ((and (symbolp select
)
4769 (assq select pr-ps-printer-alist
))
4770 (pr-menu-set-ps-title select
))
4774 (and (>= select
1) (not pr-spool-p
)
4775 (setq filename
(pr-ps-outfile-preprint
4776 (if pr-print-using-ghostscript
4779 (pr-ps-buffer-ps-print
4781 (min (max n-up
1) 100)
4782 (error "n-up must be an integer greater than zero"))
4787 (defun pr-txt-fast-fire (&optional select-printer
)
4788 "Fast fire function for text printing.
4790 If a region is active, the region will be printed instead of the whole buffer.
4791 Also if the current major-mode is defined in `pr-mode-alist', the settings in
4792 `pr-mode-alist' will be used, that is, the current buffer or region will be
4793 printed using `pr-txt-mode'.
4795 Interactively, when you use a prefix argument (C-u), the command prompts the
4796 user for a new active text printer.
4798 Noninteractively, the argument SELECT-PRINTER is treated as follows:
4800 If it's nil, the printing is sent to the current active text printer.
4802 If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new
4803 active printer and printing will immediately be done using the new active
4806 If it's non-nil, the command prompts the user for a new active text printer.
4808 Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode'
4810 (interactive (list current-prefix-arg
))
4811 (cond ((null select-printer
))
4812 ((and (symbolp select-printer
)
4813 (assq select-printer pr-txt-printer-alist
))
4814 (pr-menu-set-txt-title select-printer
))
4817 (let ((pr-auto-region t
)
4822 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4827 "Return the current `printing' setup.
4829 This is *not* an interactive command.
4830 One way to see `printing' setup is to switch to a *Scratch* buffer and type:
4832 M-: (insert (pr-setup)) RET
4834 Or choose the menu option Printing/Show Settings/printing."
4835 (let (ps-prefix-quote)
4839 (concat "\n;;; printing.el version " pr-version
"\n")
4841 (ps-comment-string "emacs-version " emacs-version
)
4842 (ps-comment-string "pr-txt-command " pr-txt-command
)
4843 (ps-comment-string "pr-txt-switches "
4844 (pr-switches-string pr-txt-switches
"pr-txt-switches"))
4845 (ps-comment-string "pr-txt-printer " pr-txt-printer
)
4846 (ps-comment-string "pr-ps-command " pr-ps-command
)
4847 (ps-comment-string "pr-ps-switches "
4848 (pr-switches-string pr-ps-switches
"pr-ps-switches"))
4849 (ps-comment-string "pr-ps-printer-switch" pr-ps-printer-switch
)
4850 (ps-comment-string "pr-ps-printer " pr-ps-printer
)
4851 (ps-comment-string "pr-cygwin-system " pr-cygwin-system
)
4852 (ps-comment-string "ps-windows-system " ps-windows-system
)
4853 (ps-comment-string "ps-lp-system " ps-lp-system
)
4855 '(14 . pr-path-style
)
4856 '(14 . pr-path-alist
)
4859 '(21 . pr-txt-printer-alist
)
4862 '(20 . pr-ps-printer-alist
)
4865 '(20 . pr-ps-temp-file
)
4866 '(20 . pr-file-modes
)
4867 '(20 . pr-delete-temp-file
)
4868 '(20 . pr-list-directory
)
4870 '(17 . pr-gv-command
)
4871 '(17 . pr-gs-command
)
4872 '(17 . pr-gs-switches
)
4873 '(17 . pr-gs-device
)
4874 '(17 . pr-gs-resolution
)
4876 '(27 . pr-print-using-ghostscript
)
4879 '(27 . pr-file-landscape
)
4880 '(27 . pr-file-duplex
)
4881 '(27 . pr-file-tumble
)
4882 '(27 . pr-auto-region
)
4883 '(27 . pr-auto-mode
)
4885 '(20 . pr-ps-utility
)
4886 '(20 . pr-ps-utility-alist
)
4888 '(14 . pr-mode-alist
)
4890 '(20 . pr-menu-lock
)
4891 '(20 . pr-menu-char-height
)
4892 '(20 . pr-menu-char-width
)
4894 '(20 . pr-setting-database
)
4896 '(22 . pr-visible-entry-list
)
4898 '(22 . pr-buffer-verbose
)
4899 '(22 . pr-buffer-name
)
4900 '(22 . pr-buffer-name-ignore
)
4901 ")\n\n;;; printing.el - end of settings\n")
4906 "Return the current `lpr' setup.
4908 This is *not* an interactive command.
4909 One way to see `lpr' setup is to switch to a *Scratch* buffer and type:
4911 M-: (insert (lpr-setup)) RET
4913 Or choose the menu option Printing/Show Settings/lpr."
4914 (let (ps-prefix-quote)
4918 "\n;;; lpr.el settings\n"
4919 (ps-comment-string "emacs-version" emacs-version
)
4921 '(25 . printer-name
)
4922 '(25 . lpr-switches
)
4923 '(25 . lpr-add-switches
)
4925 '(25 . lpr-headers-switches
)
4926 '(25 . print-region-function
)
4927 '(25 . lpr-page-header-program
)
4928 '(25 . lpr-page-header-switches
)
4929 ")\n\n;;; lpr.el - end of settings\n")
4933 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4934 ;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>)
4936 (declare-function mh-get-msg-num
"mh-utils" (error-if-no-message))
4937 (declare-function mh-show
"mh-show" (&optional message redisplay-flag
))
4938 (declare-function mh-start-of-uncleaned-message
"mh-show" ())
4939 (defvar mh-show-buffer
)
4942 (defun pr-article-date ()
4943 "Find the date of an article or mail message in current buffer.
4944 Return only the dayname, if present, weekday, month, and year."
4946 (goto-char (point-min))
4947 (if (re-search-forward
4948 "^Date:[ \t]+\\(\\([A-Za-z]+, \\)?[0-9]+ [A-Za-z]+ [0-9]+\\)" nil t
)
4949 (buffer-substring (match-beginning 1) (match-end 1))
4950 (format-time-string "%Y/%m/%d"))))
4953 (defun pr-mh-current-message ()
4954 "Go to mh-inbox current message."
4955 (let ((msg (or (mh-get-msg-num nil
) 0)))
4957 (set-buffer mh-show-buffer
)
4958 (goto-char (point-min))
4959 (mh-start-of-uncleaned-message)
4960 (message "Printing message %d" msg
)))
4963 (defun pr-mh-print-1 (n-up filename header-list
)
4964 "Print mh-inbox current message in PostScript."
4966 (save-window-excursion
4967 (pr-mh-current-message)
4968 (pr-mode-print n-up filename header-list
(point)))))
4971 (defun pr-mh-lpr-1 (header-list)
4972 "Print mh-inbox current message in text printer."
4974 (save-window-excursion
4975 (pr-mh-current-message)
4976 (pr-mode-lpr header-list
(point)))))
4979 (defalias 'pr-mh-print-2
'pr-mode-print
)
4982 (defalias 'pr-mh-lpr-2
'pr-mode-lpr
)
4985 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4986 ;; rmail (hacked from ps-print.el)
4989 (defun pr-rmail-lpr (header-list)
4990 "Print RMAIL current message in text printer."
4991 (pr-lpr-message-from-summary header-list
4992 'rmail-buffer
'rmail-summary-buffer
))
4995 (defun pr-rmail-print (n-up filename header-list
)
4996 "Print RMAIL current message in PostScript."
4997 (pr-ps-message-from-summary n-up filename header-list
4998 'rmail-buffer
'rmail-summary-buffer
))
5001 (defun pr-ps-message-from-summary (n-up filename header-list
5002 summary-buffer summary-default
)
5003 "Print current message in PostScript."
5004 (let ((buf (or (and (boundp summary-buffer
)
5005 (symbol-value summary-buffer
))
5006 (symbol-value summary-default
))))
5007 (and (get-buffer buf
)
5008 (with-current-buffer buf
5009 (pr-mode-print n-up filename header-list
)))))
5012 (defun pr-lpr-message-from-summary (header-list summary-buffer summary-default
)
5013 "Print current message in text printer."
5014 (let ((buf (or (and (boundp summary-buffer
)
5015 (symbol-value summary-buffer
))
5016 (symbol-value summary-default
))))
5017 (and (get-buffer buf
)
5018 (with-current-buffer buf
5019 (pr-mode-lpr header-list
)))))
5022 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5023 ;; gnus (hacked from ps-print.el)
5026 (defvar pr-gnus-article
"*Article*")
5029 (defun pr-gnus-print (n-up filename header-list
)
5030 "Print *Article* current message in PostScript."
5031 (pr-ps-message-from-summary n-up filename header-list
5032 'gnus-article-buffer
'pr-gnus-article
))
5035 (defun pr-gnus-lpr (header-list)
5036 "Print *Article* current message in text printer."
5037 (pr-lpr-message-from-summary header-list
5038 'gnus-article-buffer
'pr-gnus-article
))
5041 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5042 ;; vm (hacked from ps-print.el)
5045 (defvar pr-vm-summary
"")
5048 (defun pr-vm-print (n-up filename header-list
)
5049 "Print current vm message in PostScript."
5050 (pr-ps-message-from-summary n-up filename header-list
5051 'vm-mail-buffer
'pr-vm-summary
))
5054 (defun pr-vm-lpr (header-list)
5055 "Print current vm message in text printer."
5056 (pr-lpr-message-from-summary header-list
5057 'vm-mail-buffer
'pr-vm-summary
))
5060 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5064 (defun pr-ps-mode (n-up filename
)
5065 "If current major mode is declared, print it in PostScript."
5066 (let ((args (pr-mode-alist-p)))
5068 (let ((fun (cdr args
)))
5069 (funcall (car fun
) n-up filename
(cdr fun
))
5072 (message "`%s' major mode not declared." major-mode
)
5076 (defmacro pr-local-variable
(header-list &rest body
)
5078 (let ((ps-header-lines (or (nth 0 ,header-list
) ps-header-lines
))
5079 (ps-left-header (or (nth 1 ,header-list
) ps-left-header
))
5080 (ps-right-header (or (nth 2 ,header-list
) ps-right-header
))
5082 (let ((local-var-list (pr-eval-local-alist (nthcdr 4 ,header-list
))))
5084 (and (nth 3 ,header-list
)
5085 (pr-kill-local-variable local-var-list
))))))
5088 (defun pr-mode-print (n-up filename header-list
&optional from to
)
5089 "Print current major mode in PostScript."
5092 (let ((file (pr-ps-file filename
))
5094 ((pr-region-active-p) (region-beginning))
5097 (pr-text2ps (pr-region-active-symbol start
) n-up file start
5099 ((pr-region-active-p) (region-end))
5102 (unless (or pr-spool-p filename
)
5103 (pr-ps-file-print file
)
5104 (pr-delete-file file
)))))
5107 (defun pr-mode-lpr (header-list &optional from to
)
5108 "Print current major mode in text printer."
5111 (pr-txt-print (cond (from)
5112 ((pr-region-active-p) (region-beginning))
5115 ((pr-region-active-p) (region-end))
5119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5123 (defconst pr-menu-entry-alist
5126 (postscript-options .
9)
5127 (postscript-process .
3)
5131 "Alist that associates menu part with number of items per part.
5133 It's used by `pr-menu-index'.
5135 Each element has the form:
5137 (MENU-PART . NUMBER-OF-ITEMS)
5139 See `pr-visible-entry-alist'.")
5142 (defun pr-menu-index (entry index
)
5144 (cond ((eq entry
'text
)
5146 ((eq entry
'postscript-options
)
5148 ((eq entry
'postscript-process
)
5149 '(postscript text postscript-options
))
5150 ((eq entry
'printing
)
5151 '(postscript text postscript-options postscript-process
))
5157 (setq key
(car base-list
)
5158 base-list
(cdr base-list
))
5159 (and (pr-visible-p key
)
5160 (setq index
(+ index
5161 (cdr (assq key pr-menu-entry-alist
)))))))
5165 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5166 ;; Printer & Utility Selection
5169 (defun pr-update-var (var-sym alist
)
5170 (or (assq (symbol-value var-sym
) alist
)
5171 (set var-sym
(car (car alist
)))))
5174 (defun pr-update-menus (&optional force
)
5175 "Update utility, PostScript and text printer menus.
5177 If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist',
5178 `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not;
5179 otherwise, update PostScript printer menu if `pr-ps-printer-menu-modified' is
5180 non-nil, update text printer menu if `pr-txt-printer-menu-modified' is
5181 non-nil, and update PostScript File menus if `pr-ps-utility-menu-modified' is
5184 If menu binding was not done, calls `pr-menu-bind'."
5186 (if pr-menu-print-item
; since v6.8.4
5187 ;; There was no menu binding yet, so do it now!
5188 ;; This is a hack to be compatible with old versions of printing.
5189 ;; So, user does not need to change printing calling in init files.
5191 ;; Here menu binding is ok.
5192 (pr-update-var 'pr-ps-name pr-ps-printer-alist
)
5193 (pr-update-var 'pr-txt-name pr-txt-printer-alist
)
5194 (pr-update-var 'pr-ps-utility pr-ps-utility-alist
)
5195 (pr-do-update-menus force
)))
5198 (defun pr-menu-create (name alist var-sym fun entry index
)
5202 (let ((sym (car elt
)))
5205 (list fun
(list 'quote sym
) nil
(list 'quote entry
) index
)
5207 :selected
(list 'eq var-sym
(list 'quote sym
)))))
5211 (defun pr-ps-set-utility (value)
5212 (let ((item (cdr (assq value pr-ps-utility-alist
))))
5215 "Invalid PostScript utility name `%s' for variable `pr-ps-utility'"
5217 (setq pr-ps-utility value
)
5218 (pr-eval-alist (nthcdr 9 item
)))
5219 (pr-update-mode-line))
5222 (defun pr-ps-set-printer (value)
5223 (let ((ps (cdr (assq value pr-ps-printer-alist
))))
5226 "Invalid PostScript printer name `%s' for variable `pr-ps-name'"
5228 (setq pr-ps-name value
5229 pr-ps-command
(pr-dosify-file-name (nth 0 ps
))
5230 pr-ps-switches
(nth 1 ps
)
5231 pr-ps-printer-switch
(nth 2 ps
)
5232 pr-ps-printer
(nth 3 ps
))
5233 (or (stringp pr-ps-command
)
5235 (cond (ps-windows-system "print")
5239 (or (stringp pr-ps-printer-switch
)
5240 (setq pr-ps-printer-switch
5241 (cond (ps-windows-system "/D:")
5245 (pr-eval-alist (nthcdr 4 ps
)))
5246 (pr-update-mode-line))
5249 (defun pr-txt-set-printer (value)
5250 (let ((txt (cdr (assq value pr-txt-printer-alist
))))
5252 (error "Invalid text printer name `%s' for variable `pr-txt-name'"
5254 (setq pr-txt-name value
5255 pr-txt-command
(pr-dosify-file-name (nth 0 txt
))
5256 pr-txt-switches
(nth 1 txt
)
5257 pr-txt-printer
(nth 2 txt
)))
5258 (or (stringp pr-txt-command
)
5259 (setq pr-txt-command
5260 (cond (ps-windows-system "print")
5264 (pr-update-mode-line))
5267 (defun pr-eval-alist (alist)
5268 (mapcar #'(lambda (option)
5269 (let ((var-sym (car option
))
5270 (value (cdr option
)))
5271 (if (eq var-sym
'inherits-from
:)
5272 (pr-eval-setting-alist value
'global
)
5273 (set var-sym
(eval value
)))))
5277 (defun pr-eval-local-alist (alist)
5279 (mapc #'(lambda (option)
5280 (let ((var-sym (car option
))
5281 (value (cdr option
)))
5283 (if (eq var-sym
'inherits-from
:)
5284 (nconc (pr-eval-setting-alist value
) local-list
)
5285 (set (make-local-variable var-sym
) (eval value
))
5286 (cons var-sym local-list
)))))
5291 (defun pr-eval-setting-alist (key &optional global old
)
5292 (let ((setting (cdr (assq key pr-setting-database
))))
5294 (let ((inherits (nth 0 setting
))
5295 (local (nth 1 setting
))
5296 (kill (nth 2 setting
))
5301 (message "There are local buffer settings for `%S'." key
)
5304 (if (memq inherits old
)
5305 (error "Circular inheritance for `%S'" inherits
)
5307 (pr-eval-setting-alist inherits global
5308 (cons inherits old
)))))
5310 (cond ((not local
) ; global settings
5312 (let ((var-sym (car option
)))
5313 (or (eq var-sym
'inherits-from
:)
5314 (set var-sym
(eval (cdr option
)))))))
5315 (kill ; local settings with killing
5317 (let ((var-sym (car option
)))
5318 (unless (eq var-sym
'inherits-from
:)
5319 (setq local-list
(cons var-sym local-list
))
5320 (set (make-local-variable var-sym
)
5321 (eval (cdr option
)))))))
5322 (t ; local settings without killing
5324 (let ((var-sym (car option
)))
5325 (or (eq var-sym
'inherits-from
:)
5326 (set (make-local-variable var-sym
)
5327 (eval (cdr option
))))))))
5332 (defun pr-kill-local-variable (local-var-list)
5333 (mapcar 'kill-local-variable local-var-list
))
5336 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5337 ;; Internal Functions (II)
5340 (defun pr-toggle (var-sym mess entry index horizontal state
5341 &optional path no-menu
)
5342 (set var-sym
(not (symbol-value var-sym
)))
5343 (message "%s is %s" mess
(if (symbol-value var-sym
) "on" "off"))
5345 (pr-menu-lock entry index horizontal state path
)))
5348 (defun pr-toggle-file-duplex-menu (&optional no-menu
)
5349 "Toggle whether to print PostScript files in duplex mode."
5351 (pr-toggle 'pr-file-duplex
"PS file duplex" nil
7 5 nil
5352 '("PostScript Print" "File") no-menu
))
5355 (defun pr-toggle-file-tumble-menu (&optional no-menu
)
5356 "Toggle whether to print PostScript files in tumble mode."
5358 (pr-toggle 'pr-file-tumble
"PS file tumble" nil
8 5 nil
5359 '("PostScript Print" "File") no-menu
))
5362 (defun pr-toggle-file-landscape-menu (&optional no-menu
)
5363 "Toggle whether to print PostScript files in landscape orientation."
5365 (pr-toggle 'pr-file-landscape
"PS file landscape" nil
6 5 nil
5366 '("PostScript Print" "File") no-menu
))
5369 (defun pr-toggle-ghostscript-menu (&optional no-menu
)
5370 "Toggle whether to print using ghostscript."
5372 (pr-toggle 'pr-print-using-ghostscript
"Printing using ghostscript"
5373 'postscript-process
2 12 'toggle nil no-menu
))
5376 (defun pr-toggle-faces-menu (&optional no-menu
)
5377 "Toggle whether to print with face attributes."
5379 (pr-toggle 'pr-faces-p
"Printing with faces"
5380 'postscript-process
1 12 'toggle nil no-menu
))
5383 (defun pr-toggle-spool-menu (&optional no-menu
)
5384 "Toggle whether to spool printing in a buffer."
5386 (pr-toggle 'pr-spool-p
"Spooling printing"
5387 'postscript-process
0 12 'toggle nil no-menu
))
5390 (defun pr-toggle-duplex-menu (&optional no-menu
)
5391 "Toggle whether to generate PostScript for a two-sided printer."
5393 (pr-toggle 'ps-spool-duplex
"Printing duplex"
5394 'postscript-options
5 12 'toggle nil no-menu
))
5397 (defun pr-toggle-tumble-menu (&optional no-menu
)
5398 "Toggle how pages on opposite sides of a sheet are oriented."
5400 (pr-toggle 'ps-spool-tumble
"Tumble"
5401 'postscript-options
6 12 'toggle nil no-menu
))
5404 (defun pr-toggle-landscape-menu (&optional no-menu
)
5405 "Toggle whether to print in landscape mode."
5407 (pr-toggle 'ps-landscape-mode
"Landscape"
5408 'postscript-options
0 12 'toggle nil no-menu
))
5411 (defun pr-toggle-upside-down-menu (&optional no-menu
)
5412 "Toggle whether to print upside-down (that is, rotated by 180 degrees)."
5414 (pr-toggle 'ps-print-upside-down
"Upside-Down"
5415 'postscript-options
7 12 'toggle nil no-menu
))
5418 (defun pr-toggle-line-menu (&optional no-menu
)
5419 "Toggle whether to means print line numbers."
5421 (pr-toggle 'ps-line-number
"Line number"
5422 'postscript-options
3 12 'toggle nil no-menu
))
5425 (defun pr-toggle-zebra-menu (&optional no-menu
)
5426 "Toggle whether to print zebra stripes."
5428 (pr-toggle 'ps-zebra-stripes
"Zebra stripe"
5429 'postscript-options
4 12 'toggle nil no-menu
))
5432 (defun pr-toggle-header-menu (&optional no-menu
)
5433 "Toggle whether to print a header at the top of each page."
5435 (pr-toggle 'ps-print-header
"Print header"
5436 'postscript-options
1 12 'toggle nil no-menu
))
5439 (defun pr-toggle-header-frame-menu (&optional no-menu
)
5440 "Toggle whether to draw a gaudy frame around the header."
5442 (pr-toggle 'ps-print-header-frame
"Print header frame"
5443 'postscript-options
2 12 'toggle nil no-menu
))
5446 (defun pr-toggle-lock-menu (&optional no-menu
)
5447 "Toggle whether the menu is locked while selecting toggle options."
5449 (pr-toggle 'pr-menu-lock
"Menu lock"
5450 'printing
2 12 'toggle nil no-menu
))
5453 (defun pr-toggle-region-menu (&optional no-menu
)
5454 "Toggle whether the region is automagically detected."
5456 (pr-toggle 'pr-auto-region
"Auto region"
5457 'printing
0 12 'toggle nil no-menu
))
5460 (defun pr-toggle-mode-menu (&optional no-menu
)
5461 "Toggle whether major-mode specific printing is preferred over normal printing."
5463 (pr-toggle 'pr-auto-mode
"Auto mode"
5464 'printing
1 12 'toggle nil no-menu
))
5467 (defun pr-prompt (str)
5468 (if (pr-auto-mode-p)
5469 (concat str
" mode")
5470 (pr-region-active-string str
)))
5473 (defun pr-prompt-region (str)
5474 (concat str
(if (pr-auto-mode-p)
5479 (defun pr-prompt-gs (str)
5480 (if (pr-using-ghostscript-p)
5485 (defun pr-region-active-symbol (&optional region-p
)
5486 (if (or region-p
(pr-region-active-p))
5491 (defun pr-region-active-string (prefix)
5493 (if (pr-region-active-p)
5498 (defun pr-show-setup (settings buffer-name
)
5499 (with-output-to-temp-buffer buffer-name
5501 (help-print-return-message)))
5504 (defun pr-complete-alist (prompt alist default
)
5505 (let ((collection (mapcar #'(lambda (elt)
5506 (setq elt
(car elt
))
5507 (cons (symbol-name elt
) elt
))
5509 (cdr (assoc (completing-read (concat prompt
": ")
5511 (symbol-name default
) nil
5512 (symbol-name default
))
5516 (defun pr-delete-file (file)
5517 (and pr-delete-temp-file
(file-exists-p file
)
5518 (delete-file file
)))
5521 (defun pr-expand-file-name (filename)
5522 (pr-dosify-file-name (expand-file-name filename
)))
5525 (defun pr-ps-outfile-preprint (&optional mess
)
5526 (let* ((prompt (format "%soutput PostScript file name: " (or mess
"")))
5527 (res (read-file-name prompt default-directory
"" nil
)))
5528 (while (cond ((not (file-writable-p res
))
5530 (setq prompt
"is unwritable"))
5531 ((file-directory-p res
)
5533 (setq prompt
"is a directory"))
5534 ((file-exists-p res
)
5536 (setq prompt
"exists")
5537 (not (y-or-n-p (format "File `%s' exists; overwrite? "
5540 (setq res
(read-file-name
5541 (format "File %s; PostScript file: " prompt
)
5542 (file-name-directory res
) nil nil
5543 (file-name-nondirectory res
))))
5544 (pr-expand-file-name res
)))
5547 (defun pr-ps-infile-preprint (&optional mess
)
5548 (let* ((prompt (format "%sinput PostScript file name: " (or mess
"")))
5549 (res (read-file-name prompt default-directory
"" nil
)))
5550 (while (cond ((not (file-exists-p res
))
5552 (setq prompt
"doesn't exist"))
5553 ((not (file-readable-p res
))
5555 (setq prompt
"is unreadable"))
5556 ((file-directory-p res
)
5558 (setq prompt
"is a directory"))
5560 (setq res
(read-file-name
5561 (format "File %s; PostScript file: " prompt
)
5562 (file-name-directory res
) nil nil
5563 (file-name-nondirectory res
))))
5564 (pr-expand-file-name res
)))
5567 (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt
)
5568 ;; check arguments for PostScript file processing.
5570 (or (symbol-value n-up-sym
)
5571 (set n-up-sym
(pr-interactive-n-up prompt
)))
5573 (and (eq (symbol-value infile-sym
) t
)
5574 (set infile-sym
(pr-ps-infile-preprint prompt
)))
5575 (or (symbol-value infile-sym
)
5576 (error "%s: input PostScript file name is missing" prompt
))
5577 (set infile-sym
(pr-dosify-file-name (symbol-value infile-sym
)))
5579 (and (eq (symbol-value outfile-sym
) t
)
5580 (set outfile-sym
(and current-prefix-arg
5581 (pr-ps-outfile-preprint prompt
))))
5582 (and (symbol-value outfile-sym
)
5583 (set outfile-sym
(pr-dosify-file-name (symbol-value outfile-sym
))))
5584 (pr-ps-file (symbol-value outfile-sym
)))
5587 (defun pr-ps-utility-process (n-up infile outfile
)
5588 ;; activate utility to process a PostScript file.
5590 (and (stringp infile
) (file-exists-p infile
)
5591 (setq item
(cdr (assq pr-ps-utility pr-ps-utility-alist
)))
5592 (pr-call-process (nth 0 item
)
5593 (pr-switches-string (nth 1 item
)
5594 "pr-ps-utility-alist entry")
5595 (pr-switches-string (nth 8 item
)
5596 "pr-ps-utility-alist entry")
5598 (format (nth 2 item
) ps-paper-type
))
5599 (format (nth 3 item
) n-up
)
5600 (and pr-file-landscape
(nth 4 item
))
5601 (and pr-file-duplex
(nth 5 item
))
5602 (and pr-file-tumble
(nth 6 item
))
5603 (pr-expand-file-name infile
)
5605 (pr-expand-file-name outfile
)))))
5608 (defun pr-remove-nil-from-list (lst)
5609 (while (and lst
(null (car lst
)))
5610 (setq lst
(cdr lst
)))
5622 (defun pr-call-process (command &rest args
)
5623 (let ((buffer (get-buffer-create "*Printing Command Output*"))
5624 (cmd (pr-command command
))
5626 (setq args
(pr-remove-nil-from-list args
))
5627 ;; *Printing Command Output* == show command & args
5628 (with-current-buffer buffer
5629 (goto-char (point-max))
5630 (insert (format "%s %S\n" cmd args
)))
5631 ;; *Printing Command Output* == show any return message from command
5634 (condition-case data
5635 (apply 'call-process cmd nil buffer nil args
)
5637 (error-message-string data
)))))
5638 ;; *Printing Command Output* == show exit status
5639 (with-current-buffer buffer
5640 (goto-char (point-max))
5641 (insert (format "Exit status: %s\n\n" status
)))
5642 ;; message if error status
5643 (if (or (stringp status
)
5644 (and (integerp status
) (/= status
0)))
5646 "Printing error status: %s (see *Printing Command Output* buffer)"
5650 (defun pr-txt-print (from to
)
5651 (let ((lpr-command (pr-standard-file-name (pr-command pr-txt-command
)))
5652 (lpr-switches (pr-switches pr-txt-switches
"pr-txt-switches"))
5653 (printer-name pr-txt-printer
))
5654 (lpr-region from to
)))
5657 (defun pr-switches-string (switches mess
)
5658 ;; If SWITCHES is nil, return nil.
5659 ;; Otherwise, return the list of string in a string.
5661 (mapconcat 'identity
(pr-switches switches mess
) " ")))
5664 (defun pr-switches (switches mess
)
5665 (or (listp switches
)
5666 (error "%S should have a list of strings" mess
))
5667 (ps-flatten-list ; dynamic evaluation
5668 (mapcar 'ps-eval-switch switches
)))
5671 (defun pr-ps-preview (kind n-up filename mess
)
5672 (pr-set-n-up-and-filename 'n-up
'filename mess
)
5673 (let ((file (pr-ps-file filename
)))
5674 (pr-text2ps kind n-up file
)
5675 (or pr-spool-p
(pr-ps-file-preview file
))))
5678 (defun pr-ps-using-ghostscript (kind n-up filename mess
)
5679 (pr-set-n-up-and-filename 'n-up
'filename mess
)
5680 (let ((file (pr-ps-file filename
)))
5681 (pr-text2ps kind n-up file
)
5682 (unless (or pr-spool-p filename
)
5683 (pr-ps-file-using-ghostscript file
)
5684 (pr-delete-file file
))))
5687 (defun pr-ps-print (kind n-up filename mess
)
5688 (pr-set-n-up-and-filename 'n-up
'filename mess
)
5689 (let ((file (pr-ps-file filename
)))
5690 (pr-text2ps kind n-up file
)
5691 (unless (or pr-spool-p filename
)
5692 (pr-ps-file-print file
)
5693 (pr-delete-file file
))))
5696 (defun pr-ps-file (&optional filename
)
5697 (pr-dosify-file-name (or filename
5699 (convert-standard-filename
5700 (expand-file-name pr-ps-temp-file pr-temp-dir
))
5704 (defun pr-interactive-n-up (mess)
5705 (or (stringp mess
) (setq mess
"*"))
5707 (let* ((fmt-prompt "%s[%s] N-up printing (default 1): ")
5709 (str (pr-read-string (format fmt-prompt prompt mess
) "1" nil
"1"))
5711 (while (if (string-match "^\\s *[0-9]+$" str
)
5712 (setq int
(string-to-number str
)
5713 prompt
(cond ((< int
1) "Integer below 1; ")
5714 ((> int
100) "Integer above 100; ")
5716 (setq prompt
"Invalid integer syntax; "))
5719 (pr-read-string (format fmt-prompt prompt mess
) str nil
"1")))
5723 (defun pr-interactive-dir (mess)
5724 (let* ((dir-name (file-name-directory (or (buffer-file-name)
5725 default-directory
)))
5726 (fmt-prompt (concat "%s[" mess
"] Directory to print: "))
5727 (dir (read-directory-name (format fmt-prompt
"")
5728 "" dir-name nil dir-name
))
5730 (while (cond ((not (file-directory-p dir
))
5732 (setq prompt
"It's not a directory! "))
5733 ((not (file-readable-p dir
))
5735 (setq prompt
"Directory is unreadable! "))
5737 (setq dir-name
(file-name-directory dir
)
5738 dir
(read-directory-name (format fmt-prompt prompt
)
5739 "" dir-name nil dir-name
)))
5740 (file-name-as-directory dir
)))
5743 (defun pr-interactive-regexp (mess)
5744 (pr-read-string (format "[%s] File regexp to print: " mess
) "" nil
""))
5747 (defun pr-interactive-dir-args (mess)
5749 ;; get directory argument
5750 (pr-interactive-dir mess
)
5751 ;; get file name regexp
5752 (pr-interactive-regexp mess
)))
5755 (defun pr-interactive-ps-dir-args (mess)
5757 ;; get n-up argument
5758 (pr-interactive-n-up mess
)
5759 ;; get directory argument
5760 (pr-interactive-dir mess
)
5761 ;; get file name regexp
5762 (pr-interactive-regexp mess
)
5763 ;; get output file name
5764 (and (not pr-spool-p
)
5765 (ps-print-preprint current-prefix-arg
))))
5768 (defun pr-interactive-n-up-file (mess)
5770 ;; get n-up argument
5771 (pr-interactive-n-up mess
)
5772 ;; get output file name
5773 (and (not pr-spool-p
)
5774 (ps-print-preprint current-prefix-arg
))))
5777 (defun pr-interactive-n-up-inout (mess)
5779 ;; get n-up argument
5780 (pr-interactive-n-up mess
)
5781 ;; get input file name
5782 (pr-ps-infile-preprint (concat mess
" "))
5783 ;; get output file name
5784 (ps-print-preprint current-prefix-arg
)))
5787 (defun pr-set-outfilename (filename-sym)
5788 (and (not pr-spool-p
)
5789 (eq (symbol-value filename-sym
) t
)
5790 (set filename-sym
(and current-prefix-arg
5791 (ps-print-preprint current-prefix-arg
))))
5792 (and (symbol-value filename-sym
)
5793 (set filename-sym
(pr-dosify-file-name (symbol-value filename-sym
)))))
5796 (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess
)
5798 (or (symbol-value n-up-sym
)
5799 (set n-up-sym
(pr-interactive-n-up mess
)))
5801 (pr-set-outfilename filename-sym
))
5804 (defun pr-set-dir-args (dir-sym regexp-sym mess
)
5806 (or (symbol-value dir-sym
)
5807 (set dir-sym
(pr-interactive-dir mess
)))
5809 (or (symbol-value regexp-sym
)
5810 (set regexp-sym
(pr-interactive-regexp mess
))))
5813 (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess
)
5815 (or (symbol-value n-up-sym
)
5816 (set n-up-sym
(pr-interactive-n-up mess
)))
5817 ;; directory & file name regexp
5818 (pr-set-dir-args dir-sym regexp-sym mess
)
5820 (pr-set-outfilename filename-sym
))
5823 (defun pr-find-buffer-visiting (file)
5824 (if (not (file-directory-p file
))
5825 (find-buffer-visiting (if ps-windows-system
5828 (let ((truename (file-truename file
))
5829 (blist (buffer-list))
5831 (while (and (not found
) blist
)
5832 (with-current-buffer (car blist
)
5833 (and (eq major-mode
'dired-mode
)
5835 (goto-char (point-min))
5836 (string= (buffer-substring-no-properties
5842 (setq found
(car blist
))))
5843 (setq blist
(cdr blist
)))
5847 (defun pr-file-list (dir file-regexp fun
)
5848 (mapcar #'(lambda (file)
5849 (and (or pr-list-directory
5850 (not (file-directory-p file
)))
5851 (let ((buffer (pr-find-buffer-visiting file
))
5855 (file-readable-p file
))
5856 (with-current-buffer (or buffer
5857 (find-file-noselect file
))
5860 (kill-buffer (current-buffer))))))))
5861 (directory-files dir t file-regexp
)))
5864 (defun pr-delete-file-if-exists (filename)
5865 (and (not pr-spool-p
) (stringp filename
) (file-exists-p filename
)
5866 (delete-file filename
)))
5869 (defun pr-ps-file-list (n-up dir file-regexp filename
)
5870 (pr-delete-file-if-exists (setq filename
(pr-expand-file-name filename
)))
5871 (let ((pr-spool-p t
))
5872 (pr-file-list dir file-regexp
5874 (if (pr-auto-mode-p)
5875 (pr-ps-mode n-up filename
)
5876 (pr-text2ps 'buffer n-up filename
)))))
5878 (pr-despool-print filename
)))
5881 (defun pr-text2ps (kind n-up filename
&optional from to
)
5883 (let ((ps-n-up-printing n-up
)
5884 (ps-spool-config (and (eq ps-spool-config
'setpagedevice
)
5886 (pr-delete-file-if-exists filename
)
5889 ;; pr-faces-p and pr-spool-p
5890 ;; here FILENAME arg is ignored
5891 (cond ((eq kind
'buffer
)
5892 (ps-spool-buffer-with-faces))
5894 (ps-spool-region-with-faces (or from
(point))
5897 ;; pr-faces-p and not pr-spool-p
5899 (ps-print-buffer-with-faces filename
))
5901 (ps-print-region-with-faces (or from
(point))
5902 (or to
(mark)) filename
))
5905 ;; not pr-faces-p and pr-spool-p
5906 ;; here FILENAME arg is ignored
5907 (cond ((eq kind
'buffer
)
5910 (ps-spool-region (or from
(point)) (or to
(mark))))
5912 ;; not pr-faces-p and not pr-spool-p
5914 (ps-print-buffer filename
))
5916 (ps-print-region (or from
(point)) (or to
(mark)) filename
))
5920 (defun pr-command (command)
5921 "Return absolute file name specification for COMMAND.
5923 If COMMAND is an empty string, return it.
5925 If COMMAND is already an absolute file name specification, return it.
5926 Else it uses `pr-path-alist' to find COMMAND, if find it then return it;
5927 otherwise, gives an error.
5929 When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and
5930 `unix' are used (see `pr-path-alist' for documentation).
5932 If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND,
5933 COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
5934 (if (string= command
"")
5936 (pr-dosify-file-name
5937 (or (pr-find-command command
)
5938 (pr-path-command (cond (pr-cygwin-system 'cygwin
)
5939 (ps-windows-system 'windows
)
5941 (file-name-nondirectory command
)
5943 (error "Command not found: %s"
5944 (file-name-nondirectory command
))))))
5947 (defun pr-path-command (symbol command sym-list
)
5948 (let ((lpath (cdr (assq symbol pr-path-alist
)))
5951 (and (eq symbol
'PATH
) (null lpath
)
5952 (setq lpath
(parse-colon-path (getenv "PATH"))))
5956 (let ((path (car lpath
)))
5960 (and (not (memq path sym-list
))
5961 (pr-path-command path command
5962 (cons path sym-list
))))
5967 (substitute-in-file-name
5968 (concat (file-name-as-directory path
)
5971 (setq lpath
(cdr lpath
)))
5975 (defun pr-find-command (cmd)
5976 (if ps-windows-system
5978 (let ((ext (cons (file-name-extension cmd t
)
5979 (list ".exe" ".bat" ".com")))
5981 (setq cmd
(file-name-sans-extension cmd
))
5983 (setq found
(concat cmd
(car ext
)))
5984 (not (and (file-regular-p found
)
5985 (file-executable-p found
))))
5989 ;; non-windows systems
5990 (and (file-regular-p cmd
)
5991 (file-executable-p cmd
)
5995 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5996 ;; Printing Interface (inspired by ps-print-interface.el)
6005 (defvar pr-i-window-configuration nil
)
6007 (defvar pr-i-buffer nil
)
6008 (defvar pr-i-region nil
)
6009 (defvar pr-i-mode nil
)
6010 (defvar pr-i-despool nil
)
6011 (defvar pr-i-ps-as-is t
)
6012 (defvar pr-i-n-up
1)
6013 (defvar pr-i-directory
"./")
6014 (defvar pr-i-regexp
"")
6015 (defvar pr-i-ps-file
"")
6016 (defvar pr-i-out-file
"")
6017 (defvar pr-i-answer-yes nil
)
6018 (defvar pr-i-process
'buffer
)
6019 (defvar pr-i-ps-send
'printer
)
6022 (defvar pr-interface-map nil
6023 "Keymap for pr-interface.")
6025 (unless pr-interface-map
6026 (let ((map (make-sparse-keymap)))
6027 (cond ((featurep 'xemacs
) ; XEmacs
6028 (pr-set-keymap-parents map
(list widget-keymap
))
6029 (pr-set-keymap-name map
'pr-interface-map
))
6031 (pr-set-keymap-parents map widget-keymap
)))
6032 (define-key map
"q" 'pr-interface-quit
)
6033 (define-key map
"?" 'pr-interface-help
)
6034 (setq pr-interface-map map
)))
6037 (defmacro pr-interface-save
(&rest body
)
6038 `(with-current-buffer pr-i-buffer
6042 (defun pr-create-interface ()
6043 "Create the front end for printing package."
6044 (setq pr-i-buffer
(buffer-name (current-buffer))
6045 pr-i-region
(ps-mark-active-p)
6046 pr-i-mode
(pr-mode-alist-p)
6047 pr-i-window-configuration
(current-window-configuration))
6049 (put 'pr-i-process
'pr-widget-list nil
)
6050 (put 'pr-i-ps-send
'pr-widget-list nil
)
6052 (delete-other-windows)
6053 (kill-buffer (get-buffer-create pr-buffer-name
))
6054 (switch-to-buffer (get-buffer-create pr-buffer-name
))
6057 (let ((versions (concat "printing v" pr-version
6058 " ps-print v" ps-print-version
)))
6059 ;; to keep compatibility with Emacs 20 & 21:
6060 ;; DO NOT REPLACE `?\ ' BY `?\s'
6061 (widget-insert (make-string (- 79 (length versions
)) ?\
) versions
))
6062 (pr-insert-italic "\nCurrent Directory : " 1)
6063 (pr-insert-italic default-directory
)
6065 (pr-insert-section-1) ; 1. Print
6066 (pr-insert-section-2) ; 2. PostScript Printer
6067 (pr-insert-section-3) ; 3. Text Printer
6070 (widget-insert "\n\n " (make-string 77 ?-
))
6072 (pr-insert-section-4) ; 4. Settings
6073 (pr-insert-section-5) ; 5. Customize
6074 (pr-insert-section-6) ; 6. Show Settings
6075 (pr-insert-section-7) ; 7. Help
6077 (use-local-map pr-interface-map
)
6079 (goto-char (point-min))
6081 (and pr-i-region
; let region activated
6082 (pr-keep-region-active)))
6085 (defun pr-insert-section-1 ()
6087 (pr-insert-italic "\nPrint :" 1)
6090 ;; 1a. Buffer: Buffer List
6091 (pr-insert-radio-button 'pr-i-process
'buffer
)
6092 (pr-insert-menu "Buffer List" 'pr-i-buffer
6093 (let ((blist (buffer-list))
6094 case-fold-search choices
)
6096 (let ((name (buffer-name (car blist
)))
6097 (ignore pr-buffer-name-ignore
)
6099 (setq blist
(cdr blist
))
6100 (while (and ignore
(not found
))
6101 (setq found
(string-match (car ignore
) name
)
6102 ignore
(cdr ignore
)))
6114 (setq pr-i-region
(ps-mark-active-p)
6115 pr-i-mode
(pr-mode-alist-p)))
6116 (pr-update-checkbox 'pr-i-region
)
6117 (pr-update-checkbox 'pr-i-mode
)))
6118 ;; 1a. Buffer: Region
6119 (put 'pr-i-region
'pr-widget
6123 #'(lambda (widget &rest ignore
)
6124 (let ((region-p (pr-interface-save
6125 (ps-mark-active-p))))
6126 (cond ((null (widget-value widget
)) ; widget is nil
6127 (setq pr-i-region nil
))
6128 (region-p ; widget is true and there is a region
6129 (setq pr-i-region t
)
6130 (widget-value-set widget t
)
6131 (widget-setup)) ; MUST be called after widget-value-set
6132 (t ; widget is true and there is no region
6134 (message "There is no region active")
6135 (setq pr-i-region nil
)
6136 (widget-value-set widget nil
)
6137 (widget-setup))))) ; MUST be called after widget-value-set
6140 (put 'pr-i-mode
'pr-widget
6144 #'(lambda (widget &rest ignore
)
6145 (let ((mode-p (pr-interface-save
6146 (pr-mode-alist-p))))
6148 ((null (widget-value widget
)) ; widget is nil
6149 (setq pr-i-mode nil
))
6150 (mode-p ; widget is true and there is a `mode'
6152 (widget-value-set widget t
)
6153 (widget-setup)) ; MUST be called after widget-value-set
6154 (t ; widget is true and there is no `mode'
6157 "This buffer isn't in a mode that printing treats specially.")
6158 (setq pr-i-mode nil
)
6159 (widget-value-set widget nil
)
6160 (widget-setup))))) ; MUST be called after widget-value-set
6164 (pr-insert-radio-button 'pr-i-process
'directory
)
6168 :format
" Directory : %v"
6169 :notify
'pr-interface-directory
6170 :action
(lambda (widget &optional event
)
6171 (if (pr-interface-directory widget
)
6172 (pr-widget-field-action widget event
)
6174 (message "Please specify a readable directory")))
6176 ;; 1b. Directory: File Regexp
6177 (widget-create 'regexp
6179 :format
"\n File Regexp : %v\n"
6180 :notify
(lambda (widget &rest ignore
)
6181 (setq pr-i-regexp
(widget-value widget
)))
6183 ;; 1b. Directory: List Directory Entry
6185 (pr-insert-toggle 'pr-list-directory
" List Directory Entry\n")
6187 ;; 1c. PostScript File:
6188 (pr-insert-radio-button 'pr-i-process
'file
)
6192 :format
" PostScript File : %v"
6193 :notify
'pr-interface-infile
6194 :action
(lambda (widget &rest event
)
6195 (if (pr-interface-infile widget
)
6196 (pr-widget-field-action widget event
)
6198 (message "Please specify a readable PostScript file")))
6200 ;; 1c. PostScript File: PostScript Utility
6201 (pr-insert-menu "PostScript Utility" 'pr-ps-utility
6202 (pr-choice-alist pr-ps-utility-alist
)
6203 "\n PostScript Utility : "
6205 ;; 1c. PostScript File: No Preprocessing
6206 (pr-insert-toggle 'pr-i-ps-as-is
" No Preprocessing"))
6209 (defun pr-insert-section-2 ()
6210 ;; 2. PostScript Printer:
6211 ;; 2. PostScript Printer: PostScript Printer List
6212 (pr-insert-italic "\n\nPostScript Printer : " 2 20)
6213 (pr-insert-menu "PostScript Printer" 'pr-ps-name
6214 (pr-choice-alist pr-ps-printer-alist
))
6215 ;; 2. PostScript Printer: Despool
6216 (put 'pr-i-despool
'pr-widget
6220 #'(lambda (widget &rest ignore
)
6222 (setq pr-i-despool
(not pr-i-despool
))
6224 (message "Can despool only when spooling is actually selected")
6225 (setq pr-i-despool nil
))
6226 (widget-value-set widget pr-i-despool
)
6227 (widget-setup)) ; MUST be called after widget-value-set
6229 ;; 2. PostScript Printer: Preview Print Quit
6230 (pr-insert-button 'pr-interface-preview
"Preview" " ")
6231 (pr-insert-button 'pr-interface-ps-print
"Print" " ")
6232 (pr-insert-button 'pr-interface-quit
"Quit")
6233 ;; 2. PostScript Printer: Send to Printer/Temporary File
6234 (pr-insert-radio-button 'pr-i-ps-send
'printer
)
6235 (widget-insert " Send to Printer/Temporary File")
6236 ;; 2. PostScript Printer: Send to File
6237 (pr-insert-radio-button 'pr-i-ps-send
'file
)
6241 :format
" Send to File : %v"
6242 :notify
'pr-interface-outfile
6243 :action
(lambda (widget &rest event
)
6244 (if (and (pr-interface-outfile widget
)
6245 (or (not (file-exists-p pr-i-out-file
))
6246 (setq pr-i-answer-yes
6247 (y-or-n-p "File exists; overwrite? "))))
6248 (pr-widget-field-action widget event
)
6250 (message "Please specify a writable PostScript file")))
6252 ;; 2. PostScript Printer: N-Up
6256 :format
"\n N-Up : %v"
6257 :notify
(lambda (widget &rest ignore
)
6258 (let ((value (if (string= (widget-apply widget
:value-get
) "")
6260 (widget-value widget
))))
6261 (if (and (integerp value
)
6262 (<= 1 value
) (<= value
100))
6265 (setq pr-i-n-up value
))
6267 (message "Please specify an integer between 1 and 100"))))
6271 (defun pr-insert-section-3 ()
6273 (pr-insert-italic "\n\nText Printer : " 2 14)
6274 (pr-insert-menu "Text Printer" 'pr-txt-name
6275 (pr-choice-alist pr-txt-printer-alist
)
6277 (pr-insert-button 'pr-interface-printify
"Printify" " ")
6278 (pr-insert-button 'pr-interface-txt-print
"Print" " ")
6279 (pr-insert-button 'pr-interface-quit
"Quit"))
6282 (defun pr-insert-section-4 ()
6284 ;; 4. Settings: Landscape Auto Region Verbose
6285 (pr-insert-checkbox "\n\n " 'ps-landscape-mode
6286 #'(lambda (&rest ignore
)
6287 (setq ps-landscape-mode
(not ps-landscape-mode
)
6288 pr-file-landscape ps-landscape-mode
))
6290 (pr-insert-toggle 'pr-auto-region
" Auto Region ")
6291 (pr-insert-toggle 'pr-buffer-verbose
" Verbose\n ")
6293 ;; 4. Settings: Print Header Auto Mode
6294 (pr-insert-toggle 'ps-print-header
" Print Header ")
6295 (pr-insert-toggle 'pr-auto-mode
" Auto Mode\n ")
6297 ;; 4. Settings: Print Header Frame Menu Lock
6298 (pr-insert-toggle 'ps-print-header-frame
" Print Header Frame ")
6299 (pr-insert-toggle 'pr-menu-lock
" Menu Lock\n ")
6301 ;; 4. Settings: Line Number
6302 (pr-insert-toggle 'ps-line-number
" Line Number\n ")
6304 ;; 4. Settings: Zebra Stripes Spool Buffer
6305 (pr-insert-toggle 'ps-zebra-stripes
" Zebra Stripes")
6306 (pr-insert-checkbox " "
6308 #'(lambda (&rest ignore
)
6309 (setq pr-spool-p
(not pr-spool-p
))
6311 (setq pr-i-despool nil
)
6312 (pr-update-checkbox 'pr-i-despool
)))
6315 ;; 4. Settings: Duplex Print with faces
6316 (pr-insert-checkbox "\n "
6318 #'(lambda (&rest ignore
)
6319 (setq ps-spool-duplex
(not ps-spool-duplex
)
6320 pr-file-duplex ps-spool-duplex
))
6322 (pr-insert-toggle 'pr-faces-p
" Print with faces")
6324 ;; 4. Settings: Tumble Print via Ghostscript
6325 (pr-insert-checkbox "\n "
6327 #'(lambda (&rest ignore
)
6328 (setq ps-spool-tumble
(not ps-spool-tumble
)
6329 pr-file-tumble ps-spool-tumble
))
6331 (pr-insert-toggle 'pr-print-using-ghostscript
" Print via Ghostscript\n ")
6333 ;; 4. Settings: Upside-Down Page Parity
6334 (pr-insert-toggle 'ps-print-upside-down
" Upside-Down")
6335 (pr-insert-italic "\n\nSelect Pages : " 2 14)
6336 (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages
6337 (mapcar #'(lambda (alist)
6342 :value
(car alist
))))
6343 pr-even-or-odd-alist
)))
6346 (defun pr-insert-section-5 ()
6348 (pr-insert-italic "\n\nCustomize : " 2 11)
6349 (pr-insert-button 'pr-customize
"printing" " ")
6350 (pr-insert-button #'(lambda (&rest ignore
) (ps-print-customize))
6352 (pr-insert-button 'lpr-customize
"lpr"))
6355 (defun pr-insert-section-6 ()
6356 ;; 6. Show Settings:
6357 (pr-insert-italic "\nShow Settings : " 1 14)
6358 (pr-insert-button 'pr-show-pr-setup
"printing" " ")
6359 (pr-insert-button 'pr-show-ps-setup
"ps-print" " ")
6360 (pr-insert-button 'pr-show-lpr-setup
"lpr"))
6363 (defun pr-insert-section-7 ()
6365 (pr-insert-italic "\nHelp : " 1 5)
6366 (pr-insert-button 'pr-interface-help
"Interface Help" " ")
6367 (pr-insert-button 'pr-help
"Menu Help" " ")
6368 (pr-insert-button 'pr-interface-quit
"Quit" "\n ")
6369 (pr-insert-button 'pr-kill-help
"Kill All Printing Help Buffer"))
6372 (defun pr-kill-help (&rest ignore
)
6373 "Kill all printing help buffer."
6375 (let ((help '("*Printing Interface Help*" "*Printing Help*"
6376 "*LPR Setup*" "*PR Setup*" "*PS Setup*")))
6378 (let ((buffer (get-buffer (car help
))))
6379 (setq help
(cdr help
))
6381 (delete-windows-on buffer
)
6382 (kill-buffer buffer
)))))
6383 (recenter (- (window-height) 2)))
6386 (defun pr-interface-quit (&rest ignore
)
6387 "Kill the printing buffer interface and quit."
6389 (kill-buffer pr-buffer-name
)
6390 (set-window-configuration pr-i-window-configuration
))
6393 (defun pr-interface-help (&rest ignore
)
6394 "printing buffer interface help."
6396 (pr-show-setup pr-interface-help-message
"*Printing Interface Help*"))
6399 (defun pr-interface-txt-print (&rest ignore
)
6400 "Print using lpr package."
6402 (condition-case data
6404 ((eq pr-i-process
'directory
)
6407 (pr-txt-directory pr-i-directory pr-i-regexp
)))
6408 ((eq pr-i-process
'buffer
)
6411 (let ((pr-auto-mode pr-i-mode
))
6414 (let (pr-auto-region)
6417 (let (pr-auto-mode pr-auto-region
)
6420 ((eq pr-i-process
'file
)
6421 (error "Please specify a text file"))
6423 (error "Internal error: `pr-i-process' = %S" pr-i-process
))
6428 (message "%s" (error-message-string data
)))))
6431 (defun pr-interface-printify (&rest ignore
)
6432 "Printify a buffer."
6434 (condition-case data
6436 ((eq pr-i-process
'directory
)
6439 (pr-printify-directory pr-i-directory pr-i-regexp
)))
6440 ((eq pr-i-process
'buffer
)
6443 (pr-printify-region)
6444 (pr-printify-buffer))))
6445 ((eq pr-i-process
'file
)
6446 (error "Cannot printify a PostScript file"))
6448 (error "Internal error: `pr-i-process' = %S" pr-i-process
))
6453 (message "%s" (error-message-string data
)))))
6456 (defun pr-interface-ps-print (&rest ignore
)
6457 "Print using ps-print package."
6459 (pr-interface-ps 'pr-despool-ps-print
'pr-ps-directory-ps-print
6460 'pr-ps-file-ps-print
'pr-ps-file-up-ps-print
6461 'pr-ps-region-ps-print
'pr-ps-mode-ps-print
6462 'pr-ps-buffer-ps-print
))
6465 (defun pr-interface-preview (&rest ignore
)
6466 "Preview a PostScript file."
6468 (pr-interface-ps 'pr-despool-preview
'pr-ps-directory-preview
6469 'pr-ps-file-preview
'pr-ps-file-up-preview
6470 'pr-ps-region-preview
'pr-ps-mode-preview
6471 'pr-ps-buffer-preview
))
6474 (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region
6476 (condition-case data
6477 (let ((outfile (or (and (eq pr-i-process
'file
) pr-i-ps-as-is
)
6480 ((and pr-i-despool pr-spool-p
)
6482 (funcall ps-despool outfile
))
6483 (setq pr-i-despool nil
)
6484 (pr-update-checkbox 'pr-i-despool
))
6485 ((eq pr-i-process
'directory
)
6488 (funcall ps-directory
6489 pr-i-n-up pr-i-directory pr-i-regexp outfile
)))
6490 ((eq pr-i-process
'file
)
6491 (cond ((or (file-directory-p pr-i-ps-file
)
6492 (not (file-readable-p pr-i-ps-file
)))
6493 (error "Please specify a readable PostScript file"))
6496 (funcall ps-file pr-i-ps-file
)))
6499 (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile
)))
6501 ((eq pr-i-process
'buffer
)
6504 (let ((pr-auto-mode pr-i-mode
))
6505 (funcall ps-region pr-i-n-up outfile
)))
6507 (let (pr-auto-region)
6508 (funcall ps-mode pr-i-n-up outfile
)))
6510 (let (pr-auto-mode pr-auto-region
)
6511 (funcall ps-buffer pr-i-n-up outfile
)))
6514 (error "Internal error: `pr-i-process' = %S" pr-i-process
))
6519 (message "%s" (error-message-string data
)))))
6522 (defun pr-i-ps-send ()
6523 (cond ((eq pr-i-ps-send
'printer
)
6525 ((not (eq pr-i-ps-send
'file
))
6526 (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send
))
6527 ((or (file-directory-p pr-i-out-file
)
6528 (not (file-writable-p pr-i-out-file
)))
6529 (error "Please specify a writable PostScript file"))
6530 ((or (not (file-exists-p pr-i-out-file
))
6532 (setq pr-i-answer-yes
6533 (y-or-n-p (format "File `%s' exists; overwrite? "
6537 (error "File already exists"))))
6540 (defun pr-i-directory ()
6541 (or (and (file-directory-p pr-i-directory
)
6542 (file-readable-p pr-i-directory
))
6543 (error "Please specify be a readable directory")))
6546 (defun pr-interface-directory (widget &rest ignore
)
6547 (and pr-buffer-verbose
6548 (message "You can use M-TAB or ESC TAB for file completion"))
6549 (let ((dir (widget-value widget
)))
6550 (and (file-directory-p dir
)
6551 (file-readable-p dir
)
6552 (setq pr-i-directory dir
))))
6555 (defun pr-interface-infile (widget &rest ignore
)
6556 (and pr-buffer-verbose
6557 (message "You can use M-TAB or ESC TAB for file completion"))
6558 (let ((file (widget-value widget
)))
6559 (and (not (file-directory-p file
))
6560 (file-readable-p file
)
6561 (setq pr-i-ps-file file
))))
6564 (defun pr-interface-outfile (widget &rest ignore
)
6565 (setq pr-i-answer-yes nil
)
6566 (and pr-buffer-verbose
6567 (message "You can use M-TAB or ESC TAB for file completion"))
6568 (let ((file (widget-value widget
)))
6569 (and (not (file-directory-p file
))
6570 (file-writable-p file
)
6571 (setq pr-i-out-file file
))))
6574 (defun pr-widget-field-action (widget event
)
6575 (and (get-buffer "*Completions*") ; clean frame window
6576 (delete-windows-on "*Completions*"))
6577 (message " ") ; clean echo area
6578 (widget-field-action widget event
))
6581 (defun pr-insert-italic (str &optional from to
)
6582 (let ((len (length str
)))
6583 (put-text-property (if from
(max from
0) 0)
6584 (if to
(max to len
) len
)
6586 (widget-insert str
)))
6589 (defun pr-insert-checkbox (before var-sym fun label
)
6590 (widget-insert before
)
6592 (widget-create 'checkbox
6594 (symbol-value var-sym
))
6595 (widget-insert label
)))
6598 (defun pr-insert-toggle (var-sym label
)
6599 (widget-create 'checkbox
6600 :notify
`(lambda (&rest ignore
)
6601 (setq ,var-sym
(not ,var-sym
)))
6602 (symbol-value var-sym
))
6603 (widget-insert label
))
6606 (defun pr-insert-button (fun label
&optional separator
)
6607 (widget-create 'push-button
6611 (widget-insert separator
)))
6614 (defun pr-insert-menu (tag var-sym choices
&optional before after
&rest body
)
6615 (and before
(widget-insert before
))
6616 (eval `(widget-create 'menu-choice
6621 :notify
(lambda (widget &rest ignore
)
6622 (setq ,var-sym
(widget-value widget
))
6624 :void
'(choice-item :format
"%[%t%]"
6625 :tag
"Can not display value!")
6627 (and after
(widget-insert after
)))
6630 (defun pr-insert-radio-button (var-sym sym
)
6631 (widget-insert "\n")
6632 (let ((wid-list (get var-sym
'pr-widget-list
))
6633 (wid (eval `(widget-create
6636 :value
(eq ,var-sym
(quote ,sym
))
6637 :notify
(lambda (&rest ignore
)
6638 (setq ,var-sym
(quote ,sym
))
6639 (pr-update-radio-button (quote ,var-sym
)))))))
6640 (put var-sym
'pr-widget-list
(cons (cons wid sym
) wid-list
))))
6643 (defun pr-update-radio-button (var-sym)
6644 (let ((wid-list (get var-sym
'pr-widget-list
)))
6646 (let ((wid (car (car wid-list
)))
6647 (value (cdr (car wid-list
))))
6648 (setq wid-list
(cdr wid-list
))
6649 (widget-value-set wid
(eq (symbol-value var-sym
) value
))))
6653 (defun pr-update-checkbox (var-sym)
6654 (let ((wid (get var-sym
'pr-widget
)))
6656 (widget-value-set wid
(symbol-value var-sym
))
6660 (defun pr-choice-alist (alist)
6661 (let ((max (apply 'max
(mapcar #'(lambda (alist)
6662 (length (symbol-name (car alist
))))
6664 (mapcar #'(lambda (alist)
6665 (let* ((sym (car alist
))
6666 (name (symbol-name sym
)))
6673 (make-string (- max
(length name
)) ?_
))
6678 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6684 ;;; printing.el ends here