aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-01-16 05:09:21 +0000
committerRichard M. Stallman1997-01-16 05:09:21 +0000
commit090be653c38dbe456e536426f33568f8e4971ad9 (patch)
tree8bc70b58b76adc8c692700c534967c2e361a277f
parent3da4f3679606bf1d990db49929d781d9dacf3693 (diff)
downloademacs-090be653c38dbe456e536426f33568f8e4971ad9.tar.gz
emacs-090be653c38dbe456e536426f33568f8e4971ad9.zip
(ps-print-version): Fix value.
(cl lisp-float-type): Require them. (ps-number-of-columns ps-*-font-size): Try to select defaults better suited when `ps-landscape-mode' is non-nil. (ps-*-faces): Change default for Font Lock mode faces when `ps-print-color-p' is nil. (ps-right-header): Replace `time-stamp-yy/mm/dd' by `time-stamp-mon-dd-yyyy'. (ps-end-file ps-begin-page): Fix bug in page count for Ghostview. (ps-generate-postscript-with-faces): Replace `ps-sorter' by `car-less-than-car'. (ps-plot ps-generate): Replace `%d' by `%3d'.
-rw-r--r--lisp/ps-print.el168
1 files changed, 62 insertions, 106 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 57e9b378fe3..cecdb75b571 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -2,9 +2,23 @@
2 2
3;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4 4
5;; Author: Jim Thompson <thompson@wg2.waii.com> 5;; Author: Jim Thompson (was <thompson@wg2.waii.com>)
6;; Maintainer: duthen@cegelec-red.fr (Jacques Duthen Prestataire) 6;; Maintainer: Jacques Duthen <duthen@cegelec-red.fr>
7;; Keywords: print, PostScript 7;; Keywords: print, PostScript
8;; Time-stamp: <97/01/09 13:52:08 duthen>
9;; Version: 3.04
10
11(defconst ps-print-version "3.04"
12 "ps-print.el, v 3.04 <97/01/09 duthen>
13
14Jack's last change version -- this file may have been edited as part of
15Emacs without changes to the version number. When reporting bugs,
16please also report the version of Emacs, if any, that ps-print was
17distributed with.
18
19Please send all bug fixes and enhancements to
20 Jacques Duthen <duthen@cegelec-red.fr>.
21")
8 22
9;; This file is part of GNU Emacs. 23;; This file is part of GNU Emacs.
10 24
@@ -23,72 +37,6 @@
23;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 37;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; Boston, MA 02111-1307, USA. 38;; Boston, MA 02111-1307, USA.
25 39
26;; LCD Archive Entry:
27;; ps-print|James C. Thompson|thompson@wg2.waii.com|
28;; Jim's Pretty-Good PostScript Generator for Emacs 19 (ps-print)|
29;; 26-Feb-1994|2.8|~/packages/ps-print.el|
30
31;; 3.03 [jack] Sept 27, 1996 Jacques Duthen <duthen@cegelec-red.fr>
32;; Merge 31 diffs between 19.29 and 19.34
33
34;; 3.02 [jack] June 26, 1996 Jacques Duthen <duthen@cegelec-red.fr>
35;; Add new page dimensions to `ps-page-dimensions-database' for `paper-type'
36;; Improve landscape mode `ps-landscape-mode' and multiple columns
37;; printing `ps-number-of-columns':
38;; The text and the margins are no more scaled.
39;; Simplify the semantics of `ps-inter-column' (space between columns).
40;; Add error checking for negative `ps-print-width' and `ps-print-height'.
41;; Change the semantics of `ps-top-margin' which is now the TOP MARGIN,
42;; and add `ps-header-offset' instead of having `ps-top-margin' split in 2.
43;; Add `ps-header-font-family', `ps-header-font-size' and
44;; `ps-header-title-font-size' to control the header.
45;; Add `ps-header-line-pad'.
46;; Change the semantics of `ps-font-info-database' to have symbolic
47;; font families.
48;; Add new fonts to `ps-font-info-database': `Courier' `Helvetica'
49;; `Times' `Palatino' `Helvetica-Narrow' `NewCenturySchlbk'
50;; Make public `ps-font-family' and `ps-font-size' so that the user
51;; can directly control the text font and size without loading ps-print.
52;; Add error checking for unknown font families and a message giving
53;; the exhaustive list of available font families.
54;; Document how to install a new font family.
55;; Add `/ReportAllFontInfo' to get all the font families of the printer.
56;; Add the possibility to make `mixed' font families.
57;; Add `ps-setup' to get the current setup.
58;; Add tools `ps-line-lengths' `ps-nb-pages-buffer' `ps-nb-pages-region'
59;; to help choose the font size.
60;; Split `ps-print-prologue' in two to insert info from header fonts
61;; Replace indexes by macro `ps-page-dimensions-get-width'
62;; to get access to the dimensions list.
63;; Add `ps-select-font' inside `ps-get-page-dimensions'.
64;; Fix the "clumsy" `ps-page-height' management.
65;; Move `ps-get-page-dimensions' to the beginning of `ps-begin-file'
66;; to get early error checking.
67;; Add sample setup `ps-jack-setup'.
68;;
69;; Rewrite a lot of postscript code and add comments inside it
70;; (maybe they should not (or optionally) be included in the generated
71;; Postscript).
72;; Translate the origin to (lm, bm) to simplify the other moves.
73;; Fix bug in `/HeaderOffset' with `/PrintStartY'.
74;; Fix bug in `/SetHeaderLines'.
75;; Change `/ReportFontInfo' for use by `/ReportAllFontInfo'.
76;;
77
78;; 3.01 [jack] June 4, 1996 Jacques Duthen <duthen@cegelec-red.fr>
79;; Manage float value for every variable representing a size.
80;; Add `ps-font-info-database' `ps-inter-column'
81
82;; 3.00 [jack] May 17, 1996 Jacques Duthen <duthen@cegelec-red.fr>
83;; based on 2.8 Jim's Pretty-Good version:
84;; Add `ps-landscape-mode' and `ps-number-of-columns'
85;; for dumb multi-column landscape mode.
86
87;; Baseline-version: 2.8. (Jim's last change version -- this
88;; file may have been edited as part of Emacs without changes to the
89;; version number. When reporting bugs, please also report the
90;; version of Emacs, if any, that ps-print was distributed with.)
91
92;;; Commentary: 40;;; Commentary:
93 41
94;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 42;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -659,17 +607,11 @@
659 607
660;;; Code: 608;;; Code:
661 609
662(defconst ps-print-version "3.01" 610(eval-when-compile
663 "ps-print.el,v 3.01 1996/06/13 18:12 jack 611 (require 'cl))
664
665Jack's last change version -- this file may have been edited as part of
666Emacs without changes to the version number. When reporting bugs,
667please also report the version of Emacs, if any, that ps-print was
668distributed with.
669 612
670Please send all bug fixes and enhancements to 613(unless (featurep 'lisp-float-type)
671 Jacques Duthen <duthen@cegelec-red.fr>. 614 (error "`ps-print' requires floating point support"))
672")
673 615
674;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 616;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
675;; User Variables: 617;; User Variables:
@@ -720,13 +662,13 @@ see `ps-paper-type'.")
720 662
721(defvar ps-paper-type 'letter 663(defvar ps-paper-type 'letter
722 "*Specifies the size of paper to format for. 664 "*Specifies the size of paper to format for.
723Should be one of the paper types defined in `ps-page-dimensions-database': 665Should be one of the paper types defined in `ps-page-dimensions-database', for
724`letter', `legal', `a4'...") 666example `letter', `legal' or `a4'.")
725 667
726(defvar ps-landscape-mode 'nil 668(defvar ps-landscape-mode 'nil
727 "*Non-nil means print in landscape mode.") 669 "*Non-nil means print in landscape mode.")
728 670
729(defvar ps-number-of-columns 1 671(defvar ps-number-of-columns (if ps-landscape-mode 2 1)
730 "*Specifies the number of columns") 672 "*Specifies the number of columns")
731 673
732;;; Horizontal layout 674;;; Horizontal layout
@@ -871,16 +813,16 @@ You can get all the fonts of YOUR printer using `ReportAllFontInfo'.")
871(defvar ps-font-family 'Courier 813(defvar ps-font-family 'Courier
872 "Font family name for ordinary text, when generating Postscript.") 814 "Font family name for ordinary text, when generating Postscript.")
873 815
874(defvar ps-font-size 8.5 816(defvar ps-font-size (if ps-landscape-mode 7 8.5)
875 "Font size, in points, for ordinary text, when generating Postscript.") 817 "Font size, in points, for ordinary text, when generating Postscript.")
876 818
877(defvar ps-header-font-family 'Helvetica 819(defvar ps-header-font-family 'Helvetica
878 "Font family name for text in the header, when generating Postscript.") 820 "Font family name for text in the header, when generating Postscript.")
879 821
880(defvar ps-header-font-size 12 822(defvar ps-header-font-size (if ps-landscape-mode 10 12)
881 "Font size, in points, for text in the header, when generating Postscript.") 823 "Font size, in points, for text in the header, when generating Postscript.")
882 824
883(defvar ps-header-title-font-size 14 825(defvar ps-header-title-font-size (if ps-landscape-mode 12 14)
884 "Font size, in points, for the top line of text in the header, 826 "Font size, in points, for the top line of text in the header,
885when generating Postscript.") 827when generating Postscript.")
886 828
@@ -902,15 +844,31 @@ when generating Postscript.")
902nil means rely solely on the lists `ps-bold-faces', `ps-italic-faces', 844nil means rely solely on the lists `ps-bold-faces', `ps-italic-faces',
903and `ps-underlined-faces'.") 845and `ps-underlined-faces'.")
904 846
905(defvar ps-bold-faces '() 847(defvar ps-bold-faces
848 (unless ps-print-color-p
849 '(font-lock-function-name-face
850 font-lock-builtin-face
851 font-lock-variable-name-face
852 font-lock-keyword-face
853 font-lock-warning-face))
906 "*A list of the \(non-bold\) faces that should be printed in bold font. 854 "*A list of the \(non-bold\) faces that should be printed in bold font.
907This applies to generating Postscript.") 855This applies to generating Postscript.")
908 856
909(defvar ps-italic-faces '() 857(defvar ps-italic-faces
858 (unless ps-print-color-p
859 '(font-lock-variable-name-face
860 font-lock-string-face
861 font-lock-comment-face
862 font-lock-warning-face))
910 "*A list of the \(non-italic\) faces that should be printed in italic font. 863 "*A list of the \(non-italic\) faces that should be printed in italic font.
911This applies to generating Postscript.") 864This applies to generating Postscript.")
912 865
913(defvar ps-underlined-faces '() 866(defvar ps-underlined-faces
867 (unless ps-print-color-p
868 '(font-lock-function-name-face
869 font-lock-type-face
870 font-lock-reference-face
871 font-lock-warning-face))
914 "*A list of the \(non-underlined\) faces that should be printed underlined. 872 "*A list of the \(non-underlined\) faces that should be printed underlined.
915This applies to generating Postscript.") 873This applies to generating Postscript.")
916 874
@@ -934,7 +892,7 @@ string delimiters added to it.")
934(make-variable-buffer-local 'ps-left-header) 892(make-variable-buffer-local 'ps-left-header)
935 893
936(defvar ps-right-header 894(defvar ps-right-header
937 (list "/pagenumberstring load" 'time-stamp-yy/mm/dd 'time-stamp-hh:mm:ss) 895 (list "/pagenumberstring load" 'time-stamp-mon-dd-yyyy 'time-stamp-hh:mm:ss)
938 "*The items to display (each on a line) on the right part of the page header. 896 "*The items to display (each on a line) on the right part of the page header.
939This applies to generating Postscript. 897This applies to generating Postscript.
940 898
@@ -2165,7 +2123,8 @@ page-height == bm + print-height + tm - ho - hh
2165(defun ps-end-file () 2123(defun ps-end-file ()
2166 (ps-output "\nEndDoc\n\n") 2124 (ps-output "\nEndDoc\n\n")
2167 (ps-output "%%Trailer\n") 2125 (ps-output "%%Trailer\n")
2168 (ps-output "%%Pages: " (format "%d\n" ps-showpage-count))) 2126 (ps-output (format "%%%%Pages: %d\n" (1+ (/ (1- ps-page-count)
2127 ps-number-of-columns)))))
2169 2128
2170(defun ps-next-page () 2129(defun ps-next-page ()
2171 (ps-end-page) 2130 (ps-end-page)
@@ -2177,19 +2136,20 @@ page-height == bm + print-height + tm - ho - hh
2177 (setq ps-width-remaining ps-print-width) 2136 (setq ps-width-remaining ps-print-width)
2178 (setq ps-height-remaining ps-print-height) 2137 (setq ps-height-remaining ps-print-height)
2179 2138
2180 (setq ps-page-count (+ ps-page-count 1)) 2139 ;; Print only when a new real page begins.
2140 (when (zerop (mod ps-page-count ps-number-of-columns))
2141 (ps-output (format "\n%%%%Page: %d %d\n"
2142 (1+ (/ ps-page-count ps-number-of-columns))
2143 (1+ (/ ps-page-count ps-number-of-columns)))))
2181 2144
2182 (ps-output "\n%%Page: "
2183 (format "%d %d\n" ps-page-count (+ 1 ps-showpage-count)))
2184 (ps-output "BeginDSCPage\n") 2145 (ps-output "BeginDSCPage\n")
2185 (ps-output (format "/PageNumber %d def\n" ps-page-count)) 2146 (ps-output (format "/PageNumber %d def\n" (incf ps-page-count)))
2186 (ps-output "/PageCount 0 def\n") 2147 (ps-output "/PageCount 0 def\n")
2187 2148
2188 (if ps-print-header 2149 (when ps-print-header
2189 (progn 2150 (ps-generate-header "HeaderLinesLeft" ps-left-header)
2190 (ps-generate-header "HeaderLinesLeft" ps-left-header) 2151 (ps-generate-header "HeaderLinesRight" ps-right-header)
2191 (ps-generate-header "HeaderLinesRight" ps-right-header) 2152 (ps-output (format "%d SetHeaderLines\n" ps-header-lines)))
2192 (ps-output (format "%d SetHeaderLines\n" ps-header-lines))))
2193 2153
2194 (ps-output "BeginPage\n") 2154 (ps-output "BeginPage\n")
2195 (ps-set-font ps-current-font) 2155 (ps-set-font ps-current-font)
@@ -2276,7 +2236,7 @@ EndDSCPage\n"))
2276 (if (< q-todo 100) 2236 (if (< q-todo 100)
2277 (/ (* 100 q-done) q-todo) 2237 (/ (* 100 q-done) q-todo)
2278 (/ q-done (/ q-todo 100)))) 2238 (/ q-done (/ q-todo 100))))
2279 (message "Formatting...%d%%" foo)))))) 2239 (message "Formatting...%3d%%" foo))))))
2280 2240
2281(defun ps-set-font (font) 2241(defun ps-set-font (font)
2282 (setq ps-current-font font) 2242 (setq ps-current-font font)
@@ -2490,9 +2450,6 @@ EndDSCPage\n"))
2490 (list (extent-end-position extent) 'pull extent))) 2450 (list (extent-end-position extent) 'pull extent)))
2491 nil) 2451 nil)
2492 2452
2493(defun ps-sorter (a b)
2494 (< (car a) (car b)))
2495
2496(defun ps-extent-sorter (a b) 2453(defun ps-extent-sorter (a b)
2497 (< (extent-priority a) (extent-priority b))) 2454 (< (extent-priority a) (extent-priority b)))
2498 2455
@@ -2528,8 +2485,7 @@ EndDSCPage\n"))
2528 (let ((a (cons 'dummy nil)) 2485 (let ((a (cons 'dummy nil))
2529 record type extent extent-list) 2486 record type extent extent-list)
2530 (map-extents 'ps-mapper nil from to a) 2487 (map-extents 'ps-mapper nil from to a)
2531 (setq a (cdr a)) 2488 (setq a (sort (cdr a) 'car-less-than-car))
2532 (setq a (sort a 'ps-sorter))
2533 2489
2534 (setq extent-list nil) 2490 (setq extent-list nil)
2535 2491
@@ -2640,7 +2596,7 @@ EndDSCPage\n"))
2640 (save-restriction 2596 (save-restriction
2641 (narrow-to-region from to) 2597 (narrow-to-region from to)
2642 (if ps-razzle-dazzle 2598 (if ps-razzle-dazzle
2643 (message "Formatting...%d%%" (setq ps-razchunk 0))) 2599 (message "Formatting...%3d%%" (setq ps-razchunk 0)))
2644 (set-buffer buffer) 2600 (set-buffer buffer)
2645 (setq ps-source-buffer buffer) 2601 (setq ps-source-buffer buffer)
2646 (setq ps-spool-buffer (get-buffer-create ps-spool-buffer-name)) 2602 (setq ps-spool-buffer (get-buffer-create ps-spool-buffer-name))