From 8c19b36b7140e0c90e2377d017c0631d71ca2e1f Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Mon, 22 Oct 2007 02:37:14 +0000 Subject: * mail/vms-pmail.el (insert-signature): Don't use end-of-buffer. * tooltip.el: Use featurep 'xemacs. * printing.el: Move variable definitions before use, no code change. --- lisp/printing.el | 3270 +++++++++++++++++++++++++++--------------------------- 1 file changed, 1633 insertions(+), 1637 deletions(-) (limited to 'lisp/printing.el') diff --git a/lisp/printing.el b/lisp/printing.el index 0f589564083..b487abb1f92 100644 --- a/lisp/printing.el +++ b/lisp/printing.el @@ -1094,1039 +1094,958 @@ If SUFFIX is non-nil, add that at the end of the file name." -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; XEmacs Definitions - - -(cond - ((featurep 'xemacs) ; XEmacs - ;; XEmacs - (defalias 'pr-f-set-keymap-parents 'set-keymap-parents) - (defalias 'pr-f-set-keymap-name 'set-keymap-name) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; User Interface (II) - ;; XEmacs - (defun pr-f-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) +(defcustom pr-path-alist + '((unix PATH) + (cygwin PATH) + (windows PATH)) + "*Specify an alist for command paths. - ;; XEmacs - (defun pr-keep-region-active () - (setq zmacs-region-stays t)) +It's used to find commands used for printing package, like gv, gs, gsview.exe, +mpage, print.exe, etc. See also `pr-command' function. - ;; XEmacs - (defun pr-region-active-p () - (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))) +Each element has the form: - ;; XEmacs - (defun pr-menu-char-height () - (font-height (face-font 'default))) + (ENTRY DIRECTORY...) - ;; XEmacs - (defun pr-menu-char-width () - (font-width (face-font 'default))) +Where: - ;; 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)))) +ENTRY It's a symbol, used to identify this entry. + There must exist at least one of the following entries: - ;; 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)) + unix this entry is used when Emacs is running on GNU or + Unix system. - ;; 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))))) + cygwin this entry is used when Emacs is running on Windows + 95/98/NT/2000 with Cygwin. - (defvar pr-menu-position nil) - (defvar pr-menu-state nil) + windows this entry is used when Emacs is running on Windows + 95/98/NT/2000. - ;; XEmacs - (defvar current-menubar nil) ; to avoid compilation gripes - (defun pr-menu-lookup (path) - (car (find-menu-item current-menubar (cons "Printing" path)))) +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. - ;; 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))) + The directory specification may contain: + $var environment variable expansion + ~/ tilde expansion + ./ current directory + ../ previous directory - ;; XEmacs - (defalias 'pr-update-mode-line 'set-menubar-dirty-flag) + For example, let's say the home directory is /home/my and the + current directory is /home/my/dir, so: - ;; 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") + 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 - ;; 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)) + 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. - ;; 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))) +Examples: - ;; 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))) +* On GNU or Unix system: - ;; 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))) + '((unix \".\" \"~/bin\" ghostview mpage PATH) + (ghostview \"$HOME/bin/gsview-dir\") + (mpage \"$HOME/bin/mpage-dir\") + ) - ;; 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))) +* On Windows system: - ;; 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")))) + '((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))))) + :version "20" + :group 'printing) - ;; 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 +(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). - -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; GNU Emacs Definitions +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 + :version "20" + :group 'printing) -(cond - ((featurep 'xemacs) ; XEmacs - ;; Do nothing - ) - (t ; GNU Emacs - ;; GNU Emacs - (defalias 'pr-f-set-keymap-parents 'set-keymap-parent) - (defalias 'pr-f-set-keymap-name 'ignore) - (defalias 'pr-f-read-string 'read-string) +(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). - ;; GNU Emacs - (defvar deactivate-mark) +The alist element has the form: - ;; GNU Emacs - (defun pr-keep-region-active () - (setq deactivate-mark nil)) + (SYMBOL COMMAND SWITCHES NAME) - ;; GNU Emacs - (defun pr-region-active-p () - (and pr-auto-region transient-mark-mode mark-active)) +Where: - ;; GNU Emacs - (defun pr-menu-char-height () - (frame-char-height)) +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 - ;; GNU Emacs - (defun pr-menu-char-width () - (frame-char-width)) +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\" - ;; 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-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))) - ))) - ))) +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 - (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 - ))) +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\" - (defvar pr-menu-position nil) - (defvar pr-menu-state nil) + . for lpr or lp + \"share-name\" - ;; 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))) +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. - ;; 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))) +Examples: - ;; GNU Emacs - (defalias 'pr-update-mode-line 'force-mode-line-update) +* On GNU or Unix system: - ;; 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)) + '((prt_06a \"lpr\" nil \"prt_06a\") + (prt_07c nil nil \"prt_07c\") + ) - ;; 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))))) +* On Windows system: - ;; GNU Emacs - (defvar pr-temp-menu nil) + '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\") + (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\") + (PRN \"\" nil \"PRN\") + (standard \"redpr.exe\" 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))) +Useful links: - ;; GNU Emacs - (defun pr-menu-set-item-name (item name) - (and item - (setcar (nthcdr 2 item) name))) ; ITEM-NAME +* Information about the print command (print.exe) + `http://www.computerhope.com/printhlp.htm' - ;; 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))) +* RedMon - Redirection Port Monitor (redpr.exe) + `http://www.cs.wisc.edu/~ghost/redmon/index.htm' - ;; 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))) +* Redirection Port Monitor (redpr.exe on-line help) + `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm' - ;; 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")))) +* 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' - ;; 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))) +* 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 + :version "20" + :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 + :version "20" + :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\" - )) ; end cond featurep + . 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: -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Customization Functions + (VARIABLE . VALUE) + Which associates VARIABLE with VALUE. When this entry is + selected, it's executed the following command: -(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))) + (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)) -(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))) +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: -(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))) +* 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\") + ) -(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))) +* 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 \"\" \"\") + ) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; User Interface (I) +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. -(defgroup printing nil - "Printing Utilities group." - :tag "Printing Utilities" - :link '(emacs-library-link :tag "Source Lisp File" "printing.el") - :prefix "pr-" - :version "20" - :group 'wp - :group 'postscript) +To print non-monochrome PostScript file, the efficiency of ghostscript is +similar to gsprint. +Also the gsprint utility comes together with gsview distribution. -(defcustom pr-path-style - (if (and (not pr-cygwin-system) - ps-windows-system) - 'windows - 'unix) - "*Specify which path style to use for external commands. +As an example of gsprint declaration: -Valid values are: + (setq pr-ps-printer-alist + '((A \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"lps_015\") + (B \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer lps_015\") + ;; some other printer declaration + )) - windows Windows 9x/NT style (\\) +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. - unix Unix style (/)" - :type '(choice :tag "Path style" - (const :tag "Windows 9x/NT Style (\\)" :value windows) - (const :tag "Unix Style (/)" :value unix)) - :version "20" - :group 'printing) +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. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Internal Functions (I) +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. -(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)) +Useful links: +* GSPRINT - Ghostscript print to Windows printer + `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm' -(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)) +* 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' -(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))) +* 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' -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; User Interface (II) +* 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' -(defcustom pr-path-alist - '((unix PATH) - (cygwin PATH) - (windows PATH)) - "*Specify an alist for command paths. +* 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' -It's used to find commands used for printing package, like gv, gs, gsview.exe, -mpage, print.exe, etc. See also `pr-command' function. +* 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 + :version "20" + :group 'printing) -Each element has the form: - (ENTRY DIRECTORY...) +(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") + ((memq system-type '(vax-vms axp-vms)) "SYS$SCRATCH:") + (t "/tmp") + ))))) + "*Specify a directory for temporary files during printing. -Where: +See also `pr-ps-temp-file' and `pr-file-modes'." + :type '(directory :tag "Temporary Directory") + :version "20" + :group 'printing) -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. +(defcustom pr-ps-temp-file "prspool-" + "*Specify PostScript temporary file name prefix. - cygwin this entry is used when Emacs is running on Windows - 95/98/NT/2000 with Cygwin. +See also `pr-temp-dir' and `pr-file-modes'." + :type '(file :tag "PostScript Temporary File Name") + :version "21" + :group 'printing) - 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. +;; 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. - The directory specification may contain: - $var environment variable expansion - ~/ tilde expansion - ./ current directory - ../ previous directory +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") + :version "21.3" + :group 'printing) - 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 +(defcustom pr-gv-command + (if ps-windows-system + "gsview32.exe" + "gv") + "*Specify path and name of the gsview/gv utility. - 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. +See also `pr-path-alist'. -Examples: +Useful links: -* On GNU or Unix system: +* GNU gv manual + `http://www.gnu.org/software/gv/manual/gv.html' - '((unix \".\" \"~/bin\" ghostview mpage PATH) - (ghostview \"$HOME/bin/gsview-dir\") - (mpage \"$HOME/bin/mpage-dir\") - ) +* GSview Help + `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm' -* On Windows system: +* GSview Help - Common Problems + `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm#Common_Problems' - '((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))))) - :version "20" - :group 'printing) +* 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' -(defcustom pr-txt-name 'default - "*Specify a printer for printing a text file. +* Ghostscript, Ghostview and GSview + `http://www.cs.wisc.edu/~ghost/' -The printer name symbol should be defined on `pr-txt-printer-alist' (see it for -documentation). +* Ghostview + `http://www.cs.wisc.edu/~ghost/gv/index.htm' -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 +* 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") :version "20" :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). +(defcustom pr-gs-command + (if ps-windows-system + "gswin32.exe" + "gs") + "*Specify path and name of the ghostscript utility. -The alist element has the form: +See also `pr-path-alist'. - (SYMBOL COMMAND SWITCHES NAME) +Useful links: -Where: +* Ghostscript, Ghostview and GSview + `http://www.cs.wisc.edu/~ghost/' -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 +* Introduction to Ghostscript + `http://www.cs.wisc.edu/~ghost/doc/intro.htm' -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\" +* How to use Ghostscript + `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' -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 +* Printer compatibility + `http://www.cs.wisc.edu/~ghost/doc/printer.htm' +" + :type '(string :tag "Ghostscript Utility") + :version "20" + :group 'printing) -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\" +(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. -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. +It's a list of strings, where each string is one or more ghostscript switches. -Examples: +A note on the gs switches: -* On GNU or Unix system: +-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 - '((prt_06a \"lpr\" nil \"prt_06a\") - (prt_07c nil nil \"prt_07c\") - ) +To see ghostscript documentation for more information: -* On Windows system: +* On GNU or Unix system: + - for full documentation, type: man gs + - for brief documentation, type: gs -h - '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\") - (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\") - (PRN \"\" nil \"PRN\") - (standard \"redpr.exe\" nil \"\") - ) +* 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: -* Information about the print command (print.exe) - `http://www.computerhope.com/printhlp.htm' +* Introduction to Ghostscript + `http://www.cs.wisc.edu/~ghost/doc/intro.htm' -* RedMon - Redirection Port Monitor (redpr.exe) - `http://www.cs.wisc.edu/~ghost/redmon/index.htm' +* How to use Ghostscript + `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' -* Redirection Port Monitor (redpr.exe on-line help) - `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm' +* Printer compatibility + `http://www.cs.wisc.edu/~ghost/doc/printer.htm' +" + :type '(repeat (string :tag "Ghostscript Switch")) + :version "20" + :group 'printing) -* 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 +(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") :version "20" :group 'printing) -(defcustom pr-ps-name 'default - "*Specify a printer for printing a PostScript file. +(defcustom pr-gs-resolution 300 + "*Specify ghostscript resolution switch value (-r). -This printer name symbol should be defined on `pr-ps-printer-alist' (see it for -documentation). +A note on the gs switches: -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 +-r300 resolution 300x300 + +See `pr-gs-switches' for documentation. +See also `pr-ps-printer-alist'." + :type '(integer :tag "Ghostscript Resolution") :version "20" :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: +(defcustom pr-print-using-ghostscript nil + "*Non-nil means print using ghostscript. - (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...) +This is useful if you don't have a PostScript printer, so you could use the +ghostscript to print a PostScript file. -Where: +In GNU or Unix system, if ghostscript is set as a PostScript filter, this +variable should be nil." + :type 'boolean + :version "20" + :group 'printing) -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\" +(defcustom pr-faces-p nil + "*Non-nil means print with face attributes." + :type 'boolean + :version "20" + :group 'printing) -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\") +(defcustom pr-spool-p nil + "*Non-nil means spool printing in a buffer." + :type 'boolean + :version "20" + :group 'printing) -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 \" +(defcustom pr-file-landscape nil + "*Non-nil means print PostScript file in landscape orientation." + :type 'boolean + :version "20" + :group 'printing) - . for print.exe - \"/D:\" - . for gsprint.exe - \"-printer \" +(defcustom pr-file-duplex nil + "*Non-nil means print PostScript file in duplex mode." + :type 'boolean + :version "20" + :group 'printing) -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\" +(defcustom pr-file-tumble nil + "*Non-nil means print PostScript file in tumble mode. - . for lpr or lp - \"share-name\" +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 + :version "20" + :group 'printing) -DEFAULT It's a way to set default values when this entry is selected. - It's a cons like: - (VARIABLE . VALUE) +(defcustom pr-auto-region t + "*Non-nil means region is automagically detected. - Which associates VARIABLE with VALUE. When this entry is - selected, it's executed the following command: +Note that this will only work if you're using transient mark mode. - (set VARIABLE (eval VALUE)) +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 + :version "20" + :group 'printing) - 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. +(defcustom pr-auto-mode t + "*Non-nil means major-mode specific printing is prefered over normal printing. -Examples: +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 + :version "20" + :group 'printing) -* 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\") +(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 ) - -* 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 \"\" \"\") + (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: -gsprint: + (MAJOR-MODE + LPR-PRINT PS-PRINT + HEADER-LINES + LEFT-HEADER + RIGHT-HEADER + KILL-LOCAL-VARIABLE + DEFAULT...) -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. +Where: -To print non-monochrome PostScript file, the efficiency of ghostscript is -similar to gsprint. +MAJOR-MODE It's the major mode symbol. -Also the gsprint utility comes together with gsview distribution. +LPR-PRINT It's a symbol function for text printing. It's invoked with + one argument: + (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...). -As an example of gsprint declaration: + 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. - (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 `pr-mode-lpr' definition is: -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. + (pr-mode-lpr HEADER-LIST &optional FROM TO) -There are other command line options like: + 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). - -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. +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...). -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. + 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: -Useful links: + (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO) -* GSPRINT - Ghostscript print to Windows printer - `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm' + 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). -* Introduction to Ghostscript - `http://www.cs.wisc.edu/~ghost/doc/intro.htm' +HEADER-LINES It's the number of header lines; if is nil, it uses + `ps-header-lines' value. -* How to use Ghostscript - `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' +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. -* Information about the print command (print.exe) - `http://www.computerhope.com/printhlp.htm' +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. -* RedMon - Redirection Port Monitor (redpr.exe) - `http://www.cs.wisc.edu/~ghost/redmon/index.htm' +KILL-LOCAL-VARIABLE + Non-nil means to kill all buffer local variable declared in + DEFAULT (see below). -* Redirection Port Monitor (redpr.exe on-line help) - `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm' +DEFAULT It's a way to set default values when this entry is selected. + It's a cons like: -* 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' + (VARIABLE-SYM . VALUE) -* 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' + Which associates VARIABLE-SYM with VALUE. When this entry is + selected, it's executed the following command: -* GNU utilities for Win32 (cp.exe) - `http://unxutils.sourceforge.net/' -" + (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 "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) + :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 @@ -2154,421 +2073,347 @@ Useful links: (variable :tag "Other")) (sexp :tag "Value"))) )) - :set 'pr-alist-custom-set - :version "20" - :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") - ((memq system-type '(vax-vms axp-vms)) "SYS$SCRATCH:") - (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") - :version "20" - :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") - :version "21" - :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") - :version "21.3" - :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") :version "20" :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/' +(defcustom pr-ps-utility 'mpage + "*Specify PostScript utility symbol. -* Introduction to Ghostscript - `http://www.cs.wisc.edu/~ghost/doc/intro.htm' +This utility symbol should be defined on `pr-ps-utility-alist' (see it for +documentation). -* How to use Ghostscript - `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' +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. -* Printer compatibility - `http://www.cs.wisc.edu/~ghost/doc/printer.htm' -" - :type '(string :tag "Ghostscript Utility") +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 :version "20" :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. +(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). -It's a list of strings, where each string is one or more ghostscript switches. +The alist element has the form: -A note on the gs switches: + (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT + SWITCHES DEFAULT...) --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 +Where: -To see ghostscript documentation for more information: +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 -* On GNU or Unix system: - - for full documentation, type: man gs - - for brief documentation, type: gs -h +UTILITY Name of utility for processing a PostScript file. + See also `pr-path-alist'. + Examples: + . for GNU or Unix system: + \"mpage\" + \"psnup -q\" -* 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 + . for Windows system: + \"c:/psutils/psnup -q\" -Useful links: +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\") -* Introduction to Ghostscript - `http://www.cs.wisc.edu/~ghost/doc/intro.htm' +PAPERSIZE It's a format string to specify paper size switch. + Example: + . for mpage + \"-b%s\" -* How to use Ghostscript - `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' +N-UP It's a format string to specify n-up switch. + Example: + . for psnup + \"-%d\" -* Printer compatibility - `http://www.cs.wisc.edu/~ghost/doc/printer.htm' -" - :type '(repeat (string :tag "Ghostscript Switch")) - :version "20" - :group 'printing) +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 -(defcustom pr-gs-device - (if ps-windows-system - "mswinpr2" - "uniprint") - "*Specify the ghostscript device switch value (-sDEVICE=). +TUMBLE It's a string to specify tumble switch. If the utility doesn't + have tumble switch, set to nil. + Example: + . for psnup + nil -A note on the gs switches: +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 --sDEVICE=djet500 the printer - works with HP DeskJet 540 + . for mpage + \">\" ; mpage ... input > output -See `pr-gs-switches' for documentation. -See also `pr-ps-printer-alist'." - :type '(string :tag "Ghostscript Device") - :version "20" - :group 'printing) +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: -(defcustom pr-gs-resolution 300 - "*Specify ghostscript resolution switch value (-r). + (VARIABLE . VALUE) -A note on the gs switches: + Which associates VARIABLE with VALUE. When this entry is + selected, it's executed the following command: --r300 resolution 300x300 + (set VARIABLE (eval VALUE)) -See `pr-gs-switches' for documentation. -See also `pr-ps-printer-alist'." - :type '(integer :tag "Ghostscript Resolution") - :version "20" - :group 'printing) + 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. -(defcustom pr-print-using-ghostscript nil - "*Non-nil means print using ghostscript. +NOTE: Don't forget to download and install the utilities declared on + `pr-ps-utility-alist'. -This is useful if you don't have a PostScript printer, so you could use the -ghostscript to print a PostScript file. +Examples: -In GNU or Unix system, if ghostscript is set as a PostScript filter, this -variable should be nil." - :type 'boolean - :version "20" - :group 'printing) +* 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)) + ) -(defcustom pr-faces-p nil - "*Non-nil means print with face attributes." - :type 'boolean - :version "20" - :group 'printing) +* On Windows system: + '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" + nil (pr-file-duplex . nil) (pr-file-tumble . nil)) + ) -(defcustom pr-spool-p nil - "*Non-nil means spool printing in a buffer." - :type 'boolean - :version "20" - :group 'printing) +Useful links: +* mpage download (GNU or Unix) + `http://www.mesa.nl/pub/mpage/' -(defcustom pr-file-landscape nil - "*Non-nil means print PostScript file in landscape orientation." - :type 'boolean - :version "20" - :group 'printing) +* 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' -(defcustom pr-file-duplex nil - "*Non-nil means print PostScript file in duplex mode." - :type 'boolean +* 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 :version "20" :group 'printing) -(defcustom pr-file-tumble nil - "*Non-nil means print PostScript file in tumble mode. +(defcustom pr-menu-lock t + "*Non-nil means menu is locked while selecting toggle options. -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." +See also `pr-menu-char-height' and `pr-menu-char-width'." :type 'boolean :version "20" :group 'printing) -(defcustom pr-auto-region t - "*Non-nil means region is automagically detected. +(defcustom pr-menu-char-height (pr-menu-char-height) + "*Specify menu char height in pixels. -Note that this will only work if you're using transient mark mode. +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. -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 +See also `pr-menu-lock' and `pr-menu-char-width'." + :type 'integer :version "20" :group 'printing) -(defcustom pr-auto-mode t - "*Non-nil means major-mode specific printing is prefered over normal printing. +(defcustom pr-menu-char-width (pr-menu-char-width) + "*Specify menu char width in pixels. -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 +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 :version "20" :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 - ) +(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 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. + "*Specify an alist for settings in general. The elements have the following form: - (MAJOR-MODE - LPR-PRINT PS-PRINT - HEADER-LINES - LEFT-HEADER - RIGHT-HEADER - KILL-LOCAL-VARIABLE - DEFAULT...) + (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...) 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...). +SYMBOL It's a symbol to identify the setting group. - 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. +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. - The `pr-mode-print' definition is: + Let's see an example to illustrate the inheritance mechanism: - (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO) + (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 + ))) - 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). + 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. -HEADER-LINES It's the number of header lines; if is nil, it uses - `ps-header-lines' value. + 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. -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. + Take care with circular inheritance. It's an error if circular + inheritance happens. -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. +LOCAL Non-nil means that all settings for SYMBOL group will be + declared local buffer. -KILL-LOCAL-VARIABLE - Non-nil means to kill all buffer local variable declared in - DEFAULT (see below). +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. -DEFAULT It's a way to set default values when this entry is selected. - It's a cons like: +SETTING It's a cons like: - (VARIABLE-SYM . VALUE) + (VARIABLE . VALUE) - Which associates VARIABLE-SYM with VALUE. When this entry is + Which associates VARIABLE with VALUE. When this entry is selected, it's executed the following command: - (set (make-local-variable VARIABLE-SYM) (eval VALUE)) + * 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. - 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. + This setting is ignored if VARIABLE is equal to keyword + `inherits-from:'. Examples: '(ps-landscape-mode . nil) '(ps-spool-duplex . t) @@ -2576,24 +2421,15 @@ DEFAULT It's a way to set default values when this entry is selected. :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)) + (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 "Default Value List" + :tag "Setting List" :inline t (cons :tag "" @@ -2615,7 +2451,6 @@ DEFAULT It's a way to set default values when this entry is selected. (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"))) )) @@ -2623,541 +2458,724 @@ DEFAULT It's a way to set default values when this entry is selected. :group 'printing) -(defcustom pr-ps-utility 'mpage - "*Specify PostScript utility symbol. +(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))) + :version "20" + :group 'printing) + + +(defcustom pr-delete-temp-file t + "*Non-nil means delete temporary files. -This utility symbol should be defined on `pr-ps-utility-alist' (see it for -documentation). +Set `pr-delete-temp-file' to nil, if the following message (or a similar) +happens when printing: -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. + Error: could not open \"c:\\temp\\prspool.ps\" for reading." + :type 'boolean + :version "20" + :group 'printing) -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 + +(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 :version "20" :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). +(defcustom pr-buffer-name "*Printing Interface*" + "*Specify the name of the buffer interface for printing package. -The alist element has the form: +It's used by `pr-interface'." + :type 'string + :version "20" + :group 'printing) - (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT - SWITCHES DEFAULT...) -Where: +(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. -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 +NOTE: Case is important for matching, that is, `case-fold-search' is always + nil. -UTILITY Name of utility for processing a PostScript file. - See also `pr-path-alist'. - Examples: - . for GNU or Unix system: - \"mpage\" - \"psnup -q\" +It's used by `pr-interface'." + :type '(repeat (regexp :tag "Buffer Name Regexp")) + :version "20" + :group 'printing) - . 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\") +(defcustom pr-buffer-verbose t + "*Non-nil means to be verbose when editing a field in interface buffer. -PAPERSIZE It's a format string to specify paper size switch. - Example: - . for mpage - \"-b%s\" +It's used by `pr-interface'." + :type 'boolean + :version "20" + :group 'printing) -N-UP It's a format string to specify n-up switch. - Example: - . for psnup - \"-%d\" +(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"))) -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 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Internal Variables -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 +(defvar pr-txt-command nil + "Name of program for printing a text file. +See `pr-txt-printer-alist'.") - . 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 +(defvar pr-txt-switches nil + "List of sexp's to pass as extra options to the text printer program. +See `pr-txt-printer-alist'.") -DEFAULT It's a way to set default values when this entry is selected. - It's a cons like: - (VARIABLE . VALUE) +(defvar pr-txt-printer nil + "Specify text printer name. +See `pr-txt-printer-alist'.") - Which associates VARIABLE with VALUE. When this entry is - selected, it's executed the following command: - (set VARIABLE (eval VALUE)) +(defvar pr-ps-command nil + "Name of program for printing a PostScript file. +See `pr-ps-printer-alist'.") - 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. +(defvar pr-ps-switches nil + "List of sexp's to pass as extra options to the PostScript printer program. +See `pr-ps-printer-alist'.") -NOTE: Don't forget to download and install the utilities declared on - `pr-ps-utility-alist'. -Examples: +(defvar pr-ps-printer-switch nil + "Specify PostScript printer name switch. +See `pr-ps-printer-alist'.") -* 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)) - ) +(defvar pr-ps-printer nil + "Specify PostScript printer name. +See `pr-ps-printer-alist'.") -* On Windows system: - '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" - nil (pr-file-duplex . nil) (pr-file-tumble . nil)) - ) +(defvar pr-menu-bar nil + "Specify Printing menu-bar entry.") -Useful links: +(defvar pr-menu-print-item "print" + "Non-nil means that menu binding was not done. -* mpage download (GNU or Unix) - `http://www.mesa.nl/pub/mpage/' +Used by `pr-menu-bind' and `pr-update-menus'.") -* 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/' +(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.") -* psnup (PsUtils for Windows) - `http://gnuwin32.sourceforge.net/packages/psutils.htm' +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; XEmacs Definitions -* 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/' +(cond + ((featurep 'xemacs) ; XEmacs + ;; XEmacs + (defalias 'pr-f-set-keymap-parents 'set-keymap-parents) + (defalias 'pr-f-set-keymap-name 'set-keymap-name) -* 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 - :version "20" - :group 'printing) + ;; XEmacs + (defun pr-f-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) -(defcustom pr-menu-lock t - "*Non-nil means menu is locked while selecting toggle options. + ;; XEmacs + (defun pr-keep-region-active () + (setq zmacs-region-stays t)) -See also `pr-menu-char-height' and `pr-menu-char-width'." - :type 'boolean - :version "20" - :group 'printing) + ;; 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))) -(defcustom pr-menu-char-height (pr-menu-char-height) - "*Specify menu char height in pixels. + ;; XEmacs + (defun pr-menu-char-width () + (font-width (face-font 'default))) -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. + ;; 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)))) -See also `pr-menu-lock' and `pr-menu-char-width'." - :type 'integer - :version "20" - :group 'printing) + ;; 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))))) -(defcustom pr-menu-char-width (pr-menu-char-width) - "*Specify menu char width in pixels. + (defvar pr-menu-position nil) + (defvar pr-menu-state nil) -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. + ;; XEmacs + (defvar current-menubar nil) ; to avoid compilation gripes + (defun pr-menu-lookup (path) + (car (find-menu-item current-menubar (cons "Printing" path)))) -See also `pr-menu-lock' and `pr-menu-char-height'." - :type 'integer - :version "20" - :group 'printing) + ;; 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) -(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. + ;; 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") -The elements have the following form: + ;; 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)) - (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...) + ;; 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))) -Where: + ;; 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))) -SYMBOL It's a symbol to identify the setting group. + ;; 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))) -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. + ;; 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))) - Let's see an example to illustrate the inheritance mechanism: + ;; 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")))) - (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 - ))) + ;; 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))) - 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. + ) + (t ; GNU Emacs + ;; Do nothing + )) ; end cond featurep - 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. + +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; GNU Emacs Definitions -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. +(cond + ((featurep 'xemacs) ; XEmacs + ;; Do nothing + ) + (t ; GNU Emacs + ;; GNU Emacs + (defalias 'pr-f-set-keymap-parents 'set-keymap-parent) + (defalias 'pr-f-set-keymap-name 'ignore) + (defalias 'pr-f-read-string 'read-string) -SETTING It's a cons like: + ;; GNU Emacs + (defvar deactivate-mark) - (VARIABLE . VALUE) + ;; GNU Emacs + (defun pr-keep-region-active () + (setq deactivate-mark nil)) - Which associates VARIABLE with VALUE. When this entry is - selected, it's executed the following command: + ;; GNU Emacs + (defun pr-region-active-p () + (and pr-auto-region transient-mark-mode mark-active)) - * If LOCAL is non-nil: - (set (make-local-variable VARIABLE) (eval VALUE)) + ;; GNU Emacs + (defun pr-menu-char-height () + (frame-char-height)) - * If LOCAL is nil: - (set VARIABLE (eval VALUE)) + ;; GNU Emacs + (defun pr-menu-char-width () + (frame-char-width)) - 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 + ;; 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-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 - :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"))) - )) - :version "20" - :group 'printing) + (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) -(defcustom pr-visible-entry-list - '(postscript text postscript-options postscript-process printing help) - "*Specify a list of Printing menu visible entries. + ;; 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))) -Valid values with the corresponding menu parts are: + ;; 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))) - +------------------------------+ - | 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 | - +------------------------------+ + ;; 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)) -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))) - :version "20" - :group 'printing) + ;; 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) -(defcustom pr-delete-temp-file t - "*Non-nil means delete temporary files. + ;; 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))) -Set `pr-delete-temp-file' to nil, if the following message (or a similar) -happens when printing: + ;; GNU Emacs + (defun pr-menu-set-item-name (item name) + (and item + (setcar (nthcdr 2 item) name))) ; ITEM-NAME - Error: could not open \"c:\\temp\\prspool.ps\" for reading." - :type 'boolean - :version "20" - :group 'printing) + ;; 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))) -(defcustom pr-list-directory nil - "*Non-nil means list directory when processing a directory. + ;; 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")))) -That is, any subdirectories (and the superdirectory) of the directory (given as -argument of functions below) are also printed (as dired-mode listings). + ;; 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))) -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 - :version "20" - :group 'printing) + )) ; end cond featurep -(defcustom pr-buffer-name "*Printing Interface*" - "*Specify the name of the buffer interface for printing package. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Customization Functions -It's used by `pr-interface'." - :type 'string - :version "20" - :group 'printing) +(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))) -(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. +(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))) -It's used by `pr-interface'." - :type '(repeat (regexp :tag "Buffer Name Regexp")) - :version "20" - :group 'printing) +(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))) -(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 - :version "20" - :group 'printing) +(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))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Internal Variables - - -(defvar pr-txt-command nil - "Name of program for printing a text file. -See `pr-txt-printer-alist'.") +;; User Interface (I) -(defvar pr-txt-switches nil - "List of sexp's to pass as extra options to the text printer program. -See `pr-txt-printer-alist'.") +(defgroup printing nil + "Printing Utilities group." + :tag "Printing Utilities" + :link '(emacs-library-link :tag "Source Lisp File" "printing.el") + :prefix "pr-" + :version "20" + :group 'wp + :group 'postscript) -(defvar pr-txt-printer nil - "Specify text printer name. -See `pr-txt-printer-alist'.") +(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: -(defvar pr-ps-command nil - "Name of program for printing a PostScript file. -See `pr-ps-printer-alist'.") + 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)) + :version "20" + :group 'printing) -(defvar pr-ps-switches nil - "List of sexp's to pass as extra options to the PostScript printer program. -See `pr-ps-printer-alist'.") +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Internal Functions (I) -(defvar pr-ps-printer-switch nil - "Specify PostScript printer name switch. -See `pr-ps-printer-alist'.") +(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)) -(defvar pr-ps-printer nil - "Specify PostScript printer name. -See `pr-ps-printer-alist'.") +(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)) -(defvar pr-menu-bar nil - "Specify Printing menu-bar entry.") +(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))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Macros @@ -3438,12 +3456,6 @@ See `pr-ps-printer-alist'.") ))) -(defvar pr-menu-print-item "print" - "Non-nil means that menu binding was not done. - -Used by `pr-menu-bind' and `pr-update-menus'.") - - (defun pr-menu-bind () "Install `printing' menu in the menubar. @@ -5214,22 +5226,6 @@ If menu binding was not done, calls `pr-menu-bind'." (pr-do-update-menus force))) -(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"))) - - (defun pr-menu-create (name alist var-sym fun entry index) (cons name (mapcar -- cgit v1.2.1