;;; printing.el --- printing utilities
-;; Copyright (C) 2000, 2001, 2003, 2004, 2005,
-;; 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2001, 2003-2011 Free Software Foundation, Inc.
;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
(require 'easymenu)) ; to avoid compilation gripes
(eval-and-compile
- (cond
- ;; GNU Emacs 20
- ((< emacs-major-version 21)
- (defun pr-global-menubar (pr-menu-spec)
- (require 'easymenu)
- (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item)
- (when pr-menu-print-item
- (easy-menu-remove-item nil '("tools") pr-menu-print-item)
- (setq pr-menu-print-item nil
- pr-menu-bar (vector 'menu-bar 'tools
- (pr-get-symbol "Printing")))))
- )
- ;; GNU Emacs 21 & 22
- (t
(defun pr-global-menubar (pr-menu-spec)
(require 'easymenu)
(let ((menu-file (if (= emacs-major-version 21)
(t
(easy-menu-add-item global-map menu-file
(easy-menu-create-menu "Print" pr-menu-spec)))
- )))
- )))
+ ))))
(eval-and-compile
(cond
ps-windows-system)
'windows
'unix)
- "*Specify which path style to use for external commands.
+ "Specify which path style to use for external commands.
Valid values are:
'((unix PATH)
(cygwin PATH)
(windows PATH))
- "*Specify an alist for command paths.
+ "Specify an alist for command paths.
It's used to find commands used for printing package, like gv, gs, gsview.exe,
mpage, print.exe, etc. See also `pr-command' function.
(defcustom pr-txt-name 'default
- "*Specify a printer for printing a text file.
+ "Specify a printer for printing a text file.
The printer name symbol should be defined on `pr-txt-printer-alist' (see it for
documentation).
;; (PRN "" nil "PRN")
;; (standard "redpr.exe" nil "")
;; )
- "*Specify an alist of all text printers (text printer database).
+ "Specify an alist of all text printers (text printer database).
The alist element has the form:
(defcustom pr-ps-name 'default
- "*Specify a printer for printing a PostScript file.
+ "Specify a printer for printing a PostScript file.
This printer name symbol should be defined on `pr-ps-printer-alist' (see it for
documentation).
;; (PRN "" nil "" "PRN")
;; (standard "redpr.exe" nil "" "")
;; )
- "*Specify an alist for all PostScript printers (PostScript printer database).
+ "Specify an alist for all PostScript printers (PostScript printer database).
The alist element has the form:
(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.
+ "Specify a directory for temporary files during printing.
See also `pr-ps-temp-file' and `pr-file-modes'."
:type '(directory :tag "Temporary Directory")
(defcustom pr-ps-temp-file "prspool-"
- "*Specify PostScript temporary file name prefix.
+ "Specify PostScript temporary file name prefix.
See also `pr-temp-dir' and `pr-file-modes'."
:type '(file :tag "PostScript Temporary File Name")
;; 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.
+ "Specify the file permission bits for newly created files.
It should be an integer; only the low 9 bits are used.
(if ps-windows-system
"gsview32.exe"
"gv")
- "*Specify path and name of the gsview/gv utility.
+ "Specify path and name of the gsview/gv utility.
See also `pr-path-alist'.
(if ps-windows-system
"gswin32.exe"
"gs")
- "*Specify path and name of the ghostscript utility.
+ "Specify path and name of the ghostscript utility.
See also `pr-path-alist'.
(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.
+ "Specify ghostscript switches. See the documentation on GS for more info.
It's a list of strings, where each string is one or more ghostscript switches.
(if ps-windows-system
"mswinpr2"
"uniprint")
- "*Specify the ghostscript device switch value (-sDEVICE=).
+ "Specify the ghostscript device switch value (-sDEVICE=).
A note on the gs switches:
(defcustom pr-gs-resolution 300
- "*Specify ghostscript resolution switch value (-r).
+ "Specify ghostscript resolution switch value (-r).
A note on the gs switches:
(defcustom pr-print-using-ghostscript nil
- "*Non-nil means print using ghostscript.
+ "Non-nil means print using ghostscript.
This is useful if you don't have a PostScript printer, so you could use the
ghostscript to print a PostScript file.
(defcustom pr-faces-p nil
- "*Non-nil means print with face attributes."
+ "Non-nil means print with face attributes."
:type 'boolean
:group 'printing)
(defcustom pr-spool-p nil
- "*Non-nil means spool printing in a buffer."
+ "Non-nil means spool printing in a buffer."
:type 'boolean
:group 'printing)
(defcustom pr-file-landscape nil
- "*Non-nil means print PostScript file in landscape orientation."
+ "Non-nil means print PostScript file in landscape orientation."
:type 'boolean
:group 'printing)
(defcustom pr-file-duplex nil
- "*Non-nil means print PostScript file in duplex mode."
+ "Non-nil means print PostScript file in duplex mode."
:type 'boolean
:group 'printing)
(defcustom pr-file-tumble nil
- "*Non-nil means print PostScript file in tumble mode.
+ "Non-nil means print PostScript file in tumble mode.
If tumble is off, produces a printing suitable for binding on the left or
right.
(defcustom pr-auto-region t
- "*Non-nil means region is automagically detected.
+ "Non-nil means region is automagically detected.
Note that this will only work if you're using transient mark mode.
(defcustom pr-auto-mode t
- "*Non-nil means major-mode specific printing is prefered over normal printing.
+ "Non-nil means major-mode specific printing is prefered over normal printing.
That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*'
and `*-region*' commands will behave like `*-mode*' commands; otherwise,
nil
)
)
- "*Specify an alist for a major-mode and printing functions.
+ "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
(defcustom pr-ps-utility 'mpage
- "*Specify PostScript utility symbol.
+ "Specify PostScript utility symbol.
This utility symbol should be defined on `pr-ps-utility-alist' (see it for
documentation).
;; '((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).
+ "Specify an alist for PostScript utility processing (PS utility database).
The alist element has the form:
(defcustom pr-menu-lock t
- "*Non-nil means menu is locked while selecting toggle options.
+ "Non-nil means menu is locked while selecting toggle options.
See also `pr-menu-char-height' and `pr-menu-char-width'."
:type 'boolean
(defcustom pr-menu-char-height (pr-menu-char-height)
- "*Specify menu char height in pixels.
+ "Specify menu char height in pixels.
This variable is used to guess which vertical position should be locked the
menu, so don't forget to adjust it if menu position is not ok.
(defcustom pr-menu-char-width (pr-menu-char-width)
- "*Specify menu char width in pixels.
+ "Specify menu char width in pixels.
This variable is used to guess which horizontal position should be locked the
menu, so don't forget to adjust it if menu position is not ok.
(pr-file-duplex . nil) ; settings
(pr-file-tumble . nil))
)
- "*Specify an alist for settings in general.
+ "Specify an alist for settings in general.
The elements have the following form:
(defcustom pr-visible-entry-list
'(postscript text postscript-options postscript-process printing help)
- "*Specify a list of Printing menu visible entries.
+ "Specify a list of Printing menu visible entries.
Valid values with the corresponding menu parts are:
(defcustom pr-delete-temp-file t
- "*Non-nil means delete temporary files.
+ "Non-nil means delete temporary files.
Set `pr-delete-temp-file' to nil, if the following message (or a similar)
happens when printing:
(defcustom pr-list-directory nil
- "*Non-nil means list directory when processing a directory.
+ "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).
(defcustom pr-buffer-name "*Printing Interface*"
- "*Specify the name of the buffer interface for printing package.
+ "Specify the name of the buffer interface for printing package.
It's used by `pr-interface'."
:type 'string
(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.
+ "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.
(defcustom pr-buffer-verbose t
- "*Non-nil means to be verbose when editing a field in interface buffer.
+ "Non-nil means to be verbose when editing a field in interface buffer.
It's used by `pr-interface'."
:type 'boolean
(defun pr-menu-bind ()
"Install `printing' menu in the menubar.
-
-On Emacs 20, it replaces the Tools/Print menu by Tools/Printing menu.
-
-On Emacs 21 and 22, it replaces the File/Print* menu entries by File/Print
-menu.
-
+This replaces the File/Print* menu entries with a File/Print sub-menu.
Calls `pr-update-menus' to adjust menus."
(interactive)
(pr-global-menubar pr-menu-spec)
For more information, type \\[pr-interface-help]."
(interactive)
- (save-excursion
- (set-buffer (or buffer (current-buffer)))
+ (with-current-buffer (or buffer (current-buffer))
(pr-create-interface)))
(if (string= pr-ps-command "")
;; default action
(let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
- (save-excursion
- (set-buffer ps-spool-buffer)
+ (with-current-buffer ps-spool-buffer
(erase-buffer)
(insert-file-contents-literally file))
(pr-despool-print))
;;;###autoload
(defun pr-toggle-region ()
- "Toggle auto region."
+ "Toggle whether the region is automagically detected."
(interactive)
(pr-toggle-region-menu t))
"Interactively select a PostScript utility."
(interactive)
(pr-menu-set-utility-title
- (pr-complete-alist "Postscript utility"
+ (pr-complete-alist "PostScript utility"
pr-ps-utility-alist pr-ps-utility)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>)
-
-(defalias 'pr-mh-get-msg-num 'mh-get-msg-num)
-(defalias 'pr-mh-show 'mh-show)
-(defalias 'pr-mh-start-of-uncleaned-message 'mh-start-of-uncleaned-message)
-(defvar mh-show-buffer nil)
+(declare-function mh-get-msg-num "mh-utils" (error-if-no-message))
+(declare-function mh-show "mh-show" (&optional message redisplay-flag))
+(declare-function mh-start-of-uncleaned-message "mh-show" ())
+(defvar mh-show-buffer)
(defun pr-article-date ()
(defun pr-mh-current-message ()
"Go to mh-inbox current message."
- (let ((msg (or (pr-mh-get-msg-num nil) 0)))
- (pr-mh-show)
+ (let ((msg (or (mh-get-msg-num nil) 0)))
+ (mh-show)
(set-buffer mh-show-buffer)
(goto-char (point-min))
- (pr-mh-start-of-uncleaned-message)
+ (mh-start-of-uncleaned-message)
(message "Printing message %d" msg)))
(symbol-value summary-buffer))
(symbol-value summary-default))))
(and (get-buffer buf)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(pr-mode-print n-up filename header-list)))))
(symbol-value summary-buffer))
(symbol-value summary-default))))
(and (get-buffer buf)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(pr-mode-lpr header-list)))))
(defun pr-toggle-file-duplex-menu (&optional no-menu)
+ "Toggle whether to print PostScript files in duplex mode."
(interactive)
(pr-toggle 'pr-file-duplex "PS file duplex" nil 7 5 nil
'("PostScript Print" "File") no-menu))
(defun pr-toggle-file-tumble-menu (&optional no-menu)
+ "Toggle whether to print PostScript files in tumble mode."
(interactive)
(pr-toggle 'pr-file-tumble "PS file tumble" nil 8 5 nil
'("PostScript Print" "File") no-menu))
(defun pr-toggle-file-landscape-menu (&optional no-menu)
+ "Toggle whether to print PostScript files in landscape orientation."
(interactive)
(pr-toggle 'pr-file-landscape "PS file landscape" nil 6 5 nil
'("PostScript Print" "File") no-menu))
(defun pr-toggle-ghostscript-menu (&optional no-menu)
+ "Toggle whether to print using ghostscript."
(interactive)
(pr-toggle 'pr-print-using-ghostscript "Printing using ghostscript"
'postscript-process 2 12 'toggle nil no-menu))
(defun pr-toggle-faces-menu (&optional no-menu)
+ "Toggle whether to print with face attributes."
(interactive)
(pr-toggle 'pr-faces-p "Printing with faces"
'postscript-process 1 12 'toggle nil no-menu))
(defun pr-toggle-spool-menu (&optional no-menu)
+ "Toggle whether to spool printing in a buffer."
(interactive)
(pr-toggle 'pr-spool-p "Spooling printing"
'postscript-process 0 12 'toggle nil no-menu))
(defun pr-toggle-duplex-menu (&optional no-menu)
+ "Toggle whether to generate PostScript for a two-sided printer."
(interactive)
(pr-toggle 'ps-spool-duplex "Printing duplex"
'postscript-options 5 12 'toggle nil no-menu))
(defun pr-toggle-tumble-menu (&optional no-menu)
+ "Toggle how pages on opposite sides of a sheet are oriented."
(interactive)
(pr-toggle 'ps-spool-tumble "Tumble"
'postscript-options 6 12 'toggle nil no-menu))
(defun pr-toggle-landscape-menu (&optional no-menu)
+ "Toggle whether to print in landscape mode."
(interactive)
(pr-toggle 'ps-landscape-mode "Landscape"
'postscript-options 0 12 'toggle nil no-menu))
(defun pr-toggle-upside-down-menu (&optional no-menu)
+ "Toggle whether to print upside-down (that is, rotated by 180 degrees)."
(interactive)
(pr-toggle 'ps-print-upside-down "Upside-Down"
'postscript-options 7 12 'toggle nil no-menu))
(defun pr-toggle-line-menu (&optional no-menu)
+ "Toggle whether to means print line numbers."
(interactive)
(pr-toggle 'ps-line-number "Line number"
'postscript-options 3 12 'toggle nil no-menu))
(defun pr-toggle-zebra-menu (&optional no-menu)
+ "Toggle whether to print zebra stripes."
(interactive)
(pr-toggle 'ps-zebra-stripes "Zebra stripe"
'postscript-options 4 12 'toggle nil no-menu))
(defun pr-toggle-header-menu (&optional no-menu)
+ "Toggle whether to print a header at the top of each page."
(interactive)
(pr-toggle 'ps-print-header "Print header"
'postscript-options 1 12 'toggle nil no-menu))
(defun pr-toggle-header-frame-menu (&optional no-menu)
+ "Toggle whether to draw a gaudy frame around the header."
(interactive)
(pr-toggle 'ps-print-header-frame "Print header frame"
'postscript-options 2 12 'toggle nil no-menu))
(defun pr-toggle-lock-menu (&optional no-menu)
+ "Toggle whether the menu is locked while selecting toggle options."
(interactive)
(pr-toggle 'pr-menu-lock "Menu lock"
'printing 2 12 'toggle nil no-menu))
(defun pr-toggle-region-menu (&optional no-menu)
+ "Toggle whether the region is automagically detected."
(interactive)
(pr-toggle 'pr-auto-region "Auto region"
'printing 0 12 'toggle nil no-menu))
(defun pr-toggle-mode-menu (&optional no-menu)
+ "Toggle whether major-mode specific printing is prefered over normal printing."
(interactive)
(pr-toggle 'pr-auto-mode "Auto mode"
'printing 1 12 'toggle nil no-menu))
(defun pr-show-setup (settings buffer-name)
(with-output-to-temp-buffer buffer-name
(princ settings)
- (print-help-return-message)))
+ (help-print-return-message)))
(defun pr-complete-alist (prompt alist default)
status)
(setq args (pr-remove-nil-from-list args))
;; *Printing Command Output* == show command & args
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(goto-char (point-max))
(insert (format "%s %S\n" cmd args)))
;; *Printing Command Output* == show any return message from command
((quit error)
(error-message-string data)))))
;; *Printing Command Output* == show exit status
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(goto-char (point-max))
(insert (format "Exit status: %s\n\n" status)))
;; message if error status
(let* ((dir-name (file-name-directory (or (buffer-file-name)
default-directory)))
(fmt-prompt (concat "%s[" mess "] Directory to print: "))
- (dir (read-file-name (format fmt-prompt "")
- "" dir-name nil dir-name))
+ (dir (read-directory-name (format fmt-prompt "")
+ "" dir-name nil dir-name))
prompt)
(while (cond ((not (file-directory-p dir))
(ding)
(setq prompt "Directory is unreadable! "))
(t nil))
(setq dir-name (file-name-directory dir)
- dir (read-file-name (format fmt-prompt prompt)
- "" dir-name nil dir-name)))
+ dir (read-directory-name (format fmt-prompt prompt)
+ "" dir-name nil dir-name)))
(file-name-as-directory dir)))
(blist (buffer-list))
found)
(while (and (not found) blist)
- (save-excursion
- (set-buffer (car blist))
+ (with-current-buffer (car blist)
(and (eq major-mode 'dired-mode)
(save-excursion
(goto-char (point-min))
pop-up-frames)
(and (or buffer
(file-readable-p file))
- (save-excursion
- (set-buffer (or buffer
- (find-file-noselect file)))
+ (with-current-buffer (or buffer
+ (find-file-noselect file))
(funcall fun)
(or buffer
(kill-buffer (current-buffer))))))))
(defmacro pr-interface-save (&rest body)
- `(save-excursion
- (set-buffer pr-i-buffer)
+ `(with-current-buffer pr-i-buffer
,@body))
(provide 'printing)
-;; arch-tag: 9ce9ac3f-0f60-4370-900b-1943215d9d18
;;; printing.el ends here