Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: d435f14bad
Fetching contributors…

Cannot retrieve contributors at this time

6684 lines (5606 sloc) 223.771 kB
;;; printing.el --- printing utilities
;; Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
;; 2010, 2011 Free Software Foundation, Inc.
;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Keywords: wp, print, PostScript
;; Version: 6.9.3
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
(defconst pr-version "6.9.3"
"printing.el, v 6.9.3 <2007/12/09 vinicius>
Please send all bug fixes and enhancements to
Vinicius Jose Latorre <viniciusjl@ig.com.br>
")
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Introduction
;; ------------
;;
;; With `printing' you can preview or print a PostScript file. You can also
;; print a text file using PostScript, and preview or print buffers that use
;; certain special modes like mh-folder-mode, rmail-summary-mode,
;; gnus-summary-mode, etc. This package also includes a PostScript/text
;; printer database.
;;
;; There are two user interfaces:
;;
;; * Menu interface:
;; The `printing' menu replaces the usual print options in the menu bar.
;; This is the default user interface.
;;
;; * Buffer interface:
;; You can use a buffer interface instead of menus. It looks like a
;; customization buffer. Basically, it has the same options found in the
;; menu and some extra options, all this on a buffer.
;;
;; `printing' is prepared to run on GNU, Unix and NT systems.
;; On GNU or Unix system, `printing' depends on gs and gv utilities.
;; On NT system, `printing' depends on gstools (gswin32.exe and gsview32.exe).
;; To obtain ghostscript, ghostview and GSview see the URL
;; `http://www.gnu.org/software/ghostscript/ghostscript.html'.
;;
;; `printing' depends on ps-print package to generate PostScript files, to
;; spool and to despool PostScript buffer. So, `printing' provides an
;; interface to ps-print package and it also provides some extra stuff.
;;
;; To download the latest ps-print package see
;; `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'.
;; Please, see README file for ps-print installation instructions.
;;
;; `printing' was inspired by:
;;
;; print-nt.el Frederic Corne <frederic.corne@erli.fr>
;; Special printing functions for Windows NT
;;
;; mh-e-init.el Tom Vogels <tov@ece.cmu.edu>
;; PS-print for mail messages
;;
;; win32-ps-print.el Matthew O. Persico <mpersico@erols.com>
;; PostScript printing with ghostscript
;;
;; ps-print-interface.el Volker Franz <volker.franz@tuebingen.mpg.de>
;; Graphical front end for ps-print and previewing
;;
;;
;; Log Messages
;; ------------
;;
;; The buffer *Printing Command Output* is where the `printing' log messages
;; are inserted. All program called by `printing' has a log entry in the
;; buffer *Printing Command Output*. A log entry has the following form:
;;
;; PROGRAM (ARG...)
;; MESSAGE
;; Exit status: CODE
;;
;; Where
;; PROGRAM is the program activated by `printing',
;; ARG is an argument passed to PROGRAM (it can have more than one argument),
;; MESSAGE is an error message returned by PROGRAM (it can have no message, if
;; PROGRAM is successful),
;; and CODE is a numeric exit status or a signal description string.
;;
;; For example, after previewing a PostScript file, *Printing Command Output*
;; will have the following entry:
;;
;; /usr/X11R6/bin/gv ("/home/user/example/file.ps")
;; Exit status: 0
;;
;; In the example above, the previewing was successful. If during previewing,
;; you quit gv execution (by typing C-g during Emacs session), the log entry
;; would be:
;;
;; /usr/X11R6/bin/gv ("/home/user/example/file.ps")
;; Exit status: Quit
;;
;; So, if something goes wrong, a good place to take a look is the buffer
;; *Printing Command Output*. Don't forget to see also the buffer *Messages*,
;; it can help.
;;
;;
;; Novices (First Users)
;; ---------------------
;;
;; First of all, see printing documentation only to get an idea of what
;; `printing' is capable.
;;
;; Then try to set the variables: `pr-ps-name', `pr-ps-printer-alist',
;; `pr-txt-name', `pr-txt-printer-alist' and `pr-path-alist'. These variables
;; are the main variables for printing processing.
;;
;; Now, please, see these variables documentation deeper. You can do this by
;; typing C-h v pr-ps-name RET (for example) if you already loaded printing
;; package, or by browsing printing.el source file.
;;
;; If the documentation isn't clear or if you find a way to improve the
;; documentation, please, send an email to maintainer. All printing users
;; will thank you.
;;
;; One way to set variables is by calling `pr-customize', customize all
;; variables and save the customization by future sessions (see Options
;; section). Other way is by coding your settings on Emacs init file (that is,
;; ~/.emacs file), see below for a first setting template that it should be
;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT
;; or MS-DOS):
;;
;; * Example of setting for Windows system:
;;
;; (require 'printing) ; load printing package
;; (setq pr-path-alist
;; '((windows "c:/applications/executables" PATH ghostview mpage)
;; (ghostview "c:/gs/gsview-dir")
;; (mpage "c:/mpage-dir")
;; ))
;; (setq pr-txt-name 'prt_06a)
;; (setq pr-txt-printer-alist
;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
;; (PRN "" nil "PRN")
;; (standard "redpr.exe" nil "")
;; ))
;; (setq pr-ps-name 'lps_06b)
;; (setq pr-ps-printer-alist
;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
;; (LPT1 "" nil "" "LPT1:")
;; (PRN "" nil "" "PRN")
;; (standard "redpr.exe" nil "" "")
;; ))
;; (pr-update-menus t) ; update now printer and utility menus
;;
;; * Example of setting for GNU or Unix system:
;;
;; (require 'printing) ; load printing package
;; (setq pr-path-alist
;; '((unix "." "~/bin" ghostview mpage PATH)
;; (ghostview "$HOME/bin/gsview-dir")
;; (mpage "$HOME/bin/mpage-dir")
;; ))
;; (setq pr-txt-name 'prt_06a)
;; (setq pr-txt-printer-alist
;; '((prt_06a "lpr" nil "prt_06a")
;; (prt_07c nil nil "prt_07c")
;; ))
;; (setq pr-ps-name 'lps_06b)
;; (setq pr-ps-printer-alist
;; '((lps_06b "lpr" nil "-P" "lps_06b")
;; (lps_07c "lpr" nil nil "lps_07c")
;; (lps_08c nil nil nil "lps_08c")
;; ))
;; (pr-update-menus t) ; update now printer and utility menus
;;
;;
;; NOTE 1: Don't forget to download and install ghostscript utilities (see
;; Utilities section).
;;
;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be
;; set, as they are implicit set by `pr-ps-printer-alist' and
;; `pr-txt-printer-alist'.
;;
;; NOTE 3: The duplex feature will only work on PostScript printers that
;; support this feature.
;; You can check if your PostScript printer supports duplex feature
;; by checking the printer manual. Or you can try these steps:
;; 1. Open a buffer (or use the *scratch* buffer).
;; 2. Type:
;; First line (on first page)
;; ^L
;; Second line (on second page)
;; 3. Print this buffer with duplex turned on.
;; If it's printed 2 (two) sheets of paper, then your PostScript
;; printer doesn't have duplex feature; otherwise, it's ok, your
;; printer does have duplex feature.
;;
;; NOTE 4: See Tips section.
;;
;;
;; Tips
;; ----
;;
;; 1. If you have a local printer, that is, a printer which is connected
;; directly to your computer, don't forget to connect the printer to your
;; computer before printing.
;;
;; 2. If you try to print a file and it seems that the file was printed, but
;; there is no paper in the printer, then try to set `pr-delete-temp-file'
;; to nil. Probably `printing' is deleting the temporary file before your
;; local system can get it to send to the printer.
;;
;; 3. Don't try to print a dynamic buffer, that is, a buffer which is
;; modifying while `printing' tries to print. Eventually you got an error
;; message. Instead, save the dynamic buffer to a file or copy it in
;; another buffer and, then, print the file or the new static buffer.
;; An example of dynamic buffer is the *Messages* buffer.
;;
;; 4. When running Emacs on Windows (with or without cygwin), check if your
;; printer is a text printer or not by typing in a DOS window:
;;
;; print /D:\\host\printer somefile.txt
;;
;; Where, `host' is the machine where the printer is directly connected,
;; `printer' is the printer name and `somefile.txt' is a text file.
;;
;; If the printer `\\host\printer' doesn't print the content of
;; `somefile.txt' or, instead, it returns the following message:
;;
;; PostScript Error Handler
;; Offending Command = CCC
;; Stack =
;;
;; Where `CCC' is whatever is at the beginning of the text to be printed.
;;
;; Therefore, the printer `\\host\printer' is not a text printer, but a
;; PostScript printer. So, please, don't include this printer in
;; `pr-txt-printer-alist' (which see).
;;
;; 5. You can use gsprint instead of ghostscript to print monochrome PostScript
;; files in Windows. The gsprint utility documentation says that it is more
;; efficient than ghostscript to print monochrome PostScript.
;;
;; To print non-monochrome PostScript file, the efficiency of ghostscript
;; is similar to gsprint.
;;
;; Also the gsprint utility comes together with gsview distribution.
;;
;; For more information about gsprint see
;; `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'.
;;
;; As an example of gsprint declaration:
;;
;; (setq pr-ps-printer-alist
;; '((A "gsprint" ("-all" "-twoup") "-printer " "my-b/w-printer-name")
;; (B "gsprint" ("-all" "-twoup") nil "-printer my-b/w-printer-name")
;; ;; some other printer declaration
;; ))
;;
;; The example above declares that printer A prints all pages (-all) and two
;; pages per sheet (-twoup). The printer B declaration does the same as the
;; printer A declaration, the only difference is the printer name selection.
;;
;; There are other command line options like:
;;
;; -mono Render in monochrome as 1bit/pixel (only black and white).
;; -grey Render in greyscale as 8bits/pixel.
;; -color Render in color as 24bits/pixel.
;;
;; The default is `-mono'. So, printer A and B in the example above are
;; using implicitly the `-mono' option. Note that in `-mono' no gray tone
;; or color is printed, this includes the zebra stripes, that is, in `-mono'
;; the zebra stripes are not printed.
;;
;; See also documentation for `pr-ps-printer-alist'.
;;
;;
;; Using `printing'
;; ----------------
;;
;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're
;; using Windows 9x/NT or MS-DOS):
;;
;; (require 'printing)
;; ;; ...some user settings...
;; (pr-update-menus t)
;;
;; During `pr-update-menus' evaluation:
;; * On Emacs 20:
;; it replaces the Tools/Print menu by Tools/Printing menu.
;; * On Emacs 21:
;; it replaces the File/Print* menu entries by File/Print menu.
;; Please, see section Menu Layout below for menu explanation.
;;
;; To use `printing' utilities you can use the Printing menu options, type M-x
;; followed by one of the commands below, or type a key associated with the
;; command you want (if there is a key binding).
;;
;; `printing' has the following commands:
;;
;; pr-interface
;; pr-ps-directory-preview
;; pr-ps-directory-using-ghostscript
;; pr-ps-directory-print
;; pr-ps-directory-ps-print
;; pr-ps-buffer-preview
;; pr-ps-buffer-using-ghostscript
;; pr-ps-buffer-print
;; pr-ps-buffer-ps-print
;; pr-ps-region-preview
;; pr-ps-region-using-ghostscript
;; pr-ps-region-print
;; pr-ps-region-ps-print
;; pr-ps-mode-preview
;; pr-ps-mode-using-ghostscript
;; pr-ps-mode-print
;; pr-ps-mode-ps-print
;; pr-ps-file-preview
;; pr-ps-file-up-preview
;; pr-ps-file-using-ghostscript
;; pr-ps-file-print
;; pr-ps-file-ps-print
;; pr-ps-file-up-ps-print
;; pr-ps-fast-fire
;; pr-despool-preview
;; pr-despool-using-ghostscript
;; pr-despool-print
;; pr-despool-ps-print
;; pr-printify-directory
;; pr-printify-buffer
;; pr-printify-region
;; pr-txt-directory
;; pr-txt-buffer
;; pr-txt-region
;; pr-txt-mode
;; pr-txt-fast-fire
;; pr-toggle-file-duplex
;; pr-toggle-file-tumble
;; pr-toggle-file-landscape
;; pr-toggle-ghostscript
;; pr-toggle-faces
;; pr-toggle-spool
;; pr-toggle-duplex
;; pr-toggle-tumble
;; pr-toggle-landscape
;; pr-toggle-upside-down
;; pr-toggle-line
;; pr-toggle-zebra
;; pr-toggle-header
;; pr-toggle-lock
;; pr-toggle-region
;; pr-toggle-mode
;; pr-customize
;; lpr-customize
;; pr-help
;; pr-ps-name
;; pr-txt-name
;; pr-ps-utility
;; pr-show-ps-setup
;; pr-show-pr-setup
;; pr-show-lpr-setup
;;
;; The general meanings of above commands are:
;;
;; PREFIX:
;; `pr-interface' buffer interface for printing package.
;; `pr-help' help for printing package.
;; `pr-ps-name' interactively select a PostScript printer.
;; `pr-txt-name' interactively select a text printer.
;; `pr-ps-utility' interactively select a PostScript utility.
;; `pr-show-*-setup' show current settings.
;; `pr-ps-*' deal with PostScript code generation.
;; `pr-txt-*' deal with text generation.
;; `pr-toggle-*' toggle on/off some boolean variable.
;; `pr-despool-*' despool the PostScript spooling buffer.
;; `pr-printify-*' replace nonprintable ASCII by printable ASCII
;; representation.
;;
;; SUFFIX:
;; `*-customize' customization.
;; `*-preview' preview a PostScript file.
;; `*-using-ghostscript' use ghostscript to print.
;; `*-fast-fire' fast fire command (see it for documentation).
;; `*-print' send PostScript directly to printer.
;; `*-ps-print' send PostScript directly to printer or use
;; ghostscript to print. It depends on
;; `pr-print-using-ghostscript' option.
;;
;; INFIX/SUFFIX:
;; `*-directory*' process a directory.
;; `*-buffer*' process a buffer.
;; `*-region*' process a region.
;; `*-mode*' process a major mode (see explanation below).
;; `*-file-*' process a PostScript file.
;; `*-file-up-*' process a PostScript file using a filter utility.
;;
;; Here are some examples:
;;
;; `pr-ps-buffer-using-ghostscript'
;; Use ghostscript to print a buffer.
;;
;; `pr-ps-file-print'
;; Print a PostScript file.
;;
;; `pr-toggle-spool'
;; Toggle spooling buffer.
;;
;; So you can preview through ghostview, use ghostscript to print (if you don't
;; have a PostScript printer) or send directly to printer a PostScript code
;; generated by `ps-print' package.
;;
;; Besides operating one buffer or region each time, you also can postpone
;; previewing or printing by saving the PostScript code generated in a
;; temporary Emacs buffer. This way you can save banner pages between
;; successive printing. You can toggle on/off spooling by invoking
;; `pr-toggle-spool' interactively or through menu bar.
;;
;; If you type, for example:
;;
;; C-u M-x pr-ps-buffer-print RET
;;
;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and
;; a file name, and save the PostScript code generated to the file name instead
;; of sending to printer.
;;
;; This behavior is similar with the commands that deal with PostScript code
;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If
;; spooling is on, only `pr-despool-*' commands prompt for a file name and save
;; the PostScript code spooled in this file.
;;
;; Besides the behavior described above, the `*-directory*' commands also
;; prompt for a directory and a file name regexp. So, it's possible to process
;; all or certain files on a directory at once (see also documentation for
;; `pr-list-directory').
;;
;; `printing' has also a special way to handle some major mode through
;; `*-mode*' commands. So it's possible to customize a major mode printing,
;; it's only needed to declare the customization in `pr-mode-alist' (see
;; section Options) and invoke some of `*-mode*' commands. An example for
;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and
;; you're in the *Summary* buffer, if you forget to switch to the *Article*
;; buffer before printing, you'll get a nicely formatted list of article
;; subjects shows up at the printer. With major mode printing you don't need
;; to switch from gnus *Summary* buffer first.
;;
;; Current global keyboard mapping for GNU Emacs is:
;;
;; (global-set-key [print] 'pr-ps-fast-fire)
;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript)
;; (global-set-key [S-print] 'pr-ps-mode-using-ghostscript)
;; (global-set-key [C-print] 'pr-txt-fast-fire)
;; (global-set-key [C-M-print] 'pr-txt-fast-fire)
;;
;; And for XEmacs is:
;;
;; (global-set-key 'f22 'pr-ps-fast-fire)
;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript)
;; (global-set-key '(shift f22) 'pr-ps-mode-using-ghostscript)
;; (global-set-key '(control f22) 'pr-txt-fast-fire)
;; (global-set-key '(control meta f22) 'pr-txt-fast-fire)
;;
;; As a suggestion of global keyboard mapping for some `printing' commands:
;;
;; (global-set-key "\C-ci" 'pr-interface)
;; (global-set-key "\C-cbp" 'pr-ps-buffer-print)
;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview)
;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
;; (global-set-key "\C-crp" 'pr-ps-region-print)
;; (global-set-key "\C-crx" 'pr-ps-region-preview)
;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
;;
;;
;; Options
;; -------
;;
;; Below it's shown a brief description of `printing' options, please, see the
;; options declaration in the code for a long documentation.
;;
;; `pr-path-style' Specify which path style to use for external
;; commands.
;;
;; `pr-path-alist' Specify an alist for command paths.
;;
;; `pr-txt-name' Specify a printer for printing a text file.
;;
;; `pr-txt-printer-alist' Specify an alist of all text printers.
;;
;; `pr-ps-name' Specify a printer for printing a PostScript
;; file.
;;
;; `pr-ps-printer-alist' Specify an alist for all PostScript printers.
;;
;; `pr-temp-dir' Specify a directory for temporary files during
;; printing.
;;
;; `pr-ps-temp-file' Specify PostScript temporary file name prefix.
;;
;; `pr-file-modes' Specify the file permission bits for newly
;; created files.
;;
;; `pr-gv-command' Specify path and name of the gsview/gv
;; utility.
;;
;; `pr-gs-command' Specify path and name of the ghostscript
;; utility.
;;
;; `pr-gs-switches' Specify ghostscript switches.
;;
;; `pr-gs-device' Specify ghostscript device switch value.
;;
;; `pr-gs-resolution' Specify ghostscript resolution switch value.
;;
;; `pr-print-using-ghostscript' Non-nil means print using ghostscript.
;;
;; `pr-faces-p' Non-nil means print with face attributes.
;;
;; `pr-spool-p' Non-nil means spool printing in a buffer.
;;
;; `pr-file-landscape' Non-nil means print PostScript file in
;; landscape orientation.
;;
;; `pr-file-duplex' Non-nil means print PostScript file in duplex
;; mode.
;;
;; `pr-file-tumble' Non-nil means print PostScript file in tumble
;; mode.
;;
;; `pr-auto-region' Non-nil means region is automagically detected.
;;
;; `pr-auto-mode' Non-nil means major-mode specific printing is
;; prefered over normal printing.
;;
;; `pr-mode-alist' Specify an alist for a major-mode and printing
;; function.
;;
;; `pr-ps-utility' Specify PostScript utility processing.
;;
;; `pr-ps-utility-alist' Specify an alist for PostScript utility
;; processing.
;;
;; `pr-menu-lock' Non-nil means menu is locked while selecting
;; toggle options.
;;
;; `pr-menu-char-height' Specify menu char height in pixels.
;;
;; `pr-menu-char-width' Specify menu char width in pixels.
;;
;; `pr-setting-database' Specify an alist for settings in general.
;;
;; `pr-visible-entry-list' Specify a list of Printing menu visible
;; entries.
;;
;; `pr-delete-temp-file' Non-nil means delete temporary files.
;;
;; `pr-list-directory' Non-nil means list directory when processing a
;; directory.
;;
;; `pr-buffer-name' Specify the name of the buffer interface for
;; printing package.
;;
;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be
;; ignored in interface buffer.
;;
;; `pr-buffer-verbose' Non-nil means to be verbose when editing a
;; field in interface buffer.
;;
;; To set the above options you may:
;;
;; a) insert the code in your ~/.emacs, like:
;;
;; (setq pr-faces-p t)
;;
;; This way always keep your default settings when you enter a new Emacs
;; session.
;;
;; b) or use `set-variable' in your Emacs session, like:
;;
;; M-x set-variable RET pr-faces-p RET t RET
;;
;; This way keep your settings only during the current Emacs session.
;;
;; c) or use customization, for example:
;; click on menu-bar *Help* option,
;; then click on *Customize*,
;; then click on *Browse Customization Groups*,
;; expand *PostScript* group,
;; expand *Printing* group
;; and then customize `printing' options.
;; Through this way, you may choose if the settings are kept or not when
;; you leave out the current Emacs session.
;;
;; d) or see the option value:
;;
;; C-h v pr-faces-p RET
;;
;; and click the *customize* hypertext button.
;; Through this way, you may choose if the settings are kept or not when
;; you leave out the current Emacs session.
;;
;; e) or invoke:
;;
;; M-x pr-customize RET
;;
;; and then customize `printing' options.
;; Through this way, you may choose if the settings are kept or not when
;; you leave out the current Emacs session.
;;
;; f) or use menu bar, for example:
;; click on menu-bar *File* option,
;; then click on *Printing*,
;; then click on *Customize*,
;; then click on *printing*
;; and then customize `printing' options.
;; Through this way, you may choose if the settings are kept or not when
;; you leave out the current Emacs session.
;;
;;
;; Menu Layout
;; -----------
;;
;; The `printing' menu (Tools/Printing or File/Print) has the following layout:
;;
;; +-----------------------------+
;; A 0 | Printing Interface |
;; +-----------------------------+ +-A---------+ +-B------+
;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
;; +-----------------------------+ |Mode >|-- B |Other...|
;; II 4 | Printify >|-----\ |File >|--\ +--------+
;; 5 | Print >|---\ | |Despool... | |
;; 6 | Text Printer: name >|-\ | | +-----------+ |
;; +-----------------------------+ | | | +---------+ +------------+
;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia
;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib
;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C
;; 10 |[ ]Line Number | | | +---------+ +------------+
;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
;; 12 |[ ]Duplex | | \---|Directory| | 2-up... |
;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... |
;; 14 |[ ]Upside-Down | | |Region | | Other... |
;; 15 | Print All Pages >|--\ | |Mode | +------------+
;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id
;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If
;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+
;; +-----------------------------+ | |... |
;; V 19 |[ ]Auto Region | | |(*)name |
;; 20 |[ ]Auto Mode | | |... |
;; 21 |[ ]Menu Lock | | +---------+ +--------------+
;; +-----------------------------+ \------------------|(*)All Pages |
;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
;; 23 | Show Settings >|-------|printing| |( )Odd Pages |
;; 24 | Help | |ps-print| |( )Even Sheets|
;; +-----------------------------+ |lpr | |( )Odd Sheets |
;; +--------+ +--------------+
;;
;; See `pr-visible-entry-list' for hiding some parts of the menu.
;;
;; The menu has the following sections:
;;
;; A. Interface:
;;
;; 0. You can use a buffer interface instead of menus. It looks like the
;; customization buffer. Basically, it has the same options found in the
;; menu and some extra options, all this on a buffer.
;;
;; I. PostScript printing:
;;
;; 1. You can generate a PostScript file (if you type C-u before activating
;; menu) or PostScript temporary file for a directory, a buffer, a region
;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
;; after file generation, ghostview is activated using the file generated
;; as argument. This option is disabled if spooling is on (option 16).
;; Also, if you already have a PostScript file you can preview it.
;; Instead of previewing each buffer, region or major mode at once, you
;; can save temporarily the PostScript code generated in a buffer and
;; preview it later. The option `Despool...' despools the PostScript
;; spooling buffer in a temporary file and uses ghostview to preview it.
;; If you type C-u before choosing this option, the PostScript code
;; generated is saved in a file instead of saving in a temporary file.
;; To spool the PostScript code generated you need to turn on the option
;; 16. The option `Despool...' is enabled if spooling is on (option
;; 16).
;;
;; NOTE 1: It's possible to customize a major mode printing, just declare
;; the customization in `pr-mode-alist' and invoke some of
;; `*-mode*' commands or select Mode option in Printing menu. An
;; example for major mode usage is when you're using gnus (or mh,
;; or rmail, etc.) and you're in the *Summary* buffer, if you
;; forget to switch to the *Article* buffer before printing,
;; you'll get a nicely formatted list of article subjects shows
;; up at the printer. With major mode printing you don't need to
;; switch from gnus *Summary* buffer first.
;;
;; NOTE 2: There are the following options for PostScript file
;; processing:
;; Ia. Print the file *No Preprocessing*, that is, send it
;; directly to PostScript printer.
;; Ib. PostScript utility processing selection.
;; See `pr-ps-utility-alist' and `pr-setting-database' for
;; documentation.
;; Ic. Do n-up processing before printing.
;; Id. Toggle on/off landscape for PostScript file processing.
;; Ie. Toggle on/off duplex for PostScript file processing.
;; If. Toggle on/off tumble for PostScript file processing.
;;
;; NOTE 3: Don't forget to download and install the utilities declared on
;; `pr-ps-utility-alist'.
;;
;; 2. Operate the same way as option 1, but it sends directly the PostScript
;; code (or put in a file, if you've typed C-u) or it uses ghostscript to
;; print the PostScript file generated. It depends on option 18, if it's
;; turned on, it uses ghostscript; otherwise, it sends directly to
;; printer. If spooling is on (option 16), the PostScript code is saved
;; temporarily in a buffer instead of printing it or saving it in a file.
;; Also, if you already have a PostScript file you can print it. Instead
;; of printing each buffer, region or major mode at once, you can save
;; temporarily the PostScript code generated in a buffer and print it
;; later. The option `Despool...' despools the PostScript spooling
;; buffer directly on a printer. If you type C-u before choosing this
;; option, the PostScript code generated is saved in a file instead of
;; sending to printer. To spool the PostScript code generated you need
;; to turn on the option 16. This option is enabled if spooling is on
;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
;;
;; 3. You can select a new PostScript printer to send PostScript code
;; generated. For selection it's used all PostScript printers defined
;; in `pr-ps-printer-alist' variable (see it for documentation).
;; See also `pr-setting-database'.
;;
;; II. Text printing:
;;
;; 4. If you have control characters (character code from \000 to \037) in a
;; buffer and you want to print them in a text printer, select this
;; option. All control characters in your buffer or region will be
;; replaced by a printable representation. The printable representations
;; use ^ (for ASCII control characters) or hex. The characters tab,
;; linefeed, space, return and formfeed are not affected. You don't need
;; to select this option if you use any option of section I, the
;; PostScript engine treats control characters properly.
;;
;; 5. If you want to print a directory, buffer, region or major mode in a
;; text printer, select this option. See also the NOTE 1 on option 1.
;;
;; 6. You can select a new text printer to send text generated. For
;; selection it's used all text printers defined in
;; `pr-txt-printer-alist' variable (see it for documentation).
;; See also `pr-setting-database'.
;;
;; III. PostScript page toggle options:
;;
;; 7. If you want a PostScript landscape printing, turn on this option.
;;
;; 8. If you want to have a header in each page in your PostScript code,
;; turn on this option.
;;
;; 9. If you want to draw a gaudy frame around the header, turn on this
;; option. This option is enabled if print header is on (option 8).
;;
;; 10. If you want that the line number is printed in your PostScript code,
;; turn on this option.
;;
;; 11. If you want background zebra stripes in your PostScript code, turn on
;; this option.
;;
;; 12. If you want a duplex printing and your PostScript printer has this
;; feature, turn on this option.
;;
;; 13. If you turned on duplex printing, you can choose if you want to have
;; a printing suitable for binding on the left or right (tumble off), or
;; to have a printing suitable for binding at top or bottom (tumble on).
;; This option is enabled if duplex is on (option 12).
;;
;; 14. If you want a PostScript upside-down printing, turn on this option.
;;
;; 15. With this option, you can choose if you want to print all pages, odd
;; pages, even pages, odd sheets or even sheets.
;; See also `ps-even-or-odd-pages'.
;;
;; IV. PostScript processing toggle options:
;;
;; 16. If you want to spool the PostScript code generated, turn on this
;; option. To spool the PostScript code generated use option 2. You
;; can despool later by choosing option 1 or 2, sub-option `Despool...'.
;;
;; 17. If you use colors in your buffers and want to see these colors on
;; your PostScript code generated, turn on this option. If you have a
;; black/white PostScript printer, these colors are displayed in gray
;; scale by PostScript printer interpreter.
;;
;; 18. If you don't have a PostScript printer to send PostScript files, turn
;; on this option. When this option is on, the ghostscript is used to
;; print PostScript files. In GNU or Unix system, if ghostscript is set
;; as a PostScript filter, you don't need to turn on this option.
;;
;; V. Printing customization:
;;
;; 19. If you want that region is automagically detected, turn on this
;; option. Note that this will only work if you're using transient mark
;; mode. When this option is on, the `*-buffer*' commands will behave
;; like `*-region*' commands, that is, `*-buffer*' commands will print
;; only the region marked instead of all buffer.
;;
;; 20. Turn this option on if you want that when current major-mode is
;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
;; behave like `*-mode*' commands.
;;
;; 21. If you want that Printing menu stays open while you are setting
;; toggle options, turn on this option. The variables
;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the
;; menu position, so don't forget to adjust these variables if menu
;; position is not ok.
;;
;; VI. Customization:
;;
;; 22. Besides all options in section III, IV and V, you can customize much
;; more PostScript options in `ps-print' option. Or you can customize
;; some `lpr' options for text printing. Or customize `printing'
;; options.
;;
;; 23. Show current settings for `printing', `ps-print' or `lpr'.
;;
;; 24. Quick help for printing menu layout.
;;
;;
;; Option Settings
;; ---------------
;;
;; Below it's shown only the main options that affect all `printing' package.
;; Check all the settings below *BEFORE* running `printing' commands.
;;
;; * Example of setting for GNU or Unix system:
;;
;; (require 'printing)
;; (setq pr-path-alist
;; '((unix "." "~/bin" ghostview mpage PATH)
;; (ghostview "$HOME/bin/gsview-dir")
;; (mpage "$HOME/bin/mpage-dir")
;; ))
;; (setq pr-txt-name 'prt_06a)
;; (setq pr-txt-printer-alist
;; '((prt_06a "lpr" nil "prt_06a")
;; (prt_07c nil nil "prt_07c")
;; ))
;; (setq pr-ps-name 'lps_06b)
;; (setq pr-ps-printer-alist
;; '((lps_06b "lpr" nil "-P" "lps_06b")
;; (lps_07c "lpr" nil nil "lps_07c")
;; (lps_08c nil nil nil "lps_08c")
;; ))
;; (setq pr-temp-dir "/tmp/")
;; (setq pr-gv-command "gv")
;; (setq pr-gs-command "gs")
;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
;; (setq pr-gs-device "uniprint")
;; (setq pr-gs-resolution 300)
;; (setq pr-ps-utility 'mpage)
;; (setq pr-ps-utility-alist
;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
;; (inherits-from: . no-duplex))
;; ))
;; (setq pr-setting-database
;; '((no-duplex
;; nil nil nil
;; (pr-file-duplex . nil)
;; (pr-file-tumble . nil))
;; ))
;; (pr-update-menus t) ; update now printer and utility menus
;;
;; * Example of setting for Windows system:
;;
;; (require 'printing)
;; (setq pr-path-alist
;; '((windows "c:/applications/executables" PATH ghostview mpage)
;; (ghostview "c:/gs/gsview-dir")
;; (mpage "c:/mpage-dir")
;; ))
;; (setq pr-txt-name 'prt_06a)
;; (setq pr-txt-printer-alist
;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
;; (PRN "" nil "PRN")
;; (standard "redpr.exe" nil "")
;; ))
;; (setq pr-ps-name 'lps_06b)
;; (setq pr-ps-printer-alist
;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name")
;; (LPT1 "" nil "" "LPT1:")
;; (PRN "" nil "" "PRN")
;; (standard "redpr.exe" nil "" "")
;; ))
;; (setq pr-temp-dir "C:/WINDOWS/TEMP/")
;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe")
;; (setq pr-gs-command "c:/gs/gswin32.exe")
;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts"))
;; (setq pr-gs-device "mswinpr2")
;; (setq pr-gs-resolution 300)
;; (setq pr-ps-utility 'psnup)
;; (setq pr-ps-utility-alist
;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " "
;; nil (inherits-from: . no-duplex))
;; ))
;; (setq pr-setting-database
;; '((no-duplex
;; nil nil nil
;; (pr-file-duplex . nil)
;; (pr-file-tumble . nil))
;; ))
;; (pr-update-menus t) ; update now printer and utility menus
;;
;; NOTE: Don't forget to download and install the utilities declared on
;; `pr-ps-utility-alist'.
;;
;;
;; Utilities
;; ---------
;;
;; `printing' package has the following utilities:
;;
;; `pr-setup' Return the current `printing' setup.
;;
;; `lpr-setup' Return the current `lpr' setup.
;;
;; `pr-update-menus' Update utility, PostScript and text printer menus.
;;
;; `pr-menu-bind' Install `printing' menu in the menubar.
;;
;;
;; Below are some URL where you can find good utilities.
;;
;; * For `printing' package:
;;
;; printing `http://www.emacswiki.org/cgi-bin/emacs/download/printing.el'
;; ps-print `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'
;;
;; * For GNU or Unix system:
;;
;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
;; enscript `http://people.ssh.fi/mtr/genscript/'
;; psnup `http://www.knackered.org/angus/psutils/'
;; mpage `http://www.mesa.nl/pub/mpage/'
;;
;; * For Windows system:
;;
;; gswin32, gsview32
;; `http://www.gnu.org/software/ghostscript/ghostscript.html'
;; gsprint `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'.
;; enscript `http://people.ssh.fi/mtr/genscript/'
;; psnup `http://gnuwin32.sourceforge.net/packages/psutils.htm'
;; redmon `http://www.cs.wisc.edu/~ghost/redmon/'
;;
;;
;; Acknowledgments
;; ---------------
;;
;; Thanks to Stefan Monnier <monnier@iro.umontreal.ca> for GNU Emacs and XEmacs
;; printing menu (in `pr-menu-spec') merging suggestion.
;;
;; Thanks to Lennart Borgman <lennart.borgman.073@student.lu.se> for gsprint
;; suggestion (see tip 5 in section Tips).
;;
;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions:
;; - directory processing.
;; - `pr-path-alist' variable.
;; - doc fix.
;; - a lot of tests on Windows.
;;
;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests.
;;
;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging
;; and for suggestions:
;; - even/odd pages printing.
;; - ghostscript parameters for `pr-ps-printer-alist'.
;; - default printer name.
;; - completion functions.
;; - automagic region detection.
;; - menu entry hiding.
;; - fast fire PostScript printing command.
;; - `pr-path-style' variable.
;;
;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions:
;; - PostScript Print and PostScript Print Preview merge.
;; - Tools/Printing menu.
;; - replace *-using-preview by *-using-ghostscript.
;; - printer selection.
;; - extra parameters for `pr-ps-printer-alist'.
;;
;; Thanks to:
;; Frederic Corne <frederic.corne@erli.fr> print-nt.el
;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el
;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el
;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el
;; And to all people who contributed with them.
;;
;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
(require 'lpr)
(require 'ps-print)
(and (string< ps-print-version "6.6.4")
(error "`printing' requires `ps-print' package version 6.6.4 or later"))
(defconst pr-cygwin-system
(and ps-windows-system (getenv "OSTYPE")
(string-match "cygwin" (getenv "OSTYPE"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; To avoid compilation gripes
(or (fboundp 'subst-char-in-string) ; hacked from subr.el
(defun subst-char-in-string (fromchar tochar string &optional inplace)
"Replace FROMCHAR with TOCHAR in STRING each time it occurs.
Unless optional argument INPLACE is non-nil, return a new string."
(let ((i (length string))
(newstr (if inplace string (copy-sequence string))))
(while (> (setq i (1- i)) 0)
(if (eq (aref newstr i) fromchar)
(aset newstr i tochar)))
newstr)))
(or (fboundp 'make-temp-file) ; hacked from subr.el
(defun make-temp-file (prefix &optional dir-flag suffix)
"Create a temporary file.
The returned file name (created by appending some random characters at the end
of PREFIX, and expanding against `temporary-file-directory' if necessary),
is guaranteed to point to a newly created empty file.
You can then use `write-region' to write new data into the file.
If DIR-FLAG is non-nil, create a new empty directory instead of a file.
If SUFFIX is non-nil, add that at the end of the file name."
(let ((umask (default-file-modes))
file)
(unwind-protect
(progn
;; Create temp files with strict access rights. It's easy to
;; loosen them later, whereas it's impossible to close the
;; time-window of loose permissions otherwise.
(set-default-file-modes ?\700)
(while (condition-case ()
(progn
(setq file
(make-temp-name
(expand-file-name prefix temporary-file-directory)))
(if suffix
(setq file (concat file suffix)))
(if dir-flag
(make-directory file)
(write-region "" nil file nil 'silent nil 'excl))
nil)
(file-already-exists t))
;; the file was somehow created by someone else between
;; `make-temp-name' and `write-region', let's try again.
nil)
file)
;; Reset the umask.
(set-default-file-modes umask)))))
(eval-when-compile
;; User Interface --- declared here to avoid compiler warnings
(defvar pr-path-style)
(defvar pr-auto-region)
(defvar pr-menu-char-height)
(defvar pr-menu-char-width)
(defvar pr-menu-lock)
(defvar pr-ps-printer-alist)
(defvar pr-txt-printer-alist)
(defvar pr-ps-utility-alist)
;; Internal fun alias to avoid compilation gripes
(defalias 'pr-menu-lookup 'ignore)
(defalias 'pr-menu-lock 'ignore)
(defalias 'pr-menu-alist 'ignore)
(defalias 'pr-even-or-odd-pages 'ignore)
(defalias 'pr-menu-get-item 'ignore)
(defalias 'pr-menu-set-item-name 'ignore)
(defalias 'pr-menu-set-utility-title 'ignore)
(defalias 'pr-menu-set-ps-title 'ignore)
(defalias 'pr-menu-set-txt-title 'ignore)
(defalias 'pr-region-active-p 'ignore)
(defalias 'pr-do-update-menus 'ignore)
(defalias 'pr-update-mode-line 'ignore)
(defalias 'pr-read-string 'ignore)
(defalias 'pr-set-keymap-parents 'ignore)
(defalias 'pr-keep-region-active 'ignore))
;; Internal Vars --- defined here to avoid compiler warnings
(defvar pr-menu-print-item "print"
"Non-nil means that menu binding was not done.
Used by `pr-menu-bind' and `pr-update-menus'.")
(defvar pr-ps-printer-menu-modified t
"Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.")
(defvar pr-txt-printer-menu-modified t
"Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.")
(defvar pr-ps-utility-menu-modified t
"Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.")
(defconst pr-even-or-odd-alist
'((nil . "Print All Pages")
(even-page . "Print Even Pages")
(odd-page . "Print Odd Pages")
(even-sheet . "Print Even Sheets")
(odd-sheet . "Print Odd Sheets")))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; XEmacs Definitions
(cond
((featurep 'xemacs) ; XEmacs
;; XEmacs
(defalias 'pr-set-keymap-parents 'set-keymap-parents)
(defalias 'pr-set-keymap-name 'set-keymap-name)
;; XEmacs
(defun pr-read-string (prompt initial history default)
(let ((str (read-string prompt initial)))
(if (and str (not (string= str "")))
str
default)))
;; XEmacs
(defvar zmacs-region-stays nil)
;; XEmacs
(defun pr-keep-region-active ()
(setq zmacs-region-stays t))
;; XEmacs
(defun pr-region-active-p ()
(and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p)))
;; XEmacs
(defun pr-menu-char-height ()
(font-height (face-font 'default)))
;; XEmacs
(defun pr-menu-char-width ()
(font-width (face-font 'default)))
;; XEmacs
(defmacro pr-xemacs-global-menubar (&rest body)
`(save-excursion
(let ((temp (get-buffer-create (make-temp-name " *Temp"))))
;; be sure to access global menubar
(set-buffer temp)
,@body
(kill-buffer temp))))
;; XEmacs
(defun pr-global-menubar (pr-menu-spec)
;; Menu binding
(pr-xemacs-global-menubar
(add-submenu nil (cons "Printing" pr-menu-spec) "Apps"))
(setq pr-menu-print-item nil))
;; XEmacs
(defvar current-mouse-event nil)
(defun pr-menu-position (entry index horizontal)
(make-event
'button-release
(list 'button 1
'x (- (event-x-pixel current-mouse-event) ; X
(* horizontal pr-menu-char-width))
'y (- (event-y-pixel current-mouse-event) ; Y
(* (pr-menu-index entry index) pr-menu-char-height)))))
(defvar pr-menu-position nil)
(defvar pr-menu-state nil)
;; XEmacs
(defvar current-menubar nil) ; to avoid compilation gripes
(defun pr-menu-lookup (path)
(car (find-menu-item current-menubar (cons "Printing" path))))
;; XEmacs
(defun pr-menu-lock (entry index horizontal state path)
(when pr-menu-lock
(or (and pr-menu-position (eq state pr-menu-state))
(setq pr-menu-position (pr-menu-position entry index horizontal)
pr-menu-state state))
(let* ((menu (pr-menu-lookup path))
(result (get-popup-menu-response menu pr-menu-position)))
(and (misc-user-event-p result)
(funcall (event-function result)
(event-object result))))
(setq pr-menu-position nil)))
;; XEmacs
(defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
;; XEmacs
(defvar pr-ps-name-old "PostScript Printers")
(defvar pr-txt-name-old "Text Printers")
(defvar pr-ps-utility-old "PostScript Utility")
(defvar pr-even-or-odd-old "Print All Pages")
;; XEmacs
(defun pr-do-update-menus (&optional force)
(pr-menu-alist pr-ps-printer-alist
'pr-ps-name
'pr-menu-set-ps-title
'("Printing")
'pr-ps-printer-menu-modified
force
pr-ps-name-old
'postscript 2)
(pr-menu-alist pr-txt-printer-alist
'pr-txt-name
'pr-menu-set-txt-title
'("Printing")
'pr-txt-printer-menu-modified
force
pr-txt-name-old
'text 2)
(let ((save-var pr-ps-utility-menu-modified))
(pr-menu-alist pr-ps-utility-alist
'pr-ps-utility
'pr-menu-set-utility-title
'("Printing" "PostScript Print" "File")
'save-var
force
pr-ps-utility-old
nil 1))
(pr-menu-alist pr-ps-utility-alist
'pr-ps-utility
'pr-menu-set-utility-title
'("Printing" "PostScript Preview" "File")
'pr-ps-utility-menu-modified
force
pr-ps-utility-old
nil 1)
(pr-even-or-odd-pages ps-even-or-odd-pages force))
;; XEmacs
(defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
entry index)
(when (and alist (or force (symbol-value modified-sym)))
(pr-xemacs-global-menubar
(add-submenu menu-path
(pr-menu-create name alist var-sym
fun entry index)))
(funcall fun (symbol-value var-sym))
(set modified-sym nil)))
;; XEmacs
(defun pr-relabel-menu-item (newname var-sym)
(pr-xemacs-global-menubar
(relabel-menu-item
(list "Printing" (symbol-value var-sym))
newname)
(set var-sym newname)))
;; XEmacs
(defun pr-menu-set-ps-title (value &optional item entry index)
(pr-relabel-menu-item (format "PostScript Printer: %s" value)
'pr-ps-name-old)
(pr-ps-set-printer value)
(and index
(pr-menu-lock entry index 12 'toggle nil)))
;; XEmacs
(defun pr-menu-set-txt-title (value &optional item entry index)
(pr-relabel-menu-item (format "Text Printer: %s" value)
'pr-txt-name-old)
(pr-txt-set-printer value)
(and index
(pr-menu-lock entry index 12 'toggle nil)))
;; XEmacs
(defun pr-menu-set-utility-title (value &optional item entry index)
(pr-xemacs-global-menubar
(let ((newname (format "%s" value)))
(relabel-menu-item
(list "Printing" "PostScript Print" "File" pr-ps-utility-old)
newname)
(relabel-menu-item
(list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
newname)
(setq pr-ps-utility-old newname)))
(pr-ps-set-utility value)
(and index
(pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
;; XEmacs
(defun pr-even-or-odd-pages (value &optional no-lock)
(pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
'pr-even-or-odd-old)
(setq ps-even-or-odd-pages value)
(or no-lock
(pr-menu-lock 'postscript-options 8 12 'toggle nil)))
)
(t ; GNU Emacs
;; Do nothing
)) ; end cond featurep
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; GNU Emacs Definitions
(cond
((featurep 'xemacs) ; XEmacs
;; Do nothing
)
(t ; GNU Emacs
;; GNU Emacs
(defalias 'pr-set-keymap-parents 'set-keymap-parent)
(defalias 'pr-set-keymap-name 'ignore)
(defalias 'pr-read-string 'read-string)
;; GNU Emacs
(defvar deactivate-mark)
;; GNU Emacs
(defun pr-keep-region-active ()
(setq deactivate-mark nil))
;; GNU Emacs
(defun pr-region-active-p ()
(and pr-auto-region transient-mark-mode mark-active))
;; GNU Emacs
(defun pr-menu-char-height ()
(frame-char-height))
;; GNU Emacs
(defun pr-menu-char-width ()
(frame-char-width))
(defvar pr-menu-bar nil
"Specify Printing menu-bar entry.")
;; GNU Emacs
;; Menu binding
;; Replace existing "print" item by "Printing" item.
;; If you're changing this file, you'll load it a second,
;; third... time, but "print" item exists only in the first load.
(eval-when-compile
(require 'easymenu)) ; to avoid compilation gripes
(eval-and-compile
(cond
;; GNU Emacs 20
((< emacs-major-version 21)
(defun pr-global-menubar (pr-menu-spec)
(require 'easymenu)
(easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item)
(when pr-menu-print-item
(easy-menu-remove-item nil '("tools") pr-menu-print-item)
(setq pr-menu-print-item nil
pr-menu-bar (vector 'menu-bar 'tools
(pr-get-symbol "Printing")))))
)
;; GNU Emacs 21 & 22
(t
(defun pr-global-menubar (pr-menu-spec)
(require 'easymenu)
(let ((menu-file (if (= emacs-major-version 21)
'("menu-bar" "files") ; GNU Emacs 21
'("menu-bar" "file")))) ; GNU Emacs 22 or higher
(cond
(pr-menu-print-item
(easy-menu-add-item global-map menu-file
(easy-menu-create-menu "Print" pr-menu-spec)
"print-buffer")
(dolist (item '("print-buffer" "print-region"
"ps-print-buffer-faces" "ps-print-region-faces"
"ps-print-buffer" "ps-print-region"))
(easy-menu-remove-item global-map menu-file item))
(setq pr-menu-print-item nil
pr-menu-bar (vector 'menu-bar
(pr-get-symbol (nth 1 menu-file))
(pr-get-symbol "Print"))))
(t
(easy-menu-add-item global-map menu-file
(easy-menu-create-menu "Print" pr-menu-spec)))
)))
)))
(eval-and-compile
(cond
(ps-windows-system
;; GNU Emacs for Windows 9x/NT
(defun pr-menu-position (entry index horizontal)
(let ((pos (cdr (mouse-pixel-position))))
(list
(list (or (car pos) 0) ; X
(- (or (cdr pos) 0) ; Y
(* (pr-menu-index entry index) pr-menu-char-height)))
(selected-frame)))) ; frame
)
(t
;; GNU Emacs
(defun pr-menu-position (entry index horizontal)
(let ((pos (cdr (mouse-pixel-position))))
(list
(list (- (or (car pos) 0) ; X
(* horizontal pr-menu-char-width))
(- (or (cdr pos) 0) ; Y
(* (pr-menu-index entry index) pr-menu-char-height)))
(selected-frame)))) ; frame
)))
(defvar pr-menu-position nil)
(defvar pr-menu-state nil)
;; GNU Emacs
(defun pr-menu-lookup (path)
(lookup-key global-map
(if path
(vconcat pr-menu-bar
(mapcar 'pr-get-symbol
(if (listp path)
path
(list path))))
pr-menu-bar)))
;; GNU Emacs
(defun pr-menu-lock (entry index horizontal state path)
(when pr-menu-lock
(or (and pr-menu-position (eq state pr-menu-state))
(setq pr-menu-position (pr-menu-position entry index horizontal)
pr-menu-state state))
(let* ((menu (pr-menu-lookup path))
(result (x-popup-menu pr-menu-position menu)))
(and result
(let ((command (lookup-key menu (vconcat result))))
(if (fboundp command)
(funcall command)
(eval command)))))
(setq pr-menu-position nil)))
;; GNU Emacs
(defalias 'pr-update-mode-line 'force-mode-line-update)
;; GNU Emacs
(defun pr-do-update-menus (&optional force)
(pr-menu-alist pr-ps-printer-alist
'pr-ps-name
'pr-menu-set-ps-title
"PostScript Printers"
'pr-ps-printer-menu-modified
force
"PostScript Printers"
'postscript 2)
(pr-menu-alist pr-txt-printer-alist
'pr-txt-name
'pr-menu-set-txt-title
"Text Printers"
'pr-txt-printer-menu-modified
force
"Text Printers"
'text 2)
(let ((save-var pr-ps-utility-menu-modified))
(pr-menu-alist pr-ps-utility-alist
'pr-ps-utility
'pr-menu-set-utility-title
'("PostScript Print" "File" "PostScript Utility")
'save-var
force
"PostScript Utility"
nil 1))
(pr-menu-alist pr-ps-utility-alist
'pr-ps-utility
'pr-menu-set-utility-title
'("PostScript Preview" "File" "PostScript Utility")
'pr-ps-utility-menu-modified
force
"PostScript Utility"
nil 1)
(pr-even-or-odd-pages ps-even-or-odd-pages force))
;; GNU Emacs
(defun pr-menu-get-item (name-list)
;; NAME-LIST is a string or a list of strings.
(or (listp name-list)
(setq name-list (list name-list)))
(and name-list
(let* ((reversed (reverse name-list))
(name (pr-get-symbol (car reversed)))
(path (nreverse (cdr reversed)))
(menu (lookup-key
global-map
(vconcat pr-menu-bar
(mapcar 'pr-get-symbol path)))))
(assq name (nthcdr 2 menu)))))
;; GNU Emacs
(defvar pr-temp-menu nil)
;; GNU Emacs
(defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
entry index)
(when (and alist (or force (symbol-value modified-sym)))
(easy-menu-define pr-temp-menu nil ""
(pr-menu-create name alist var-sym fun entry index))
(let ((item (pr-menu-get-item menu-path)))
(and item
(let* ((binding (nthcdr 3 item))
(key-binding (cdr binding)))
(setcar binding pr-temp-menu)
(and key-binding (listp (car key-binding))
(setcdr binding (cdr key-binding))) ; skip KEY-BINDING
(funcall fun (symbol-value var-sym) item))))
(set modified-sym nil)))
;; GNU Emacs
(defun pr-menu-set-item-name (item name)
(and item
(setcar (nthcdr 2 item) name))) ; ITEM-NAME
;; GNU Emacs
(defun pr-menu-set-ps-title (value &optional item entry index)
(pr-menu-set-item-name (or item
(pr-menu-get-item "PostScript Printers"))
(format "PostScript Printer: %s" value))
(pr-ps-set-printer value)
(and index
(pr-menu-lock entry index 12 'toggle nil)))
;; GNU Emacs
(defun pr-menu-set-txt-title (value &optional item entry index)
(pr-menu-set-item-name (or item
(pr-menu-get-item "Text Printers"))
(format "Text Printer: %s" value))
(pr-txt-set-printer value)
(and index
(pr-menu-lock entry index 12 'toggle nil)))
;; GNU Emacs
(defun pr-menu-set-utility-title (value &optional item entry index)
(let ((name (symbol-name value)))
(if item
(pr-menu-set-item-name item name)
(pr-menu-set-item-name
(pr-menu-get-item
'("PostScript Print" "File" "PostScript Utility"))
name)
(pr-menu-set-item-name
(pr-menu-get-item
'("PostScript Preview" "File" "PostScript Utility"))
name)))
(pr-ps-set-utility value)
(and index
(pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
;; GNU Emacs
(defun pr-even-or-odd-pages (value &optional no-lock)
(pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
(cdr (assq value pr-even-or-odd-alist)))
(setq ps-even-or-odd-pages value)
(or no-lock
(pr-menu-lock 'postscript-options 8 12 'toggle nil)))
)) ; end cond featurep
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal Functions (I)
(defun pr-dosify-file-name (path)
"Replace unix-style directory separator character with dos/windows one."
(interactive "sPath: ")
(if (eq pr-path-style 'windows)
(subst-char-in-string ?/ ?\\ path)
path))
(defun pr-unixify-file-name (path)
"Replace dos/windows-style directory separator character with unix one."
(interactive "sPath: ")
(if (eq pr-path-style 'windows)
(subst-char-in-string ?\\ ?/ path)
path))
(defun pr-standard-file-name (path)
"Ensure the proper directory separator depending on the OS.
That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory
separator; otherwise, ensure unix-style directory separator."
(if (or pr-cygwin-system ps-windows-system)
(subst-char-in-string ?/ ?\\ path)
(subst-char-in-string ?\\ ?/ path)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Customization Functions
(defun pr-alist-custom-set (symbol value)
"Set the value of custom variables for printer & utility selection."
(set symbol value)
(and (featurep 'printing) ; update only after printing is loaded
(pr-update-menus t)))
(defun pr-ps-utility-custom-set (symbol value)
"Update utility menu entry."
(set symbol value)
(and (featurep 'printing) ; update only after printing is loaded
(pr-menu-set-utility-title value)))
(defun pr-ps-name-custom-set (symbol value)
"Update `PostScript Printer:' menu entry."
(set symbol value)
(and (featurep 'printing) ; update only after printing is loaded
(pr-menu-set-ps-title value)))
(defun pr-txt-name-custom-set (symbol value)
"Update `Text Printer:' menu entry."
(set symbol value)
(and (featurep 'printing) ; update only after printing is loaded
(pr-menu-set-txt-title value)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; User Interface
(defgroup printing nil
"Printing Utilities group."
:tag "Printing Utilities"
:link '(emacs-library-link :tag "Source Lisp File" "printing.el")
:prefix "pr-"
:version "22.1"
:group 'wp
:group 'postscript)
(defcustom pr-path-style
(if (and (not pr-cygwin-system)
ps-windows-system)
'windows
'unix)
"Specify which path style to use for external commands.
Valid values are:
windows Windows 9x/NT style (\\)
unix Unix style (/)"
:type '(choice :tag "Path style"
(const :tag "Windows 9x/NT Style (\\)" :value windows)
(const :tag "Unix Style (/)" :value unix))
:group 'printing)
(defcustom pr-path-alist
'((unix PATH)
(cygwin PATH)
(windows PATH))
"Specify an alist for command paths.
It's used to find commands used for printing package, like gv, gs, gsview.exe,
mpage, print.exe, etc. See also `pr-command' function.
Each element has the form:
(ENTRY DIRECTORY...)
Where:
ENTRY It's a symbol, used to identify this entry.
There must exist at least one of the following entries:
unix this entry is used when Emacs is running on GNU or
Unix system.
cygwin this entry is used when Emacs is running on Windows
95/98/NT/2000 with Cygwin.
windows this entry is used when Emacs is running on Windows
95/98/NT/2000.
DIRECTORY It should be a string or a symbol. If it's a symbol, it should
exist an equal entry in `pr-path-alist'. If it's a string,
it's considered a directory specification.
The directory specification may contain:
$var environment variable expansion
~/ tilde expansion
./ current directory
../ previous directory
For example, let's say the home directory is /home/my and the
current directory is /home/my/dir, so:
THE ENTRY IS EXPANDED TO
~/entry /home/my/entry
./entry /home/my/dir/entry
../entry /home/my/entry
$HOME/entry /home/my/entry
$HOME/~/other/../my/entry /home/my/entry
SPECIAL SYMBOL: If the symbol `PATH' is used in the directory
list and there isn't a `PATH' entry in `pr-path-alist' or the
`PATH' entry has a null directory list, the PATH environment
variable is used.
Examples:
* On GNU or Unix system:
'((unix \".\" \"~/bin\" ghostview mpage PATH)
(ghostview \"$HOME/bin/gsview-dir\")
(mpage \"$HOME/bin/mpage-dir\")
)
* On Windows system:
'((windows \"c:/applications/executables\" PATH ghostview mpage)
(ghostview \"c:/gs/gsview-dir\")
(mpage \"c:/mpage-dir\")
)"
:type '(repeat
(cons :tag ""
(symbol :tag "Identifier ")
(repeat :tag "Directory List"
(choice :menu-tag "Directory"
:tag "Directory"
(string :value "")
(symbol :value symbol)))))
:group 'printing)
(defcustom pr-txt-name 'default
"Specify a printer for printing a text file.
The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
documentation).
This variable should be modified by customization engine. If this variable is
modified by other means (for example, a lisp function), use `pr-update-menus'
function (see it for documentation) to update text printer menu."
:type 'symbol
:set 'pr-txt-name-custom-set
:group 'printing)
(defcustom pr-txt-printer-alist
(list (list 'default lpr-command nil
(cond ((boundp 'printer-name) printer-name)
(ps-windows-system "PRN")
(t nil)
)))
;; Examples:
;; * On GNU or Unix system:
;; '((prt_06a "lpr" nil "prt_06a")
;; (prt_07c nil nil "prt_07c")
;; )
;; * On Windows system:
;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a")
;; (prt_07c nil nil "/D:\\\\printers\\prt_07c")
;; (PRN "" nil "PRN")
;; (standard "redpr.exe" nil "")
;; )
"Specify an alist of all text printers (text printer database).
The alist element has the form:
(SYMBOL COMMAND SWITCHES NAME)
Where:
SYMBOL It's a symbol to identify a text printer. It's for
`pr-txt-name' variable setting and for menu selection.
Examples:
'prt_06a
'my_printer
COMMAND Name of the program for printing a text file. On MS-DOS and
MS-Windows systems, if the value is an empty string, then Emacs
will write directly to the printer port given by NAME (see text
below), that is, the NAME should be something like \"PRN\" or
\"LPT1:\".
If NAME is something like \"\\\\\\\\host\\\\share-name\" then
COMMAND shouldn't be an empty string.
The programs `print' and `nprint' (the standard print programs
on Windows NT and Novell Netware respectively) are handled
specially, using NAME as the destination for output; any other
program is treated like `lpr' except that an explicit filename
is given as the last argument.
If COMMAND is nil, it's used the default printing program:
`print' for Windows system, `lp' for lp system and `lpr' for
all other systems. See also `pr-path-alist'.
Examples:
\"print\"
\"lpr\"
\"lp\"
SWITCHES List of sexp's to pass as extra options for text printer
program. It is recommended to set NAME (see text below)
instead of including an explicit switch on this list.
Example:
. for lpr
'(\"-#3\" \"-l\")
nil
NAME A string that specifies a text printer name.
On Unix-like systems, a string value should be a name
understood by lpr's -P option (or lp's -d option).
On MS-DOS and MS-Windows systems, it is the name of a printer
device or port. Typical non-default settings would be \"LPT1:\"
to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
\"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
(or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
printer. You can also set it to a name of a file, in which
case the output gets appended to that file. If you want to
discard the printed output, set this to \"NUL\".
Examples:
. for print.exe
\"/D:\\\\\\\\host\\\\share-name\"
\"LPT1:\"
\"PRN\"
. for lpr or lp
\"share-name\"
This variable should be modified by customization engine. If this variable is
modified by other means (for example, a lisp function), use `pr-update-menus'
function (see it for documentation) to update text printer menu.
Examples:
* On GNU or Unix system:
'((prt_06a \"lpr\" nil \"prt_06a\")
(prt_07c nil nil \"prt_07c\")
)
* On Windows system:
'((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\")
(prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\")
(PRN \"\" nil \"PRN\")
(standard \"redpr.exe\" nil \"\")
)
Useful links:
* Information about the print command (print.exe)
`http://www.computerhope.com/printhlp.htm'
* RedMon - Redirection Port Monitor (redpr.exe)
`http://www.cs.wisc.edu/~ghost/redmon/index.htm'
* Redirection Port Monitor (redpr.exe on-line help)
`http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm'
* UNIX man pages: lpr (or type `man lpr')
`http://bama.ua.edu/cgi-bin/man-cgi?lpr'
`http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr'
* UNIX man pages: lp (or type `man lp')
`http://bama.ua.edu/cgi-bin/man-cgi?lp'
`http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
"
:type '(repeat
(list :tag "Text Printer"
(symbol :tag "Printer Symbol Name")
(string :tag "Printer Command")
(repeat :tag "Printer Switches"
(sexp :tag "Switch" :value ""))
(choice :menu-tag "Printer Name"
:tag "Printer Name"
(const :tag "None" nil)
string)))
:set 'pr-alist-custom-set
:group 'printing)
(defcustom pr-ps-name 'default
"Specify a printer for printing a PostScript file.
This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
documentation).
This variable should be modified by customization engine. If this variable is
modified by other means (for example, a lisp function), use `pr-update-menus'
function (see it for documentation) to update PostScript printer menu."
:type 'symbol
:set 'pr-ps-name-custom-set
:group 'printing)
(defcustom pr-ps-printer-alist
(list (list 'default lpr-command nil
(cond (ps-windows-system nil)
(ps-lp-system "-d")
(t "-P"))
(or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name)))
;; Examples:
;; * On GNU or Unix system:
;; '((lps_06b "lpr" nil "-P" "lps_06b")
;; (lps_07c "lpr" nil nil "lps_07c")
;; (lps_08c nil nil nil "lps_08c")
;; )
;; * On Windows system:
;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a")
;; (lps_06b "print" nil nil "\\\\printers\\lps_06b")
;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c")
;; (lps_08c nil nil nil "\\\\printers\\lps_08c")
;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name")
;; (LPT1 "" nil "" "LPT1:")
;; (PRN "" nil "" "PRN")
;; (standard "redpr.exe" nil "" "")
;; )
"Specify an alist for all PostScript printers (PostScript printer database).
The alist element has the form:
(SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...)
Where:
SYMBOL It's a symbol to identify a PostScript printer. It's for
`pr-ps-name' variable setting and for menu selection.
Examples:
'prt_06a
'my_printer
COMMAND Name of the program for printing a PostScript file. On MS-DOS
and MS-Windows systems, if the value is an empty string then
Emacs will write directly to the printer port given by NAME
(see text below), that is, the NAME should be something like
\"PRN\" or \"LPT1:\".
If NAME is something like \"\\\\\\\\host\\\\share-name\" then
COMMAND shouldn't be an empty string.
The programs `print' and `nprint' (the standard print programs
on Windows NT and Novell Netware respectively) are handled
specially, using NAME as the destination for output; any other
program is treated like `lpr' except that an explicit filename
is given as the last argument.
If COMMAND is nil, it's used the default printing program:
`print' for Windows system, `lp' for lp system and `lpr' for
all other systems. See also `pr-path-alist'.
Examples:
\"print\"
\"lpr\"
\"lp\"
\"cp\"
\"gsprint\"
SWITCHES List of sexp's to pass as extra options for PostScript printer
program. It is recommended to set NAME (see text below)
instead of including an explicit switch on this list.
Example:
. for lpr
'(\"-#3\" \"-l\")
nil
. for gsprint.exe
'(\"-all\" \"-twoup\")
PRINTER-SWITCH A string that specifies PostScript printer name switch. If
it's necessary to have a space between PRINTER-SWITCH and NAME,
it should be inserted at the end of PRINTER-SWITCH string.
If PRINTER-SWITCH is nil, it's used the default printer name
switch: `/D:' for Windows system, `-d' for lp system and `-P'
for all other systems.
Examples:
. for lpr
\"-P \"
. for lp
\"-d \"
. for print.exe
\"/D:\"
. for gsprint.exe
\"-printer \"
NAME A string that specifies a PostScript printer name.
On Unix-like systems, a string value should be a name
understood by lpr's -P option (or lp's -d option).
On MS-DOS and MS-Windows systems, it is the name of a printer
device or port. Typical non-default settings would be \"LPT1:\"
to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or
\"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\"
(or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network
printer. You can also set it to a name of a file, in which
case the output gets appended to that file. If you want to
discard the printed output, set this to \"NUL\".
Examples:
. for cp.exe
\"\\\\\\\\host\\\\share-name\"
. for print.exe or gsprint.exe
\"/D:\\\\\\\\host\\\\share-name\"
\"\\\\\\\\host\\\\share-name\"
\"LPT1:\"
\"PRN\"
. for lpr or lp
\"share-name\"
DEFAULT It's a way to set default values when this entry is selected.
It's a cons like:
(VARIABLE . VALUE)
Which associates VARIABLE with VALUE. When this entry is
selected, it's executed the following command:
(set VARIABLE (eval VALUE))
Note that VALUE can be any valid lisp expression. So, don't
forget to quote symbols and constant lists.
If VARIABLE is the special keyword `inherits-from:', VALUE must
be a symbol name setting defined in `pr-setting-database' from
which the current setting inherits the context. Take care with
circular inheritance.
Examples:
'(ps-landscape-mode . nil)
'(ps-spool-duplex . t)
'(pr-gs-device . (my-gs-device t))
This variable should be modified by customization engine. If this variable is
modified by other means (for example, a lisp function), use `pr-update-menus'
function (see it for documentation) to update PostScript printer menu.
Examples:
* On GNU or Unix system:
'((lps_06b \"lpr\" nil \"-P\" \"lps_06b\")
(lps_07c \"lpr\" nil nil \"lps_07c\")
(lps_08c nil nil nil \"lps_08c\")
)
* On Windows system:
'((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\")
(lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\")
(lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\")
(lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\")
(b/w1 \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"b/w-pr-name\")
(b/w2 \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer \\\\\\\\printers\\\\lps_06a\")
(LPT1 \"\" nil \"\" \"LPT1:\")
(PRN \"\" nil \"\" \"PRN\")
(standard \"redpr.exe\" nil \"\" \"\")
)
gsprint:
You can use gsprint instead of ghostscript to print monochrome PostScript files
in Windows. The gsprint utility documentation says that it is more efficient
than ghostscript to print monochrome PostScript.
To print non-monochrome PostScript file, the efficiency of ghostscript is
similar to gsprint.
Also the gsprint utility comes together with gsview distribution.
As an example of gsprint declaration:
(setq pr-ps-printer-alist
'((A \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"lps_015\")
(B \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer lps_015\")
;; some other printer declaration
))
The example above declares that printer A prints all pages (-all) and two pages
per sheet (-twoup). The printer B declaration does the same as the printer A
declaration, the only difference is the printer name selection.
There are other command line options like:
-mono Render in monochrome as 1bit/pixel (only black and white).
-grey Render in greyscale as 8bits/pixel.
-color Render in color as 24bits/pixel.
The default is `-mono'. So, printer A and B in the example above are using
implicitly the `-mono' option. Note that in `-mono' no gray tone or color is
printed, this includes the zebra stripes, that is, in `-mono' the zebra stripes
are not printed.
Useful links:
* GSPRINT - Ghostscript print to Windows printer
`http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'
* Introduction to Ghostscript
`http://www.cs.wisc.edu/~ghost/doc/intro.htm'
* How to use Ghostscript
`http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
* Information about the print command (print.exe)
`http://www.computerhope.com/printhlp.htm'
* RedMon - Redirection Port Monitor (redpr.exe)
`http://www.cs.wisc.edu/~ghost/redmon/index.htm'
* Redirection Port Monitor (redpr.exe on-line help)
`http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm'
* UNIX man pages: lpr (or type `man lpr')
`http://bama.ua.edu/cgi-bin/man-cgi?lpr'
`http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr'
* UNIX man pages: lp (or type `man lp')
`http://bama.ua.edu/cgi-bin/man-cgi?lp'
`http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
* GNU utilities for Win32 (cp.exe)
`http://unxutils.sourceforge.net/'
"
:type '(repeat
(list
:tag "PostScript Printer"
(symbol :tag "Printer Symbol Name")
(string :tag "Printer Command")
(repeat :tag "Printer Switches"
(sexp :tag "Switch" :value ""))
(choice :menu-tag "Printer Name Switch"
:tag "Printer Name Switch"
(const :tag "None" nil)
string)
(choice :menu-tag "Printer Name"
:tag "Printer Name"
(const :tag "None" nil)
string)
(repeat
:tag "Default Value List"
:inline t
(cons
:tag ""
(choice
:menu-tag "Variable"
:tag "Variable"
(const :tag "Landscape" ps-landscape-mode)
(const :tag "Print Header" ps-print-header)
(const :tag "Print Header Frame" ps-print-header-frame)
(const :tag "Line Number" ps-line-number)
(const :tag "Zebra Stripes" ps-zebra-stripes)
(const :tag "Duplex" ps-spool-duplex)
(const :tag "Tumble" ps-spool-tumble)
(const :tag "Upside-Down" ps-print-upside-down)
(const :tag "PS File Landscape" pr-file-landscape)
(const :tag "PS File Duplex" pr-file-duplex)
(const :tag "PS File Tumble" pr-file-tumble)
(const :tag "Auto Region" pr-auto-region)
(const :tag "Auto Mode" pr-auto-mode)
(const :tag "Ghostscript Device" pr-gs-device)
(const :tag "Ghostscript Resolution" pr-gs-resolution)
(const :tag "inherits-from:" inherits-from:)
(variable :tag "Other"))
(sexp :tag "Value")))
))
:set 'pr-alist-custom-set
:group 'printing)
(defcustom pr-temp-dir
(pr-dosify-file-name
(if (boundp 'temporary-file-directory)
(symbol-value 'temporary-file-directory)
;; hacked from `temporary-file-directory' variable in files.el
(file-name-as-directory
(or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
(cond (ps-windows-system "c:/temp")
(t "/tmp")
)))))
"Specify a directory for temporary files during printing.
See also `pr-ps-temp-file' and `pr-file-modes'."
:type '(directory :tag "Temporary Directory")
:group 'printing)
(defcustom pr-ps-temp-file "prspool-"
"Specify PostScript temporary file name prefix.
See also `pr-temp-dir' and `pr-file-modes'."
:type '(file :tag "PostScript Temporary File Name")
:group 'printing)
;; It uses 0600 as default instead of (default-file-modes).
;; So, by default, only the session owner have permission to deal with files
;; generated by `printing'.
(defcustom pr-file-modes ?\600
"Specify the file permission bits for newly created files.
It should be an integer; only the low 9 bits are used.
See also `pr-temp-dir' and `pr-ps-temp-file'."
:type '(integer :tag "File Permission Bits")
:group 'printing)
(defcustom pr-gv-command
(if ps-windows-system
"gsview32.exe"
"gv")
"Specify path and name of the gsview/gv utility.
See also `pr-path-alist'.
Useful links:
* GNU gv manual
`http://www.gnu.org/software/gv/manual/gv.html'
* GSview Help
`http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm'
* GSview Help - Common Problems
`http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm#Common_Problems'
* GSview Readme (compilation & installation)
`http://www.cs.wisc.edu/~ghost/gsview/Readme.htm'
* GSview (main site)
`http://www.cs.wisc.edu/~ghost/gsview/index.htm'
* Ghostscript, Ghostview and GSview
`http://www.cs.wisc.edu/~ghost/'
* Ghostview
`http://www.cs.wisc.edu/~ghost/gv/index.htm'
* gv 3.5, June 1997
`http://www.cs.wisc.edu/~ghost/gv/gv_doc/gv.html'
* MacGSView (MacOS)
`http://www.cs.wisc.edu/~ghost/macos/index.htm'
"
:type '(string :tag "Ghostview Utility")
:group 'printing)
(defcustom pr-gs-command
(if ps-windows-system
"gswin32.exe"
"gs")
"Specify path and name of the ghostscript utility.
See also `pr-path-alist'.
Useful links:
* Ghostscript, Ghostview and GSview
`http://www.cs.wisc.edu/~ghost/'
* Introduction to Ghostscript
`http://www.cs.wisc.edu/~ghost/doc/intro.htm'
* How to use Ghostscript
`http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
* Printer compatibility
`http://www.cs.wisc.edu/~ghost/doc/printer.htm'
"
:type '(string :tag "Ghostscript Utility")
:group 'printing)
(defcustom pr-gs-switches
(if ps-windows-system
'("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")
'("-q -dNOPAUSE -I/usr/share/ghostscript/5.10"))
"Specify ghostscript switches. See the documentation on GS for more info.
It's a list of strings, where each string is one or more ghostscript switches.
A note on the gs switches:
-q quiet
-dNOPAUSE don't wait for user intervention
-Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs
-c quit it's added at the end to terminate gs
To see ghostscript documentation for more information:
* On GNU or Unix system:
- for full documentation, type: man gs
- for brief documentation, type: gs -h
* On Windows system:
- for full documentation, see in a browser the file
c:/gstools/gs5.50/index.html, that is, the file index.html which is
located in the same directory as gswin32.exe.
- for brief documentation, type: gswin32.exe -h
Useful links:
* Introduction to Ghostscript
`http://www.cs.wisc.edu/~ghost/doc/intro.htm'
* How to use Ghostscript
`http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm'
* Printer compatibility
`http://www.cs.wisc.edu/~ghost/doc/printer.htm'
"
:type '(repeat (string :tag "Ghostscript Switch"))
:group 'printing)
(defcustom pr-gs-device
(if ps-windows-system
"mswinpr2"
"uniprint")
"Specify the ghostscript device switch value (-sDEVICE=).
A note on the gs switches:
-sDEVICE=djet500 the printer - works with HP DeskJet 540
See `pr-gs-switches' for documentation.
See also `pr-ps-printer-alist'."
:type '(string :tag "Ghostscript Device")
:group 'printing)
(defcustom pr-gs-resolution 300
"Specify ghostscript resolution switch value (-r).
A note on the gs switches:
-r300 resolution 300x300
See `pr-gs-switches' for documentation.
See also `pr-ps-printer-alist'."
:type '(integer :tag "Ghostscript Resolution")
:group 'printing)
(defcustom pr-print-using-ghostscript nil
"Non-nil means print using ghostscript.
This is useful if you don't have a PostScript printer, so you could use the
ghostscript to print a PostScript file.
In GNU or Unix system, if ghostscript is set as a PostScript filter, this
variable should be nil."
:type 'boolean
:group 'printing)
(defcustom pr-faces-p nil
"Non-nil means print with face attributes."
:type 'boolean
:group 'printing)
(defcustom pr-spool-p nil
"Non-nil means spool printing in a buffer."
:type 'boolean
:group 'printing)
(defcustom pr-file-landscape nil
"Non-nil means print PostScript file in landscape orientation."
:type 'boolean
:group 'printing)
(defcustom pr-file-duplex nil
"Non-nil means print PostScript file in duplex mode."
:type 'boolean
:group 'printing)
(defcustom pr-file-tumble nil
"Non-nil means print PostScript file in tumble mode.
If tumble is off, produces a printing suitable for binding on the left or
right.
If tumble is on, produces a printing suitable for binding at the top or
bottom."
:type 'boolean
:group 'printing)
(defcustom pr-auto-region t
"Non-nil means region is automagically detected.
Note that this will only work if you're using transient mark mode.
When this variable is non-nil, the `*-buffer*' commands will behave like
`*-region*' commands, that is, `*-buffer*' commands will print only the region
marked instead of all buffer."
:type 'boolean
:group 'printing)
(defcustom pr-auto-mode t
"Non-nil means major-mode specific printing is prefered over normal printing.
That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
and `*-region*' commands will behave like `*-mode*' commands; otherwise,
`*-buffer*' commands will print the current buffer and `*-region*' commands
will print the current region."
:type 'boolean
:group 'printing)
(defcustom pr-mode-alist
'((mh-folder-mode ; mh summary buffer
pr-mh-lpr-1 pr-mh-print-1
2
(ps-article-author ps-article-subject)
("/pagenumberstring load" pr-article-date)
nil
)
(mh-letter-mode ; mh letter buffer
pr-mh-lpr-2 pr-mh-print-2
2
(ps-article-author ps-article-subject)
("/pagenumberstring load" pr-article-date)
nil
)
(rmail-summary-mode ; rmail summary buffer
pr-rmail-lpr pr-rmail-print
3
(ps-article-subject ps-article-author buffer-name)
nil
nil
)
(rmail-mode ; rmail buffer
pr-rmail-lpr pr-rmail-print
3
(ps-article-subject ps-article-author buffer-name)
nil
nil
)
(gnus-summary-mode ; gnus summary buffer
pr-gnus-lpr pr-gnus-print
3
(ps-article-subject ps-article-author gnus-newsgroup-name)
nil
nil
)
(gnus-article-mode ; gnus article buffer
pr-gnus-lpr pr-gnus-print
3
(ps-article-subject ps-article-author gnus-newsgroup-name)
nil
nil
)
(Info-mode ; Info buffer
pr-mode-lpr pr-mode-print
2
(ps-info-node ps-info-file)
nil
nil
)
(vm-mode ; vm mode
pr-vm-lpr pr-vm-print
3
(ps-article-subject ps-article-author buffer-name)
nil
nil
)
)
"Specify an alist for a major-mode and printing functions.
To customize a major mode printing, just declare the customization in
`pr-mode-alist' and invoke some of `*-mode*' commands. An example for major
mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the
*Summary* buffer, if you forget to switch to the *Article* buffer before
printing, you'll get a nicely formatted list of article subjects shows up at
the printer. With major mode printing you don't need to switch from gnus
*Summary* buffer first.
The elements have the following form:
(MAJOR-MODE
LPR-PRINT PS-PRINT
HEADER-LINES
LEFT-HEADER
RIGHT-HEADER
KILL-LOCAL-VARIABLE
DEFAULT...)
Where:
MAJOR-MODE It's the major mode symbol.
LPR-PRINT It's a symbol function for text printing. It's invoked with
one argument:
(HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
Usually LPR-PRINT function prepares the environment or buffer
and then call the function `pr-mode-lpr' which it's used to
process the buffer and send it to text printer.
The `pr-mode-lpr' definition is:
(pr-mode-lpr HEADER-LIST &optional FROM TO)
Where HEADER-LIST is like the argument passed to LPR-PRINT.
FROM and TO are the beginning and end markers, respectively,
for a region. If FROM is nil, it's used (point-min); if TO is
nil, it's used (point-max).
PS-PRINT It's a symbol function for PostScript printing. It's invoked
with 3 arguments: n-up printing, file name and the list:
(HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...).
Usually PS-PRINT function prepares the environment or buffer
and then call the function `pr-mode-print' which it's used to
process the buffer and send it to PostScript printer.
The `pr-mode-print' definition is:
(pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO)
Where N-UP, FILENAME and HEADER-LIST are like the arguments
passed to PS-PRINT. FROM and TO are the beginning and end
markers, respectively, for a region. If TO is nil, it's used
(point-max).
HEADER-LINES It's the number of header lines; if is nil, it uses
`ps-header-lines' value.
LEFT-HEADER It's the left header part, it's a list of string, variable
symbol or function symbol (with no argument); if is nil, it
uses `ps-left-header' value.
RIGHT-HEADER It's the right header part, it's a list of string, variable
symbol or function symbol (with no argument); if is nil, it
uses `ps-right-header' value.
KILL-LOCAL-VARIABLE
Non-nil means to kill all buffer local variable declared in
DEFAULT (see below).
DEFAULT It's a way to set default values when this entry is selected.
It's a cons like:
(VARIABLE-SYM . VALUE)
Which associates VARIABLE-SYM with VALUE. When this entry is
selected, it's executed the following command:
(set (make-local-variable VARIABLE-SYM) (eval VALUE))
Note that VALUE can be any valid lisp expression. So, don't
forget to quote symbols and constant lists.
If VARIABLE is the special keyword `inherits-from:', VALUE must
be a symbol name setting defined in `pr-setting-database' from
which the current setting inherits the context. Take care with
circular inheritance.
Examples:
'(ps-landscape-mode . nil)
'(ps-spool-duplex . t)
'(pr-gs-device . (my-gs-device t))"
:type '(repeat
(list
:tag ""
(symbol :tag "Major Mode")
(function :tag "Text Printing Function")
(function :tag "PS Printing Function")
(choice :menu-tag "Number of Header Lines"
:tag "Number of Header Lines"
(integer :tag "Number")
(const :tag "Default Number" nil))
(repeat :tag "Left Header List"
(choice :menu-tag "Left Header"
:tag "Left Header"
string symbol))
(repeat :tag "Right Header List"
(choice :menu-tag "Right Header"
:tag "Right Header"
string symbol))
(boolean :tag "Kill Local Variable At End")
(repeat
:tag "Default Value List"
:inline t
(cons
:tag ""
(choice
:menu-tag "Variable"
:tag "Variable"
(const :tag "Landscape" ps-landscape-mode)
(const :tag "Print Header" ps-print-header)
(const :tag "Print Header Frame" ps-print-header-frame)
(const :tag "Line Number" ps-line-number)
(const :tag "Zebra Stripes" ps-zebra-stripes)
(const :tag "Duplex" ps-spool-duplex)
(const :tag "Tumble" ps-spool-tumble)
(const :tag "Upside-Down" ps-print-upside-down)
(const :tag "PS File Landscape" pr-file-landscape)
(const :tag "PS File Duplex" pr-file-duplex)
(const :tag "PS File Tumble" pr-file-tumble)
(const :tag "Auto Region" pr-auto-region)
(const :tag "Auto Mode" pr-auto-mode)
(const :tag "Ghostscript Device" pr-gs-device)
(const :tag "Ghostscript Resolution" pr-gs-resolution)
(const :tag "inherits-from:" inherits-from:)
(variable :tag "Other"))
(sexp :tag "Value")))
))
:group 'printing)
(defcustom pr-ps-utility 'mpage
"Specify PostScript utility symbol.
This utility symbol should be defined on `pr-ps-utility-alist' (see it for
documentation).
This variable should be modified by customization engine. If this variable is
modified by other means (for example, a lisp function), use `pr-update-menus'
function (see it for documentation) to update PostScript utility menu.
NOTE: Don't forget to download and install the utilities declared on
`pr-ps-utility-alist'."
:type '(symbol :tag "PS File Utility")
:set 'pr-ps-utility-custom-set
:group 'printing)
(defcustom pr-ps-utility-alist
'((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
(psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
(inherits-from: . no-duplex))
)
;; Examples:
;; * On GNU or Unix system:
;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil)
;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
;; (pr-file-duplex . nil) (pr-file-tumble . nil))
;; )
;; * On Windows system:
;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil
;; (pr-file-duplex . nil) (pr-file-tumble . nil))
;; )
"Specify an alist for PostScript utility processing (PS utility database).
The alist element has the form:
(SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT
SWITCHES DEFAULT...)
Where:
SYMBOL It's a symbol to identify a PostScript utility. It's for
`pr-ps-utility' variable setting and for menu selection.
Examples:
'mpage
'psnup
UTILITY Name of utility for processing a PostScript file.
See also `pr-path-alist'.
Examples:
. for GNU or Unix system:
\"mpage\"
\"psnup -q\"
. for Windows system:
\"c:/psutils/psnup -q\"
MUST-SWITCHES List of sexp's to pass as options to the PostScript utility
program. These options are necessary to process the utility
program and must be placed before any other switches.
Example:
. for psnup:
'(\"-q\")
PAPERSIZE It's a format string to specify paper size switch.
Example:
. for mpage
\"-b%s\"
N-UP It's a format string to specify n-up switch.
Example:
. for psnup
\"-%d\"
LANDSCAPE It's a string to specify landscape switch. If the utility
doesn't have landscape switch, set to nil.
Example:
. for psnup
\"-l\"
DUPLEX It's a string to specify duplex switch. If the utility doesn't
have duplex switch, set to nil.
Example:
. for psnup
nil
TUMBLE It's a string to specify tumble switch. If the utility doesn't
have tumble switch, set to nil.
Example:
. for psnup
nil
OUTPUT It's a string to specify how to generate an output file. Some
utilities accept an output file option, but some others need
output redirection or some other way to specify an output file.
Example:
. for psnup
\" \" ; psnup ... input output
. for mpage
\">\" ; mpage ... input > output
SWITCHES List of sexp's to pass as extra options to the PostScript utility
program.
Example:
. for psnup
'(\"-q\")
nil
DEFAULT It's a way to set default values when this entry is selected.
It's a cons like:
(VARIABLE . VALUE)
Which associates VARIABLE with VALUE. When this entry is
selected, it's executed the following command:
(set VARIABLE (eval VALUE))
Note that VALUE can be any valid lisp expression. So, don't
forget to quote symbols and constant lists.
If VARIABLE is the special keyword `inherits-from:', VALUE must
be a symbol name setting defined in `pr-setting-database' from
which the current setting inherits the context. Take care with
circular inheritance.
Examples:
'(pr-file-landscape . nil)
'(pr-file-duplex . t)
'(pr-gs-device . (my-gs-device t))
This variable should be modified by customization engine. If this variable is
modified by other means (for example, a lisp function), use `pr-update-menus'
function (see it for documentation) to update PostScript utility menu.
NOTE: Don't forget to download and install the utilities declared on
`pr-ps-utility-alist'.
Examples:
* On GNU or Unix system:
'((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil)
(psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil
(pr-file-duplex . nil) (pr-file-tumble . nil))
)
* On Windows system:
'((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \"
nil (pr-file-duplex . nil) (pr-file-tumble . nil))
)
Useful links:
* mpage download (GNU or Unix)
`http://www.mesa.nl/pub/mpage/'
* mpage documentation (GNU or Unix - or type `man mpage')
`http://www.cs.umd.edu/faq/guides/manual_unix/node48.html'
`http://www.rt.com/man/mpage.1.html'
* psnup (Windows, GNU or Unix)
`http://www.knackered.org/angus/psutils/'
`http://gershwin.ens.fr/vdaniel/Doc-Locale/Outils-Gnu-Linux/PsUtils/'
* psnup (PsUtils for Windows)
`http://gnuwin32.sourceforge.net/packages/psutils.htm'
* psnup documentation (GNU or Unix - or type `man psnup')
`http://linux.about.com/library/cmd/blcmdl1_psnup.htm'
`http://amath.colorado.edu/computing/software/man/psnup.html'
* GNU Enscript (Windows, GNU or Unix)
`http://people.ssh.com/mtr/genscript/'
* GNU Enscript documentation (Windows, GNU or Unix)
`http://people.ssh.com/mtr/genscript/enscript.man.html'
(on GNU or Unix, type `man enscript')
"
:type '(repeat
(list :tag "PS File Utility"
(symbol :tag "Utility Symbol")
(string :tag "Utility Name")
(repeat :tag "Must Utility Switches"
(sexp :tag "Switch" :value ""))
(choice :menu-tag "Paper Size"
:tag "Paper Size"
(const :tag "No Paper Size" nil)
(string :tag "Paper Size Format"))
(choice :menu-tag "N-Up"
:tag "N-Up"
(const :tag "No N-Up" nil)
(string :tag "N-Up Format"))
(choice :menu-tag "Landscape"
:tag "Landscape"
(const :tag "No Landscape" nil)
(string :tag "Landscape Switch"))
(choice :menu-tag "Duplex"
:tag "Duplex"
(const :tag "No Duplex" nil)
(string :tag "Duplex Switch"))
(choice :menu-tag "Tumble"
:tag "Tumble"
(const :tag "No Tumble" nil)
(string :tag "Tumble Switch"))
(string :tag "Output Separator")
(repeat :tag "Utility Switches"
(sexp :tag "Switch" :value ""))
(repeat
:tag "Default Value List"
:inline t
(cons
:tag ""
(choice
:menu-tag "Variable"
:tag "Variable"
(const :tag "PS File Landscape" pr-file-landscape)
(const :tag "PS File Duplex" pr-file-duplex)
(const :tag "PS File Tumble" pr-file-tumble)
(const :tag "Ghostscript Device" pr-gs-device)
(const :tag "Ghostscript Resolution" pr-gs-resolution)
(const :tag "inherits-from:" inherits-from:)
(variable :tag "Other"))
(sexp :tag "Value")))
))
:set 'pr-alist-custom-set
:group 'printing)
(defcustom pr-menu-lock t
"Non-nil means menu is locked while selecting toggle options.
See also `pr-menu-char-height' and `pr-menu-char-width'."
:type 'boolean
:group 'printing)
(defcustom pr-menu-char-height (pr-menu-char-height)
"Specify menu char height in pixels.
This variable is used to guess which vertical position should be locked the
menu, so don't forget to adjust it if menu position is not ok.
See also `pr-menu-lock' and `pr-menu-char-width'."
:type 'integer
:group 'printing)
(defcustom pr-menu-char-width (pr-menu-char-width)
"Specify menu char width in pixels.
This variable is used to guess which horizontal position should be locked the
menu, so don't forget to adjust it if menu position is not ok.
See also `pr-menu-lock' and `pr-menu-char-height'."
:type 'integer
:group 'printing)
(defcustom pr-setting-database
'((no-duplex ; setting symbol name
nil nil nil ; inherits local kill-local
(pr-file-duplex . nil) ; settings
(pr-file-tumble . nil))
)
"Specify an alist for settings in general.
The elements have the following form:
(SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...)
Where:
SYMBOL It's a symbol to identify the setting group.
INHERITS Specify the inheritance for SYMBOL group. It's a symbol name
setting from which the current setting inherits the context.
If INHERITS is nil, means that there is no inheritance.
This is a simple inheritance mechanism.
Let's see an example to illustrate the inheritance mechanism:
(setq pr-setting-database
'((no-duplex ; setting symbol name
nil ; inherits
nil nil ; local kill-local
(pr-file-duplex . nil) ; settings
(pr-file-tumble . nil)
)
(no-duplex-and-landscape ; setting symbol name
no-duplex ; inherits
nil nil ; local kill-local
(pr-file-landscape . nil) ; settings
)))
The example above has two setting groups: no-duplex and
no-duplex-and-landscape. When setting no-duplex is activated
through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist'
and `pr-ps-printer-alist'), the variables pr-file-duplex and
pr-file-tumble are both set to nil.
Now when setting no-duplex-and-landscape is activated through
`inherits-from:', the variable pr-file-landscape is set to nil
and also the settings for no-duplex are done, because
no-duplex-and-landscape inherits settings from no-duplex.
Take care with circular inheritance. It's an error if circular
inheritance happens.
LOCAL Non-nil means that all settings for SYMBOL group will be
declared local buffer.
KILL-LOCAL Non-nil means that all settings for SYMBOL group will be
killed at end. It has effect only when LOCAL is non-nil.
SETTING It's a cons like:
(VARIABLE . VALUE)
Which associates VARIABLE with VALUE. When this entry is
selected, it's executed the following command:
* If LOCAL is non-nil:
(set (make-local-variable VARIABLE) (eval VALUE))
* If LOCAL is nil:
(set VARIABLE (eval VALUE))
Note that VALUE can be any valid lisp expression. So, don't
forget to quote symbols and constant lists.
This setting is ignored if VARIABLE is equal to keyword
`inherits-from:'.
Examples:
'(ps-landscape-mode . nil)
'(ps-spool-duplex . t)
'(pr-gs-device . (my-gs-device t))"
:type '(repeat
(list
:tag ""
(symbol :tag "Setting Name")
(choice :menu-tag "Inheritance"
:tag "Inheritance"
(const :tag "No Inheritance" nil)
(symbol :tag "Inherits From"))
(boolean :tag "Local Buffer Setting")
(boolean :tag "Kill Local Variable At End")
(repeat
:tag "Setting List"
:inline t
(cons
:tag ""
(choice
:menu-tag "Variable"
:tag "Variable"
(const :tag "Landscape" ps-landscape-mode)
(const :tag "Print Header" ps-print-header)
(const :tag "Print Header Frame" ps-print-header-frame)
(const :tag "Line Number" ps-line-number)
(const :tag "Zebra Stripes" ps-zebra-stripes)
(const :tag "Duplex" ps-spool-duplex)
(const :tag "Tumble" ps-spool-tumble)
(const :tag "Upside-Down" ps-print-upside-down)
(const :tag "PS File Landscape" pr-file-landscape)
(const :tag "PS File Duplex" pr-file-duplex)
(const :tag "PS File Tumble" pr-file-tumble)
(const :tag "Auto Region" pr-auto-region)
(const :tag "Auto Mode" pr-auto-mode)
(const :tag "Ghostscript Device" pr-gs-device)
(const :tag "Ghostscript Resolution" pr-gs-resolution)
(variable :tag "Other"))
(sexp :tag "Value")))
))
:group 'printing)
(defcustom pr-visible-entry-list
'(postscript text postscript-options postscript-process printing help)
"Specify a list of Printing menu visible entries.
Valid values with the corresponding menu parts are:
+------------------------------+
| Printing Interface |
+------------------------------+
`postscript' | PostScript Preview >|
| PostScript Print >|
| PostScript Printer: name >|
+------------------------------+
`text' | Printify >|
| Print >|
| Text Printer: name >|
+------------------------------+
`postscript-options' |[ ] Landscape |
|[ ] Print Header |
|[ ] Print Header Frame |
|[ ] Line Number |
|[ ] Zebra Stripes |
|[ ] Duplex |
|[ ] Tumble |
|[ ] Upside-Down |
| Print All Pages >|
+------------------------------+
`postscript-process' |[ ] Spool Buffer |
|[ ] Print with faces |
|[ ] Print via Ghostscript |
+------------------------------+
`printing' |[ ] Auto Region |
|[ ] Auto Mode |
|[ ] Menu Lock |
+------------------------------+
`help' | Customize >|
| Show Settings >|
| Help |
+------------------------------+
Any other value is ignored."
:type '(repeat :tag "Menu Visible Part"
(choice :menu-tag "Menu Part"
:tag "Menu Part"
(const postscript)
(const text)
(const postscript-options)
(const postscript-process)
(const printing)
(const help)))
:group 'printing)
(defcustom pr-delete-temp-file t
"Non-nil means delete temporary files.
Set `pr-delete-temp-file' to nil, if the following message (or a similar)
happens when printing:
Error: could not open \"c:\\temp\\prspool.ps\" for reading."
:type 'boolean
:group 'printing)
(defcustom pr-list-directory nil
"Non-nil means list directory when processing a directory.
That is, any subdirectories (and the superdirectory) of the directory (given as
argument of functions below) are also printed (as dired-mode listings).
It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
`pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
and `pr-txt-directory'."
:type 'boolean
:group 'printing)
(defcustom pr-buffer-name "*Printing Interface*"
"Specify the name of the buffer interface for printing package.
It's used by `pr-interface'."
:type 'string
:group 'printing)
(defcustom pr-buffer-name-ignore
(list (regexp-quote pr-buffer-name) ; ignore printing interface buffer
"^ .*$") ; ignore invisible buffers
"Specify a regexp list for buffer names to be ignored in interface buffer.
NOTE: Case is important for matching, that is, `case-fold-search' is always
nil.
It's used by `pr-interface'."
:type '(repeat (regexp :tag "Buffer Name Regexp"))
:group 'printing)
(defcustom pr-buffer-verbose t
"Non-nil means to be verbose when editing a field in interface buffer.
It's used by `pr-interface'."
:type 'boolean
:group 'printing)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal Variables
(defvar pr-txt-command nil
"Name of program for printing a text file.
See `pr-txt-printer-alist'.")
(defvar pr-txt-switches nil
"List of sexp's to pass as extra options to the text printer program.
See `pr-txt-printer-alist'.")
(defvar pr-txt-printer nil
"Specify text printer name.
See `pr-txt-printer-alist'.")
(defvar pr-ps-command nil
"Name of program for printing a PostScript file.
See `pr-ps-printer-alist'.")
(defvar pr-ps-switches nil
"List of sexp's to pass as extra options to the PostScript printer program.
See `pr-ps-printer-alist'.")
(defvar pr-ps-printer-switch nil
"Specify PostScript printer name switch.
See `pr-ps-printer-alist'.")
(defvar pr-ps-printer nil
"Specify PostScript printer name.
See `pr-ps-printer-alist'.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Macros
(defmacro pr-save-file-modes (&rest body)
"Set temporally file modes to `pr-file-modes'."
`(let ((pr--default-file-modes (default-file-modes))) ; save default
(set-default-file-modes pr-file-modes)
,@body
(set-default-file-modes pr--default-file-modes))) ; restore default
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keys & Menus
(defsubst pr-visible-p (key)
(memq key pr-visible-entry-list))
(defsubst pr-mode-alist-p ()
(cdr (assq major-mode pr-mode-alist)))
(defsubst pr-auto-mode-p ()
(and pr-auto-mode (pr-mode-alist-p)))
(defsubst pr-using-ghostscript-p ()
(and pr-print-using-ghostscript (not pr-spool-p)))
(defalias 'pr-get-symbol
(if (fboundp 'easy-menu-intern) ; hacked from easymenu.el
'easy-menu-intern
(lambda (s) (if (stringp s) (intern s) s))))
(defconst pr-menu-spec
;; Menu mapping:
;; unfortunately XEmacs doesn't support :active for submenus,
;; only for items.
;; So, it uses :included instead of :active.
;; Also, XEmacs doesn't support :help tag.
(let ((pr-:active (if (featurep 'xemacs)
:included ; XEmacs
:active)) ; GNU Emacs
(pr-:help (if (featurep 'xemacs)
'ignore ; XEmacs
#'(lambda (text) (list :help text))))) ; GNU Emacs
`(
["Printing Interface" pr-interface
,@(funcall
pr-:help "Use buffer interface instead of menu interface")]
"--"
("PostScript Preview" :included (pr-visible-p 'postscript)
,@(funcall
pr-:help "Preview PostScript instead of sending to printer")
("Directory" ,pr-:active (not pr-spool-p)
["1-up" (pr-ps-directory-preview 1 nil nil t) t]
["2-up" (pr-ps-directory-preview 2 nil nil t) t]
["4-up" (pr-ps-directory-preview 4 nil nil t) t]
["Other..." (pr-ps-directory-preview nil nil nil t)
:keys "\\[pr-ps-buffer-preview]"])
("Buffer" ,pr-:active (not pr-spool-p)
["1-up" (pr-ps-buffer-preview 1 t) t]
["2-up" (pr-ps-buffer-preview 2 t) t]
["4-up" (pr-ps-buffer-preview 4 t) t]
["Other..." (pr-ps-buffer-preview nil t)
:keys "\\[pr-ps-buffer-preview]"])
("Region" ,pr-:active (and (not pr-spool-p) (ps-mark-active-p))
["1-up" (pr-ps-region-preview 1 t) t]
["2-up" (pr-ps-region-preview 2 t) t]
["4-up" (pr-ps-region-preview 4 t) t]
["Other..." (pr-ps-region-preview nil t)
:keys "\\[pr-ps-region-preview]"])
("Mode" ,pr-:active (and (not pr-spool-p) (pr-mode-alist-p))
["1-up" (pr-ps-mode-preview 1 t) t]
["2-up" (pr-ps-mode-preview 2 t) t]
["4-up" (pr-ps-mode-preview 4 t) t]
["Other..." (pr-ps-mode-preview nil t)
:keys "\\[pr-ps-mode-preview]"])
("File"
["No Preprocessing..." (call-interactively 'pr-ps-file-preview)
:keys "\\[pr-ps-file-preview]"
,@(funcall
pr-:help "Preview PostScript file")]
"--"
["PostScript Utility" pr-update-menus :active pr-ps-utility-alist
,@(funcall
pr-:help "Select PostScript utility")]
"--"
["1-up..." (pr-ps-file-up-preview 1 t t) pr-ps-utility-alist]
["2-up..." (pr-ps-file-up-preview 2 t t) pr-ps-utility-alist]
["4-up..." (pr-ps-file-up-preview 4 t t) pr-ps-utility-alist]
["Other..." (pr-ps-file-up-preview nil t t)
:keys "\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist]
"--"
["Landscape" pr-toggle-file-landscape-menu
:style toggle :selected pr-file-landscape
,@(funcall
pr-:help "Toggle landscape for PostScript file")
:active pr-ps-utility-alist]
["Duplex" pr-toggle-file-duplex-menu
:style toggle :selected pr-file-duplex
,@(funcall
pr-:help "Toggle duplex for PostScript file")
:active pr-ps-utility-alist]
["Tumble" pr-toggle-file-tumble-menu
:style toggle :selected pr-file-tumble
,@(funcall
pr-:help "Toggle tumble for PostScript file")
:active (and pr-file-duplex pr-ps-utility-alist)])
["Despool..." (call-interactively 'pr-despool-preview)
:active pr-spool-p :keys "\\[pr-despool-preview]"
,@(funcall
pr-:help "Despool PostScript buffer to printer or file (C-u)")])
("PostScript Print" :included (pr-visible-p 'postscript)
,@(funcall
pr-:help "Send PostScript to printer or file (C-u)")
("Directory"
["1-up" (pr-ps-directory-ps-print 1 nil nil t) t]
["2-up" (pr-ps-directory-ps-print 2 nil nil t) t]
["4-up" (pr-ps-directory-ps-print 4 nil nil t) t]
["Other..." (pr-ps-directory-ps-print nil nil nil t)
:keys "\\[pr-ps-buffer-ps-print]"])
("Buffer"
["1-up" (pr-ps-buffer-ps-print 1 t) t]
["2-up" (pr-ps-buffer-ps-print 2 t) t]
["4-up" (pr-ps-buffer-ps-print 4 t) t]
["Other..." (pr-ps-buffer-ps-print nil t)
:keys "\\[pr-ps-buffer-ps-print]"])
("Region" ,pr-:active (ps-mark-active-p)
["1-up" (pr-ps-region-ps-print 1 t) t]
["2-up" (pr-ps-region-ps-print 2 t) t]
["4-up" (pr-ps-region-ps-print 4 t) t]
["Other..." (pr-ps-region-ps-print nil t)
:keys "\\[pr-ps-region-ps-print]"])
("Mode" ,pr-:active (pr-mode-alist-p)
["1-up" (pr-ps-mode-ps-print 1 t) t]
["2-up" (pr-ps-mode-ps-print 2 t) t]
["4-up" (pr-ps-mode-ps-print 4 t) t]
["Other..." (pr-ps-mode-ps-print nil t)
:keys "\\[pr-ps-mode-ps-print]"])
("File"
["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print)
:keys "\\[pr-ps-file-ps-print]"
,@(funcall
pr-:help "Send PostScript file to printer")]
"--"
["PostScript Utility" pr-update-menus :active pr-ps-utility-alist
,@(funcall
pr-:help "Select PostScript utility")]
"--"
["1-up..." (pr-ps-file-up-ps-print 1 t t) pr-ps-utility-alist]
["2-up..." (pr-ps-file-up-ps-print 2 t t) pr-ps-utility-alist]
["4-up..." (pr-ps-file-up-ps-print 4 t t) pr-ps-utility-alist]
["Other..." (pr-ps-file-up-ps-print nil t t)
:keys "\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist]
"--"
["Landscape" pr-toggle-file-landscape-menu
:style toggle :selected pr-file-landscape
,@(funcall
pr-:help "Toggle landscape for PostScript file")
:active pr-ps-utility-alist]
["Duplex" pr-toggle-file-duplex-menu
:style toggle :selected pr-file-duplex
,@(funcall
pr-:help "Toggle duplex for PostScript file")
:active pr-ps-utility-alist]
["Tumble" pr-toggle-file-tumble-menu
:style toggle :selected pr-file-tumble
,@(funcall
pr-:help "Toggle tumble for PostScript file")
:active (and pr-file-duplex pr-ps-utility-alist)])
["Despool..." (call-interactively 'pr-despool-ps-print)
:active pr-spool-p :keys "\\[pr-despool-ps-print]"
,@(funcall
pr-:help "Despool PostScript buffer to printer or file (C-u)")])
["PostScript Printers" pr-update-menus
:active pr-ps-printer-alist :included (pr-visible-p 'postscript)
,@(funcall
pr-:help "Select PostScript printer")]
"--"
("Printify" :included (pr-visible-p 'text)
,@(funcall
pr-:help
"Replace non-printing chars with printable representations.")
["Directory" pr-printify-directory t]
["Buffer" pr-printify-buffer t]
["Region" pr-printify-region (ps-mark-active-p)])
("Print" :included (pr-visible-p 'text)
,@(funcall
pr-:help "Send text to printer")
["Directory" pr-txt-directory t]
["Buffer" pr-txt-buffer t]
["Region" pr-txt-region (ps-mark-active-p)]
["Mode" pr-txt-mode (pr-mode-alist-p)])
["Text Printers" pr-update-menus
:active pr-txt-printer-alist :included (pr-visible-p 'text)
,@(funcall
pr-:help "Select text printer")]
"--"
["Landscape" pr-toggle-landscape-menu
:style toggle :selected ps-landscape-mode
:included (pr-visible-p 'postscript-options)]
["Print Header" pr-toggle-header-menu
:style toggle :selected ps-print-header
:included (pr-visible-p 'postscript-options)]
["Print Header Frame" pr-toggle-header-frame-menu
:style toggle :selected ps-print-header-frame :active ps-print-header
:included (pr-visible-p 'postscript-options)]
["Line Number" pr-toggle-line-menu
:style toggle :selected ps-line-number
:included (pr-visible-p 'postscript-options)]
["Zebra Stripes" pr-toggle-zebra-menu
:style toggle :selected ps-zebra-stripes
:included (pr-visible-p 'postscript-options)]
["Duplex" pr-toggle-duplex-menu
:style toggle :selected ps-spool-duplex
:included (pr-visible-p 'postscript-options)]
["Tumble" pr-toggle-tumble-menu
:style toggle :selected ps-spool-tumble :active ps-spool-duplex
:included (pr-visible-p 'postscript-options)]
["Upside-Down" pr-toggle-upside-down-menu
:style toggle :selected ps-print-upside-down
:included (pr-visible-p 'postscript-options)]
("Print All Pages" :included (pr-visible-p 'postscript-options)
,@(funcall
pr-:help "Select odd/even pages/sheets to print")
["All Pages" (pr-even-or-odd-pages nil)
:style radio :selected (eq ps-even-or-odd-pages nil)]
["Even Pages" (pr-even-or-odd-pages 'even-page)
:style radio :selected (eq ps-even-or-odd-pages 'even-page)]
["Odd Pages" (pr-even-or-odd-pages 'odd-page)
:style radio :selected (eq ps-even-or-odd-pages 'odd-page)]
["Even Sheets" (pr-even-or-odd-pages 'even-sheet)
:style radio :selected (eq ps-even-or-odd-pages 'even-sheet)]
["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet)
:style radio :selected (eq ps-even-or-odd-pages 'odd-sheet)])
"--"
["Spool Buffer" pr-toggle-spool-menu
:style toggle :selected pr-spool-p
:included (pr-visible-p 'postscript-process)
,@(funcall
pr-:help "Toggle PostScript spooling")]
["Print with faces" pr-toggle-faces-menu
:style toggle :selected pr-faces-p
:included (pr-visible-p 'postscript-process)
,@(funcall
pr-:help "Toggle PostScript printing with faces")]
["Print via Ghostscript" pr-toggle-ghostscript-menu
:style toggle :selected pr-print-using-ghostscript
:included (pr-visible-p 'postscript-process)
,@(funcall
pr-:help "Toggle PostScript generation using ghostscript")]
"--"
["Auto Region" pr-toggle-region-menu
:style toggle :selected pr-auto-region
:included (pr-visible-p 'printing)]
["Auto Mode" pr-toggle-mode-menu
:style toggle :selected pr-auto-mode
:included (pr-visible-p 'printing)]
["Menu Lock" pr-toggle-lock-menu
:style toggle :selected pr-menu-lock
:included (pr-visible-p 'printing)]
"--"
("Customize" :included (pr-visible-p 'help)
["printing" pr-customize t]
["ps-print" ps-print-customize t]
["lpr" lpr-customize t])
("Show Settings" :included (pr-visible-p 'help)
["printing" pr-show-pr-setup t]
["ps-print" pr-show-ps-setup t]
["lpr" pr-show-lpr-setup t])
["Help" pr-help :active t :included (pr-visible-p 'help)]
)))
(defun pr-menu-bind ()
"Install `printing' menu in the menubar.
This replaces the File/Print* menu entries with a File/Print sub-menu.
Calls `pr-update-menus' to adjust menus."
(interactive)
(pr-global-menubar pr-menu-spec)
(pr-update-menus t))
;; Key binding
(let ((pr-print-key (if (featurep 'xemacs)
'f22 ; XEmacs
'print))) ; GNU Emacs
(global-set-key `[,pr-print-key] 'pr-ps-fast-fire)
;; Well, M-print and S-print are used because in my keyboard S-print works
;; and M-print doesn't. But M-print can work in other keyboard.
(global-set-key `[(meta ,pr-print-key)] 'pr-ps-mode-using-ghostscript)
(global-set-key `[(shift ,pr-print-key)] 'pr-ps-mode-using-ghostscript)
;; Well, C-print and C-M-print are used because in my keyboard C-M-print works
;; and C-print doesn't. But C-print can work in other keyboard.
(global-set-key `[(control ,pr-print-key)] 'pr-txt-fast-fire)
(global-set-key `[(control meta ,pr-print-key)] 'pr-txt-fast-fire))
;;; You can also use something like:
;;;(global-set-key "\C-ci" 'pr-interface)
;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print)
;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview)
;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript)
;;;(global-set-key "\C-crp" 'pr-ps-region-print)
;;;(global-set-key "\C-crx" 'pr-ps-region-preview)
;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Help Message
(defconst pr-help-message
(concat "printing.el version " pr-version
" ps-print.el version " ps-print-version
"\n\n
Menu Layout
-----------
The `printing' menu (Tools/Printing or File/Print) has the following layout:
+-----------------------------+
A 0 | Printing Interface |
+-----------------------------+ +-A---------+ +-B------+
I 1 | PostScript Preview >|-------|Directory >|-----|1-up |
2 | PostScript Print >|---- A |Buffer >|-- B |2-up |
3 | PostScript Printer: name >|---- C |Region >|-- B |4-up |
+-----------------------------+ |Mode >|-- B |Other...|
II 4 | Printify >|-----\\ |File >|--\\ +--------+
5 | Print >|---\\ | |Despool... | |
6 | Text Printer: name >|-\\ | | +-----------+ |
+-----------------------------+ | | | +---------+ +------------+
III 7 |[ ]Landscape | | | \\-|Directory| | No Prep... | Ia
8 |[ ]Print Header | | | |Buffer | +------------+ Ib
9 |[ ]Print Header Frame | | | |Region | | name >|- C
10 |[ ]Line Number | | | +---------+ +------------+
11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic
12 |[ ]Duplex | | \\---|Directory| | 2-up... |
13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... |
14 |[ ]Upside-Down | | |Region | | Other... |
15 | Print All Pages >|--\\ | |Mode | +------------+
+-----------------------------+ | | +---------+ |[ ]Landscape| Id
IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie
17 |[ ]Print with faces | | \\--|( )name A| |[ ]Tumble | If
18 |[ ]Print via Ghostscript | | |( )name B| +------------+
+-----------------------------+ | |... |
V 19 |[ ]Auto Region | | |(*)name |
20 |[ ]Auto Mode | | |... |
21 |[ ]Menu Lock | | +---------+ +--------------+
+-----------------------------+ \\------------------|(*)All Pages |
VI 22 | Customize >|--- D +-D------+ |( )Even Pages |
23 | Show Settings >|-------|printing| |( )Odd Pages |
24 | Help | |ps-print| |( )Even Sheets|
+-----------------------------+ |lpr | |( )Odd Sheets |
+--------+ +--------------+
See `pr-visible-entry-list' for hiding some parts of the menu.
The menu has the following sections:
A. Interface:
0. You can use a buffer interface instead of menus. It looks like the
customization buffer. Basically, it has the same options found in the
menu and some extra options, all this on a buffer.
I. PostScript printing:
1. You can generate a PostScript file (if you type C-u before activating
menu) or PostScript temporary file for a directory, a buffer, a region
or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing;
after file generation, ghostview is activated using the file generated
as argument. This option is disabled if spooling is on (option 16).
Also, if you already have a PostScript file you can preview it.
Instead of previewing each buffer, region or major mode at once, you
can save temporarily the PostScript code generated in a buffer and
preview it later. The option `Despool...' despools the PostScript
spooling buffer in a temporary file and uses ghostview to preview it.
If you type C-u before choosing this option, the PostScript code
generated is saved in a file instead of saving in a temporary file. To
spool the PostScript code generated you need to turn on the option 16.
The option `Despool...' is enabled if spooling is on (option 16).
NOTE 1: It's possible to customize a major mode printing, just declare
the customization in `pr-mode-alist' and invoke some of
`*-mode*' commands or select Mode option in Printing menu. An
example for major mode usage is when you're using gnus (or mh,
or rmail, etc.) and you're in the *Summary* buffer, if you
forget to switch to the *Article* buffer before printing,
you'll get a nicely formatted list of article subjects shows
up at the printer. With major mode printing you don't need to
switch from gnus *Summary* buffer first.
NOTE 2: There are the following options for PostScript file processing:
Ia. Print the file *No Preprocessing*, that is, send it
directly to PostScript printer.
Ib. PostScript utility processing selection.
See `pr-ps-utility-alist' and `pr-setting-database' for
documentation.
Ic. Do n-up processing before printing.
Id. Toggle on/off landscape for PostScript file processing.
Ie. Toggle on/off duplex for PostScript file processing.
If. Toggle on/off tumble for PostScript file processing.
NOTE 3: Don't forget to download and install the utilities declared on
`pr-ps-utility-alist'.
2. Operate the same way as option 1, but it sends directly the PostScript
code (or put in a file, if you've typed C-u) or it uses ghostscript to
print the PostScript file generated. It depends on option 18, if it's
turned on, it uses ghostscript; otherwise, it sends directly to
printer. If spooling is on (option 16), the PostScript code is saved
temporarily in a buffer instead of printing it or saving it in a file.
Also, if you already have a PostScript file you can print it.
Instead of printing each buffer, region or major mode at once, you can
save temporarily the PostScript code generated in a buffer and print it
later. The option `Despool...' despools the PostScript spooling buffer
directly on a printer. If you type C-u before choosing this option,
the PostScript code generated is saved in a file instead of sending it to
the printer. To spool the PostScript code generated you need to turn on
option 16. This option is enabled if spooling is on (option 16).
See also the NOTE 1, NOTE 2 and NOTE 3 on option 1.
3. You can select a new PostScript printer to send PostScript code
generated. For selection it's used all PostScript printers defined
in `pr-ps-printer-alist' variable (see it for documentation).
See also `pr-setting-database'.
II. Text printing:
4. If you have control characters (character code from \\000 to \\037) in a
buffer and you want to print them in a text printer, select this
option. All control characters in your buffer or region will be
replaced by a printable representation. The printable representations
use ^ (for ASCII control characters) or hex. The characters tab,
linefeed, space, return and formfeed are not affected.
You don't need to select this option if you use any option of section
I, the PostScript engine treats control characters properly.
5. If you want to print a directory, buffer, region or major mode in a
text printer, select this option. See also the NOTE 1 on option 1.
6. You can select a new text printer to send text generated. For
selection it's used all text printers defined in `pr-txt-printer-alist'
variable (see it for documentation).
See also `pr-setting-database'.
III. PostScript page toggle options:
7. If you want a PostScript landscape printing, turn on this option.
8. If you want to have a header in each page in your PostScript code,
turn on this option.
9. If you want to draw a gaudy frame around the header, turn on this
option. This option is enabled if print header is on (option 8).
10. If you want that the line number is printed in your PostScript code,
turn on this option.
11. If you want background zebra stripes in your PostScript code, turn on
this option.
12. If you want a duplex printing and your PostScript printer has this
feature, turn on this option.
13. If you turned on duplex printing, you can choose if you want to have a
printing suitable for binding on the left or right (tumble off), or to
have a printing suitable for binding at top or bottom (tumble on).
This option is enabled if duplex is on (option 12).
14. If you want a PostScript upside-down printing, turn on this option.
15. With this option, you can choose if you want to print all pages, odd
pages, even pages, odd sheets or even sheets.
See also `ps-even-or-odd-pages'.
IV. PostScript processing toggle options:
16. If you want to spool the PostScript code generated, turn on this
option. To spool the PostScript code generated use option 2. You can
despool later by choosing option 1 or 2, sub-option `Despool...'.
17. If you use colors in your buffers and want to see these colors on your
PostScript code generated, turn on this option. If you have a
black/white PostScript printer, these colors are displayed in gray
scale by PostScript printer interpreter.
18. If you don't have a PostScript printer to send PostScript files, turn
on this option. When this option is on, the ghostscript is used to
print PostScript files. In GNU or Unix system, if ghostscript is set
as a PostScript filter, you don't need to turn on this option.
V. Printing customization:
19. If you want that region is automagically detected, turn on this
option. Note that this will only work if you're using transient mark
mode. When this option is on, the `*-buffer*' commands will behave
like `*-region*' commands, that is, `*-buffer*' commands will print
only the region marked instead of all buffer.
20. Turn this option on if you want that when current major-mode is
declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands
behave like `*-mode*' commands.
21. If you want that Printing menu stays open while you are setting
toggle options, turn on this option. The variables
`pr-menu-char-height' and `pr-menu-char-width' are used to guess the
menu position, so don't forget to adjust these variables if menu
position is not ok.
VI. Customization:
22. Besides all options in section III, IV and V, you can customize much
more PostScript options in `ps-print' option. Or you can customize
some `lpr' options for text printing. Or customize `printing'
options.
23. Show current settings for `printing', `ps-print' or `lpr'.
24. Quick help for printing menu layout.
")
"Printing help message.")
(defconst pr-interface-help-message
(concat "printing.el version " pr-version
" ps-print.el version " ps-print-version
"\n\n
The printing interface buffer has the same functionality as the printing menu.
The major difference is that the states (like sending PostScript generated to a
file, n-up printing, etc.) are set and saved between priting buffer
activation. Also, the landscape, duplex and tumble values are the same for