annotate lisp/ps-print.el @ 8712:9bc99cd7a6ee

entered into RCS
author Richard M. Stallman <rms@gnu.org>
date Tue, 06 Sep 1994 05:29:15 +0000
parents 3759ad84023b
children a0f38717d82d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7257
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; Jim's Pretty-Good PostScript Generator for Emacs 19 (ps-print).
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Author: James C. Thompson <thompson@wg2.waii.com>
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Keywords: faces, postscript, printing
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; any later version.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Acknowledgements
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; ----------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; the Emacs 19 port.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; Thanks to Remi Houdaille and Michel Train, michel@metasoft.fdn.org,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; for adding underline support and title code. (Titling will appear
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; in the next release.)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; Thanks to Heiko Muenkel, muenkel@tnt.uni-hannover.de, for showing
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; me how to handle ISO-8859/1 characters.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Code to handle ISO-8859/1 characters borrowed from the mp prologue
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; file mp.pro.ps, used with permission of Rich Burridge of Sun
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; Microsystems (Rich.Burridge@eng.sun.com).
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; About ps-print:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; --------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; This package provides printing of Emacs buffers on PostScript
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; printers; the buffer's bold and italic text attributes are
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; preserved in the printer output. Ps-print is intended for use with
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; Emacs 19 (Lucid or FSF) and a fontifying package such as font-lock
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; or hilit.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; Installing ps-print:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; -------------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Place ps-print somewhere in your load-path and byte-compile it.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; Load ps-print with (require 'ps-print).
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; Using ps-print:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; --------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; The variables ps-bold-faces and ps-italic-faces *must* contain
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; lists of the faces that you wish to print in bold or italic font.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; These variables already contain some default values, but most users
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; will probably have to add some of their own. To add a face to one
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; of these lists, put code something like the following into your
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; .emacs startup file:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; (setq ps-bold-faces (cons 'my-bold-face ps-bold-faces))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; Ps-print's printer interface is governed by the variables ps-lpr-
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; command and ps-lpr-switches; these are analogous to the variables
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; lpr-command and lpr-switches in the Emacs lpr package.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; To use ps-print, invoke the command ps-print-buffer-with-faces.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; This will generate a PostScript image of the current buffer and
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; send it to the printer. Precede this command with a numeric prefix
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; (C-u), and the PostScript output will be saved in a file; you will
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; be prompted for a filename. Also see the functions ps-print-
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; buffer, ps-print-region, and ps-print-region-with-faces.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; I recommend binding ps-print-buffer-with-faces to a key sequence;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; on a Sun 4 keyboard, for example, you can bind to the PrSc key (aka
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; r22):
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; (global-set-key 'f22 'ps-print-buffer-with-faces)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; (global-set-key '(shift f22) 'ps-print-region-with-faces)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; Or, as I now prefer, you can also bind the ps-spool- functions to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; keys; here's my bindings:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; (global-set-key 'f22 'ps-spool-buffer-with-faces)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; (global-set-key '(shift f22) 'ps-spool-region-with-faces)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; (global-set-key '(control f22) 'ps-despool)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; Using ps-print with other Emacses:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; ---------------------------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; Although it was intended for use with Emacs 19, ps-print will also work
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; with Emacs version 18; you won't get fancy fontified output, but it
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; should work.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; A few words about support:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; -------------------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; Despite its appearance, with comment blocks, usage instructions, and
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; documentation strings, ps-print is not a supported package. That's all
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; a masquerade. Ps-print is something I threw together in my spare time--
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; an evening here, a Saturday there--to make my printouts look like my
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; Emacs buffers. It works, but is not complete.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; Unfortunately, supporting elisp code is not my job and, now that I have
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; what I need out of ps-print, additional support is going to be up to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; you, the user. But that's the spirit of Emacs, isn't it? I call on
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; all who use this package to help in developing it further. If you
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; notice a bug, fix it and send me the patches. If you add a feature,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; again, send me the patches. I will collect all such contributions and
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; periodically post the updates to the appropriate places.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; A few more words about support:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; ------------------------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; The response to my call for public support of ps-print has been
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; terrific. With the exception of the spooling mechanism, all the new
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; features in this version of ps-print were contributed by users. I have
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; some contributed code for printing headers that I'll add to the next
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; release of ps-print, but there are still other features that users can
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; write. See the "Features to Add" list a little further on, and keep
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; that elisp rolling in.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; Please send all bug fixes and enhancements to me, thompson@wg2.waii.com.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; New in version 1.5
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; ------------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; Support for Emacs 19. Works with both overlays and text
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; properties.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; Underlining.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; Local spooling; see function ps-spool-buffer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; Support for ISO8859-1 character set.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; Page breaks are now handled correctly.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; Percentages reported while formatting are now correct.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; Known bugs and limitations of ps-print:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; --------------------------------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; Slow. (Byte-compiling helps.)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; The PostScript needs review/cleanup/enhancing by a PS expert.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; ASCII Control characters other than tab, linefeed and pagefeed are
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; not handled.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;; The mechanism for determining whether a stretch of characters
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; should be printed bold, italic, or plain is crude and extremely
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; limited.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; Faces are always treated as opaque.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; Font names are hardcoded.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;; Epoch not fully supported.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; Tested with only one PostScript printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ;; Features to add:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; ---------------
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; Line numbers.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; Simple headers with date, filename, and page numbers.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;; Gaudy headers a`la enscript and mp.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;; 2-up and 4-up capability.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; Wide-print capability.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;;; Code:
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (defconst ps-print-version (substring "$Revision: 1.5 $" 11 -2)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 "$Id: ps-print.el,v 1.5 1994/04/22 13:25:18 jct Exp $
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 Please send all bug fixes and enhancements to Jim Thompson,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 thompson@wg2.waii.com.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (defvar ps-lpr-command (if (memq system-type
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 '(usg-unix-v hpux silicon-graphics-unix))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 "lp" "lpr")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 "The shell command for printing a PostScript file.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (defvar ps-lpr-switches nil
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 "A list of extra switches to pass to ps-lpr-command.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (defvar ps-bold-faces
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 '(bold
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 bold-italic
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 font-lock-function-name-face
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 message-headers
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 )
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 "A list of the faces that should be printed italic.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (defvar ps-italic-faces
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 '(italic
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 bold-italic
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 font-lock-function-name-face
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 font-lock-string-face
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 font-lock-comment-face
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 message-header-contents
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 message-highlighted-header-contents
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 message-cited-text
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 )
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 "A list of the faces that should be printed bold.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (defvar ps-underline-faces
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 '(underline
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 font-lock-string-face)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 "A list of the faces that should be printed underline.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (defvar ps-razzle-dazzle t
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 "Non-nil means report progress while formatting buffer")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (defun ps-print-buffer (&optional filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 "Generate and print a PostScript image of the buffer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 When called with a numeric prefix argument (C-u), prompt the user for
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 the name of a file to save the PostScript image in, instead of sending
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 it to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 More specifically, the FILENAME argument is treated as follows: if it
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 is nil, send the image to the printer. If FILENAME is a string, save
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 the PostScript image in a file with that name. If FILENAME is a
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 number, prompt the user for the name of the file to save in.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 The image is rendered using the PostScript font Courier.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 See also: ps-print-buffer-with-faces
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ps-spool-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 ps-spool-buffer-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (interactive "P")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (setq filename (ps-preprint filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (ps-generate (current-buffer) (point-min) (point-max)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 'ps-generate-postscript)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (ps-do-despool filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (defun ps-print-buffer-with-faces (&optional filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 "Generate and print a PostScript image of the buffer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 This function works like ps-print-buffer, with the additional benefit
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 that any bold/italic formatting information present in the buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (contained in extents and faces) will be retained in the PostScript
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 image. In other words, WYSIAWYG -- What You See Is (Almost) What You
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 Get.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 Ps-print uses three lists to determine which faces should be printed
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 bold, italic, and/or underlined; the lists are named ps-bold-faces, ps-
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 italic-faces, and ps-underline-faces. A given face should appear on as
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 many lists as are appropriate; for example, face bold-italic is in both
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 the lists ps-bold-faces and ps-italic-faces. The lists are pre-built
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 with the standard bold, italic, and bold-italic faces, with font-lock's
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 faces, and with the faces used by gnus and rmail.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 The image is rendered using the PostScript fonts Courier, Courier-Bold,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 Courier-Oblique, and Courier-BoldOblique.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 See also: ps-print-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ps-spool-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 ps-spool-buffer-with-faces."
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (interactive "P")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (setq filename (ps-preprint filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (ps-generate (current-buffer) (point-min) (point-max)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 'ps-generate-postscript-with-faces)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (ps-do-despool filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (defun ps-print-region (from to &optional filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "Generate and print a PostScript image of the region.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 When called with a numeric prefix argument (C-u), prompt the user for
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 the name of a file to save the PostScript image in, instead of sending
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 it to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 This function is essentially the same as ps-print-buffer except that it
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 prints just a region, and not the entire buffer. For more information,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 see the function ps-print-buffer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 See also: ps-print-region-with-faces
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 ps-spool-region
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 ps-spool-region-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (interactive "r\nP")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (setq filename (ps-preprint filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (ps-generate (current-buffer) from to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 'ps-generate-postscript)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (ps-do-despool filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (defun ps-print-region-with-faces (from to &optional filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 "Generate and print a PostScript image of the region.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 This function is essentially the same as ps-print-buffer except that it
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 prints just a region, and not the entire buffer. See the functions
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 ps-print-region and ps-print-buffer-with-faces for
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 more information.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 See also: ps-print-region
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ps-spool-region
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 ps-spool-region-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (interactive "r\nP")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (setq filename (ps-preprint filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (ps-generate (current-buffer) from to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 'ps-generate-postscript-with-faces)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (ps-do-despool filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (defun ps-spool-buffer ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 "Generate and spool a PostScript image of the buffer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 This function is essentially the same as function ps-print-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 except that the PostScript image is saved in a local buffer to be sent
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 to the printer later.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 Each time you call one of the ps-spool- functions, the generated
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 PostScript is appended to a buffer named *PostScript*; to send the
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 spooled PostScript to the printer, or save it to a file, use the command
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 ps-despool.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 If the variable ps-spool-duplex is non-nil, then the spooled PostScript
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 is padded with blank pages, when needed, so that each printed buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 will start on a front page when printed on a duplex printer (a printer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 that prints on both sides on the paper). Users of non-duplex printers
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 will want to leave ps-spool-duplex nil.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 The spooling mechanism was designed for printing lots of small files
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (mail messages or netnews articles) to save paper that would otherwise
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 be wasted on banner pages, and to make it easier to find your output at
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 the printer (it's easier to pick up one 50-page printout than to find 50
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 single-page printouts).
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 Ps-print has a hook in the kill-emacs-hook list so that you won't
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 accidently quit from Emacs while you have unprinted PostScript waiting
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 in the spool buffer. If you do attempt to exit with spooled PostScript,
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 you'll be asked if you want to print it, and if you decline, you'll be
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 asked to confirm the exit; this is modeled on the confirmation that
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 Emacs uses for modified buffers.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 See also: ps-despool
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 ps-print-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 ps-print-buffer-with-faces
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 ps-spool-buffer-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (interactive)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (ps-generate (current-buffer) (point-min) (point-max)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 'ps-generate-postscript))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (defun ps-spool-buffer-with-faces ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 "Generate and spool PostScript image of the buffer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 This function is essentially the same as function ps-print-buffer-with-
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 faces except that the PostScript image is saved in a local buffer to be
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 sent to the printer later.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 Use the function ps-despool to send the spooled images to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 See the function ps-spool-buffer for a description of the spooling
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 mechanism.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 See also: ps-despool
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ps-spool-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ps-print-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ps-print-buffer-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (interactive)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (ps-generate (current-buffer) (point-min) (point-max)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 'ps-generate-postscript-with-faces))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (defun ps-spool-region (from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 "Generate PostScript image of the region and spool locally.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 This function is essentially the same as function ps-print-region except
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 that the PostScript image is saved in a local buffer to be sent to the
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 printer later.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 Use the function ps-despool to send the spooled images to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 See the function ps-spool-buffer for a description of the spooling
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 mechanism.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 See also: ps-despool
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ps-spool-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 ps-print-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 ps-print-buffer-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (interactive "r")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (ps-generate (current-buffer) from to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 'ps-generate-postscript))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (defun ps-spool-region-with-faces (from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 "Generate PostScript image of the region and spool locally.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 This function is essentially the same as function ps-print-region-with-
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 faces except that the PostScript image is saved in a local buffer to be
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 sent to the printer later.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 Use the function ps-despool to send the spooled images to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 See the function ps-spool-buffer for a description of the spooling
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 mechanism.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 See also: ps-despool
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 ps-spool-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 ps-print-buffer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 ps-print-buffer-with-faces"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (interactive "r")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (ps-generate (current-buffer) from to
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 'ps-generate-postscript-with-faces))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (defvar ps-spool-duplex nil ; Not many people have duplex
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 ; printers, so default to nil.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 "*Non-nil indicates spooling is for a two-sided printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 For a duplex printer, the ps-spool functions will insert blank pages
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 as needed between print jobs so that the next buffer printed will
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 start on the right page.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (defun ps-despool (&optional filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 "Send the spooled PostScript to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 When called with a numeric prefix argument (C-u), prompt the user for
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 the name of a file to save the spooled PostScript in, instead of sending
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 it to the printer.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 More specifically, the FILENAME argument is treated as follows: if it
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 is nil, send the image to the printer. If FILENAME is a string, save
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 the PostScript image in a file with that name. If FILENAME is a
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 number, prompt the user for the name of the file to save in."
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (interactive "P")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 ;; If argument FILENAME is nil, send the image to the printer; if
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 ;; FILENAME is a string, save the PostScript image in that filename;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 ;; if FILENAME is a number, prompt the user for the name of the file
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 ;; to save in.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (setq filename (ps-preprint filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (ps-do-despool filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 ;; Here end the definitions that users need to know about; proceed
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 ;; further at your own risk!
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (defun ps-kill-emacs-check ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (if (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (buffer-modified-p ps-buffer))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (if (y-or-n-p "Unprinted PostScript waiting... print now? ")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (ps-despool)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (if (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (buffer-modified-p ps-buffer))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (if (yes-or-no-p "Unprinted PostScript waiting; exit anyway? ")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 nil
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (error "Unprinted PostScript"))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (if (fboundp 'add-hook)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (add-hook 'kill-emacs-hook 'ps-kill-emacs-check)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (if kill-emacs-hook
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (message "Won't override existing kill-emacs-hook.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (setq kill-emacs-hook 'ps-kill-emacs-check)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (defun ps-preprint (&optional filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (if (and filename
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (or (numberp filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (listp filename)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (setq filename
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (let* ((name (concat (buffer-name) ".ps"))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (prompt (format "Save PostScript to file: (default %s) "
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 name)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (read-file-name prompt default-directory
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 name nil)))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (defvar ps-spool-buffer-name "*PostScript*")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (defvar ps-col 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (defvar ps-row 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (defvar ps-xpos 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (defvar ps-ypos 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (defvar ps-chars-per-line 80)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (defvar ps-lines-per-page 66)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (defvar ps-page-start-ypos 745)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (defvar ps-line-start-xpos 40)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (defvar ps-char-xpos-inc 6)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (defvar ps-line-ypos-inc 11)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (defvar ps-current-font 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (defvar ps-multiple nil)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (defvar ps-virtual-page-number 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (defun ps-begin-file ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (goto-char (point-min))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (setq ps-real-page-number 1)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (insert
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 "%!PS-Adobe-1.0
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 /S /show load def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 /M /moveto load def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 /L { gsave newpath 3 1 roll 1 sub M 0 rlineto closepath stroke grestore } def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 /F{$fd exch get setfont}def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 /StartPage{/svpg save def}def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 /EndPage{svpg restore showpage}def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 /SetUpFonts
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 {dup/$fd exch array def{findfont exch scalefont $fd 3 1 roll put}repeat}def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 % Define /ISOLatin1Encoding only if it's not already there.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 /ISOLatin1Encoding where { pop save true }{ false } ifelse
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 /ISOLatin1Encoding [ StandardEncoding 0 45 getinterval aload pop /minus
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 StandardEncoding 46 98 getinterval aload pop /dotlessi /grave /acute
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 /circumflex /tilde /macron /breve /dotaccent /dieresis /.notdef /ring
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 /cedilla /.notdef /hungarumlaut /ogonek /caron /space /exclamdown /cent
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 /sterling /currency /yen /brokenbar /section /dieresis /copyright
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 /onequarter /onehalf /threequarters /questiondown /Agrave /Aacute
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 /otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 /udieresis /yacute /thorn /ydieresis ] def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 { restore } if
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 /reencodeISO { %def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 findfont dup length dict begin
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 { 1 index /FID ne { def }{ pop pop } ifelse } forall
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 /Encoding ISOLatin1Encoding def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 currentdict end definefont pop
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 } bind def
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 /CourierISO /Courier reencodeISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 /Courier-ObliqueISO /Courier-Oblique reencodeISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 /Courier-BoldISO /Courier-Bold reencodeISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 /Courier-BoldObliqueISO /Courier-BoldOblique reencodeISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 3 10 /Courier-BoldObliqueISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 2 10 /Courier-ObliqueISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 1 10 /Courier-BoldISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 0 10 /CourierISO
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 4 SetUpFonts
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 .4 setlinewidth
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 ")))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (defun ps-end-file ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 )
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (defun ps-next-page ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (ps-end-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (ps-begin-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (ps-set-font ps-current-font)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (ps-init-page))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (defun ps-top-of-page () (ps-next-page))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (defun ps-init-page ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (setq ps-row 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 (setq ps-col 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (setq ps-ypos ps-page-start-ypos)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (setq ps-xpos ps-line-start-xpos)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (ps-set-font))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (defun ps-begin-page ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (goto-char (point-max))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (insert (format "%%%%Page: ? %d\n" ps-real-page-number))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 (setq ps-real-page-number (+ 1 ps-real-page-number))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (insert "StartPage\n0.4 setlinewidth\n")))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (defun ps-end-page ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 (goto-char (point-max))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (insert "EndPage\n")))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (defun ps-next-line ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (setq ps-row (+ ps-row 1))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 (if (>= ps-row ps-lines-per-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (ps-next-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (setq ps-col 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (setq ps-xpos ps-line-start-xpos)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (setq ps-ypos (- ps-ypos ps-line-ypos-inc))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (defun ps-continue-line ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (ps-next-line))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (defvar ps-source-buffer nil)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 (defvar ps-output-buffer nil)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (defun ps-basic-plot-string (from to &optional underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (setq text (buffer-substring from to))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (goto-char (point-max))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (setq count (- to from))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (if underline-p
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (insert (format "%d %d %d L\n" ps-xpos ps-ypos
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (* count ps-char-xpos-inc))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (insert (format "%d %d M (" ps-xpos ps-ypos))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (insert text))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (while (re-search-forward "[()\\]" nil t)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (forward-char -1)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (insert "\\")))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (end-of-line)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (insert ") S\n")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (setq ps-xpos (+ ps-xpos (* count ps-char-xpos-inc)))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (defun ps-basic-plot-whitespace (from to underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (setq count (- to from))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (setq ps-xpos (+ ps-xpos (* count ps-char-xpos-inc))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (defun ps-plot (plotfunc from to &optional underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (while (< from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (setq count (- to from))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 ;; Test to see whether this region will fit on the current line
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (if (<= (+ ps-col count) ps-chars-per-line)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (progn
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 ;; It fits; plot it.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (funcall plotfunc from to underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (setq from to))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 ;; It needs to be wrapped; plot part of it, then loop
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (setq chars-that-will-fit (- ps-chars-per-line ps-col))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (funcall plotfunc from (+ from chars-that-will-fit))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (ps-continue-line)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (setq from (+ from chars-that-will-fit))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (let* ((q-todo (- (point-max) (point-min)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (q-done (- to (point-min)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 (chunkfrac (/ q-todo 8))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 (chunksize (if (> chunkfrac 10000) 10000 chunkfrac)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (if (> (- q-done ps-razchunk) chunksize)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 (progn
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 (setq ps-razchunk q-done)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (setq foo
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (if (< q-todo 100)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (* (/ q-done q-todo) 100)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (setq basis (/ q-todo 100))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (/ q-done basis)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (message "Formatting... %d%%" foo))))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (defun ps-set-font (&optional font)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (goto-char (point-max))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (insert (format "%d F\n" (if font font ps-current-font))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (if font
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (setq ps-current-font font)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (defun ps-plot-region (from to font &optional underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (ps-set-font font)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (goto-char from)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (while (< from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (if (re-search-forward "[\t\n\014]" to t)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (let ((match (char-after (match-beginning 0))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (cond
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 ((= match ?\n)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (ps-plot 'ps-basic-plot-string from (- (point) 1) underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (ps-next-line))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 ((= match ?\t)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (ps-plot 'ps-basic-plot-string from (- (point) 1) underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (setq linestart (save-excursion (beginning-of-line) (point)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (forward-char -1)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (setq from (+ linestart (current-column)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (if (re-search-forward "[ \t]+" to t)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (ps-plot 'ps-basic-plot-whitespace from
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (+ linestart (current-column)))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 ((= match ?\014)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (ps-plot 'ps-basic-plot-string from (- (point) 1) underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (ps-top-of-page)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (setq from (point)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 (ps-plot 'ps-basic-plot-string from to underline-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (setq from to)))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (defun ps-format-buffer ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (interactive)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 (setq ps-source-buffer (current-buffer))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (setq ps-output-buffer (get-buffer-create "%PostScript%"))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (delete-region (point-max) (point-min)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (ps-begin-file)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (ps-begin-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (ps-init-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (ps-plot-region (point-min) (point-max) 0)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (ps-end-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (ps-end-file)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 )
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (defun ps-mapper (extent list)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (nconc list (list (list (extent-start-position extent) 'push extent)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 (list (extent-end-position extent) 'pull extent)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 nil)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (defun ps-sorter (a b)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (< (car a) (car b)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (defun ps-extent-sorter (a b)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (< (extent-priority a) (extent-priority b)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (defun overlay-priority (p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (if (setq priority (overlay-get p 'priority)) priority 0))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (defun ps-overlay-sorter (a b)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (> (overlay-priority a) (overlay-priority b)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (defun ps-plot-with-face (from to face)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (setq bold-p (memq face ps-bold-faces))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 (setq italic-p (memq face ps-italic-faces))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (setq underline-p (memq face ps-underline-faces))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 (cond
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 ((and bold-p italic-p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 (ps-plot-region from to 3 underline-p))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (italic-p
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (ps-plot-region from to 2 underline-p))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 (bold-p
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (ps-plot-region from to 1 underline-p))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (t
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (ps-plot-region from to 0 underline-p))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 (defun ps-generate-postscript-with-faces (from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (save-restriction
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (narrow-to-region from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (setq face 'default)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 (cond ((string-match "Lucid" emacs-version)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 ;; Build the list of extents...
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 (let ((a (cons 'dummy nil)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (map-extents 'ps-mapper nil from to a)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (setq a (cdr a))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (setq a (sort a 'ps-sorter))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (setq extent-list nil)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 ;; Loop through the extents...
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 (while a
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (setq record (car a))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (setq position (car record))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (setq record (cdr record))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (setq type (car record))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (setq record (cdr record))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (setq extent (car record))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 ;; Plot up to this record.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 (ps-plot-with-face from position face)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (cond
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 ((eq type 'push)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (setq extent-list (sort (cons extent extent-list)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 'ps-extent-sorter)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 ((eq type 'pull)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 (setq extent-list (sort (delq extent extent-list)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 'ps-extent-sorter))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (setq face
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (if extent-list
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (extent-face (car extent-list))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 'default))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (setq from position)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (setq a (cdr a)))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 ((string-match "^19" emacs-version)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (while (< from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 (setq prop-position
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 (if (setq p (next-property-change from))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 (if (> p to) to p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 to))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 (setq over-position
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 (if (setq p (next-overlay-change from))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (if (> p to) to p)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 to))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (setq position
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (if (< prop-position over-position)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 prop-position
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 over-position))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (setq face
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 (if (setq f (get-text-property from 'face)) f 'default))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 (if (setq overlays (overlays-at from))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 (progn
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 (setq overlays (sort overlays 'ps-overlay-sorter))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (while overlays
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 (if (setq face (overlay-get (car overlays) 'face))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (setq overlays nil)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (setq overlays (cdr overlays))))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 ;; Plot up to this record.
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (ps-plot-with-face from position face)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (setq from position))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (ps-plot-with-face from to face)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 (defun ps-generate-postscript (from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (ps-plot-region from to 0))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (defun ps-generate (buffer from to genfunc)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (save-restriction
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (narrow-to-region from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (message "Formatting... %d%%" (setq ps-razchunk 0)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 (set-buffer buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (setq ps-source-buffer buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (setq ps-output-buffer (get-buffer-create ps-spool-buffer-name))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 (unwind-protect
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (progn
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 (goto-char (point-min))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (if (looking-at (regexp-quote "%!PS-Adobe-1.0"))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 (ps-set-font ps-current-font)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (ps-begin-file))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (ps-begin-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (ps-init-page)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (goto-char (point-max))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 (if (and ps-spool-duplex
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 (re-search-backward "^%%Page")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (looking-at "^%%Page.*[24680]$"))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (ps-next-page))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 (set-buffer ps-source-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (funcall genfunc from to)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 (ps-end-page)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (message "Formatting... Done."))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (defun ps-do-despool (filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (if (or (not (boundp 'ps-output-buffer))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (not ps-output-buffer))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 (message "No spooled PostScript to print.")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 (ps-end-file)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (if filename
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (message "Saving..."))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 (setq filename (expand-file-name filename))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (write-region (point-min) (point-max) filename)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 (message "Wrote %s" filename)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 ;; Else, spool to the printer
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (message "Printing..."))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (set-buffer ps-output-buffer)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (apply 'call-process-region
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (point-min) (point-max) ps-lpr-command nil 0 nil
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 ps-lpr-switches))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (if ps-razzle-dazzle
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (message "Printing... Done.")))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (kill-buffer ps-output-buffer)))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 (defun ps-testpattern ()
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (setq foo 1)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 (while (< foo 60)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (insert "|" (make-string foo ?\ ) (format "%d\n" foo))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (setq foo (+ 1 foo))))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (defun pts (stuff)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (save-excursion
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (set-buffer "*scratch*")
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (goto-char (point-max))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (insert "---------------------------------\n"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (symbol-name stuff) ":\n"
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (prin1-to-string (symbol-value stuff))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 "\n")))
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 (provide 'ps-print)
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961
3759ad84023b Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 ;; ps-print.el ends here