]> code.delx.au - gnu-emacs/blobdiff - lisp/ps-print.el
(Fformat): Add comment about the treatment of 0 as a multibyte
[gnu-emacs] / lisp / ps-print.el
index 54fbf2d6c854dddccf8e54ec1529467e5665cd68..67b25b3094a4c4f204e91f585dae8d29b3c66135 100644 (file)
 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
 ;;     Vinicius Jose Latorre <vinicius@cpqd.com.br>
 ;; Keywords: wp, print, PostScript
-;; Time-stamp: <2002/09/06 20:11:00 vinicius>
-;; Version: 6.5.6
+;; Time-stamp: <2002/09/13 10:10:20 vinicius>
+;; Version: 6.5.8
 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
 
-(defconst ps-print-version "6.5.6"
-  "ps-print.el, v 6.5.6 <2002/09/06 vinicius>
+(defconst ps-print-version "6.5.8"
+  "ps-print.el, v 6.5.8 <2002/09/13 vinicius>
 
 Vinicius's last change version -- this file may have been edited as part of
 Emacs without changes to the version number.  When reporting bugs, please also
@@ -49,8 +49,8 @@ Please send all bug fixes and enhancements to
 ;;
 ;; This package provides printing of Emacs buffers on PostScript printers; the
 ;; buffer's bold and italic text attributes are preserved in the printer
-;; output.  ps-print is intended for use with Emacs or Lucid Emacs, together
-;; with a fontifying package such as font-lock or hilit.
+;; output.  ps-print is intended for use with Emacs or XEmacs, together with a
+;; fontifying package such as font-lock or hilit.
 ;;
 ;; ps-print uses the same face attributes defined through font-lock or hilit to
 ;; print a PostScript file, but some faces are better seeing on the screen than
@@ -1329,7 +1329,7 @@ Please send all bug fixes and enhancements to
 ;;
 ;; Faces are always treated as opaque.
 ;;
-;; Epoch and Emacs 19 not supported.  At all.
+;; Epoch, Lucid and Emacs 19 not supported.  At all.
 ;;
 ;; Fixed-pitch fonts work better for line folding, but are not required.
 ;;
@@ -1442,6 +1442,20 @@ Please send all bug fixes and enhancements to
       (error "`ps-print' requires floating point support"))
 
 
+  (defvar ps-print-emacs-type
+    (let ((case-fold-search t))
+      (cond ((string-match "XEmacs" emacs-version) 'xemacs)
+           ((string-match "Lucid" emacs-version)
+            (error "`ps-print' doesn't support Lucid"))
+           ((string-match "Epoch" emacs-version)
+            (error "`ps-print' doesn't support Epoch"))
+           (t
+            (unless (and (boundp 'emacs-major-version)
+                         (> emacs-major-version 19))
+              (error "`ps-print' only supports Emacs 20 and higher"))
+            'emacs))))
+
+
   ;; For Emacs 20.2 and the earlier version.
 
   (or (fboundp 'set-buffer-multibyte)
@@ -1510,11 +1524,26 @@ Please send all bug fixes and enhancements to
     (memq system-type '(usg-unix-v dgux hpux irix)))
 
 
-  (defvar ps-print-emacs-type
-    (cond ((string-match "XEmacs" emacs-version) 'xemacs)
-         ((string-match "Lucid" emacs-version) 'lucid)
-         ((string-match "Epoch" emacs-version) 'epoch)
-         (t 'emacs))))
+  (defun ps-xemacs-color-name (color)
+    (if (ps-x-color-specifier-p color)
+       (ps-x-color-name color)
+      color))
+
+
+  (cond ((eq ps-print-emacs-type 'emacs) ; emacs
+        (defvar mark-active nil)
+        (defun ps-mark-active-p ()
+          mark-active)
+        (defalias 'ps-face-foreground-name 'face-foreground)
+        (defalias 'ps-face-background-name 'face-background)
+        )
+       (t                              ; xemacs
+        (defalias 'ps-mark-active-p 'region-active-p)
+        (defun ps-face-foreground-name (face)
+          (ps-xemacs-color-name (face-foreground face)))
+        (defun ps-face-background-name (face)
+          (ps-xemacs-color-name (face-background face)))
+        )))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2866,9 +2895,7 @@ uses the fonts resident in your printer."
 ;;                widget to work.
 ;;;###autoload
 (defcustom ps-print-color-p
-  (or (and (fboundp 'color-values)     ; Emacs
-          (ps-e-color-values "Green"))
-      (fboundp 'x-color-values)                ; Emacs
+  (or (fboundp 'x-color-values)                ; Emacs
       (fboundp 'color-instance-rgb-components))
                                        ; XEmacs
   "*Specify how buffer's text color is printed.
@@ -2890,7 +2917,8 @@ Any other value is treated as t."
                 (const :tag "Print Black/White Color" black-white))
   :group 'ps-print-color)
 
-(defcustom ps-default-fg '(0.0 0.0 0.0)
+(defcustom ps-default-fg (or (ps-face-foreground-name 'default)
+                            '(0.0 0.0 0.0)) ; black
   "*RGB values of the default foreground color.  Defaults to black."
   :type '(choice :menu-tag "Default Foreground Gray/Color"
                 :tag "Default Foreground Gray/Color"
@@ -2902,7 +2930,8 @@ Any other value is treated as t."
                       (number :tag "Blue")))
   :group 'ps-print-color)
 
-(defcustom ps-default-bg '(1.0 1.0 1.0)
+(defcustom ps-default-bg (or (ps-face-background-name 'default)
+                            '(1.0 1.0 1.0)) ; white
   "*RGB values of the default background color.  Defaults to white."
   :type '(choice :menu-tag "Default Background Gray/Color"
                 :tag "Default Background Gray/Color"
@@ -3152,13 +3181,13 @@ It's like the very first character of buffer (or region) is ^L (\\014)."
   (or (cond
        ((eq ps-print-emacs-type 'emacs)        ; emacs
        data-directory)
-       ((fboundp 'locate-data-directory) ; emacsens (xemacs, etc.)
+       ((fboundp 'locate-data-directory) ; xemacs
        (locate-data-directory "ps-print"))
-       ((boundp 'data-directory)       ; emacsens (xemacs, etc.)
+       ((boundp 'data-directory)       ; xemacs
        data-directory)
        (t                              ; don't know what to do
        nil))
-      (error "ps-postscript-code-directory isn't set properly"))
+      (error "`ps-postscript-code-directory' isn't set properly"))
   "*Directory where it's located the PostScript prologue file used by ps-print.
 By default, this directory is the same as in the variable `data-directory'."
   :type 'directory
@@ -3617,13 +3646,11 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'."
 
 
 (eval-and-compile
-  (if (memq ps-print-emacs-type '(lucid xemacs))
-      ;; XEmacs change: Need to check for emacs-major-version too.
-      (if (or (< emacs-major-version 19)
-             (and (= emacs-major-version 19) (< emacs-minor-version 12)))
-         (setq ps-print-color-p nil))
-    (require 'faces))                  ; face-font, face-underline-p,
-                                       ; x-font-regexp
+  (and (eq ps-print-emacs-type 'xemacs)
+       ;; XEmacs change: Need to check for emacs-major-version too.
+       (or (< emacs-major-version 19)
+          (and (= emacs-major-version 19) (< emacs-minor-version 12)))
+       (setq ps-print-color-p nil))
 
 
   ;; Return t if the device (which can be changed during an emacs session)
@@ -3664,11 +3691,6 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'."
           (case-fold-search t))
       (and kind-spec (string-match kind-regex kind-spec))))
 
-  (defun ps-xemacs-color-name (color)
-    (if (ps-x-color-specifier-p color)
-       (ps-x-color-name color)
-      color))
-
   (cond ((eq ps-print-emacs-type 'emacs) ; emacs
 
         (defun ps-color-values (x-color)
@@ -3680,9 +3702,6 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'."
            (t
             (error "No available function to determine X color values"))))
 
-        (defalias 'ps-face-foreground-name 'face-foreground)
-        (defalias 'ps-face-background-name 'face-background)
-
         (defun ps-face-bold-p (face)
           (or (ps-e-face-bold-p face)
               (memq face ps-bold-faces)))
@@ -3691,9 +3710,8 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'."
           (or (ps-e-face-italic-p face)
               (memq face ps-italic-faces)))
         )
-                                       ; xemacs
-                                       ; lucid
-       (t                              ; epoch
+
+       (t                              ; xemacs
 
         ;; to avoid XEmacs compilation gripes
         (defvar coding-system-for-write   nil)
@@ -3718,12 +3736,6 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'."
              (t
               (error "No available function to determine X color values")))))
 
-        (defun ps-face-foreground-name (face)
-          (ps-xemacs-color-name (face-foreground face)))
-
-        (defun ps-face-background-name (face)
-          (ps-xemacs-color-name (face-background face)))
-
         (defun ps-face-bold-p (face)
           (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
               (memq face ps-bold-faces))) ; Kludge-compatible
@@ -3821,7 +3833,7 @@ Note: No major/minor-mode is activated and no local variables are evaluated for
       ;; PostScript output.
       "%0.3f %0.3f %0.3f"
 
-    ;; Lucid emacsen will have to make do with %s (princ) for floats.
+    ;; XEmacs will have to make do with %s (princ) for floats.
     "%s %s %s"))
 
 ;; These values determine how much print-height to deduct when headers/footers
@@ -4430,10 +4442,7 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
 
 
 (defun ps-print-preprint-region (prefix-arg)
-  (or (and (fboundp 'mark-active)
-          (mark-active))
-      (and (fboundp 'region-active-p)
-          (region-active-p))
+  (or (ps-mark-active-p)
       (error "The mark is not set now"))
   (list (point) (mark) (ps-print-preprint prefix-arg)))
 
@@ -4685,11 +4694,11 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
 
 ;; Emacs understands the %f format; we'll use it to limit color RGB values
 ;; to three decimals to cut down some on the size of the PostScript output.
-;; Lucid emacsen will have to make do with %s (princ) for floats.
+;; XEmacs will have to make do with %s (princ) for floats.
 
 (defvar ps-float-format (if (eq ps-print-emacs-type 'emacs)
                            "%0.3f "    ; emacs
-                         "%s "))       ; Lucid emacsen
+                         "%s "))       ; xemacs
 
 
 (defun ps-float-format (value &optional default)
@@ -6179,7 +6188,7 @@ If FACE is not a valid face name, it is used default face."
     (let ((face 'default)
          (position to))
       (cond
-       ((memq ps-print-emacs-type '(xemacs lucid))
+       ((eq ps-print-emacs-type 'xemacs)
        ;; Build the list of extents...
        (let ((a (cons 'dummy nil))
              record type extent extent-list)