]> code.delx.au - gnu-emacs/blobdiff - lisp/printing.el
Update GPL version for Emacs images.
[gnu-emacs] / lisp / printing.el
index 2dbe460c0cc4495e135e966efccd31cef4031b26..412f0b342fc99aa31ec5aa59470e776269ff7aac 100644 (file)
@@ -1,14 +1,13 @@
 ;;; printing.el --- printing utilities
 
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2003, 2004, 2005,
+;;   2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2005/06/11 19:51:32 vinicius>
 ;; Keywords: wp, print, PostScript
 ;; Version: 6.8.4
-;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
+;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
 
 (defconst pr-version "6.8.4"
   "printing.el, v 6.8.4 <2005/06/11 vinicius>
@@ -21,7 +20,7 @@ Please send all bug fixes and enhancements to
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify it under
 ;; the terms of the GNU General Public License as published by the Free
-;; Software Foundation; either version 2, or (at your option) any later
+;; Software Foundation; either version 3, or (at your option) any later
 ;; version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -31,7 +30,7 @@ Please send all bug fixes and enhancements to
 
 ;; You should have received a copy of the GNU General Public License along with
 ;; GNU Emacs; see the file COPYING.  If not, write to the Free Software
-;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -68,7 +67,7 @@ Please send all bug fixes and enhancements to
 ;; interface to ps-print package and it also provides some extra stuff.
 ;;
 ;; To download the latest ps-print package see
-;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'.
+;; `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'.
 ;; Please, see README file for ps-print installation instructions.
 ;;
 ;; `printing' was inspired on:
@@ -958,8 +957,8 @@ Please send all bug fixes and enhancements to
 ;;
 ;; * For `printing' package:
 ;;
-;;    printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz'
-;;    ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'
+;;    printing `http://www.emacswiki.org/cgi-bin/emacs/download/printing.el'
+;;    ps-print `http://www.emacswiki.org/cgi-bin/wiki/PsPrintPackage'
 ;;
 ;; * For GNU or Unix system:
 ;;
@@ -1043,12 +1042,6 @@ Please send all bug fixes and enhancements to
 ;; To avoid compilation gripes
 
 
-(or (fboundp 'easy-menu-intern)                ; hacked from easymenu.el
-    (defsubst easy-menu-intern (s)
-      (if (stringp s) (intern s) s)))
-
-
-
 (or (fboundp 'subst-char-in-string)    ; hacked from subr.el
     (defun subst-char-in-string (fromchar tochar string &optional inplace)
       "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
@@ -2804,8 +2797,10 @@ See `pr-ps-printer-alist'.")
   (and pr-print-using-ghostscript (not pr-spool-p)))
 
 
-(defun pr-get-symbol (name)
-  (easy-menu-intern name))
+(defalias 'pr-get-symbol
+  (if (fboundp 'easy-menu-intern)      ; hacked from easymenu.el
+      'easy-menu-intern
+    (lambda (s) (if (stringp s) (intern s) s))))
 
 (cond
  ((featurep 'xemacs)                   ; XEmacs
@@ -3091,7 +3086,7 @@ Calls `pr-update-menus' to adjust menus."
     ;; third... time, but "print" item exists only in the first load.
     (cond
      ;; Emacs 20
-     ((string< emacs-version "21.")
+     ((< emacs-major-version 21)
       (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)
@@ -3100,23 +3095,26 @@ Calls `pr-update-menus' to adjust menus."
                                  (pr-get-symbol "Printing")))))
      ;; Emacs 21 & 22
      (t
-      (let* ((has-file  (lookup-key global-map (vector 'menu-bar 'file)))
-            (item-file (if has-file '("file") '("files"))))
+      (let ((menu-file (if (= emacs-major-version 21)
+                          '("menu-bar" "files") ; Emacs 21
+                        '("menu-bar" "file")))) ; Emacs 22 or higher
        (cond
         (pr-menu-print-item
-         (easy-menu-change item-file "Print" pr-menu-spec "print-buffer")
-         (let ((items '("print-buffer"          "print-region"
-                        "ps-print-buffer-faces" "ps-print-region-faces"
-                        "ps-print-buffer"       "ps-print-region")))
-           (while items
-             (easy-menu-remove-item nil item-file (car items))
-             (setq items (cdr items)))
-           (setq pr-menu-print-item nil
-                 pr-menu-bar (vector 'menu-bar
-                                     (if has-file 'file 'files)
-                                     (pr-get-symbol "Print")))))
+         (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-change item-file "Print" pr-menu-spec))))))))
+         (easy-menu-add-item global-map menu-file
+                             (easy-menu-create-menu "Print" pr-menu-spec)))
+        ))))))
   (pr-update-menus t))
 
 
@@ -4404,7 +4402,7 @@ Interactively, you have the following situations:
    C-u 2 M-x pr-ps-fast-fire RET
       The command prompts the user for a N-UP value, then for a current
       PostScript printer and, finally, for a file name.  Then change the active
-      printer to that choosen by user and saves the PostScript image in
+      printer to that chosen by user and saves the PostScript image in
       that file instead of sending it to the printer.
 
 
@@ -4423,7 +4421,7 @@ zero and the argument SELECT is treated as follows:
 
    If it's an integer greater or equal to 2, the command prompts the user for a
    current PostScript printer and for a file name.  Then change the active
-   printer to that choosen by user and saves the PostScript image in that file
+   printer to that chosen by user and saves the PostScript image in that file
    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
@@ -4945,9 +4943,9 @@ See `pr-visible-entry-alist'.")
 
 If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist',
 `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not;
-otherwise, update PostScript printer menu iff `pr-ps-printer-menu-modified' is
-non-nil, update text printer menu iff `pr-txt-printer-menu-modified' is
-non-nil, and update PostScript File menus iff `pr-ps-utility-menu-modified' is
+otherwise, update PostScript printer menu if `pr-ps-printer-menu-modified' is
+non-nil, update text printer menu if `pr-txt-printer-menu-modified' is
+non-nil, and update PostScript File menus if `pr-ps-utility-menu-modified' is
 non-nil.
 
 If menu binding was not done, calls `pr-menu-bind'."
@@ -5705,7 +5703,7 @@ If menu binding was not done, calls `pr-menu-bind'."
 (defun pr-interactive-n-up (mess)
   (or (stringp mess) (setq mess "*"))
   (save-match-data
-    (let* ((fmt-prompt "%s[%s] N-up printing: (default 1) ")
+    (let* ((fmt-prompt "%s[%s] N-up printing (default 1): ")
           (prompt "")
           (str (pr-f-read-string (format fmt-prompt prompt mess) "1" nil "1"))
           int)
@@ -6058,7 +6056,9 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
   ;; header
   (let ((versions (concat "printing v" pr-version
                          "    ps-print v" ps-print-version)))
-    (widget-insert (make-string (- 79 (length versions)) ?\s) versions))
+    ;; to keep compatibility with Emacs 20 & 21:
+    ;; DO NOT REPLACE `?\ ' BY `?\s'
+    (widget-insert (make-string (- 79 (length versions)) ?\ ) versions))
   (pr-insert-italic "\nCurrent Directory : " 1)
   (pr-insert-italic default-directory)
 
@@ -6425,7 +6425,7 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
     ;; handlers
     ((quit error)
      (ding)
-     (message (error-message-string data)))))
+     (message "%s" (error-message-string data)))))
 
 
 (defun pr-interface-printify (&rest ignore)
@@ -6450,7 +6450,7 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
     ;; handlers
     ((quit error)
      (ding)
-     (message (error-message-string data)))))
+     (message "%s" (error-message-string data)))))
 
 
 (defun pr-interface-ps-print (&rest ignore)
@@ -6516,7 +6516,7 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
     ;; handlers
     ((quit error)
      (ding)
-     (message (error-message-string data)))))
+     (message "%s" (error-message-string data)))))
 
 
 (defun pr-i-ps-send ()