*** empty log message ***
[bpt/emacs.git] / lisp / ps-print.el
index a6edc97..82c4505 100644 (file)
@@ -9,16 +9,15 @@
 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
 ;; Keywords:   wp, print, PostScript
-;; Time-stamp: <2000/04/14 11:07:23 vinicius>
-;; Version:    5.1.5
+;; Time-stamp: <2000/05/12 19:56:11 vinicius>
+;; Version:    5.2.1
 
-(defconst ps-print-version "5.1.5"
-  "ps-print.el, v 5.1.5 <2000/04/14 vinicius>
+(defconst ps-print-version "5.2.1"
+  "ps-print.el, v 5.2.1 <2000/05/12 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 report the version of Emacs, if any, that ps-print was
-distributed with.
+Emacs without changes to the version number.  When reporting bugs, please also
+report the version of Emacs, if any, that ps-print was distributed with.
 
 Please send all bug fixes and enhancements to
        Vinicius Jose Latorre <vinicius@cpqd.com.br>.
@@ -196,10 +195,10 @@ Please send all bug fixes and enhancements to
 ;; See definition of `call-process-region' for calling conventions.  The fourth
 ;; and the sixth arguments are both nil.
 ;;
-;; If you're using NTEmacs, don't forget to customize the following variables:
-;; `ps-printer-name', `ps-lpr-command', `ps-lpr-switches' and
-;; `ps-spool-config'.  See these variables documentation in the code or by
-;; typing, for example, C-h v ps-printer-name RET.
+;; If you're using Emacs for Windows 95/98/NT or MS-DOS, don't forget to
+;; customize the following variables: `ps-printer-name', `ps-lpr-command',
+;; `ps-lpr-switches' and `ps-spool-config'.  See these variables documentation
+;; in the code or by typing, for example, C-h v ps-printer-name RET.
 ;;
 ;;
 ;; The Page Layout
@@ -209,30 +208,34 @@ Please send all bug fixes and enhancements to
 ;; 1 inch  ==       2.54  cm    ==     72       points
 ;; 1 cm    ==  (/ 1 2.54) inch  ==  (/ 72 2.54) points
 ;;
-;; The variable `ps-paper-type' determines the size of paper ps-print
-;; formats for; it should contain one of the symbols:
-;; `a4' `a3' `letter' `legal' `letter-small' `tabloid'
-;; `ledger' `statement' `executive' `a4small' `b4' `b5'
+;; The variable `ps-paper-type' determines the size of paper ps-print formats
+;; for; it should contain one of the symbols: `a4' `a3' `letter' `legal'
+;; `letter-small' `tabloid' `ledger' `statement' `executive' `a4small' `b4'
+;; `b5'.
 ;;
-;; The variable `ps-landscape-mode' determines the orientation
-;; of the printing on the page:
-;; nil means `portrait' mode, non-nil means `landscape' mode.
+;; The variable `ps-landscape-mode' determines the orientation of the printing
+;; on the page: nil means `portrait' mode, non-nil means `landscape' mode.
 ;; There is no oblique mode yet, though this is easy to do in ps.
 ;;
-;; In landscape mode, the text is NOT scaled: you may print 70 lines
-;; in portrait mode and only 50 lignes in landscape mode.
-;; The margins represent margins in the printed paper:
-;; the top margin is the margin between the top of the page
+;; In landscape mode, the text is NOT scaled: you may print 70 lines in portrait
+;; mode and only 50 lines in landscape mode.  The margins represent margins in
+;; the printed paper: the top margin is the margin between the top of the page
 ;; and the printed header, whatever the orientation is.
 ;;
-;; The variable `ps-number-of-columns' determines the number of columns
-;; both in landscape and portrait mode.
+;; The variable `ps-number-of-columns' determines the number of columns both in
+;; landscape and portrait mode.
 ;; You can use:
-;; - (the standard) one column portrait mode
-;; - (my favorite) two columns landscape mode (which spares trees)
-;; but also
+;; - (the standard) one column portrait mode.
+;; - (my favorite) two columns landscape mode (which spares trees).
+;; but also:
 ;; - one column landscape mode for files with very long lines.
-;; - multi-column portrait or landscape mode
+;; - multi-column portrait or landscape mode.
+;;
+;; The variable `ps-print-upside-down' determines other orientation for printing
+;; page: nil means `normal' printing, non-nil means `upside-down' printing.  The
+;; default value is nil (`normal' printing).
+;;
+;; The `upside-down' orientation can be used in portrait or landscape mode.
 ;;
 ;;
 ;; Horizontal layout
@@ -592,6 +595,58 @@ Please send all bug fixes and enhancements to
 ;; The variable `ps-line-number' specifies whether to number each line;
 ;; non-nil means do so.  The default is nil (don't number each line).
 ;;
+;; The variable `ps-line-number-step' specifies the interval that line number is
+;; printed.  For example, if `ps-line-number-step' is set to 2, the printing
+;; will look like:
+;;
+;;    1 one line
+;;      one line
+;;    3 one line
+;;      one line
+;;    5 one line
+;;      one line
+;;      ...
+;;
+;; Valid values are:
+;;
+;; integer     an integer that specifies the interval that line number is
+;;             printed.  If it's lesser than or equal to zero, it's used the
+;;             value 1.
+;;
+;; `zebra'     specifies that only the line number of the first line in a zebra
+;;             stripe is to be printed.
+;;
+;; Any other value is treated as `zebra'.
+;; The default value is 1, so each line number is printed.
+;;
+;; The variable `ps-line-number-start' specifies the starting point in the
+;; interval given by `ps-line-number-step'.  For example, if
+;; `ps-line-number-step' is set to 3 and `ps-line-number-start' is set to 3, the
+;; printing will look like:
+;;
+;;      one line
+;;      one line
+;;    3 one line
+;;      one line
+;;      one line
+;;    6 one line
+;;      one line
+;;      one line
+;;    9 one line
+;;      one line
+;;      ...
+;;
+;; The values for `ps-line-number-start':
+;;
+;;    * If `ps-line-number-step' is an integer, must be between 1 and the value
+;;     of `ps-line-number-step' inclusive.
+;;
+;;    * If `ps-line-number-step' is set to `zebra', must be between 1 and the
+;;     value of `ps-zebra-strip-height' inclusive.
+;;
+;; The default value is 1, so the line number of the first line of each interval
+;; is printed.
+;;
 ;;
 ;; Zebra Stripes
 ;; -------------
@@ -818,6 +873,17 @@ Please send all bug fixes and enhancements to
 ;; rebuilt when ps-print is invoked, set the variable
 ;; `ps-always-build-face-reference' to t.
 ;;
+;; If you need to print without worrying about face background color, set the
+;; variable `ps-use-face-background' which specifies if face background should
+;; be used.  Valid values are:
+;;
+;;    t                always use face background color.
+;;    nil      never use face background color.
+;;    (face...)        list of faces whose background color will be used.
+;;
+;; Any other value will be treated as t.
+;; The default value is t.
+;;
 ;;
 ;; How Ps-Print Deals With Color
 ;; -----------------------------
@@ -1062,6 +1128,15 @@ Please send all bug fixes and enhancements to
 ;; Acknowledgements
 ;; ----------------
 ;;
+;; Thanks to Paul Furnanz <pfurnanz@synopsys.com> for XEmacs compatibility
+;; suggestion for `ps-postscript-code-directory' variable.
+;;
+;; Thanks to David X Callaway <dxc@xprt.net> for helping debugging PostScript
+;; level 1 compatibility.
+;;
+;; Thanks to Colin Marquardt <colin.marquardt@usa.alcatel.com> for upside-down
+;; and line number step suggestions.
+;;
 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for user defined PostScript
 ;; prologue code suggestion.
 ;;
@@ -1154,6 +1229,12 @@ Please send all bug fixes and enhancements to
        (point))))
 
 
+(defconst ps-windows-system
+  (memq system-type '(win32 w32 mswindows ms-dos windows-nt)))
+(defconst ps-lp-system
+  (memq system-type '(usq-unix-v dgux hpux irix)))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; User Variables:
 
@@ -1291,7 +1372,7 @@ For more information about PostScript, see:
    PostScript Language Reference Manual (2nd edition)
    Adobe Systems Incorporated"
   :type '(choice :tag "User Defined Prologue"
-                string symbol (const :tag "none" nil))
+                (const :tag "none" nil) string symbol)
   :group 'ps-print-miscellany)
 
 (defcustom ps-print-prologue-header nil
@@ -1319,7 +1400,7 @@ For more information about PostScript document comments, see:
    Adobe Systems Incorporated
    Appendix G: Document Structuring Conventions -- Version 3.0"
   :type '(choice :tag "Prologue Header"
-                string symbol (const :tag "none" nil))
+                (const :tag "none" nil) string symbol)
   :group 'ps-print-miscellany)
 
 (defcustom ps-printer-name (and (boundp 'printer-name)
@@ -1433,6 +1514,11 @@ example `letter', `legal' or `a4'."
   :type 'boolean
   :group 'ps-print-page)
 
+(defcustom ps-print-upside-down nil
+  "*Non-nil means print upside-down."
+  :type 'boolean
+  :group 'ps-print-page)
+
 (defcustom ps-print-control-characters 'control-8-bit
   "*Specify the printable form for control and 8-bit characters.
 That is, instead of sending, for example, a ^D (\\004) to printer,
@@ -1552,6 +1638,63 @@ See also documentation for `ps-zebra-stripes' and `ps-zebra-stripe-height'."
   :type 'boolean
   :group 'ps-print-miscellany)
 
+(defcustom ps-line-number-step 1
+  "*Specify the interval that line number is printed.
+
+For example, `ps-line-number-step' is set to 2, the printing will look like:
+
+   1 one line
+     one line
+   3 one line
+     one line
+   5 one line
+     one line
+     ...
+
+Valid values are:
+
+   integer     an integer that specifies the interval that line number is
+               printed.  If it's lesser than or equal to zero, it's used the
+               value 1.
+
+   `zebra'     specifies that only the line number of the first line in a zebra
+               stripe is to be printed.
+
+Any other value is treated as `zebra'."
+  :type '(choice :tag "Line Number Step"
+                (integer :tag "Step Interval")
+                (const :tag "Synchronize Zebra" zebra))
+  :group 'ps-print-miscellany)
+
+(defcustom ps-line-number-start 1
+  "*Specify the starting point in the interval given by `ps-line-number-step'.
+
+For example, if `ps-line-number-step' is set to 3 and `ps-line-number-start' is set to 3, the
+printing will look like:
+
+      one line
+      one line
+    3 one line
+      one line
+      one line
+    6 one line
+      one line
+      one line
+    9 one line
+      one line
+      ...
+
+The values for `ps-line-number-start':
+
+   * If `ps-line-number-step' is an integer, must be between 1 and the value
+     of `ps-line-number-step' inclusive.
+
+   * If `ps-line-number-step' is set to `zebra', must be between 1 and the
+     value of `ps-zebra-strip-height' inclusive.  Use this combination if you
+     wish that line number be relative to zebra stripes."
+  :type '(integer :tag "Start Step Interval")
+  :group 'ps-print-miscellany)
+
 (defcustom ps-print-background-image nil
   "*EPS image list to be printed on background.
 
@@ -1583,17 +1726,19 @@ PostScript programming that returns a float or integer value.
 For example, if you wish to print an EPS image on all pages do:
 
    '((\"~/images/EPS-image.ps\"))"
-  :type '(repeat (list (file   :tag "EPS File")
-                      (choice :tag "X" (const :tag "default" nil) number string)
-                      (choice :tag "Y" (const :tag "default" nil) number string)
-                      (choice :tag "X Scale" (const :tag "default" nil) number string)
-                      (choice :tag "Y Scale" (const :tag "default" nil) number string)
-                      (choice :tag "Rotation" (const :tag "default" nil) number string)
-                      (repeat :tag "Pages" :inline t
-                              (radio (integer :tag "Page")
-                                     (cons :tag "Range"
-                                           (integer :tag "From")
-                                           (integer :tag "To"))))))
+  :type '(repeat
+         (list
+          (file   :tag "EPS File")
+          (choice :tag "X" (const :tag "default" nil) number string)
+          (choice :tag "Y" (const :tag "default" nil) number string)
+          (choice :tag "X Scale" (const :tag "default" nil) number string)
+          (choice :tag "Y Scale" (const :tag "default" nil) number string)
+          (choice :tag "Rotation" (const :tag "default" nil) number string)
+          (repeat :tag "Pages" :inline t
+                  (radio (integer :tag "Page")
+                         (cons :tag "Range"
+                               (integer :tag "From")
+                               (integer :tag "To"))))))
   :group 'ps-print-background)
 
 (defcustom ps-print-background-text nil
@@ -1631,18 +1776,20 @@ PostScript programming that returns a float or integer value.
 For example, if you wish to print text \"Preliminary\" on all pages do:
 
    '((\"Preliminary\"))"
-  :type '(repeat (list (string :tag "Text")
-                      (choice :tag "X" (const :tag "default" nil) number string)
-                      (choice :tag "Y" (const :tag "default" nil) number string)
-                      (choice :tag "Font" (const :tag "default" nil) string)
-                      (choice :tag "Fontsize" (const :tag "default" nil) number string)
-                      (choice :tag "Gray" (const :tag "default" nil) number string)
-                      (choice :tag "Rotation" (const :tag "default" nil) number string)
-                      (repeat :tag "Pages" :inline t
-                              (radio (integer :tag "Page")
-                                     (cons :tag "Range"
-                                           (integer :tag "From")
-                                           (integer :tag "To"))))))
+  :type '(repeat
+         (list
+          (string :tag "Text")
+          (choice :tag "X" (const :tag "default" nil) number string)
+          (choice :tag "Y" (const :tag "default" nil) number string)
+          (choice :tag "Font" (const :tag "default" nil) string)
+          (choice :tag "Fontsize" (const :tag "default" nil) number string)
+          (choice :tag "Gray" (const :tag "default" nil) number string)
+          (choice :tag "Rotation" (const :tag "default" nil) number string)
+          (repeat :tag "Pages" :inline t
+                  (radio (integer :tag "Page")
+                         (cons :tag "Range"
+                               (integer :tag "From")
+                               (integer :tag "To"))))))
   :group 'ps-print-background)
 
 ;;; Horizontal layout
@@ -1740,7 +1887,7 @@ NOTE: page numbers are displayed as part of headers,
   :group 'ps-print-headers)
 
 (defcustom ps-spool-config
-  (if (memq system-type '(win32 w32 mswindows ms-dos windows-nt))
+  (if ps-windows-system
       nil
     'lpr-switches)
   "*Specify who is responsable for setting duplex and page size switches.
@@ -2046,6 +2193,24 @@ This applies to generating PostScript."
   :type '(repeat face)
   :group 'ps-print-face)
 
+(defcustom ps-use-face-background nil
+  "*Specify if face background should be used.
+
+Valid values are:
+
+   t           always use face background color.
+   nil         never use face background color.
+   (face...)   list of faces whose background color will be used.
+
+Any other value will be treated as t."
+  :type '(choice :tag "Use Face Background"
+                (const :tag "Always Use Face Background" t)
+                (const :tag "Never Use Face Background" nil)
+                (repeat :menu-tag "Face Background List"
+                        :tag "Face Background List"
+                        face))
+  :group 'ps-print-face)
+
 (defcustom ps-left-header
   (list 'ps-get-buffer-name 'ps-header-dirpart)
   "*The items to display (each on a line) on the left part of the page header.
@@ -2118,7 +2283,10 @@ It's like the very first character of buffer (or region) is ^L (\\014)."
   :type 'boolean
   :group 'ps-print-headers)
 
-(defcustom ps-postscript-code-directory data-directory
+(defcustom ps-postscript-code-directory
+  (or (and (fboundp 'locate-data-directory) ; xemacs
+           (locate-data-directory "ps-print"))
+      data-directory)                  ; emacs
   "*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
@@ -2276,16 +2444,21 @@ The table depends on the current ps-print setup."
 
       ps-paper-type          %s
       ps-landscape-mode      %s
+      ps-print-upside-down   %s
       ps-number-of-columns   %s
 
       ps-zebra-stripes       %s
       ps-zebra-stripe-height %s
       ps-zebra-color         %s
       ps-line-number         %s
+      ps-line-number-step    %s
+      ps-line-number-start   %S
 
       ps-default-fg %s
       ps-default-bg %s
 
+      ps-use-face-background %s
+
       ps-print-control-characters %s
 
       ps-print-background-image %s
@@ -2332,13 +2505,17 @@ The table depends on the current ps-print setup."
    (ps-print-quote ps-print-region-function)
    (ps-print-quote ps-paper-type)
    ps-landscape-mode
+   ps-print-upside-down
    ps-number-of-columns
    ps-zebra-stripes
    ps-zebra-stripe-height
    (ps-print-quote ps-zebra-color)
    ps-line-number
+   (ps-print-quote ps-line-number-step)
+   ps-line-number-start
    (ps-print-quote ps-default-fg)
    (ps-print-quote ps-default-bg)
+   (ps-print-quote ps-use-face-background)
    (ps-print-quote ps-print-control-characters)
    (ps-print-quote ps-print-background-image)
    (ps-print-quote ps-print-background-text)
@@ -2420,13 +2597,12 @@ The table depends on the current ps-print setup."
 
 (defun ps-prologue-file (filenumber)
   (save-excursion
-    (let ((buffer
-          (or (find-file-noselect
-               (format "%sps-prin%d.ps"
-                       ps-postscript-code-directory filenumber)
-               'no-warn 'rawfile)
-              (error "ps-print PostScript prologue %d file was not found."
-                     filenumber))))
+    (let* ((filename (format "%sps-prin%d.ps"
+                            ps-postscript-code-directory filenumber))
+          (buffer
+           (or (find-file-noselect filename 'no-warn 'rawfile)
+               (error "ps-print PostScript prologue `%s' file was not found."
+                      filename))))
       (set-buffer buffer)
       (prog1
          (buffer-string)
@@ -2462,6 +2638,7 @@ The table depends on the current ps-print setup."
 (defvar ps-showline-count 1)
 
 (defvar ps-control-or-escape-regexp nil)
+(defvar ps-n-up-on nil)
 
 (defvar ps-background-pages nil)
 (defvar ps-background-all-pages nil)
@@ -3748,7 +3925,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
        (tumble (if ps-landscape-mode (not ps-spool-tumble) ps-spool-tumble))
        (n-up (ps-n-up-printing))
        (n-up-filling (ps-n-up-filling)))
-    (and (> ps-n-up-printing 1) (setq tumble (not tumble)))
+    (and ps-n-up-on (setq tumble (not tumble)))
     (ps-output
      ps-adobe-tag
      "%%Title: " (buffer-name)         ; Take job name from name of
@@ -3792,6 +3969,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
     (ps-output-boolean "LandscapeMode      "
                       (or ps-landscape-mode
                           (eq (ps-n-up-landscape n-up) 'pag)))
+    (ps-output-boolean "UpsideDown         " ps-print-upside-down)
     (ps-output (format "/NumberOfColumns     %d def\n" ps-number-of-columns)
 
               (format "/LandscapePageHeight %s def\n" ps-landscape-page-height)
@@ -3827,7 +4005,13 @@ XSTART YSTART are the relative position for the first page in a sheet.")
 
     (ps-output-boolean "Zebra           " ps-zebra-stripes)
     (ps-output-boolean "PrintLineNumber " ps-line-number)
-    (ps-output (format "/ZebraHeight      %d def\n" ps-zebra-stripe-height)
+    (ps-output-boolean "SyncLineZebra   " (not (integerp ps-line-number-step)))
+    (ps-output (format "/PrintLineStep    %d def\n"
+                      (if (integerp ps-line-number-step)
+                          ps-line-number-step
+                        ps-zebra-stripe-height))
+              (format "/PrintLineStart   %d def\n" ps-line-number-start)
+              (format "/ZebraHeight      %d def\n" ps-zebra-stripe-height)
               "/ZebraColor       "
               (ps-format-color ps-zebra-color 0.95)
               "def\n/BackgroundColor  "
@@ -3907,7 +4091,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
                 "\n%%EndFeature\n")))
   (ps-output "\n/Lines 0 def\n/PageCount 0 def\n\nBeginDoc\n%%EndSetup\n")
   (and ps-banner-page-when-duplexing
-       (ps-output "\n%%Page: 0 0\nsave showpage restore\n")))
+       (ps-output "\n%%Page: banner 0\nsave showpage restore\n")))
 
 
 (defun ps-format-color (color &optional default)
@@ -3974,12 +4158,28 @@ XSTART YSTART are the relative position for the first page in a sheet.")
 
 
 (defun ps-begin-job ()
+  (let ((last-char (aref ps-postscript-code-directory
+                        (1- (length ps-postscript-code-directory)))))
+    (or (eq last-char ?/)
+       (and ps-windows-system (eq last-char ?\\))
+       (setq ps-postscript-code-directory
+             (concat ps-postscript-code-directory "/"))))
   (or (equal ps-mark-code-directory ps-postscript-code-directory)
       (setq ps-print-prologue-0     (ps-prologue-file 0)
            ps-print-prologue-1     (ps-prologue-file 1)
            ps-print-prologue-2     (ps-prologue-file 2)
            ps-print-duplex-feature (ps-prologue-file 3)
            ps-mark-code-directory  ps-postscript-code-directory))
+  (or (listp ps-use-face-background)
+      (setq ps-use-face-background t))
+  (and (integerp ps-line-number-step)
+       (<= ps-line-number-step 0)
+       (setq ps-line-number-step 1))
+  (setq ps-n-up-on           (> ps-n-up-printing 1)
+       ps-line-number-start (max 1 (min ps-line-number-start
+                                        (if (integerp ps-line-number-step)
+                                            ps-line-number-step
+                                          ps-zebra-stripe-height))))
   (save-excursion
     (set-buffer ps-spool-buffer)
     (goto-char (point-max))
@@ -4057,9 +4257,12 @@ XSTART YSTART are the relative position for the first page in a sheet.")
        ps-page-order (1+ ps-page-order))
   (and (> ps-page-order 1)
        (ps-output "EndSheet\n"))
-  (ps-output (format "\n%%%%Page: %d %d\n"
-                    ps-page-postscript ps-page-order))
-  (ps-output (format "%d BeginSheet\nBeginDSCPage\n" ps-n-up-printing)))
+  (ps-output (if ps-n-up-on
+                (format "\n%%%%Page: (%d \\(%d\\)) %d\n"
+                        ps-page-order ps-page-postscript ps-page-order)
+              (format "\n%%%%Page: %d %d\n"
+                      ps-page-postscript ps-page-order))
+            (format "%d BeginSheet\nBeginDSCPage\n" ps-n-up-printing)))
 
 
 (defsubst ps-header-page ()
@@ -4380,17 +4583,37 @@ If FACE is not a valid face name, it is used default face."
             new-face))))
 
 
+(defun ps-face-background (face background)
+  (and (or (eq ps-use-face-background t)
+          (cond ((symbolp face)
+                 (memq face ps-use-face-background))
+                ((listp face)
+                 (let (ok)
+                   (while face
+                     (if (memq (car face) ps-use-face-background)
+                         (setq face nil
+                               ok   t)
+                       (setq face (cdr face))))
+                   ok))
+                (t
+                 nil)
+                ))
+       background))
+
+
 (defun ps-face-attribute-list (face-or-list)
   (if (listp face-or-list)
       ;; list of faces
       (let ((effects 0)
-           foreground background face-attr)
+           foreground background face-attr face)
        (while face-or-list
-         (setq face-attr (ps-face-attributes (car face-or-list))
-               effects (logior effects (aref face-attr 0)))
+         (setq face         (car face-or-list)
+               face-or-list (cdr face-or-list)
+               face-attr    (ps-face-attributes face)
+               effects      (logior effects (aref face-attr 0)))
          (or foreground (setq foreground (aref face-attr 1)))
-         (or background (setq background (aref face-attr 2)))
-         (setq face-or-list (cdr face-or-list)))
+         (or background
+             (setq background (ps-face-background face (aref face-attr 2)))))
        (vector effects foreground background))
     ;; simple face
     (ps-face-attributes face-or-list)))
@@ -4408,7 +4631,7 @@ If FACE is not a valid face name, it is used default face."
     (let* ((face-bit   (ps-face-attribute-list face))
           (effect     (aref face-bit 0))
           (foreground (aref face-bit 1))
-          (background (aref face-bit 2))
+          (background (ps-face-background face (aref face-bit 2)))
           (fg-color (if (and ps-color-p foreground)
                         (ps-color-scale foreground)
                       ps-default-color))
@@ -4423,7 +4646,7 @@ If FACE is not a valid face name, it is used default face."
   (goto-char to))
 
 
-(defun ps-xemacs-face-kind-p (face kind kind-regex kind-list)
+(defun ps-xemacs-face-kind-p (face kind kind-regex)
   (let* ((frame-font (or (face-font-instance face)
                         (face-font-instance 'default)))
         (kind-cons (and frame-font
@@ -4431,9 +4654,7 @@ If FACE is not a valid face name, it is used default face."
                               (font-instance-properties frame-font))))
         (kind-spec (cdr-safe kind-cons))
         (case-fold-search t))
-    (or (and kind-spec (string-match kind-regex kind-spec))
-       ;; Kludge-compatible:
-       (memq face kind-list))))
+    (and kind-spec (string-match kind-regex kind-spec))))
 
 
 (cond ((eq ps-print-emacs-type 'emacs)  ; emacs
@@ -4450,12 +4671,13 @@ If FACE is not a valid face name, it is used default face."
                                        ; lucid
       (t                               ; epoch
        (defun ps-face-bold-p (face)
-        (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold"
-                               ps-bold-faces))
+        (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
+            (memq face ps-bold-faces))) ; Kludge-compatible
 
        (defun ps-face-italic-p (face)
-        (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o" ps-italic-faces)
-            (ps-xemacs-face-kind-p face 'SLANT "i\\|o" ps-italic-faces)))
+        (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o")
+            (ps-xemacs-face-kind-p face 'SLANT "i\\|o")
+            (memq face ps-italic-faces))) ; Kludge-compatible
        ))
 
 
@@ -4735,10 +4957,10 @@ If FACE is not a valid face name, it is used default face."
                                total-lines total-pages) t))))
 
 
-(defconst ps-printer-name-option
-  (cond ((memq system-type '(win32 w32 mswindows ms-dos windows-nt))
+(defvar ps-printer-name-option
+  (cond (ps-windows-system
         "-P")
-       ((memq system-type '(usq-unix-v dgux hpux irix))
+       (ps-lp-system
         "-d")
        (t
         "-P" )))