;; 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>.
;; 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
;; 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
;; 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
;; -------------
;; 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
;; -----------------------------
;; 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.
;;
(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:
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
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)
: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,
: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.
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
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
: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.
: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.
: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
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
(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)
(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)
(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)
(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
(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)
(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 "
"\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)
(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))
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 ()
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)))
(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))
(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
(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
; 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
))
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" )))