]> code.delx.au - gnu-emacs/blobdiff - lisp/printing.el
Merge Org 7.9.3e (commit b07a9bb).
[gnu-emacs] / lisp / printing.el
index 887668901c73787d19e398e0c4f8c04a81aad2a9..9d7efad83b42d53c9b6733016a2b357aa8be5ec8 100644 (file)
@@ -1,7 +1,6 @@
 ;;; printing.el --- printing utilities
 
-;; Copyright (C) 2000, 2001, 2003, 2004, 2005,
-;;   2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2001, 2003-2013 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
@@ -140,10 +139,9 @@ Please send all bug fixes and enhancements to
 ;;
 ;; One way to set variables is by calling `pr-customize', customize all
 ;; variables and save the customization by future sessions (see Options
-;; section).  Other way is by coding your settings on Emacs init file (that is,
-;; ~/.emacs file), see below for a first setting template that it should be
-;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT
-;; or MS-DOS):
+;; section).  Other way is by adding code to your init file; see below
+;; for a first setting template that it should be inserted on your
+;; init file:
 ;;
 ;; * Example of setting for Windows system:
 ;;
@@ -298,8 +296,7 @@ Please send all bug fixes and enhancements to
 ;; Using `printing'
 ;; ----------------
 ;;
-;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're
-;; using Windows 9x/NT or MS-DOS):
+;; To use `printing' insert in your init file:
 ;;
 ;;    (require 'printing)
 ;;    ;; ...some user settings...
@@ -548,7 +545,7 @@ Please send all bug fixes and enhancements to
 ;; `pr-auto-region'            Non-nil means region is automagically detected.
 ;;
 ;; `pr-auto-mode'              Non-nil means major-mode specific printing is
-;;                             prefered over normal printing.
+;;                             preferred over normal printing.
 ;;
 ;; `pr-mode-alist'             Specify an alist for a major-mode and printing
 ;;                             function.
@@ -1387,20 +1384,6 @@ Used by `pr-menu-bind' and `pr-update-menus'.")
     (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)
@@ -1422,8 +1405,7 @@ Used by `pr-menu-bind' and `pr-update-menus'.")
           (t
            (easy-menu-add-item global-map menu-file
                                (easy-menu-create-menu "Print" pr-menu-spec)))
-          )))
-      )))
+          ))))
 
   (eval-and-compile
     (cond
@@ -2157,7 +2139,7 @@ Useful links:
   `http://bama.ua.edu/cgi-bin/man-cgi?lp'
   `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp'
 
-* GNU utilities for Win32 (cp.exe)
+* GNU utilities for w32 (cp.exe)
   `http://unxutils.sourceforge.net/'
 "
   :type '(repeat
@@ -2442,7 +2424,7 @@ marked instead of all buffer."
 
 
 (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 preferred 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,
@@ -2552,7 +2534,7 @@ LPR-PRINT It's a symbol function for text printing.  It's invoked with
                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:
+               with three arguments: n-up printing, file name and the list:
                (HEADER-LINES  LEFT-HEADER  RIGHT-HEADER DEFAULT...).
 
                Usually PS-PRINT function prepares the environment or buffer
@@ -3453,12 +3435,7 @@ See `pr-ps-printer-alist'.")
 
 (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)
@@ -3713,7 +3690,7 @@ VI. Customization:
          "\n\n
 The printing interface buffer has the same functionality as the printing menu.
 The major difference is that the states (like sending PostScript generated to a
-file, n-up printing, etc.) are set and saved between priting buffer
+file, n-up printing, etc.) are set and saved between printing buffer
 activation.  Also, the landscape, duplex and tumble values are the same for
 PostScript file and directory/buffer/region/mode processing; using menu, there
 are different value sets for PostScript file and directory/buffer/region/mode
@@ -3953,8 +3930,7 @@ If BUFFER is nil, the current buffer is used for printing.
 
 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)))
 
 
@@ -4457,8 +4433,7 @@ image in a file with that name."
         (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))
@@ -4634,7 +4609,7 @@ bottom."
 
 ;;;###autoload
 (defun pr-toggle-region ()
-  "Toggle auto region."
+  "Toggle whether the region is automagically detected."
   (interactive)
   (pr-toggle-region-menu t))
 
@@ -4690,7 +4665,7 @@ bottom."
   "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)))
 
 
@@ -4733,12 +4708,12 @@ Interactively, you have the following situations:
 
    M-x pr-ps-fast-fire RET
       The command prompts the user for a N-UP value and printing will
-      immediatelly be done using the current active printer.
+      immediately be done using the current active printer.
 
    C-u   M-x pr-ps-fast-fire RET
    C-u 0 M-x pr-ps-fast-fire RET
       The command prompts the user for a N-UP value and also for a current
-      PostScript printer, then printing will immediatelly be done using the new
+      PostScript printer, then printing will immediately be done using the new
       current active printer.
 
    C-u 1 M-x pr-ps-fast-fire RET
@@ -4759,7 +4734,7 @@ zero and the argument SELECT is treated as follows:
    If it's nil, send the image to the printer.
 
    If it's a list or an integer lesser or equal to zero, the command prompts
-   the user for a current PostScript printer, then printing will immediatelly
+   the user for a current PostScript printer, then printing will immediately
    be done using the new current active printer.
 
    If it's an integer equal to 1, the command prompts the user for a file name
@@ -4772,7 +4747,7 @@ zero and the argument SELECT is treated as follows:
    instead of sending it to the printer.
 
    If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new
-   active printer and printing will immediatelly be done using the new active
+   active printer and printing will immediately be done using the new active
    printer.
 
    Otherwise, send the image to the printer.
@@ -4823,7 +4798,7 @@ Noninteractively, the argument SELECT-PRINTER is treated as follows:
    If it's nil, the printing is sent to the current active text printer.
 
    If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new
-   active printer and printing will immediatelly be done using the new active
+   active printer and printing will immediately be done using the new active
    printer.
 
    If it's non-nil, the command prompts the user for a new active text printer.
@@ -4956,11 +4931,10 @@ Or choose the menu option Printing/Show Settings/lpr."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; 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 ()
@@ -4976,11 +4950,11 @@ Return only the dayname, if present, weekday, month, and year."
 
 (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)))
 
 
@@ -5029,8 +5003,7 @@ Return only the dayname, if present, weekday, month, and year."
                      (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)))))
 
 
@@ -5040,8 +5013,7 @@ Return only the dayname, if present, weekday, month, and year."
                      (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)))))
 
 
@@ -5372,102 +5344,119 @@ If menu binding was not done, calls `pr-menu-bind'."
 
 
 (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 preferred over normal printing."
   (interactive)
   (pr-toggle 'pr-auto-mode "Auto mode"
             'printing 1 12 'toggle nil no-menu))
@@ -5507,7 +5496,7 @@ If menu binding was not done, calls `pr-menu-bind'."
 (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)
@@ -5634,8 +5623,7 @@ If menu binding was not done, calls `pr-menu-bind'."
        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
@@ -5646,8 +5634,7 @@ If menu binding was not done, calls `pr-menu-bind'."
             ((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
@@ -5735,8 +5722,8 @@ If menu binding was not done, calls `pr-menu-bind'."
   (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)
@@ -5746,8 +5733,8 @@ If menu binding was not done, calls `pr-menu-bind'."
                  (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)))
 
 
@@ -5840,8 +5827,7 @@ If menu binding was not done, calls `pr-menu-bind'."
          (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))
@@ -5865,9 +5851,8 @@ If menu binding was not done, calls `pr-menu-bind'."
                         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))))))))
@@ -6048,8 +6033,7 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
 
 
 (defmacro pr-interface-save (&rest body)
-  `(save-excursion
-     (set-buffer pr-i-buffer)
+  `(with-current-buffer pr-i-buffer
      ,@body))
 
 
@@ -6695,5 +6679,4 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
 (provide 'printing)
 
 
-;; arch-tag: 9ce9ac3f-0f60-4370-900b-1943215d9d18
 ;;; printing.el ends here