comparison lisp/ps-print.el @ 47674:330113e9df2b

(ps-print-emacs-type): Error if ps-print is activated in Epoch, inLucid or in Emacs v19 or lesser. Value can no longer be `lucid'. (ps-print-version): New version number (6.5.8). (faces): Never do (require 'faces).
author Richard M. Stallman <rms@gnu.org>
date Sun, 29 Sep 2002 03:30:41 +0000
parents ec3123180ac5
children e19e88bc6e58
comparison
equal deleted inserted replaced
47673:a3f7ece066e5 47674:330113e9df2b
8 ;; Vinicius Jose Latorre <vinicius@cpqd.com.br> 8 ;; Vinicius Jose Latorre <vinicius@cpqd.com.br>
9 ;; Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 9 ;; Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
10 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 10 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
11 ;; Vinicius Jose Latorre <vinicius@cpqd.com.br> 11 ;; Vinicius Jose Latorre <vinicius@cpqd.com.br>
12 ;; Keywords: wp, print, PostScript 12 ;; Keywords: wp, print, PostScript
13 ;; Time-stamp: <2002/09/11 15:52:39 vinicius> 13 ;; Time-stamp: <2002/09/13 10:10:20 vinicius>
14 ;; Version: 6.5.7 14 ;; Version: 6.5.8
15 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ 15 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
16 16
17 (defconst ps-print-version "6.5.7" 17 (defconst ps-print-version "6.5.8"
18 "ps-print.el, v 6.5.7 <2002/09/11 vinicius> 18 "ps-print.el, v 6.5.8 <2002/09/13 vinicius>
19 19
20 Vinicius's last change version -- this file may have been edited as part of 20 Vinicius's last change version -- this file may have been edited as part of
21 Emacs without changes to the version number. When reporting bugs, please also 21 Emacs without changes to the version number. When reporting bugs, please also
22 report the version of Emacs, if any, that ps-print was distributed with. 22 report the version of Emacs, if any, that ps-print was distributed with.
23 23
47 ;; About ps-print 47 ;; About ps-print
48 ;; -------------- 48 ;; --------------
49 ;; 49 ;;
50 ;; This package provides printing of Emacs buffers on PostScript printers; the 50 ;; This package provides printing of Emacs buffers on PostScript printers; the
51 ;; buffer's bold and italic text attributes are preserved in the printer 51 ;; buffer's bold and italic text attributes are preserved in the printer
52 ;; output. ps-print is intended for use with Emacs or Lucid Emacs, together 52 ;; output. ps-print is intended for use with Emacs or XEmacs, together with a
53 ;; with a fontifying package such as font-lock or hilit. 53 ;; fontifying package such as font-lock or hilit.
54 ;; 54 ;;
55 ;; ps-print uses the same face attributes defined through font-lock or hilit to 55 ;; ps-print uses the same face attributes defined through font-lock or hilit to
56 ;; print a PostScript file, but some faces are better seeing on the screen than 56 ;; print a PostScript file, but some faces are better seeing on the screen than
57 ;; on paper, specially when you have a black/white PostScript printer. 57 ;; on paper, specially when you have a black/white PostScript printer.
58 ;; 58 ;;
1327 ;; 1327 ;;
1328 ;; Default background color isn't working. 1328 ;; Default background color isn't working.
1329 ;; 1329 ;;
1330 ;; Faces are always treated as opaque. 1330 ;; Faces are always treated as opaque.
1331 ;; 1331 ;;
1332 ;; Epoch and Emacs 19 not supported. At all. 1332 ;; Epoch, Lucid and Emacs 19 not supported. At all.
1333 ;; 1333 ;;
1334 ;; Fixed-pitch fonts work better for line folding, but are not required. 1334 ;; Fixed-pitch fonts work better for line folding, but are not required.
1335 ;; 1335 ;;
1336 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care of folding 1336 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care of folding
1337 ;; lines. 1337 ;; lines.
1438 (eval-and-compile 1438 (eval-and-compile
1439 (require 'lpr) 1439 (require 'lpr)
1440 1440
1441 (or (featurep 'lisp-float-type) 1441 (or (featurep 'lisp-float-type)
1442 (error "`ps-print' requires floating point support")) 1442 (error "`ps-print' requires floating point support"))
1443
1444
1445 (defvar ps-print-emacs-type
1446 (let ((case-fold-search t))
1447 (cond ((string-match "XEmacs" emacs-version) 'xemacs)
1448 ((string-match "Lucid" emacs-version)
1449 (error "`ps-print' doesn't support Lucid"))
1450 ((string-match "Epoch" emacs-version)
1451 (error "`ps-print' doesn't support Epoch"))
1452 (t
1453 (unless (and (boundp 'emacs-major-version)
1454 (> emacs-major-version 19))
1455 (error "`ps-print' only supports Emacs 20 and higher"))
1456 'emacs))))
1443 1457
1444 1458
1445 ;; For Emacs 20.2 and the earlier version. 1459 ;; For Emacs 20.2 and the earlier version.
1446 1460
1447 (or (fboundp 'set-buffer-multibyte) 1461 (or (fboundp 'set-buffer-multibyte)
1508 (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt))) 1522 (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt)))
1509 (defconst ps-lp-system 1523 (defconst ps-lp-system
1510 (memq system-type '(usg-unix-v dgux hpux irix))) 1524 (memq system-type '(usg-unix-v dgux hpux irix)))
1511 1525
1512 1526
1513 (defvar ps-print-emacs-type
1514 (cond ((string-match "XEmacs" emacs-version) 'xemacs)
1515 ((string-match "Lucid" emacs-version) 'lucid)
1516 ((string-match "Epoch" emacs-version) 'epoch)
1517 (t 'emacs)))
1518
1519 (or (memq ps-print-emacs-type '(lucid xemacs))
1520 (require 'faces)) ; face-font, face-underline-p,
1521 ; x-font-regexp
1522
1523 (defun ps-xemacs-color-name (color) 1527 (defun ps-xemacs-color-name (color)
1524 (if (ps-x-color-specifier-p color) 1528 (if (ps-x-color-specifier-p color)
1525 (ps-x-color-name color) 1529 (ps-x-color-name color)
1526 color)) 1530 color))
1527 1531
1531 (defun ps-mark-active-p () 1535 (defun ps-mark-active-p ()
1532 mark-active) 1536 mark-active)
1533 (defalias 'ps-face-foreground-name 'face-foreground) 1537 (defalias 'ps-face-foreground-name 'face-foreground)
1534 (defalias 'ps-face-background-name 'face-background) 1538 (defalias 'ps-face-background-name 'face-background)
1535 ) 1539 )
1536 (t ; xemacs, lucid, epoch 1540 (t ; xemacs
1537 (defalias 'ps-mark-active-p 'region-active-p) 1541 (defalias 'ps-mark-active-p 'region-active-p)
1538 (defun ps-face-foreground-name (face) 1542 (defun ps-face-foreground-name (face)
1539 (ps-xemacs-color-name (face-foreground face))) 1543 (ps-xemacs-color-name (face-foreground face)))
1540 (defun ps-face-background-name (face) 1544 (defun ps-face-background-name (face)
1541 (ps-xemacs-color-name (face-background face))) 1545 (ps-xemacs-color-name (face-background face)))
3175 3179
3176 (defcustom ps-postscript-code-directory 3180 (defcustom ps-postscript-code-directory
3177 (or (cond 3181 (or (cond
3178 ((eq ps-print-emacs-type 'emacs) ; emacs 3182 ((eq ps-print-emacs-type 'emacs) ; emacs
3179 data-directory) 3183 data-directory)
3180 ((fboundp 'locate-data-directory) ; emacsens (xemacs, etc.) 3184 ((fboundp 'locate-data-directory) ; xemacs
3181 (locate-data-directory "ps-print")) 3185 (locate-data-directory "ps-print"))
3182 ((boundp 'data-directory) ; emacsens (xemacs, etc.) 3186 ((boundp 'data-directory) ; xemacs
3183 data-directory) 3187 data-directory)
3184 (t ; don't know what to do 3188 (t ; don't know what to do
3185 nil)) 3189 nil))
3186 (error "ps-postscript-code-directory isn't set properly")) 3190 (error "`ps-postscript-code-directory' isn't set properly"))
3187 "*Directory where it's located the PostScript prologue file used by ps-print. 3191 "*Directory where it's located the PostScript prologue file used by ps-print.
3188 By default, this directory is the same as in the variable `data-directory'." 3192 By default, this directory is the same as in the variable `data-directory'."
3189 :type 'directory 3193 :type 'directory
3190 :group 'ps-print-miscellany) 3194 :group 'ps-print-miscellany)
3191 3195
3640 "Return time as \"17:28:31\"." 3644 "Return time as \"17:28:31\"."
3641 (format-time-string "%T")) 3645 (format-time-string "%T"))
3642 3646
3643 3647
3644 (eval-and-compile 3648 (eval-and-compile
3645 (and (memq ps-print-emacs-type '(lucid xemacs)) 3649 (and (eq ps-print-emacs-type 'xemacs)
3646 ;; XEmacs change: Need to check for emacs-major-version too. 3650 ;; XEmacs change: Need to check for emacs-major-version too.
3647 (or (< emacs-major-version 19) 3651 (or (< emacs-major-version 19)
3648 (and (= emacs-major-version 19) (< emacs-minor-version 12))) 3652 (and (= emacs-major-version 19) (< emacs-minor-version 12)))
3649 (setq ps-print-color-p nil)) 3653 (setq ps-print-color-p nil))
3650 3654
3705 (defun ps-face-italic-p (face) 3709 (defun ps-face-italic-p (face)
3706 (or (ps-e-face-italic-p face) 3710 (or (ps-e-face-italic-p face)
3707 (memq face ps-italic-faces))) 3711 (memq face ps-italic-faces)))
3708 ) 3712 )
3709 3713
3710 (t ; xemacs, lucid, epoch 3714 (t ; xemacs
3711 3715
3712 ;; to avoid XEmacs compilation gripes 3716 ;; to avoid XEmacs compilation gripes
3713 (defvar coding-system-for-write nil) 3717 (defvar coding-system-for-write nil)
3714 (defvar coding-system-for-read nil) 3718 (defvar coding-system-for-read nil)
3715 (defvar buffer-file-coding-system nil) 3719 (defvar buffer-file-coding-system nil)
3827 ;; Emacs understands the %f format; we'll use it to limit color RGB 3831 ;; Emacs understands the %f format; we'll use it to limit color RGB
3828 ;; values to three decimals to cut down some on the size of the 3832 ;; values to three decimals to cut down some on the size of the
3829 ;; PostScript output. 3833 ;; PostScript output.
3830 "%0.3f %0.3f %0.3f" 3834 "%0.3f %0.3f %0.3f"
3831 3835
3832 ;; Lucid emacsen will have to make do with %s (princ) for floats. 3836 ;; XEmacs will have to make do with %s (princ) for floats.
3833 "%s %s %s")) 3837 "%s %s %s"))
3834 3838
3835 ;; These values determine how much print-height to deduct when headers/footers 3839 ;; These values determine how much print-height to deduct when headers/footers
3836 ;; are turned on. This is a pretty clumsy way of handling it, but it'll do for 3840 ;; are turned on. This is a pretty clumsy way of handling it, but it'll do for
3837 ;; now. 3841 ;; now.
4688 (vector 0 0 0 0))))) 4692 (vector 0 0 0 0)))))
4689 4693
4690 4694
4691 ;; Emacs understands the %f format; we'll use it to limit color RGB values 4695 ;; Emacs understands the %f format; we'll use it to limit color RGB values
4692 ;; to three decimals to cut down some on the size of the PostScript output. 4696 ;; to three decimals to cut down some on the size of the PostScript output.
4693 ;; Lucid emacsen will have to make do with %s (princ) for floats. 4697 ;; XEmacs will have to make do with %s (princ) for floats.
4694 4698
4695 (defvar ps-float-format (if (eq ps-print-emacs-type 'emacs) 4699 (defvar ps-float-format (if (eq ps-print-emacs-type 'emacs)
4696 "%0.3f " ; emacs 4700 "%0.3f " ; emacs
4697 "%s ")) ; Lucid emacsen 4701 "%s ")) ; xemacs
4698 4702
4699 4703
4700 (defun ps-float-format (value &optional default) 4704 (defun ps-float-format (value &optional default)
4701 (let ((literal (or value default))) 4705 (let ((literal (or value default)))
4702 (cond ((null literal) 4706 (cond ((null literal)
6182 (narrow-to-region from to) 6186 (narrow-to-region from to)
6183 (ps-print-ensure-fontified from to) 6187 (ps-print-ensure-fontified from to)
6184 (let ((face 'default) 6188 (let ((face 'default)
6185 (position to)) 6189 (position to))
6186 (cond 6190 (cond
6187 ((memq ps-print-emacs-type '(xemacs lucid)) 6191 ((eq ps-print-emacs-type 'xemacs)
6188 ;; Build the list of extents... 6192 ;; Build the list of extents...
6189 (let ((a (cons 'dummy nil)) 6193 (let ((a (cons 'dummy nil))
6190 record type extent extent-list) 6194 record type extent extent-list)
6191 (ps-x-map-extents 'ps-mapper nil from to a) 6195 (ps-x-map-extents 'ps-mapper nil from to a)
6192 (setq a (sort (cdr a) 'car-less-than-car) 6196 (setq a (sort (cdr a) 'car-less-than-car)