Commit | Line | Data |
---|---|---|
535efc38 | 1 | ;;; ps-print.el --- Print text from the buffer as PostScript |
12d89a2e | 2 | |
70f57a72 | 3 | ;; Copyright (C) 1993, 2000 Free Software Foundation, Inc. |
ef2cbb24 | 4 | |
e65df0a1 | 5 | ;; Author: Jim Thompson (was <thompson@wg2.waii.com>) |
024ced4d | 6 | ;; Author: Jacques Duthen (was <duthen@cegelec-red.fr>) |
e65df0a1 | 7 | ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
024ced4d KH |
8 | ;; Author: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) |
9 | ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) | |
e65df0a1 | 10 | ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
bc0d41bd | 11 | ;; Keywords: wp, print, PostScript |
ea0c615d GM |
12 | ;; Time-stamp: <2000/10/28 23:38:44 Vinicius> |
13 | ;; Version: 6.3 | |
3556c6dd | 14 | ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ |
e65df0a1 | 15 | |
ea0c615d GM |
16 | (defconst ps-print-version "6.3" |
17 | "ps-print.el, v 6.3 <2000/10/28 vinicius> | |
090be653 | 18 | |
535efc38 | 19 | Vinicius's last change version -- this file may have been edited as part of |
906d41a7 GM |
20 | Emacs without changes to the version number. When reporting bugs, please also |
21 | report the version of Emacs, if any, that ps-print was distributed with. | |
090be653 RS |
22 | |
23 | Please send all bug fixes and enhancements to | |
8bd22fcf | 24 | Vinicius Jose Latorre <vinicius@cpqd.com.br>. |
090be653 | 25 | ") |
ef2cbb24 | 26 | |
86c10ecb | 27 | ;; This file is part of GNU Emacs. |
ef2cbb24 RS |
28 | |
29 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
30 | ;; it under the terms of the GNU General Public License as published by | |
31 | ;; the Free Software Foundation; either version 2, or (at your option) | |
32 | ;; any later version. | |
33 | ||
34 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
35 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
36 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
37 | ;; GNU General Public License for more details. | |
38 | ||
39 | ;; You should have received a copy of the GNU General Public License | |
b578f267 EN |
40 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
41 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
42 | ;; Boston, MA 02111-1307, USA. | |
ef2cbb24 | 43 | |
12d89a2e | 44 | ;;; Commentary: |
ef2cbb24 | 45 | |
bc0d41bd | 46 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ef2cbb24 | 47 | ;; |
12d89a2e | 48 | ;; About ps-print |
ef2cbb24 | 49 | ;; -------------- |
bcc0d457 | 50 | ;; |
0a5daee5 KH |
51 | ;; This package provides printing of Emacs buffers on PostScript printers; |
52 | ;; the buffer's bold and italic text attributes are preserved in the printer | |
53 | ;; output. ps-print is intended for use with Emacs or Lucid Emacs, together | |
54 | ;; with a fontifying package such as font-lock or hilit. | |
12d89a2e | 55 | ;; |
87a16a06 RS |
56 | ;; ps-print uses the same face attributes defined through font-lock or hilit |
57 | ;; to print a PostScript file, but some faces are better seeing on the screen | |
58 | ;; than on paper, specially when you have a black/white PostScript printer. | |
59 | ;; | |
60 | ;; ps-print allows a remap of face to another one that it is better to print, | |
61 | ;; for example, the face font-lock-comment-face (if you are using font-lock) | |
62 | ;; could have bold or italic attribute when printing, besides foreground color. | |
63 | ;; This remap improves printing look (see How Ps-Print Maps Faces). | |
64 | ;; | |
bcc0d457 | 65 | ;; |
12d89a2e | 66 | ;; Using ps-print |
ef2cbb24 | 67 | ;; -------------- |
ef2cbb24 | 68 | ;; |
d3ab8dac | 69 | ;; ps-print provides eight commands for generating PostScript images |
12d89a2e RS |
70 | ;; of Emacs buffers: |
71 | ;; | |
72 | ;; ps-print-buffer | |
73 | ;; ps-print-buffer-with-faces | |
74 | ;; ps-print-region | |
75 | ;; ps-print-region-with-faces | |
76 | ;; ps-spool-buffer | |
77 | ;; ps-spool-buffer-with-faces | |
78 | ;; ps-spool-region | |
79 | ;; ps-spool-region-with-faces | |
80 | ;; | |
81 | ;; These commands all perform essentially the same function: they | |
82 | ;; generate PostScript images suitable for printing on a PostScript | |
83 | ;; printer or displaying with GhostScript. These commands are | |
84 | ;; collectively referred to as "ps-print- commands". | |
85 | ;; | |
86 | ;; The word "print" or "spool" in the command name determines when the | |
87 | ;; PostScript image is sent to the printer: | |
ef2cbb24 | 88 | ;; |
12d89a2e RS |
89 | ;; print - The PostScript image is immediately sent to the |
90 | ;; printer; | |
ef2cbb24 | 91 | ;; |
12d89a2e RS |
92 | ;; spool - The PostScript image is saved temporarily in an |
93 | ;; Emacs buffer. Many images may be spooled locally | |
94 | ;; before printing them. To send the spooled images | |
bcc0d457 | 95 | ;; to the printer, use the command `ps-despool'. |
ef2cbb24 | 96 | ;; |
12d89a2e RS |
97 | ;; The spooling mechanism was designed for printing lots of small |
98 | ;; files (mail messages or netnews articles) to save paper that would | |
99 | ;; otherwise be wasted on banner pages, and to make it easier to find | |
100 | ;; your output at the printer (it's easier to pick up one 50-page | |
101 | ;; printout than to find 50 single-page printouts). | |
06fb6aab | 102 | ;; |
d3ab8dac | 103 | ;; ps-print has a hook in the `kill-emacs-hook' so that you won't |
a7acbbe4 | 104 | ;; accidentally quit from Emacs while you have unprinted PostScript |
12d89a2e RS |
105 | ;; waiting in the spool buffer. If you do attempt to exit with |
106 | ;; spooled PostScript, you'll be asked if you want to print it, and if | |
107 | ;; you decline, you'll be asked to confirm the exit; this is modeled | |
108 | ;; on the confirmation that Emacs uses for modified buffers. | |
109 | ;; | |
110 | ;; The word "buffer" or "region" in the command name determines how | |
111 | ;; much of the buffer is printed: | |
112 | ;; | |
113 | ;; buffer - Print the entire buffer. | |
114 | ;; | |
115 | ;; region - Print just the current region. | |
116 | ;; | |
117 | ;; The -with-faces suffix on the command name means that the command | |
118 | ;; will include font, color, and underline information in the | |
119 | ;; PostScript image, so the printed image can look as pretty as the | |
120 | ;; buffer. The ps-print- commands without the -with-faces suffix | |
121 | ;; don't include font, color, or underline information; images printed | |
122 | ;; with these commands aren't as pretty, but are faster to generate. | |
123 | ;; | |
124 | ;; Two ps-print- command examples: | |
125 | ;; | |
126 | ;; ps-print-buffer - print the entire buffer, | |
127 | ;; without font, color, or | |
128 | ;; underline information, and | |
129 | ;; send it immediately to the | |
130 | ;; printer. | |
131 | ;; | |
132 | ;; ps-spool-region-with-faces - print just the current region; | |
133 | ;; include font, color, and | |
134 | ;; underline information, and | |
135 | ;; spool the image in Emacs to | |
136 | ;; send to the printer later. | |
137 | ;; | |
138 | ;; | |
139 | ;; Invoking Ps-Print | |
bcc0d457 | 140 | ;; ----------------- |
ef2cbb24 | 141 | ;; |
12d89a2e | 142 | ;; To print your buffer, type |
ef2cbb24 | 143 | ;; |
12d89a2e | 144 | ;; M-x ps-print-buffer |
ef2cbb24 | 145 | ;; |
12d89a2e RS |
146 | ;; or substitute one of the other seven ps-print- commands. The |
147 | ;; command will generate the PostScript image and print or spool it as | |
148 | ;; specified. By giving the command a prefix argument | |
149 | ;; | |
150 | ;; C-u M-x ps-print-buffer | |
151 | ;; | |
152 | ;; it will save the PostScript image to a file instead of sending it | |
153 | ;; to the printer; you will be prompted for the name of the file to | |
154 | ;; save the image to. The prefix argument is ignored by the commands | |
155 | ;; that spool their images, but you may save the spooled images to a | |
bcc0d457 | 156 | ;; file by giving a prefix argument to `ps-despool': |
12d89a2e RS |
157 | ;; |
158 | ;; C-u M-x ps-despool | |
159 | ;; | |
bcc0d457 | 160 | ;; When invoked this way, `ps-despool' will prompt you for the name of |
12d89a2e RS |
161 | ;; the file to save to. |
162 | ;; | |
bcc0d457 RS |
163 | ;; Any of the `ps-print-' commands can be bound to keys; I recommend |
164 | ;; binding `ps-spool-buffer-with-faces', `ps-spool-region-with-faces', | |
165 | ;; and `ps-despool'. Here are the bindings I use on my Sun 4 keyboard: | |
12d89a2e RS |
166 | ;; |
167 | ;; (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc | |
ef2cbb24 RS |
168 | ;; (global-set-key '(shift f22) 'ps-spool-region-with-faces) |
169 | ;; (global-set-key '(control f22) 'ps-despool) | |
170 | ;; | |
12d89a2e RS |
171 | ;; |
172 | ;; The Printer Interface | |
bcc0d457 | 173 | ;; --------------------- |
12d89a2e | 174 | ;; |
bcc0d457 | 175 | ;; The variables `ps-lpr-command' and `ps-lpr-switches' determine what |
12d89a2e | 176 | ;; command is used to send the PostScript images to the printer, and |
bcc0d457 RS |
177 | ;; what arguments to give the command. These are analogous to |
178 | ;; `lpr-command' and `lpr-switches'. | |
87a16a06 | 179 | ;; |
bcc0d457 RS |
180 | ;; Make sure that they contain appropriate values for your system; |
181 | ;; see the usage notes below and the documentation of these variables. | |
182 | ;; | |
bc0d41bd | 183 | ;; The variable `ps-printer-name' determines the name of a local printer for |
d3ab8dac KH |
184 | ;; printing PostScript files. |
185 | ;; | |
3556c6dd GM |
186 | ;; The variable `ps-printer-name-option' determines the option used by some |
187 | ;; utilities to indicate the printer name, it's used only when | |
188 | ;; `ps-printer-name' is a non-empty string. If you're using lpr utility to | |
189 | ;; print, for example, `ps-printer-name-option' should be set to "-P". | |
190 | ;; | |
bcc0d457 RS |
191 | ;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values |
192 | ;; from the variables `lpr-command' and `lpr-switches'. If you have | |
193 | ;; `lpr-command' set to invoke a pretty-printer such as `enscript', | |
194 | ;; then ps-print won't work properly. `ps-lpr-command' must name | |
12d89a2e | 195 | ;; a program that does not format the files it prints. |
d3ab8dac | 196 | ;; `ps-printer-name' takes its initial value from the variable |
3556c6dd GM |
197 | ;; `printer-name'. `ps-printer-name-option' tries to guess which system |
198 | ;; Emacs is running and takes its initial value in accordance with this | |
199 | ;; guess. | |
12d89a2e | 200 | ;; |
bc0d41bd KH |
201 | ;; The variable `ps-print-region-function' specifies a function to print the |
202 | ;; region on a PostScript printer. | |
203 | ;; See definition of `call-process-region' for calling conventions. The fourth | |
204 | ;; and the sixth arguments are both nil. | |
205 | ;; | |
8e234846 GM |
206 | ;; The variable `ps-manual-feed' indicates if the printer will manually feed |
207 | ;; paper. If it's nil, automatic feeding takes place. If it's non-nil, manual | |
208 | ;; feeding takes place. The default is nil (automatic feeding). | |
209 | ;; | |
98f2fbe7 | 210 | ;; If you're using Emacs for Windows 95/98/NT or MS-DOS, don't forget to |
3556c6dd GM |
211 | ;; customize the following variables: `ps-printer-name', |
212 | ;; `ps-printer-name-option', `ps-lpr-command', `ps-lpr-switches' and | |
213 | ;; `ps-spool-config'. See these variables documentation in the code or by | |
214 | ;; typing, for example, C-h v ps-printer-name RET. | |
edc9cd35 | 215 | ;; |
12d89a2e | 216 | ;; |
bcc0d457 RS |
217 | ;; The Page Layout |
218 | ;; --------------- | |
12d89a2e | 219 | ;; |
bcc0d457 RS |
220 | ;; All dimensions are floats in PostScript points. |
221 | ;; 1 inch == 2.54 cm == 72 points | |
222 | ;; 1 cm == (/ 1 2.54) inch == (/ 72 2.54) points | |
12d89a2e | 223 | ;; |
906d41a7 GM |
224 | ;; The variable `ps-paper-type' determines the size of paper ps-print formats |
225 | ;; for; it should contain one of the symbols: `a4' `a3' `letter' `legal' | |
226 | ;; `letter-small' `tabloid' `ledger' `statement' `executive' `a4small' `b4' | |
227 | ;; `b5'. | |
12d89a2e | 228 | ;; |
8e234846 GM |
229 | ;; If variable `ps-warn-paper-type' is nil, it's *not* given an error if |
230 | ;; PostScript printer doesn't have a paper with the size indicated by | |
231 | ;; `ps-paper-type', instead it uses the default paper size. If variable | |
232 | ;; `ps-warn-paper-type' is non-nil, it's given an error if PostScript printer | |
233 | ;; doesn't have a paper with the size indicated by `ps-paper-type'. It's used | |
234 | ;; when `ps-spool-config' is set to `setpagedevice' (see section Duplex | |
235 | ;; Printers). The default value is non-nil (it gives an error). | |
236 | ;; | |
906d41a7 GM |
237 | ;; The variable `ps-landscape-mode' determines the orientation of the printing |
238 | ;; on the page: nil means `portrait' mode, non-nil means `landscape' mode. | |
bcc0d457 | 239 | ;; There is no oblique mode yet, though this is easy to do in ps. |
87a16a06 | 240 | ;; |
906d41a7 GM |
241 | ;; In landscape mode, the text is NOT scaled: you may print 70 lines in portrait |
242 | ;; mode and only 50 lines in landscape mode. The margins represent margins in | |
243 | ;; the printed paper: the top margin is the margin between the top of the page | |
bcc0d457 | 244 | ;; and the printed header, whatever the orientation is. |
043620f4 | 245 | ;; |
906d41a7 GM |
246 | ;; The variable `ps-number-of-columns' determines the number of columns both in |
247 | ;; landscape and portrait mode. | |
bcc0d457 | 248 | ;; You can use: |
906d41a7 GM |
249 | ;; - (the standard) one column portrait mode. |
250 | ;; - (my favorite) two columns landscape mode (which spares trees). | |
251 | ;; but also: | |
bcc0d457 | 252 | ;; - one column landscape mode for files with very long lines. |
906d41a7 GM |
253 | ;; - multi-column portrait or landscape mode. |
254 | ;; | |
255 | ;; The variable `ps-print-upside-down' determines other orientation for printing | |
256 | ;; page: nil means `normal' printing, non-nil means `upside-down' printing. The | |
257 | ;; default value is nil (`normal' printing). | |
258 | ;; | |
259 | ;; The `upside-down' orientation can be used in portrait or landscape mode. | |
12d89a2e | 260 | ;; |
1fd9b7fe GM |
261 | ;; The variable `ps-selected-pages' specifies which pages to print. If it's |
262 | ;; nil, all pages are printed. If it's a list, the list element may be an | |
263 | ;; integer or a cons cell (FROM . TO) designating FROM page to TO page; any | |
264 | ;; invalid element is ignored, that is, an integer lesser than one or if FROM | |
265 | ;; is greater than TO. Otherwise, it's treated as nil. The default value is | |
266 | ;; nil (print all pages). After ps-print processing `ps-selected-pages' is set | |
267 | ;; to nil. But the latest `ps-selected-pages' is saved in | |
268 | ;; `ps-last-selected-pages' (see it for documentation). So you can restore the | |
269 | ;; latest selected pages by using `ps-last-selected-pages' or by calling | |
270 | ;; `ps-restore-selected-pages' command (see it for documentation). | |
271 | ;; | |
c3d6d211 GM |
272 | ;; The variable `ps-even-or-odd-pages' specifies if it prints even/odd pages. |
273 | ;; | |
274 | ;; Valid values are: | |
275 | ;; | |
276 | ;; nil print all pages. | |
277 | ;; | |
278 | ;; even print only even pages. | |
279 | ;; | |
280 | ;; odd print only odd pages. | |
281 | ;; | |
282 | ;; Any other value is treated as nil. The default value is nil. | |
283 | ;; | |
12d89a2e | 284 | ;; |
bcc0d457 RS |
285 | ;; Horizontal layout |
286 | ;; ----------------- | |
12d89a2e | 287 | ;; |
bcc0d457 RS |
288 | ;; The horizontal layout is determined by the variables |
289 | ;; `ps-left-margin' `ps-inter-column' `ps-right-margin' | |
290 | ;; as follows: | |
12d89a2e | 291 | ;; |
bcc0d457 RS |
292 | ;; ------------------------------------------ |
293 | ;; | | | | | | | | | |
294 | ;; | lm | text | ic | text | ic | text | rm | | |
295 | ;; | | | | | | | | | |
296 | ;; ------------------------------------------ | |
12d89a2e | 297 | ;; |
bcc0d457 RS |
298 | ;; If `ps-number-of-columns' is 1, `ps-inter-column' is not relevant. |
299 | ;; Usually, lm = rm > 0 and ic = lm | |
300 | ;; If (ic < 0), the text of adjacent columns can overlap. | |
12d89a2e | 301 | ;; |
12d89a2e | 302 | ;; |
bcc0d457 RS |
303 | ;; Vertical layout |
304 | ;; --------------- | |
305 | ;; | |
306 | ;; The vertical layout is determined by the variables | |
307 | ;; `ps-bottom-margin' `ps-top-margin' `ps-header-offset' | |
308 | ;; as follows: | |
309 | ;; | |
310 | ;; |--------| |--------| | |
311 | ;; | tm | | tm | | |
312 | ;; |--------| |--------| | |
313 | ;; | header | | | | |
314 | ;; |--------| | | | |
315 | ;; | ho | | | | |
316 | ;; |--------| or | text | | |
317 | ;; | | | | | |
318 | ;; | text | | | | |
319 | ;; | | | | | |
320 | ;; |--------| |--------| | |
321 | ;; | bm | | bm | | |
322 | ;; |--------| |--------| | |
323 | ;; | |
324 | ;; If `ps-print-header' is nil, `ps-header-offset' is not relevant. | |
325 | ;; The margins represent margins in the printed paper: | |
326 | ;; the top margin is the margin between the top of the page | |
327 | ;; and the printed header, whatever the orientation is. | |
12d89a2e RS |
328 | ;; |
329 | ;; | |
330 | ;; Headers | |
bcc0d457 | 331 | ;; ------- |
12d89a2e | 332 | ;; |
d3ab8dac | 333 | ;; ps-print can print headers at the top of each column or at the top |
12b88fff RS |
334 | ;; of each page; the default headers contain the following four items: |
335 | ;; on the left, the name of the buffer and, if the buffer is visiting | |
336 | ;; a file, the file's directory; on the right, the page number and | |
337 | ;; date of printing. The default headers look something like this: | |
12d89a2e RS |
338 | ;; |
339 | ;; ps-print.el 1/21 | |
340 | ;; /home/jct/emacs-lisp/ps/new 94/12/31 | |
06fb6aab | 341 | ;; |
12d89a2e | 342 | ;; When printing on duplex printers, left and right are reversed so |
bcc0d457 | 343 | ;; that the page numbers are toward the outside (cf. `ps-spool-duplex'). |
12d89a2e | 344 | ;; |
bcc0d457 RS |
345 | ;; Headers are configurable: |
346 | ;; To turn them off completely, set `ps-print-header' to nil. | |
347 | ;; To turn off the header's gaudy framing box, | |
348 | ;; set `ps-print-header-frame' to nil. | |
349 | ;; | |
12b88fff RS |
350 | ;; To print only one header at the top of each page, |
351 | ;; set `ps-print-only-one-header' to t. | |
352 | ;; | |
8e234846 GM |
353 | ;; To switch headers, set `ps-switch-header' to: |
354 | ;; | |
355 | ;; nil Never switch headers. | |
356 | ;; | |
357 | ;; t Always switch headers. | |
358 | ;; | |
359 | ;; duplex Switch headers only when duplexing is on, that is, when | |
360 | ;; `ps-spool-duplex' is non-nil (see Duplex Printers). | |
361 | ;; | |
362 | ;; Any other value is treated as t. The default value is `duplex'. | |
363 | ;; | |
bcc0d457 | 364 | ;; The font family and size of text in the header are determined |
06fb6aab | 365 | ;; by the variables `ps-header-font-family', `ps-header-font-size' and |
bcc0d457 RS |
366 | ;; `ps-header-title-font-size' (see below). |
367 | ;; | |
368 | ;; The variable `ps-header-line-pad' determines the portion of a header | |
369 | ;; title line height to insert between the header frame and the text | |
370 | ;; it contains, both in the vertical and horizontal directions: | |
371 | ;; .5 means half a line. | |
8e234846 | 372 | ;; |
bcc0d457 RS |
373 | ;; Page numbers are printed in `n/m' format, indicating page n of m pages; |
374 | ;; to omit the total page count and just print the page number, | |
375 | ;; set `ps-show-n-of-n' to nil. | |
12d89a2e RS |
376 | ;; |
377 | ;; The amount of information in the header can be changed by changing | |
bcc0d457 | 378 | ;; the number of lines. To show less, set `ps-header-lines' to 1, and |
12d89a2e | 379 | ;; the header will show only the buffer name and page number. To show |
bcc0d457 | 380 | ;; more, set `ps-header-lines' to 3, and the header will show the time of |
12d89a2e RS |
381 | ;; printing below the date. |
382 | ;; | |
383 | ;; To change the content of the headers, change the variables | |
bcc0d457 RS |
384 | ;; `ps-left-header' and `ps-right-header'. |
385 | ;; These variables are lists, specifying top-to-bottom the text | |
386 | ;; to display on the left or right side of the header. | |
387 | ;; Each element of the list should be a string or a symbol. | |
388 | ;; Strings are inserted directly into the PostScript arrays, | |
389 | ;; and should contain the PostScript string delimiters '(' and ')'. | |
12d89a2e RS |
390 | ;; |
391 | ;; Symbols in the header format lists can either represent functions | |
392 | ;; or variables. Functions are called, and should return a string to | |
393 | ;; show in the header. Variables should contain strings to display in | |
394 | ;; the header. In either case, function or variable, the PostScript | |
a7acbbe4 | 395 | ;; string delimiters are added by ps-print, and should not be part of |
12d89a2e RS |
396 | ;; the returned value. |
397 | ;; | |
398 | ;; Here's an example: say we want the left header to display the text | |
399 | ;; | |
400 | ;; Moe | |
401 | ;; Larry | |
402 | ;; Curly | |
403 | ;; | |
404 | ;; where we have a function to return "Moe" | |
405 | ;; | |
406 | ;; (defun moe-func () | |
407 | ;; "Moe") | |
408 | ;; | |
409 | ;; a variable specifying "Larry" | |
410 | ;; | |
411 | ;; (setq larry-var "Larry") | |
412 | ;; | |
bcc0d457 | 413 | ;; and a literal for "Curly". Here's how `ps-left-header' should be |
12d89a2e RS |
414 | ;; set: |
415 | ;; | |
416 | ;; (setq ps-left-header (list 'moe-func 'larry-var "(Curly)")) | |
417 | ;; | |
418 | ;; Note that Curly has the PostScript string delimiters inside his | |
bcc0d457 | 419 | ;; quotes -- those aren't misplaced lisp delimiters! |
87a16a06 | 420 | ;; |
bcc0d457 RS |
421 | ;; Without them, PostScript would attempt to call the undefined |
422 | ;; function Curly, which would result in a PostScript error. | |
87a16a06 | 423 | ;; |
bcc0d457 RS |
424 | ;; Since most printers don't report PostScript errors except by |
425 | ;; aborting the print job, this kind of error can be hard to track down. | |
87a16a06 | 426 | ;; |
bcc0d457 | 427 | ;; Consider yourself warned! |
12d89a2e RS |
428 | ;; |
429 | ;; | |
d3ab8dac KH |
430 | ;; PostScript Prologue Header |
431 | ;; -------------------------- | |
432 | ;; | |
433 | ;; It is possible to add PostScript prologue header comments besides that | |
434 | ;; ps-print generates by setting the variable `ps-print-prologue-header'. | |
435 | ;; | |
bc0d41bd KH |
436 | ;; `ps-print-prologue-header' may be a string or a symbol function which returns |
437 | ;; a string. Note that this string is inserted on PostScript prologue header | |
438 | ;; section which is used to define some document characteristic through | |
d3ab8dac KH |
439 | ;; PostScript special comments, like "%%Requirements: jog\n". |
440 | ;; | |
441 | ;; By default `ps-print-prologue-header' is nil. | |
442 | ;; | |
443 | ;; ps-print always inserts the %%Requirements: comment, so if you need to insert | |
444 | ;; more requirements put them first in `ps-print-prologue-header' using the | |
445 | ;; "%%+" comment. For example, if you need to set numcopies to 3 and jog on | |
446 | ;; requirements and set %%LanguageLevel: to 2, do: | |
447 | ;; | |
448 | ;; (setq ps-print-prologue-header | |
449 | ;; "%%+ numcopies(3) jog\n%%LanguageLevel: 2\n") | |
450 | ;; | |
451 | ;; The duplex requirement is inserted by ps-print (see section Duplex Printers). | |
452 | ;; | |
453 | ;; Do not forget to terminate the string with "\n". | |
454 | ;; | |
455 | ;; For more information about PostScript document comments, see: | |
456 | ;; PostScript Language Reference Manual (2nd edition) | |
457 | ;; Adobe Systems Incorporated | |
458 | ;; Appendix G: Document Structuring Conventions -- Version 3.0 | |
459 | ;; | |
66e63857 GM |
460 | ;; It is also possible to add an user defined PostScript prologue code before |
461 | ;; all generated prologue code by setting the variable | |
462 | ;; `ps-user-defined-prologue'. | |
463 | ;; | |
464 | ;; `ps-user-defined-prologue' may be a string or a symbol function which returns | |
465 | ;; a string. Note that this string is inserted after `ps-adobe-tag' and | |
466 | ;; PostScript prologue comments, and before ps-print PostScript prologue code | |
467 | ;; section. That is, this string is inserted after error handler initialization | |
468 | ;; and before ps-print settings. | |
469 | ;; | |
470 | ;; By default `ps-user-defined-prologue' is nil. | |
471 | ;; | |
66e63857 GM |
472 | ;; It's strongly recommended only insert PostScript code and/or comments |
473 | ;; specific for your printing system particularities. For example, some special | |
474 | ;; initialization that only your printing system needs. | |
475 | ;; | |
476 | ;; Do not insert code for duplex printing, n-up printing or error handler, | |
477 | ;; ps-print handles this in a suitable way. | |
478 | ;; | |
479 | ;; For more information about PostScript, see: | |
480 | ;; PostScript Language Reference Manual (2nd edition) | |
481 | ;; Adobe Systems Incorporated | |
482 | ;; | |
c3d6d211 GM |
483 | ;; As an example for `ps-user-defined-prologue' setting: |
484 | ;; | |
485 | ;; ;; Setting for HP PostScript printer | |
486 | ;; (setq ps-user-defined-prologue | |
487 | ;; (concat "<</DeferredMediaSelection true /PageSize [612 792] " | |
488 | ;; "/MediaPosition 2 /MediaType (Plain)>> setpagedevice")) | |
489 | ;; | |
66e63857 GM |
490 | ;; |
491 | ;; PostScript Error Handler | |
492 | ;; ------------------------ | |
493 | ;; | |
494 | ;; ps-print instruments generated PostScript code with an error handler. | |
495 | ;; | |
496 | ;; The variable `ps-error-handler-message' specifies where the error handler | |
497 | ;; message should be sent. | |
498 | ;; | |
499 | ;; Valid values are: | |
500 | ;; | |
501 | ;; none catch the error and *DON'T* send any message. | |
502 | ;; | |
503 | ;; paper catch the error and print on paper the error message. | |
504 | ;; This is the default value. | |
505 | ;; | |
506 | ;; system catch the error and send back the error message to | |
6e1b1da6 GM |
507 | ;; printing system. This is useful only if printing system |
508 | ;; send back an email reporting the error, or if there is | |
509 | ;; some other alternative way to report back the error from | |
510 | ;; the system to you. | |
66e63857 GM |
511 | ;; |
512 | ;; paper-and-system catch the error, print on paper the error message and | |
513 | ;; send back the error message to printing system. | |
514 | ;; | |
515 | ;; Any other value is treated as `paper'. | |
516 | ;; | |
d3ab8dac | 517 | ;; |
12d89a2e | 518 | ;; Duplex Printers |
bcc0d457 | 519 | ;; --------------- |
12d89a2e | 520 | ;; |
bc0d41bd KH |
521 | ;; If you have a duplex-capable printer (one that prints both sides of the |
522 | ;; paper), set `ps-spool-duplex' to t. | |
523 | ;; ps-print will insert blank pages to make sure each buffer starts on the | |
524 | ;; correct side of the paper. | |
525 | ;; | |
526 | ;; The variable `ps-spool-config' specifies who is the responsable for setting | |
527 | ;; duplex and page size switches. Valid values are: | |
528 | ;; | |
529 | ;; lpr-switches duplex and page size are configured by `ps-lpr-switches'. | |
530 | ;; Don't forget to set `ps-lpr-switches' to select duplex | |
531 | ;; printing for your printer. | |
532 | ;; | |
533 | ;; setpagedevice duplex and page size are configured by ps-print using the | |
534 | ;; setpagedevice PostScript operator. | |
535 | ;; | |
536 | ;; nil duplex and page size are configured by ps-print *not* using | |
537 | ;; the setpagedevice PostScript operator. | |
538 | ;; | |
539 | ;; Any other value is treated as nil. | |
540 | ;; | |
541 | ;; The default value is `lpr-switches'. | |
542 | ;; | |
543 | ;; WARNING: The setpagedevice PostScript operator affects ghostview utility when | |
544 | ;; viewing file generated using landscape. Also on some printers, | |
545 | ;; setpagedevice affects zebra stripes; on other printers, | |
546 | ;; setpagedevice affects the left margin. | |
547 | ;; Besides all that, if your printer does not have the paper size | |
548 | ;; specified by setpagedevice, your printing will be aborted. | |
549 | ;; So, if you need to use setpagedevice, set `ps-spool-config' to | |
550 | ;; `setpagedevice', generate a test file and send it to your printer; | |
551 | ;; if the printed file isn't ok, set `ps-spool-config' to nil. | |
552 | ;; | |
553 | ;; The variable `ps-spool-tumble' specifies how the page images on opposite | |
554 | ;; sides of a sheet are oriented with respect to each other. If | |
555 | ;; `ps-spool-tumble' is nil, produces output suitable for binding on the left or | |
556 | ;; right. If `ps-spool-tumble' is non-nil, produces output suitable for binding | |
557 | ;; at the top or bottom. It has effect only when `ps-spool-duplex' is non-nil. | |
558 | ;; The default value is nil. | |
559 | ;; | |
560 | ;; Some printer system prints a header page and forces the first page be printed | |
561 | ;; on header page back, when using duplex. If your printer system has this | |
562 | ;; behavior, set variable `ps-banner-page-when-duplexing' to t. | |
563 | ;; | |
564 | ;; When `ps-banner-page-when-duplexing' is non-nil means the very first page is | |
565 | ;; skipped. It's like the very first character of buffer (or region) is ^L | |
566 | ;; (\014). | |
567 | ;; | |
568 | ;; The default for `ps-banner-page-when-duplexing' is nil (*don't* skip the very | |
569 | ;; first page). | |
570 | ;; | |
571 | ;; | |
572 | ;; N-up Printing | |
573 | ;; ------------- | |
574 | ;; | |
575 | ;; The variable `ps-n-up-printing' specifies the number of pages per sheet of | |
576 | ;; paper. The value specified must be between 1 and 100. The default is 1. | |
577 | ;; | |
578 | ;; NOTE: some PostScript printer may crash printing if `ps-n-up-printing' is set | |
579 | ;; to a high value (for example, 23). If this happens, set a lower value. | |
580 | ;; | |
581 | ;; The variable `ps-n-up-margin' specifies the margin in points between the | |
582 | ;; sheet border and the n-up printing. The default is 1 cm (or 0.3937 inches, | |
583 | ;; or 28.35 points). | |
584 | ;; | |
585 | ;; If variable `ps-n-up-border-p' is non-nil a border is drawn around each page. | |
586 | ;; The default is t. | |
587 | ;; | |
588 | ;; The variable `ps-n-up-filling' specifies how page matrix is filled on each | |
589 | ;; sheet of paper. Following are the valid values for `ps-n-up-filling' with a | |
590 | ;; filling example using a 3x4 page matrix: | |
591 | ;; | |
592 | ;; left-top 1 2 3 4 left-bottom 9 10 11 12 | |
593 | ;; 5 6 7 8 5 6 7 8 | |
594 | ;; 9 10 11 12 1 2 3 4 | |
595 | ;; | |
596 | ;; right-top 4 3 2 1 right-bottom 12 11 10 9 | |
597 | ;; 8 7 6 5 8 7 6 5 | |
598 | ;; 12 11 10 9 4 3 2 1 | |
599 | ;; | |
600 | ;; top-left 1 4 7 10 bottom-left 3 6 9 12 | |
601 | ;; 2 5 8 11 2 5 8 11 | |
602 | ;; 3 6 9 12 1 4 7 10 | |
603 | ;; | |
604 | ;; top-right 10 7 4 1 bottom-right 12 9 6 3 | |
605 | ;; 11 8 5 2 11 8 5 2 | |
606 | ;; 12 9 6 3 10 7 4 1 | |
607 | ;; | |
608 | ;; Any other value is treated as left-top. | |
609 | ;; | |
610 | ;; The default value is left-top. | |
bcc0d457 | 611 | ;; |
06fb6aab | 612 | ;; |
857686a6 RS |
613 | ;; Control And 8-bit Characters |
614 | ;; ---------------------------- | |
615 | ;; | |
616 | ;; The variable `ps-print-control-characters' specifies whether you want to see | |
617 | ;; a printable form for control and 8-bit characters, that is, instead of | |
6bdb808e | 618 | ;; sending, for example, a ^D (\004) to printer, it is sent the string "^D". |
857686a6 RS |
619 | ;; |
620 | ;; Valid values for `ps-print-control-characters' are: | |
621 | ;; | |
c82b4a75 KH |
622 | ;; 8-bit This is the value to use when you want an ASCII encoding of |
623 | ;; any control or non-ASCII character. Control characters are | |
624 | ;; encoded as "^D", and non-ASCII characters have an | |
6bdb808e RS |
625 | ;; octal encoding. |
626 | ;; | |
c82b4a75 | 627 | ;; control-8-bit This is the value to use when you want an ASCII encoding of |
6bdb808e RS |
628 | ;; any control character, whether it is 7 or 8-bit. |
629 | ;; European 8-bits accented characters are printed according | |
630 | ;; the current font. | |
631 | ;; | |
c82b4a75 | 632 | ;; control Only ASCII control characters have an ASCII encoding. |
6bdb808e RS |
633 | ;; European 8-bits accented characters are printed according |
634 | ;; the current font. | |
635 | ;; | |
c82b4a75 | 636 | ;; nil No ASCII encoding. Any character is printed according the |
6bdb808e | 637 | ;; current font. |
857686a6 RS |
638 | ;; |
639 | ;; Any other value is treated as nil. | |
640 | ;; | |
496725ad | 641 | ;; The default is `control-8-bit'. |
857686a6 RS |
642 | ;; |
643 | ;; Characters TAB, NEWLINE and FORMFEED are always treated by ps-print engine. | |
644 | ;; | |
645 | ;; | |
024ced4d KH |
646 | ;; Printing Multi-byte Buffer |
647 | ;; -------------------------- | |
d3ab8dac | 648 | ;; |
298bfad9 | 649 | ;; See ps-mule.el for documentation. |
e65df0a1 KH |
650 | ;; |
651 | ;; | |
87a16a06 RS |
652 | ;; Line Number |
653 | ;; ----------- | |
654 | ;; | |
a18ed129 RS |
655 | ;; The variable `ps-line-number' specifies whether to number each line; |
656 | ;; non-nil means do so. The default is nil (don't number each line). | |
87a16a06 | 657 | ;; |
906d41a7 GM |
658 | ;; The variable `ps-line-number-step' specifies the interval that line number is |
659 | ;; printed. For example, if `ps-line-number-step' is set to 2, the printing | |
660 | ;; will look like: | |
661 | ;; | |
662 | ;; 1 one line | |
663 | ;; one line | |
664 | ;; 3 one line | |
665 | ;; one line | |
98f2fbe7 | 666 | ;; 5 one line |
906d41a7 GM |
667 | ;; one line |
668 | ;; ... | |
669 | ;; | |
670 | ;; Valid values are: | |
671 | ;; | |
672 | ;; integer an integer that specifies the interval that line number is | |
673 | ;; printed. If it's lesser than or equal to zero, it's used the | |
674 | ;; value 1. | |
675 | ;; | |
676 | ;; `zebra' specifies that only the line number of the first line in a zebra | |
677 | ;; stripe is to be printed. | |
678 | ;; | |
679 | ;; Any other value is treated as `zebra'. | |
680 | ;; The default value is 1, so each line number is printed. | |
681 | ;; | |
98f2fbe7 GM |
682 | ;; The variable `ps-line-number-start' specifies the starting point in the |
683 | ;; interval given by `ps-line-number-step'. For example, if | |
684 | ;; `ps-line-number-step' is set to 3 and `ps-line-number-start' is set to 3, the | |
685 | ;; printing will look like: | |
686 | ;; | |
687 | ;; one line | |
688 | ;; one line | |
689 | ;; 3 one line | |
690 | ;; one line | |
691 | ;; one line | |
692 | ;; 6 one line | |
693 | ;; one line | |
694 | ;; one line | |
695 | ;; 9 one line | |
696 | ;; one line | |
697 | ;; ... | |
698 | ;; | |
699 | ;; The values for `ps-line-number-start': | |
700 | ;; | |
701 | ;; * If `ps-line-number-step' is an integer, must be between 1 and the value | |
702 | ;; of `ps-line-number-step' inclusive. | |
703 | ;; | |
704 | ;; * If `ps-line-number-step' is set to `zebra', must be between 1 and the | |
c3d6d211 | 705 | ;; value of `ps-zebra-stripe-height' inclusive. |
98f2fbe7 GM |
706 | ;; |
707 | ;; The default value is 1, so the line number of the first line of each interval | |
708 | ;; is printed. | |
709 | ;; | |
87a16a06 RS |
710 | ;; |
711 | ;; Zebra Stripes | |
712 | ;; ------------- | |
713 | ;; | |
a18ed129 RS |
714 | ;; Zebra stripes are a kind of background that appear "underneath" the text |
715 | ;; and can make the text easier to read. They look like this: | |
87a16a06 RS |
716 | ;; |
717 | ;; XXXXXXXXXXXXXXXXXXXXXXXX | |
718 | ;; XXXXXXXXXXXXXXXXXXXXXXXX | |
535efc38 RS |
719 | ;; XXXXXXXXXXXXXXXXXXXXXXXX |
720 | ;; | |
87a16a06 RS |
721 | ;; |
722 | ;; | |
723 | ;; XXXXXXXXXXXXXXXXXXXXXXXX | |
724 | ;; XXXXXXXXXXXXXXXXXXXXXXXX | |
535efc38 | 725 | ;; XXXXXXXXXXXXXXXXXXXXXXXX |
87a16a06 | 726 | ;; |
06fb6aab | 727 | ;; The blocks of X's represent rectangles filled with a light gray color. |
a18ed129 RS |
728 | ;; Each rectangle extends all the way across the page. |
729 | ;; | |
730 | ;; The height, in lines, of each rectangle is controlled by | |
535efc38 RS |
731 | ;; the variable `ps-zebra-stripe-height', which is 3 by default. |
732 | ;; The distance between stripes equals the height of a stripe. | |
8bd22fcf | 733 | ;; |
01961237 | 734 | ;; The variable `ps-zebra-stripes' controls whether to print zebra stripes. |
a18ed129 RS |
735 | ;; Non-nil means yes, nil means no. The default is nil. |
736 | ;; | |
6e1b1da6 GM |
737 | ;; The variable `ps-zebra-color' controls the zebra stripes gray scale or RGB |
738 | ;; color. It should be a float number between 0.0 (black color) and 1.0 (white | |
739 | ;; color), a string which is a color name, or a list of 3 numbers which | |
740 | ;; corresponds to the Red Green Blue color scale. | |
741 | ;; The default is 0.95 (or "gray95", or '(0.95 0.95 0.95)). | |
bc0d41bd | 742 | ;; |
8e234846 GM |
743 | ;; The variable `ps-zebra-stripe-follow' specifies if zebra stripe should |
744 | ;; continue on next page or restart on each page. If `ps-zebra-stripe-follow' | |
745 | ;; is nil, zebra stripe is restarted on each page. If `ps-zebra-stripe-follow' | |
746 | ;; is non-nil, zebra stripe continues on next page. Visually, we have: | |
747 | ;; | |
748 | ;; `ps-zebra-stripe-follow' `ps-zebra-stripe-follow' | |
749 | ;; is nil is non-nil | |
750 | ;; Current Page ------------------------ ------------------------ | |
751 | ;; 1 XXXXXXXXXXXXXXXXXXXXX 1 XXXXXXXXXXXXXXXXXXXXX | |
752 | ;; 2 XXXXXXXXXXXXXXXXXXXXX 2 XXXXXXXXXXXXXXXXXXXXX | |
753 | ;; 3 XXXXXXXXXXXXXXXXXXXXX 3 XXXXXXXXXXXXXXXXXXXXX | |
754 | ;; 4 4 | |
755 | ;; 5 5 | |
756 | ;; 6 6 | |
757 | ;; 7 XXXXXXXXXXXXXXXXXXXXX 7 XXXXXXXXXXXXXXXXXXXXX | |
758 | ;; 8 XXXXXXXXXXXXXXXXXXXXX 8 XXXXXXXXXXXXXXXXXXXXX | |
759 | ;; ------------------------ ------------------------ | |
760 | ;; Next Page ------------------------ ------------------------ | |
761 | ;; 9 XXXXXXXXXXXXXXXXXXXXX 9 XXXXXXXXXXXXXXXXXXXXX | |
762 | ;; 10 XXXXXXXXXXXXXXXXXXXXX 10 | |
763 | ;; 11 XXXXXXXXXXXXXXXXXXXXX 11 | |
764 | ;; 12 12 | |
765 | ;; 13 13 XXXXXXXXXXXXXXXXXXXXX | |
766 | ;; 14 14 XXXXXXXXXXXXXXXXXXXXX | |
767 | ;; 15 XXXXXXXXXXXXXXXXXXXXX 15 XXXXXXXXXXXXXXXXXXXXX | |
768 | ;; 16 XXXXXXXXXXXXXXXXXXXXX 16 | |
769 | ;; ------------------------ ------------------------ | |
770 | ;; | |
a18ed129 | 771 | ;; See also section How Ps-Print Has A Text And/Or Image On Background. |
87a16a06 | 772 | ;; |
87a16a06 | 773 | ;; |
12b88fff RS |
774 | ;; Hooks |
775 | ;; ----- | |
776 | ;; | |
d3ab8dac | 777 | ;; ps-print has the following hook variables: |
12b88fff RS |
778 | ;; |
779 | ;; `ps-print-hook' | |
780 | ;; It is evaluated once before any printing process. This is the right | |
781 | ;; place to initialize ps-print global data. | |
782 | ;; For an example, see section Adding a New Font Family. | |
783 | ;; | |
bc0d41bd KH |
784 | ;; `ps-print-begin-sheet-hook' |
785 | ;; It is evaluated on each beginning of sheet of paper. | |
786 | ;; If `ps-n-up-printing' is equal to 1, `ps-print-begin-page-hook' is never | |
787 | ;; evaluated. | |
788 | ;; | |
12b88fff | 789 | ;; `ps-print-begin-page-hook' |
bc0d41bd KH |
790 | ;; It is evaluated on each beginning of page, except in the beginning |
791 | ;; of page that `ps-print-begin-sheet-hook' is evaluated. | |
12b88fff RS |
792 | ;; |
793 | ;; `ps-print-begin-column-hook' | |
794 | ;; It is evaluated on each beginning of column, except in the beginning | |
bc0d41bd KH |
795 | ;; of column that `ps-print-begin-page-hook' is evaluated or that |
796 | ;; `ps-print-begin-sheet-hook' is evaluated. | |
12b88fff RS |
797 | ;; |
798 | ;; | |
799 | ;; Font Managing | |
bcc0d457 RS |
800 | ;; ------------- |
801 | ;; | |
7d8b7e8e KH |
802 | ;; ps-print now knows rather precisely some fonts: the variable |
803 | ;; `ps-font-info-database' contains information for a list of font families | |
804 | ;; (currently mainly `Courier' `Helvetica' `Times' `Palatino' `Helvetica-Narrow' | |
805 | ;; `NewCenturySchlbk'). Each font family contains the font names for standard, | |
806 | ;; bold, italic and bold-italic characters, a reference size (usually 10) and | |
807 | ;; the corresponding line height, width of a space and average character width. | |
06fb6aab | 808 | ;; |
7d8b7e8e KH |
809 | ;; The variable `ps-font-family' determines which font family is to be used for |
810 | ;; ordinary text. If its value does not correspond to a known font family, an | |
811 | ;; error message is printed into the `*Messages*' buffer, which lists the | |
812 | ;; currently available font families. | |
bcc0d457 | 813 | ;; |
7d8b7e8e KH |
814 | ;; The variable `ps-font-size' determines the size (in points) of the font for |
815 | ;; ordinary text, when generating PostScript. Its value is a float or a cons of | |
816 | ;; floats which has the following form: | |
bcc0d457 | 817 | ;; |
7d8b7e8e KH |
818 | ;; (LANDSCAPE-SIZE . PORTRAIT-SIZE) |
819 | ;; | |
820 | ;; Similarly, the variable `ps-header-font-family' determines which font family | |
821 | ;; is to be used for text in the header. | |
822 | ;; | |
823 | ;; The variable `ps-header-font-size' determines the font size, in points, for | |
824 | ;; text in the header (similar to `ps-font-size'). | |
825 | ;; | |
826 | ;; The variable `ps-header-title-font-size' determines the font size, in points, | |
827 | ;; for the top line of text in the header (similar to `ps-font-size'). | |
bcc0d457 RS |
828 | ;; |
829 | ;; | |
12b88fff | 830 | ;; Adding a New Font Family |
bcc0d457 RS |
831 | ;; ------------------------ |
832 | ;; | |
833 | ;; To use a new font family, you MUST first teach ps-print | |
87a16a06 | 834 | ;; this font, i.e., add its information to `ps-font-info-database', |
bcc0d457 RS |
835 | ;; otherwise ps-print cannot correctly place line and page breaks. |
836 | ;; | |
87a16a06 | 837 | ;; For example, assuming `Helvetica' is unknown, |
bcc0d457 RS |
838 | ;; you first need to do the following ONLY ONCE: |
839 | ;; | |
840 | ;; - create a new buffer | |
841 | ;; - generate the PostScript image to a file (C-u M-x ps-print-buffer) | |
842 | ;; - open this file and find the line: | |
1fd9b7fe | 843 | ;; `% 3 cm 20 cm moveto 10/Courier ReportFontInfo showpage' |
a18ed129 | 844 | ;; - delete the leading `%' (which is the PostScript comment character) |
bcc0d457 RS |
845 | ;; - replace in this line `Courier' by the new font (say `Helvetica') |
846 | ;; to get the line: | |
1fd9b7fe | 847 | ;; `3 cm 20 cm moveto 10/Helvetica ReportFontInfo showpage' |
bcc0d457 RS |
848 | ;; - send this file to the printer (or to ghostscript). |
849 | ;; You should read the following on the output page: | |
850 | ;; | |
851 | ;; For Helvetica 10 point, the line height is 11.56, the space width is 2.78 | |
852 | ;; and a crude estimate of average character width is 5.09243 | |
853 | ;; | |
854 | ;; - Add these values to the `ps-font-info-database': | |
855 | ;; (setq ps-font-info-database | |
12b88fff RS |
856 | ;; (append |
857 | ;; '((Helvetica ; the family key | |
858 | ;; (fonts (normal . "Helvetica") | |
859 | ;; (bold . "Helvetica-Bold") | |
860 | ;; (italic . "Helvetica-Oblique") | |
861 | ;; (bold-italic . "Helvetica-BoldOblique")) | |
862 | ;; (size . 10.0) | |
863 | ;; (line-height . 11.56) | |
864 | ;; (space-width . 2.78) | |
865 | ;; (avg-char-width . 5.09243))) | |
866 | ;; ps-font-info-database)) | |
bcc0d457 RS |
867 | ;; - Now you can use this font family with any size: |
868 | ;; (setq ps-font-family 'Helvetica) | |
869 | ;; - if you want to use this family in another emacs session, you must | |
870 | ;; put into your `~/.emacs': | |
871 | ;; (require 'ps-print) | |
872 | ;; (setq ps-font-info-database (append ...))) | |
873 | ;; if you don't want to load ps-print, you have to copy the whole value: | |
874 | ;; (setq ps-font-info-database '(<your stuff> <the standard stuff>)) | |
12b88fff RS |
875 | ;; or, use `ps-print-hook' (see section Hooks): |
876 | ;; (add-hook 'ps-print-hook | |
bc0d41bd KH |
877 | ;; '(lambda () |
878 | ;; (or (assq 'Helvetica ps-font-info-database) | |
879 | ;; (setq ps-font-info-database (append ...))))) | |
bcc0d457 RS |
880 | ;; |
881 | ;; You can create new `mixed' font families like: | |
12b88fff RS |
882 | ;; (my-mixed-family |
883 | ;; (fonts (normal . "Courier-Bold") | |
884 | ;; (bold . "Helvetica") | |
885 | ;; (italic . "Zapf-Chancery-MediumItalic") | |
886 | ;; (bold-italic . "NewCenturySchlbk-BoldItalic") | |
887 | ;; (w3-table-hack-x-face . "LineDrawNormal")) | |
888 | ;; (size . 10.0) | |
889 | ;; (line-height . 10.55) | |
890 | ;; (space-width . 6.0) | |
891 | ;; (avg-char-width . 6.0)) | |
d3ab8dac | 892 | ;; |
bcc0d457 RS |
893 | ;; Now you can use your new font family with any size: |
894 | ;; (setq ps-font-family 'my-mixed-family) | |
895 | ;; | |
12b88fff RS |
896 | ;; Note that on above example the `w3-table-hack-x-face' entry refers to |
897 | ;; a face symbol, so when printing this face it'll be used the font | |
898 | ;; `LineDrawNormal'. If the face `w3-table-hack-x-face' is remapped to | |
899 | ;; use bold and/or italic attribute, the corresponding entry (bold, italic | |
900 | ;; or bold-italic) will be used instead of `w3-table-hack-x-face' entry. | |
901 | ;; | |
902 | ;; Note also that the font family entry order is irrelevant, so the above | |
903 | ;; example could also be written: | |
904 | ;; (my-mixed-family | |
905 | ;; (size . 10.0) | |
906 | ;; (fonts (w3-table-hack-x-face . "LineDrawNormal") | |
907 | ;; (bold . "Helvetica") | |
908 | ;; (bold-italic . "NewCenturySchlbk-BoldItalic") | |
909 | ;; (italic . "Zapf-Chancery-MediumItalic") | |
910 | ;; (normal . "Courier-Bold")) | |
911 | ;; (avg-char-width . 6.0) | |
912 | ;; (space-width . 6.0) | |
913 | ;; (line-height . 10.55)) | |
914 | ;; | |
915 | ;; Despite the note above, it is recommended that some convention about | |
916 | ;; entry order be used. | |
917 | ;; | |
bcc0d457 RS |
918 | ;; You can get information on all the fonts resident in YOUR printer |
919 | ;; by uncommenting the line: | |
920 | ;; % 3 cm 20 cm moveto ReportAllFontInfo showpage | |
921 | ;; | |
a18ed129 RS |
922 | ;; The PostScript file should be sent to YOUR PostScript printer. |
923 | ;; If you send it to ghostscript or to another PostScript printer, | |
bcc0d457 | 924 | ;; you may get slightly different results. |
c3d6d211 GM |
925 | ;; Anyway, as ghostscript fonts are autoload, you won't get much font info. |
926 | ;; | |
927 | ;; Note also that ps-print DOESN'T download any font to your printer, instead | |
928 | ;; it uses the fonts resident in your printer. | |
bcc0d457 RS |
929 | ;; |
930 | ;; | |
931 | ;; How Ps-Print Deals With Faces | |
932 | ;; ----------------------------- | |
12d89a2e | 933 | ;; |
bcc0d457 RS |
934 | ;; The ps-print-*-with-faces commands attempt to determine which faces |
935 | ;; should be printed in bold or italic, but their guesses aren't | |
936 | ;; always right. For example, you might want to map colors into faces | |
937 | ;; so that blue faces print in bold, and red faces in italic. | |
12d89a2e | 938 | ;; |
857686a6 RS |
939 | ;; It is possible to force ps-print to consider specific faces bold, |
940 | ;; italic or underline, no matter what font they are displayed in, by setting | |
941 | ;; the variables `ps-bold-faces', `ps-italic-faces' and `ps-underlined-faces'. | |
942 | ;; These variables contain lists of faces that ps-print should consider bold, | |
943 | ;; italic or underline; to set them, put code like the following into your | |
944 | ;; .emacs file: | |
12d89a2e | 945 | ;; |
12b88fff | 946 | ;; (setq ps-bold-faces '(my-blue-face)) |
bcc0d457 | 947 | ;; (setq ps-italic-faces '(my-red-face)) |
857686a6 | 948 | ;; (setq ps-underlined-faces '(my-green-face)) |
bcc0d457 RS |
949 | ;; |
950 | ;; Faces like bold-italic that are both bold and italic should go in | |
951 | ;; *both* lists. | |
952 | ;; | |
d3ab8dac | 953 | ;; ps-print keeps internal lists of which fonts are bold and which are |
bcc0d457 RS |
954 | ;; italic; these lists are built the first time you invoke ps-print. |
955 | ;; For the sake of efficiency, the lists are built only once; the same | |
956 | ;; lists are referred in later invocations of ps-print. | |
957 | ;; | |
958 | ;; Because these lists are built only once, it's possible for them to | |
959 | ;; get out of sync, if a face changes, or if new faces are added. To | |
960 | ;; get the lists back in sync, you can set the variable | |
961 | ;; `ps-build-face-reference' to t, and the lists will be rebuilt the | |
857686a6 RS |
962 | ;; next time ps-print is invoked. If you need that the lists always be |
963 | ;; rebuilt when ps-print is invoked, set the variable | |
964 | ;; `ps-always-build-face-reference' to t. | |
bcc0d457 | 965 | ;; |
906d41a7 GM |
966 | ;; If you need to print without worrying about face background color, set the |
967 | ;; variable `ps-use-face-background' which specifies if face background should | |
968 | ;; be used. Valid values are: | |
969 | ;; | |
970 | ;; t always use face background color. | |
971 | ;; nil never use face background color. | |
972 | ;; (face...) list of faces whose background color will be used. | |
973 | ;; | |
974 | ;; Any other value will be treated as t. | |
975 | ;; The default value is t. | |
976 | ;; | |
bcc0d457 RS |
977 | ;; |
978 | ;; How Ps-Print Deals With Color | |
979 | ;; ----------------------------- | |
980 | ;; | |
d3ab8dac | 981 | ;; ps-print detects faces with foreground and background colors |
bcc0d457 RS |
982 | ;; defined and embeds color information in the PostScript image. |
983 | ;; The default foreground and background colors are defined by the | |
984 | ;; variables `ps-default-fg' and `ps-default-bg'. | |
6e1b1da6 | 985 | ;; On black-and-white printers, colors are displayed in gray scale. |
bcc0d457 RS |
986 | ;; To turn off color output, set `ps-print-color-p' to nil. |
987 | ;; | |
988 | ;; | |
87a16a06 RS |
989 | ;; How Ps-Print Maps Faces |
990 | ;; ----------------------- | |
991 | ;; | |
992 | ;; As ps-print uses PostScript to print buffers, it is possible to have | |
993 | ;; other attributes associated with faces. So the new attributes used | |
994 | ;; by ps-print are: | |
995 | ;; | |
996 | ;; strikeout - like underline, but the line is in middle of text. | |
997 | ;; overline - like underline, but the line is over the text. | |
998 | ;; shadow - text will have a shadow. | |
999 | ;; box - text will be surrounded by a box. | |
a18ed129 | 1000 | ;; outline - print characters as hollow outlines. |
87a16a06 | 1001 | ;; |
06fb6aab | 1002 | ;; See the documentation for `ps-extend-face'. |
87a16a06 | 1003 | ;; |
bc0d41bd KH |
1004 | ;; Let's, for example, remap `font-lock-keyword-face' to another foreground |
1005 | ;; color and bold attribute: | |
87a16a06 | 1006 | ;; |
a18ed129 | 1007 | ;; (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE) |
87a16a06 | 1008 | ;; |
6c8f2753 RS |
1009 | ;; If you want to use a new face, define it first with `defface', |
1010 | ;; and then call `ps-extend-face' to specify how to print it. | |
1011 | ;; | |
87a16a06 RS |
1012 | ;; |
1013 | ;; How Ps-Print Has A Text And/Or Image On Background | |
1014 | ;; -------------------------------------------------- | |
1015 | ;; | |
d3ab8dac | 1016 | ;; ps-print can print texts and/or EPS PostScript images on background; it is |
87a16a06 RS |
1017 | ;; possible to define the following text attributes: font name, font size, |
1018 | ;; initial position, angle, gray scale and pages to print. | |
1019 | ;; | |
1020 | ;; It has the following EPS PostScript images attributes: file name containing | |
1021 | ;; the image, initial position, X and Y scales, angle and pages to print. | |
1022 | ;; | |
1023 | ;; See documentation for `ps-print-background-text' and | |
1024 | ;; `ps-print-background-image'. | |
1025 | ;; | |
1026 | ;; For example, if we wish to print text "preliminary" on all pages and text | |
1027 | ;; "special" on page 5 and from page 11 to page 17, we could specify: | |
1028 | ;; | |
1029 | ;; (setq ps-print-background-text | |
1030 | ;; '(("preliminary") | |
1031 | ;; ("special" | |
1032 | ;; "LeftMargin" "BottomMargin PrintHeight add" ; X and Y position | |
1033 | ;; ; (upper left corner) | |
1034 | ;; nil nil nil | |
12b88fff | 1035 | ;; "PrintHeight neg PrintPageWidth atan" ; angle |
87a16a06 RS |
1036 | ;; 5 (11 . 17)) ; page list |
1037 | ;; )) | |
1038 | ;; | |
1039 | ;; Similarly, we could print image "~/images/EPS-image1.ps" on all pages and | |
1040 | ;; image "~/images/EPS-image2.ps" on page 5 and from page 11 to page 17, we | |
1041 | ;; specify: | |
1042 | ;; | |
1043 | ;; (setq ps-print-background-image | |
1044 | ;; '(("~/images/EPS-image1.ps" | |
1045 | ;; "LeftMargin" "BottomMargin") ; X and Y position (lower left corner) | |
1046 | ;; ("~/images/EPS-image2.ps" | |
1047 | ;; "LeftMargin" "BottomMargin PrintHeight 2 div add" ; X and Y position | |
1048 | ;; ; (upper left corner) | |
1049 | ;; nil nil nil | |
1050 | ;; 5 (11 . 17)) ; page list | |
1051 | ;; )) | |
1052 | ;; | |
1053 | ;; If it is not possible to read (or does not exist) an image file, that file | |
1054 | ;; is ignored. | |
1055 | ;; | |
1056 | ;; The printing order is: | |
1057 | ;; | |
6e1b1da6 GM |
1058 | ;; 1. Print background color |
1059 | ;; 2. Print zebra stripes | |
1060 | ;; 3. Print background texts that it should be on all pages | |
1061 | ;; 4. Print background images that it should be on all pages | |
1062 | ;; 5. Print background texts only for current page (if any) | |
1063 | ;; 6. Print background images only for current page (if any) | |
1064 | ;; 7. Print header | |
1065 | ;; 8. Print buffer text (with faces, if specified) and line number | |
87a16a06 RS |
1066 | ;; |
1067 | ;; | |
bcc0d457 RS |
1068 | ;; Utilities |
1069 | ;; --------- | |
1070 | ;; | |
1071 | ;; Some tools are provided to help you customize your font setup. | |
1072 | ;; | |
1073 | ;; `ps-setup' returns (some part of) the current setup. | |
1074 | ;; | |
1075 | ;; To avoid wrapping too many lines, you may want to adjust the | |
1076 | ;; left and right margins and the font size. On UN*X systems, do: | |
1077 | ;; pr -t file | awk '{printf "%3d %s\n", length($0), $0}' | sort -r | head | |
1078 | ;; to determine the longest lines of your file. | |
87a16a06 | 1079 | ;; Then, the command `ps-line-lengths' will give you the correspondence |
bcc0d457 RS |
1080 | ;; between a line length (number of characters) and the maximum font |
1081 | ;; size which doesn't wrap such a line with the current ps-print setup. | |
1082 | ;; | |
1083 | ;; The commands `ps-nb-pages-buffer' and `ps-nb-pages-region' display | |
87a16a06 | 1084 | ;; the correspondence between a number of pages and the maximum font |
bcc0d457 RS |
1085 | ;; size which allow the number of lines of the current buffer or of |
1086 | ;; its current region to fit in this number of pages. | |
a18ed129 RS |
1087 | ;; |
1088 | ;; NOTE: line folding is not taken into account in this process and could | |
1089 | ;; change the results. | |
b87c5d3d | 1090 | ;; |
0a5daee5 KH |
1091 | ;; The command `ps-print-customize' activates a customization buffer for |
1092 | ;; ps-print options. | |
1093 | ;; | |
b87c5d3d | 1094 | ;; |
b87c5d3d RS |
1095 | ;; New since version 1.5 |
1096 | ;; --------------------- | |
b87c5d3d | 1097 | ;; |
bcc0d457 | 1098 | ;; Color output capability. |
b87c5d3d | 1099 | ;; Automatic detection of font attributes (bold, italic). |
b87c5d3d | 1100 | ;; Configurable headers with page numbers. |
b87c5d3d | 1101 | ;; Slightly faster. |
b87c5d3d | 1102 | ;; Support for different paper sizes. |
b87c5d3d RS |
1103 | ;; Better conformance to PostScript Document Structure Conventions. |
1104 | ;; | |
ef2cbb24 | 1105 | ;; |
bcc0d457 RS |
1106 | ;; New since version 2.8 |
1107 | ;; --------------------- | |
1108 | ;; | |
1fd9b7fe | 1109 | ;; [vinicius] Vinicius Jose Latorre <vinicius@cpqd.com.br> |
0a5daee5 | 1110 | ;; |
c3d6d211 GM |
1111 | ;; 20000821 |
1112 | ;; `ps-even-or-odd-pages' | |
1113 | ;; | |
1fd9b7fe GM |
1114 | ;; 20000617 |
1115 | ;; `ps-manual-feed', `ps-warn-paper-type', `ps-print-upside-down', | |
1116 | ;; `ps-selected-pages', `ps-last-selected-pages', | |
1117 | ;; `ps-restore-selected-pages', `ps-switch-header', | |
1118 | ;; `ps-line-number-step', `ps-line-number-start', | |
1119 | ;; `ps-zebra-stripe-follow' and `ps-use-face-background'. | |
0a5daee5 | 1120 | ;; |
1fd9b7fe GM |
1121 | ;; 20000310 |
1122 | ;; PostScript error handler. | |
1123 | ;; `ps-user-defined-prologue' and `ps-error-handler-message'. | |
bc0d41bd | 1124 | ;; |
df5e6194 | 1125 | ;; 19991211 |
1fd9b7fe | 1126 | ;; `ps-print-customize'. |
bc0d41bd | 1127 | ;; |
df5e6194 | 1128 | ;; 19990703 |
1fd9b7fe GM |
1129 | ;; Better customization. |
1130 | ;; `ps-banner-page-when-duplexing' and `ps-zebra-color'. | |
bc0d41bd | 1131 | ;; |
df5e6194 | 1132 | ;; 19990513 |
1fd9b7fe GM |
1133 | ;; N-up printing. |
1134 | ;; Hook: `ps-print-begin-sheet-hook'. | |
bc0d41bd | 1135 | ;; |
df5e6194 | 1136 | ;; [keinichi] 19990509 Kein'ichi Handa <handa@etl.go.jp> |
bc0d41bd KH |
1137 | ;; |
1138 | ;; `ps-print-region-function' | |
1139 | ;; | |
1fd9b7fe | 1140 | ;; [vinicius] Vinicius Jose Latorre <vinicius@cpqd.com.br> |
bc0d41bd | 1141 | ;; |
df5e6194 | 1142 | ;; 19990301 |
1fd9b7fe | 1143 | ;; PostScript tumble and setpagedevice. |
bc0d41bd | 1144 | ;; |
df5e6194 | 1145 | ;; 19980922 |
1fd9b7fe GM |
1146 | ;; PostScript prologue header comment insertion. |
1147 | ;; Skip invisible text better. | |
d3ab8dac | 1148 | ;; |
df5e6194 | 1149 | ;; [keinichi] 19980819 Kein'ichi Handa <handa@etl.go.jp> |
e65df0a1 | 1150 | ;; |
024ced4d | 1151 | ;; Multi-byte buffer handling. |
e65df0a1 | 1152 | ;; |
1fd9b7fe | 1153 | ;; [vinicius] Vinicius Jose Latorre <vinicius@cpqd.com.br> |
12b88fff | 1154 | ;; |
df5e6194 | 1155 | ;; 19980306 |
1fd9b7fe | 1156 | ;; Skip invisible text. |
12b88fff | 1157 | ;; |
df5e6194 | 1158 | ;; 19971130 |
1fd9b7fe GM |
1159 | ;; Hooks: `ps-print-hook', `ps-print-begin-page-hook' and |
1160 | ;; `ps-print-begin-column-hook'. | |
1161 | ;; Put one header per page over the columns. | |
1162 | ;; Better database font management. | |
1163 | ;; Better control characters handling. | |
12b88fff | 1164 | ;; |
df5e6194 | 1165 | ;; 19971121 |
1fd9b7fe GM |
1166 | ;; Dynamic evaluation at print time of `ps-lpr-switches'. |
1167 | ;; Handle control characters. | |
1168 | ;; Face remapping. | |
1169 | ;; New face attributes. | |
1170 | ;; Line number. | |
1171 | ;; Zebra stripes. | |
1172 | ;; Text and/or image on background. | |
87a16a06 | 1173 | ;; |
df5e6194 | 1174 | ;; [jack] 19960517 Jacques Duthen <duthen@cegelec-red.fr> |
bcc0d457 | 1175 | ;; |
a18ed129 | 1176 | ;; Font family and float size for text and header. |
bcc0d457 RS |
1177 | ;; Landscape mode. |
1178 | ;; Multiple columns. | |
1179 | ;; Tools for page setup. | |
1180 | ;; | |
1181 | ;; | |
d3ab8dac | 1182 | ;; Known bugs and limitations of ps-print |
ef2cbb24 | 1183 | ;; -------------------------------------- |
bcc0d457 | 1184 | ;; |
043620f4 KH |
1185 | ;; Although color printing will work in XEmacs 19.12, it doesn't work |
1186 | ;; well; in particular, bold or italic fonts don't print in the right | |
1187 | ;; background color. | |
1188 | ;; | |
1189 | ;; Invisible properties aren't correctly ignored in XEmacs 19.12. | |
1190 | ;; | |
b87c5d3d | 1191 | ;; Automatic font-attribute detection doesn't work well, especially |
00aa16af | 1192 | ;; with hilit19 and older versions of get-create-face. Users having |
bcc0d457 | 1193 | ;; problems with auto-font detection should use the lists |
857686a6 RS |
1194 | ;; `ps-italic-faces', `ps-bold-faces' and `ps-underlined-faces' and/or |
1195 | ;; turn off automatic detection by setting `ps-auto-font-detect' to nil. | |
00aa16af | 1196 | ;; |
043620f4 | 1197 | ;; Automatic font-attribute detection doesn't work with XEmacs 19.12 |
857686a6 RS |
1198 | ;; in tty mode; use the lists `ps-italic-faces', `ps-bold-faces' and |
1199 | ;; `ps-underlined-faces' instead. | |
12d89a2e | 1200 | ;; |
00aa16af | 1201 | ;; Still too slow; could use some hand-optimization. |
ef2cbb24 | 1202 | ;; |
12d89a2e | 1203 | ;; Default background color isn't working. |
ef2cbb24 RS |
1204 | ;; |
1205 | ;; Faces are always treated as opaque. | |
1206 | ;; | |
41481e4b | 1207 | ;; Epoch and Emacs 19 not supported. At all. |
ef2cbb24 | 1208 | ;; |
06fb6aab | 1209 | ;; Fixed-pitch fonts work better for line folding, but are not required. |
bcc0d457 RS |
1210 | ;; |
1211 | ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care | |
1212 | ;; of folding lines. | |
ef2cbb24 | 1213 | ;; |
12d89a2e | 1214 | ;; |
d3ab8dac | 1215 | ;; Things to change |
bcc0d457 | 1216 | ;; ---------------- |
ef2cbb24 | 1217 | ;; |
12b88fff | 1218 | ;; Avoid page break inside a paragraph. |
bcc0d457 | 1219 | ;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy). |
bcc0d457 RS |
1220 | ;; Improve the memory management for big files (hard?). |
1221 | ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' should take care | |
1222 | ;; of folding lines. | |
ef2cbb24 | 1223 | ;; |
ef2cbb24 | 1224 | ;; |
12d89a2e RS |
1225 | ;; Acknowledgements |
1226 | ;; ---------------- | |
12b88fff | 1227 | ;; |
c3d6d211 GM |
1228 | ;; Thanks to Gord Wait <Gord_Wait@spectrumsignal.com> for |
1229 | ;; `ps-user-defined-prologue' example setting for HP PostScript printer. | |
1230 | ;; | |
98f2fbe7 GM |
1231 | ;; Thanks to Paul Furnanz <pfurnanz@synopsys.com> for XEmacs compatibility |
1232 | ;; suggestion for `ps-postscript-code-directory' variable. | |
1233 | ;; | |
906d41a7 GM |
1234 | ;; Thanks to David X Callaway <dxc@xprt.net> for helping debugging PostScript |
1235 | ;; level 1 compatibility. | |
1236 | ;; | |
8e234846 GM |
1237 | ;; Thanks to Colin Marquardt <colin.marquardt@usa.alcatel.com> for upside-down, |
1238 | ;; line number step, line number start and zebra stripe follow suggestions, and | |
1239 | ;; for XEmacs beta-tests. | |
906d41a7 | 1240 | ;; |
66e63857 | 1241 | ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for user defined PostScript |
c3d6d211 | 1242 | ;; prologue code suggestion and for odd/even printing suggestion. |
66e63857 | 1243 | ;; |
024ced4d | 1244 | ;; Thanks to Kein'ichi Handa <handa@etl.go.jp> for multi-byte buffer handling. |
915293a2 KH |
1245 | ;; |
1246 | ;; Thanks to Matthew O Persico <Matthew.Persico@lazard.com> for line number on | |
1247 | ;; empty columns. | |
1248 | ;; | |
1249 | ;; Thanks to Theodore Jump <tjump@cais.com> for adjust PostScript code order on | |
1250 | ;; last page. | |
1251 | ;; | |
6bdb808e RS |
1252 | ;; Thanks to Roland Ducournau <ducour@lirmm.fr> for |
1253 | ;; `ps-print-control-characters' variable documentation. | |
1254 | ;; | |
12b88fff RS |
1255 | ;; Thanks to Marcus G Daniels <marcus@cathcart.sysc.pdx.edu> for a better |
1256 | ;; database font management. | |
1257 | ;; | |
1258 | ;; Thanks to Martin Boyer <gamin@videotron.ca> for some ideas on putting one | |
6bdb808e RS |
1259 | ;; header per page over the columns and correct line numbers when printing a |
1260 | ;; region. | |
12b88fff RS |
1261 | ;; |
1262 | ;; Thanks to Steven L Baur <steve@miranova.com> for dynamic evaluation at | |
1263 | ;; print time of `ps-lpr-switches'. | |
1264 | ;; | |
6bdb808e RS |
1265 | ;; Thanks to Kevin Rodgers <kevinr@ihs.com> for handling control characters |
1266 | ;; (his code was severely modified, but the main idea was kept). | |
1267 | ;; | |
12b88fff RS |
1268 | ;; Thanks to some suggestions on: |
1269 | ;; * Face color map: Marco Melgazzi <marco@techie.com> | |
1270 | ;; * XEmacs compatibility: William J. Henney <will@astrosmo.unam.mx> | |
984e7bd9 | 1271 | ;; * Check `ps-paper-type': Sudhakar Frederick <sfrederi@asc.corp.mot.com> |
12b88fff | 1272 | ;; |
857686a6 RS |
1273 | ;; Thanks to Jacques Duthen <duthen@cegelec-red.fr> (Jack) for the 3.4 version |
1274 | ;; I started from. [vinicius] | |
1275 | ;; | |
bcc0d457 RS |
1276 | ;; Thanks to Jim Thompson <?@?> for the 2.8 version I started from. |
1277 | ;; [jack] | |
1278 | ;; | |
12d89a2e RS |
1279 | ;; Thanks to Kevin Rodgers <kevinr@ihs.com> for adding support for |
1280 | ;; color and the invisible property. | |
ef2cbb24 | 1281 | ;; |
12d89a2e RS |
1282 | ;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing |
1283 | ;; the initial port to Emacs 19. His code is no longer part of | |
1284 | ;; ps-print, but his work is still appreciated. | |
ef2cbb24 | 1285 | ;; |
12d89a2e RS |
1286 | ;; Thanks to Remi Houdaille and Michel Train, michel@metasoft.fdn.org, |
1287 | ;; for adding underline support. Their code also is no longer part of | |
1288 | ;; ps-print, but their efforts are not forgotten. | |
1289 | ;; | |
1290 | ;; Thanks also to all of you who mailed code to add features to | |
1291 | ;; ps-print; although I didn't use your code, I still appreciate your | |
1292 | ;; sharing it with me. | |
1293 | ;; | |
1294 | ;; Thanks to all who mailed comments, encouragement, and criticism. | |
1295 | ;; Thanks also to all who responded to my survey; I had too many | |
1296 | ;; responses to reply to them all, but I greatly appreciate your | |
1297 | ;; interest. | |
1298 | ;; | |
1299 | ;; Jim | |
bc0d41bd | 1300 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
ef2cbb24 RS |
1301 | |
1302 | ;;; Code: | |
1303 | ||
ea0c615d GM |
1304 | (eval-and-compile |
1305 | (unless (featurep 'lisp-float-type) | |
1306 | (error "`ps-print' requires floating point support")) | |
68e684a0 | 1307 | |
68e684a0 | 1308 | |
ea0c615d | 1309 | ;; For Emacs 20.2 and the earlier version. |
68e684a0 | 1310 | |
ea0c615d GM |
1311 | (or (fboundp 'set-buffer-multibyte) |
1312 | (defun set-buffer-multibyte (arg) | |
1313 | (setq enable-multibyte-characters arg))) | |
68e684a0 | 1314 | |
ea0c615d GM |
1315 | (or (fboundp 'string-as-unibyte) |
1316 | (defun string-as-unibyte (arg) arg)) | |
df5e6194 | 1317 | |
ea0c615d GM |
1318 | (or (fboundp 'string-as-multibyte) |
1319 | (defun string-as-multibyte (arg) arg)) | |
298bfad9 | 1320 | |
ea0c615d GM |
1321 | (or (fboundp 'char-charset) |
1322 | (defun char-charset (arg) 'ascii)) | |
0a5daee5 | 1323 | |
ea0c615d GM |
1324 | (or (fboundp 'charset-after) |
1325 | (defun charset-after (&optional arg) | |
1326 | (char-charset (char-after arg)))) | |
712dc9e0 GM |
1327 | |
1328 | ||
ea0c615d GM |
1329 | ;; GNU Emacs |
1330 | (or (fboundp 'line-beginning-position) | |
1331 | (defun line-beginning-position (&optional n) | |
1332 | (save-excursion | |
1333 | (and n (/= n 1) (forward-line (1- n))) | |
1334 | (beginning-of-line) | |
1335 | (point)))) | |
1336 | ||
1337 | ||
1338 | ;; to avoid compilation gripes | |
1339 | ||
1340 | ;; XEmacs | |
1341 | (defalias 'ps-x-color-instance-p 'color-instance-p) | |
1342 | (defalias 'ps-x-color-instance-rgb-components 'color-instance-rgb-components) | |
1343 | (defalias 'ps-x-color-name 'color-name) | |
1344 | (defalias 'ps-x-color-specifier-p 'color-specifier-p) | |
1345 | (defalias 'ps-x-copy-coding-system 'copy-coding-system) | |
1346 | (defalias 'ps-x-device-class 'device-class) | |
1347 | (defalias 'ps-x-extent-end-position 'extent-end-position) | |
1348 | (defalias 'ps-x-extent-face 'extent-face) | |
1349 | (defalias 'ps-x-extent-priority 'extent-priority) | |
1350 | (defalias 'ps-x-extent-start-position 'extent-start-position) | |
1351 | (defalias 'ps-x-face-font-instance 'face-font-instance) | |
1352 | (defalias 'ps-x-find-coding-system 'find-coding-system) | |
1353 | (defalias 'ps-x-font-instance-properties 'font-instance-properties) | |
1354 | (defalias 'ps-x-make-color-instance 'make-color-instance) | |
1355 | (defalias 'ps-x-map-extents 'map-extents) | |
1356 | ||
1357 | ;; GNU Emacs | |
1358 | (defalias 'ps-e-x-color-values 'x-color-values) | |
1359 | (defalias 'ps-e-color-values 'color-values) | |
1360 | (if (fboundp 'find-composition) | |
1361 | (defalias 'ps-e-find-composition 'find-composition) | |
1362 | (defalias 'ps-e-find-composition 'ignore)) | |
1363 | ||
1364 | ||
1365 | (defconst ps-windows-system | |
1366 | (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt))) | |
1367 | (defconst ps-lp-system | |
1368 | (memq system-type '(usq-unix-v dgux hpux irix)))) | |
906d41a7 GM |
1369 | |
1370 | ||
ef2cbb24 | 1371 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12d89a2e RS |
1372 | ;; User Variables: |
1373 | ||
0a5daee5 | 1374 | |
bcc0d457 RS |
1375 | ;;; Interface to the command system |
1376 | ||
bc0d41bd KH |
1377 | (defgroup postscript nil |
1378 | "PostScript Group" | |
1379 | :tag "PostScript" | |
1380 | :group 'emacs) | |
1381 | ||
e0af0d3e | 1382 | (defgroup ps-print nil |
3556c6dd GM |
1383 | "PostScript generator for Emacs" |
1384 | :link '(emacs-library-link :tag "Source Lisp File" "ps-print.el") | |
e0af0d3e | 1385 | :prefix "ps-" |
bc0d41bd KH |
1386 | :group 'wp |
1387 | :group 'postscript) | |
e0af0d3e RS |
1388 | |
1389 | (defgroup ps-print-horizontal nil | |
1390 | "Horizontal page layout" | |
1391 | :prefix "ps-" | |
1392 | :tag "Horizontal" | |
1393 | :group 'ps-print) | |
1394 | ||
1395 | (defgroup ps-print-vertical nil | |
1396 | "Vertical page layout" | |
1397 | :prefix "ps-" | |
1398 | :tag "Vertical" | |
1399 | :group 'ps-print) | |
1400 | ||
6e1b1da6 | 1401 | (defgroup ps-print-headers nil |
e0af0d3e RS |
1402 | "Headers layout" |
1403 | :prefix "ps-" | |
1404 | :tag "Header" | |
1405 | :group 'ps-print) | |
1406 | ||
1407 | (defgroup ps-print-font nil | |
1408 | "Fonts customization" | |
1409 | :prefix "ps-" | |
1410 | :tag "Font" | |
1411 | :group 'ps-print) | |
1412 | ||
1413 | (defgroup ps-print-color nil | |
1414 | "Color customization" | |
1415 | :prefix "ps-" | |
1416 | :tag "Color" | |
1417 | :group 'ps-print) | |
1418 | ||
1419 | (defgroup ps-print-face nil | |
1420 | "Faces customization" | |
1421 | :prefix "ps-" | |
1422 | :tag "PS Faces" | |
1423 | :group 'ps-print | |
1424 | :group 'faces) | |
1425 | ||
bc0d41bd KH |
1426 | (defgroup ps-print-n-up nil |
1427 | "N-up customization" | |
1428 | :prefix "ps-" | |
1429 | :tag "N-Up" | |
1430 | :group 'ps-print) | |
1431 | ||
1432 | (defgroup ps-print-zebra nil | |
1433 | "Zebra customization" | |
1434 | :prefix "ps-" | |
1435 | :tag "Zebra" | |
1436 | :group 'ps-print) | |
1437 | ||
1438 | (defgroup ps-print-background nil | |
1439 | "Background customization" | |
1440 | :prefix "ps-" | |
1441 | :tag "Background" | |
1442 | :group 'ps-print) | |
1443 | ||
1444 | (defgroup ps-print-printer nil | |
1445 | "Printer customization" | |
1446 | :prefix "ps-" | |
1447 | :tag "Printer" | |
1448 | :group 'ps-print) | |
1449 | ||
1450 | (defgroup ps-print-page nil | |
1451 | "Page customization" | |
1452 | :prefix "ps-" | |
1453 | :tag "Page" | |
1454 | :group 'ps-print) | |
1455 | ||
6e1b1da6 GM |
1456 | (defgroup ps-print-miscellany nil |
1457 | "Miscellany customization" | |
1458 | :prefix "ps-" | |
1459 | :tag "Miscellany" | |
1460 | :group 'ps-print) | |
1461 | ||
bc0d41bd | 1462 | |
66e63857 GM |
1463 | (defcustom ps-error-handler-message 'paper |
1464 | "*Specify where the error handler message should be sent. | |
1465 | ||
1466 | Valid values are: | |
1467 | ||
1468 | `none' catch the error and *DON'T* send any message. | |
1469 | ||
1470 | `paper' catch the error and print on paper the error message. | |
1471 | ||
1472 | `system' catch the error and send back the error message to | |
6e1b1da6 GM |
1473 | printing system. This is useful only if printing system |
1474 | send back an email reporting the error, or if there is | |
1475 | some other alternative way to report back the error from | |
1476 | the system to you. | |
66e63857 GM |
1477 | |
1478 | `paper-and-system' catch the error, print on paper the error message and | |
1479 | send back the error message to printing system. | |
1480 | ||
1481 | Any other value is treated as `paper'." | |
8e234846 GM |
1482 | :type '(choice :menu-tag "Error Handler Message" |
1483 | :tag "Error Handler Message" | |
66e63857 GM |
1484 | (const none) (const paper) |
1485 | (const system) (const paper-and-system)) | |
6e1b1da6 | 1486 | :group 'ps-print-miscellany) |
66e63857 GM |
1487 | |
1488 | (defcustom ps-user-defined-prologue nil | |
1489 | "*User defined PostScript prologue code inserted before all prologue code. | |
1490 | ||
1491 | `ps-user-defined-prologue' may be a string or a symbol function which returns a | |
1492 | string. Note that this string is inserted after `ps-adobe-tag' and PostScript | |
1493 | prologue comments, and before ps-print PostScript prologue code section. That | |
1494 | is, this string is inserted after error handler initialization and before | |
1495 | ps-print settings. | |
1496 | ||
66e63857 GM |
1497 | It's strongly recommended only insert PostScript code and/or comments specific |
1498 | for your printing system particularities. For example, some special | |
1499 | initialization that only your printing system needs. | |
1500 | ||
1501 | Do not insert code for duplex printing, n-up printing or error handler, ps-print | |
1502 | handles this in a suitable way. | |
1503 | ||
1504 | For more information about PostScript, see: | |
1505 | PostScript Language Reference Manual (2nd edition) | |
c3d6d211 GM |
1506 | Adobe Systems Incorporated |
1507 | ||
1508 | As an example for `ps-user-defined-prologue' setting: | |
1509 | ||
1510 | ;; Setting for HP PostScript printer | |
1511 | (setq ps-user-defined-prologue | |
1512 | (concat \"<</DeferredMediaSelection true /PageSize [612 792] \" | |
1513 | \"/MediaPosition 2 /MediaType (Plain)>> setpagedevice\")) | |
1514 | " | |
8e234846 GM |
1515 | :type '(choice :menu-tag "User Defined Prologue" |
1516 | :tag "User Defined Prologue" | |
98f2fbe7 | 1517 | (const :tag "none" nil) string symbol) |
6e1b1da6 | 1518 | :group 'ps-print-miscellany) |
66e63857 | 1519 | |
d3ab8dac KH |
1520 | (defcustom ps-print-prologue-header nil |
1521 | "*PostScript prologue header comments besides that ps-print generates. | |
1522 | ||
1523 | `ps-print-prologue-header' may be a string or a symbol function which | |
1524 | returns a string. Note that this string is inserted on PostScript prologue | |
1525 | header section which is used to define some document characteristic through | |
1526 | PostScript special comments, like \"%%Requirements: jog\\n\". | |
1527 | ||
1528 | ps-print always inserts the %%Requirements: comment, so if you need to insert | |
1529 | more requirements put them first in `ps-print-prologue-header' using the | |
1530 | \"%%+\" comment. For example, if you need to set numcopies to 3 and jog on | |
1531 | requirements and set %%LanguageLevel: to 2, do: | |
1532 | ||
1533 | (setq ps-print-prologue-header | |
1534 | \"%%+ numcopies(3) jog\\n%%LanguageLevel: 2\\n\") | |
1535 | ||
1536 | The duplex requirement is inserted by ps-print (see `ps-spool-duplex'). | |
1537 | ||
1538 | Do not forget to terminate the string with \"\\n\". | |
1539 | ||
1540 | For more information about PostScript document comments, see: | |
1541 | PostScript Language Reference Manual (2nd edition) | |
1542 | Adobe Systems Incorporated | |
1543 | Appendix G: Document Structuring Conventions -- Version 3.0" | |
8e234846 GM |
1544 | :type '(choice :menu-tag "Prologue Header" |
1545 | :tag "Prologue Header" | |
98f2fbe7 | 1546 | (const :tag "none" nil) string symbol) |
6e1b1da6 | 1547 | :group 'ps-print-miscellany) |
d3ab8dac | 1548 | |
298bfad9 KH |
1549 | (defcustom ps-printer-name (and (boundp 'printer-name) |
1550 | printer-name) | |
03820514 RS |
1551 | "*The name of a local printer for printing PostScript files. |
1552 | ||
3556c6dd GM |
1553 | On Unix-like systems, a string value should be a name understood by lpr's -P |
1554 | option; a value of nil means use the value of `printer-name' instead. | |
1555 | ||
1556 | On MS-DOS and MS-Windows systems, a string value is taken as the name of the | |
1557 | printer device or port to which PostScript files are written, provided | |
1558 | `ps-lpr-command' is \"\". By default it is the same as `printer-name'; typical | |
1559 | non-default settings would be \"LPT1\" to \"LPT3\" for parallel printers, or | |
1560 | \"COM1\" to \"COM4\" or \"AUX\" for serial printers, or \"//hostname/printer\" | |
1561 | for a shared network printer. You can also set it to a name of a file, in | |
1562 | which case the output gets appended to that file. \(Note that `ps-print' | |
1563 | package already has facilities for printing to a file, so you might as well use | |
1564 | them instead of changing the setting of this variable.\) If you want to | |
1565 | silently discard the printed output, set this to \"NUL\". | |
1566 | ||
1567 | Set to t, if the utility given by `ps-lpr-command' needs an empty printer name. | |
1568 | ||
1569 | Any other value is treated as t, that is, an empty printer name. | |
1570 | ||
1571 | See also `ps-printer-name-option' for documentation." | |
8e234846 GM |
1572 | :type '(choice :menu-tag "Printer Name" |
1573 | :tag "Printer Name" | |
1574 | (const :tag "Same as printer-name" nil) | |
3556c6dd | 1575 | (const :tag "No Printer Name" t) |
6e1b1da6 | 1576 | (file :tag "Print to file") |
8e234846 | 1577 | (string :tag "Pipe to ps-lpr-command")) |
bc0d41bd | 1578 | :group 'ps-print-printer) |
03820514 | 1579 | |
3556c6dd GM |
1580 | (defcustom ps-printer-name-option |
1581 | (cond (ps-windows-system | |
1582 | "/D:") | |
1583 | (ps-lp-system | |
1584 | "-d") | |
1585 | (t | |
1586 | "-P" )) | |
1587 | "*Option for `ps-printer-name' variable (see it). | |
1588 | ||
1589 | On Unix-like systems, if it's been used lpr utility, it should be the string | |
1590 | \"-P\"; if it's been used lp utility, it should be the string \"-d\". | |
1591 | ||
1592 | On MS-DOS and MS-Windows systems, if it's been used print utility, it should be | |
1593 | the string \"/D:\". | |
1594 | ||
1595 | For any other printing utility, see the proper manual or documentation. | |
1596 | ||
1597 | Set to \"\" or nil, if the utility given by `ps-lpr-command' needs an empty | |
1598 | option printer name option. | |
1599 | ||
1600 | Any other value is treated as nil, that is, an empty printer name option. | |
1601 | ||
1602 | This variable is used only when `ps-printer-name' is a non-empty string." | |
1603 | :type '(choice :menu-tag "Printer Name Option" | |
1604 | :tag "Printer Name Option" | |
1605 | (const :tag "None" nil) | |
1606 | (string :tag "Option")) | |
1607 | :group 'ps-print-printer) | |
1608 | ||
e0af0d3e | 1609 | (defcustom ps-lpr-command lpr-command |
52cf535f AI |
1610 | "*Name of program for printing a PostScript file. |
1611 | ||
3556c6dd GM |
1612 | On MS-DOS and MS-Windows systems, if the value is an empty string then Emacs |
1613 | will write directly to the printer port named by `ps-printer-name'. The | |
1614 | programs `print' and `nprint' (the standard print programs on Windows NT and | |
1615 | Novell Netware respectively) are handled specially, using `ps-printer-name' as | |
1616 | the destination for output; any other program is treated like `lpr' except that | |
1617 | an explicit filename is given as the last argument." | |
e0af0d3e | 1618 | :type 'string |
bc0d41bd | 1619 | :group 'ps-print-printer) |
e0af0d3e RS |
1620 | |
1621 | (defcustom ps-lpr-switches lpr-switches | |
1622 | "*A list of extra switches to pass to `ps-lpr-command'." | |
edc9cd35 GM |
1623 | :type '(repeat :tag "PostScript lpr Switches" |
1624 | (choice string symbol (repeat sexp))) | |
bc0d41bd | 1625 | :group 'ps-print-printer) |
12d89a2e | 1626 | |
52cf535f | 1627 | (defcustom ps-print-region-function nil |
bc0d41bd KH |
1628 | "*Specify a function to print the region on a PostScript printer. |
1629 | See definition of `call-process-region' for calling conventions. The fourth and | |
1630 | the sixth arguments are both nil." | |
52cf535f | 1631 | :type 'function |
bc0d41bd | 1632 | :group 'ps-print-printer) |
52cf535f | 1633 | |
8e234846 GM |
1634 | (defcustom ps-manual-feed nil |
1635 | "*Non-nil means the printer will manually feed paper. | |
1636 | ||
1637 | If it's nil, automatic feeding takes place." | |
1638 | :type 'boolean | |
1639 | :group 'ps-print-printer) | |
1640 | ||
bcc0d457 | 1641 | ;;; Page layout |
12d89a2e | 1642 | |
bcc0d457 RS |
1643 | ;; All page dimensions are in PostScript points. |
1644 | ;; 1 inch == 2.54 cm == 72 points | |
1645 | ;; 1 cm == (/ 1 2.54) inch == (/ 72 2.54) points | |
1646 | ||
1647 | ;; Letter 8.5 inch x 11.0 inch | |
1648 | ;; Legal 8.5 inch x 14.0 inch | |
1649 | ;; A4 8.26 inch x 11.69 inch = 21.0 cm x 29.7 cm | |
1650 | ||
1651 | ;; LetterSmall 7.68 inch x 10.16 inch | |
1652 | ;; Tabloid 11.0 inch x 17.0 inch | |
1653 | ;; Ledger 17.0 inch x 11.0 inch | |
1654 | ;; Statement 5.5 inch x 8.5 inch | |
1655 | ;; Executive 7.5 inch x 10.0 inch | |
1656 | ;; A3 11.69 inch x 16.5 inch = 29.7 cm x 42.0 cm | |
1657 | ;; A4Small 7.47 inch x 10.85 inch | |
1658 | ;; B4 10.125 inch x 14.33 inch | |
1659 | ;; B5 7.16 inch x 10.125 inch | |
1660 | ||
e0af0d3e | 1661 | (defcustom ps-page-dimensions-database |
bc0d41bd KH |
1662 | (list (list 'a4 (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54) "A4") |
1663 | (list 'a3 (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54) "A3") | |
1664 | (list 'letter (* 72 8.5) (* 72 11.0) "Letter") | |
1665 | (list 'legal (* 72 8.5) (* 72 14.0) "Legal") | |
1666 | (list 'letter-small (* 72 7.68) (* 72 10.16) "LetterSmall") | |
1667 | (list 'tabloid (* 72 11.0) (* 72 17.0) "Tabloid") | |
1668 | (list 'ledger (* 72 17.0) (* 72 11.0) "Ledger") | |
1669 | (list 'statement (* 72 5.5) (* 72 8.5) "Statement") | |
1670 | (list 'executive (* 72 7.5) (* 72 10.0) "Executive") | |
1671 | (list 'a4small (* 72 7.47) (* 72 10.85) "A4Small") | |
1672 | (list 'b4 (* 72 10.125) (* 72 14.33) "B4") | |
1673 | (list 'b5 (* 72 7.16) (* 72 10.125) "B5")) | |
1674 | "*List associating a symbolic paper type to its width, height and doc media. | |
1675 | See `ps-paper-type'." | |
e0af0d3e RS |
1676 | :type '(repeat (list :tag "Paper Type" |
1677 | (symbol :tag "Name") | |
1678 | (number :tag "Width") | |
bc0d41bd KH |
1679 | (number :tag "Height") |
1680 | (string :tag "Media"))) | |
1681 | :group 'ps-print-page) | |
e0af0d3e | 1682 | |
857686a6 | 1683 | ;;;###autoload |
e0af0d3e | 1684 | (defcustom ps-paper-type 'letter |
bc0d41bd | 1685 | "*Specify the size of paper to format for. |
090be653 | 1686 | Should be one of the paper types defined in `ps-page-dimensions-database', for |
e0af0d3e RS |
1687 | example `letter', `legal' or `a4'." |
1688 | :type '(symbol :validate (lambda (wid) | |
87a16a06 RS |
1689 | (if (assq (widget-value wid) |
1690 | ps-page-dimensions-database) | |
e0af0d3e RS |
1691 | nil |
1692 | (widget-put wid :error "Unknown paper size") | |
1693 | wid))) | |
bc0d41bd | 1694 | :group 'ps-print-page) |
e0af0d3e | 1695 | |
8e234846 GM |
1696 | (defcustom ps-warn-paper-type t |
1697 | "*Non-nil means give an error if paper size is not equal to `ps-paper-type'. | |
1698 | ||
1699 | It's used when `ps-spool-config' is set to `setpagedevice'." | |
1700 | :type 'boolean | |
1701 | :group 'ps-print-page) | |
1702 | ||
87a16a06 | 1703 | (defcustom ps-landscape-mode nil |
e0af0d3e RS |
1704 | "*Non-nil means print in landscape mode." |
1705 | :type 'boolean | |
bc0d41bd | 1706 | :group 'ps-print-page) |
e0af0d3e | 1707 | |
906d41a7 GM |
1708 | (defcustom ps-print-upside-down nil |
1709 | "*Non-nil means print upside-down." | |
1710 | :type 'boolean | |
1711 | :group 'ps-print-page) | |
1712 | ||
1fd9b7fe GM |
1713 | (defcustom ps-selected-pages nil |
1714 | "*Specify which pages to print. | |
1715 | ||
1716 | If it's nil, all pages are printed. | |
1717 | ||
1718 | If it's a list, the list element may be an integer or a cons cell (FROM . TO) | |
1719 | designating FROM page to TO page; any invalid element is ignored, that is, an | |
1720 | integer lesser than one or if FROM is greater than TO. | |
1721 | ||
1722 | Otherwise, it's treated as nil. | |
1723 | ||
1724 | After ps-print processing `ps-selected-pages' is set to nil. But the latest | |
1725 | `ps-selected-pages' is saved in `ps-last-selected-pages' (see it for | |
1726 | documentation). So you can restore the latest selected pages by using | |
1727 | `ps-last-selected-pages' or by calling `ps-restore-selected-pages' command (see | |
ea0c615d GM |
1728 | it for documentation). |
1729 | ||
1730 | See also `ps-even-or-odd-pages'." | |
1fd9b7fe GM |
1731 | :type '(repeat :tag "Selected Pages" |
1732 | (radio :tag "Page" | |
1733 | (integer :tag "Number") | |
1734 | (cons :tag "Range" | |
1735 | (integer :tag "From") | |
1736 | (integer :tag "To")))) | |
1737 | :group 'ps-print-page) | |
1738 | ||
c3d6d211 GM |
1739 | (defcustom ps-even-or-odd-pages nil |
1740 | "*Specify if it prints even/odd pages. | |
1741 | ||
1742 | Valid values are: | |
1743 | ||
1744 | nil print all pages. | |
1745 | ||
1746 | `even' print only even pages. | |
1747 | ||
1748 | `odd' print only odd pages. | |
1749 | ||
ea0c615d GM |
1750 | Any other value is treated as nil. |
1751 | ||
1752 | If you set `ps-selected-pages' (see it for documentation), first the pages are | |
1753 | filtered by `ps-selected-pages' and then by `ps-even-or-odd-pages'. For | |
1754 | example, if we have: | |
1755 | ||
1756 | (setq ps-selected-pages '(1 4 (6 . 10) 12)) | |
1757 | ||
1758 | We have the following results: | |
1759 | ||
1760 | `ps-even-or-odd-pages' PAGES PRINTED | |
1761 | nil 1, 4, 6, 7, 8, 9, 10, 12 | |
1762 | even 4, 6, 8, 10, 12 | |
1763 | odd 1, 7, 9" | |
c3d6d211 GM |
1764 | :type '(choice :menu-tag "Print Even/Odd Pages" |
1765 | :tag "Print Even/Odd Pages" | |
1766 | (const :tag "All Pages" nil) | |
1767 | (const :tag "Only Even Pages" even) | |
1768 | (const :tag "Only Odd Pages" odd)) | |
1769 | :group 'ps-print-page) | |
1770 | ||
857686a6 | 1771 | (defcustom ps-print-control-characters 'control-8-bit |
bc0d41bd KH |
1772 | "*Specify the printable form for control and 8-bit characters. |
1773 | That is, instead of sending, for example, a ^D (\\004) to printer, | |
915293a2 | 1774 | it is sent the string \"^D\". |
6bdb808e | 1775 | |
857686a6 | 1776 | Valid values are: |
6bdb808e | 1777 | |
984e7bd9 | 1778 | `8-bit' This is the value to use when you want an ASCII encoding of |
d3ab8dac KH |
1779 | any control or non-ASCII character. Control characters are |
1780 | encoded as \"^D\", and non-ASCII characters have an | |
1781 | octal encoding. | |
6bdb808e | 1782 | |
984e7bd9 | 1783 | `control-8-bit' This is the value to use when you want an ASCII encoding of |
d3ab8dac KH |
1784 | any control character, whether it is 7 or 8-bit. |
1785 | European 8-bits accented characters are printed according | |
1786 | the current font. | |
6bdb808e | 1787 | |
c82b4a75 | 1788 | `control' Only ASCII control characters have an ASCII encoding. |
d3ab8dac KH |
1789 | European 8-bits accented characters are printed according |
1790 | the current font. | |
6bdb808e | 1791 | |
984e7bd9 | 1792 | nil No ASCII encoding. Any character is printed according the |
d3ab8dac | 1793 | current font. |
6bdb808e | 1794 | |
857686a6 | 1795 | Any other value is treated as nil." |
8e234846 GM |
1796 | :type '(choice :menu-tag "Control Char" |
1797 | :tag "Control Char" | |
bc0d41bd | 1798 | (const 8-bit) (const control-8-bit) |
edc9cd35 | 1799 | (const control) (const :tag "nil" nil)) |
6e1b1da6 | 1800 | :group 'ps-print-miscellany) |
857686a6 | 1801 | |
bc0d41bd KH |
1802 | (defcustom ps-n-up-printing 1 |
1803 | "*Specify the number of pages per sheet paper." | |
1804 | :type '(integer | |
1805 | :tag "N Up Printing" | |
1806 | :validate | |
1807 | (lambda (wid) | |
1808 | (if (and (< 0 (widget-value wid)) | |
1809 | (<= (widget-value wid) 100)) | |
1810 | nil | |
1811 | (widget-put | |
1812 | wid :error | |
1813 | "Number of pages per sheet paper must be between 1 and 100.") | |
1814 | wid))) | |
1815 | :group 'ps-print-n-up) | |
1816 | ||
1817 | (defcustom ps-n-up-margin (/ (* 72 1.0) 2.54) ; 1 cm | |
1818 | "*Specify the margin in points between the sheet border and n-up printing." | |
1819 | :type 'number | |
1820 | :group 'ps-print-n-up) | |
1821 | ||
1822 | (defcustom ps-n-up-border-p t | |
1823 | "*Non-nil means a border is drawn around each page." | |
1824 | :type 'boolean | |
1825 | :group 'ps-print-n-up) | |
1826 | ||
1827 | (defcustom ps-n-up-filling 'left-top | |
1828 | "*Specify how page matrix is filled on each sheet of paper. | |
1829 | ||
1830 | Following are the valid values for `ps-n-up-filling' with a filling example | |
1831 | using a 3x4 page matrix: | |
1832 | ||
1833 | `left-top' 1 2 3 4 `left-bottom' 9 10 11 12 | |
1834 | 5 6 7 8 5 6 7 8 | |
1835 | 9 10 11 12 1 2 3 4 | |
1836 | ||
1837 | `right-top' 4 3 2 1 `right-bottom' 12 11 10 9 | |
1838 | 8 7 6 5 8 7 6 5 | |
1839 | 12 11 10 9 4 3 2 1 | |
1840 | ||
1841 | `top-left' 1 4 7 10 `bottom-left' 3 6 9 12 | |
1842 | 2 5 8 11 2 5 8 11 | |
1843 | 3 6 9 12 1 4 7 10 | |
1844 | ||
1845 | `top-right' 10 7 4 1 `bottom-right' 12 9 6 3 | |
1846 | 11 8 5 2 11 8 5 2 | |
1847 | 12 9 6 3 10 7 4 1 | |
1848 | ||
1849 | Any other value is treated as `left-top'." | |
8e234846 GM |
1850 | :type '(choice :menu-tag "N-Up Filling" |
1851 | :tag "N-Up Filling" | |
bc0d41bd KH |
1852 | (const left-top) (const left-bottom) |
1853 | (const right-top) (const right-bottom) | |
1854 | (const top-left) (const bottom-left) | |
1855 | (const top-right) (const bottom-right)) | |
1856 | :group 'ps-print-n-up) | |
1857 | ||
e0af0d3e | 1858 | (defcustom ps-number-of-columns (if ps-landscape-mode 2 1) |
bc0d41bd | 1859 | "*Specify the number of columns" |
87a16a06 | 1860 | :type 'number |
6e1b1da6 | 1861 | :group 'ps-print-miscellany) |
87a16a06 | 1862 | |
535efc38 | 1863 | (defcustom ps-zebra-stripes nil |
87a16a06 | 1864 | "*Non-nil means print zebra stripes. |
6e1b1da6 | 1865 | See also documentation for `ps-zebra-stripe-height' and `ps-zebra-color'." |
87a16a06 | 1866 | :type 'boolean |
bc0d41bd | 1867 | :group 'ps-print-zebra) |
87a16a06 | 1868 | |
535efc38 | 1869 | (defcustom ps-zebra-stripe-height 3 |
87a16a06 | 1870 | "*Number of zebra stripe lines. |
6e1b1da6 | 1871 | See also documentation for `ps-zebra-stripes' and `ps-zebra-color'." |
87a16a06 | 1872 | :type 'number |
bc0d41bd KH |
1873 | :group 'ps-print-zebra) |
1874 | ||
6e1b1da6 GM |
1875 | (defcustom ps-zebra-color 0.95 |
1876 | "*Zebra stripe gray scale or RGB color. | |
bc0d41bd | 1877 | See also documentation for `ps-zebra-stripes' and `ps-zebra-stripe-height'." |
8e234846 GM |
1878 | :type '(choice :menu-tag "Zebra Gray/Color" |
1879 | :tag "Zebra Gray/Color" | |
6e1b1da6 GM |
1880 | (number :tag "Gray Scale" :value 0.95) |
1881 | (string :tag "Color Name" :value "gray95") | |
1882 | (list :tag "RGB Color" :value (0.95 0.95 0.95) | |
1883 | (number :tag "Red") | |
1884 | (number :tag "Green") | |
1885 | (number :tag "Blue"))) | |
bc0d41bd | 1886 | :group 'ps-print-zebra) |
87a16a06 | 1887 | |
8e234846 GM |
1888 | (defcustom ps-zebra-stripe-follow nil |
1889 | "*Non-nil means zebra stripe continues on next page. | |
1890 | ||
1891 | If `ps-zebra-stripe-follow' is nil, zebra stripe is restarted on each page. | |
1892 | If `ps-zebra-stripe-follow' is non-nil, zebra stripe continues on next page. | |
1893 | ||
1894 | Visually, we have: | |
1895 | ||
1896 | `ps-zebra-stripe-follow' `ps-zebra-stripe-follow' | |
1897 | is nil is non-nil | |
1898 | Current Page ------------------------ ------------------------ | |
1899 | 1 XXXXXXXXXXXXXXXXXXXXX 1 XXXXXXXXXXXXXXXXXXXXX | |
1900 | 2 XXXXXXXXXXXXXXXXXXXXX 2 XXXXXXXXXXXXXXXXXXXXX | |
1901 | 3 XXXXXXXXXXXXXXXXXXXXX 3 XXXXXXXXXXXXXXXXXXXXX | |
1902 | 4 4 | |
1903 | 5 5 | |
1904 | 6 6 | |
1905 | 7 XXXXXXXXXXXXXXXXXXXXX 7 XXXXXXXXXXXXXXXXXXXXX | |
1906 | 8 XXXXXXXXXXXXXXXXXXXXX 8 XXXXXXXXXXXXXXXXXXXXX | |
1907 | ------------------------ ------------------------ | |
1908 | Next Page ------------------------ ------------------------ | |
1909 | 9 XXXXXXXXXXXXXXXXXXXXX 9 XXXXXXXXXXXXXXXXXXXXX | |
1910 | 10 XXXXXXXXXXXXXXXXXXXXX 10 | |
1911 | 11 XXXXXXXXXXXXXXXXXXXXX 11 | |
1912 | 12 12 | |
1913 | 13 13 XXXXXXXXXXXXXXXXXXXXX | |
1914 | 14 14 XXXXXXXXXXXXXXXXXXXXX | |
1915 | 15 XXXXXXXXXXXXXXXXXXXXX 15 XXXXXXXXXXXXXXXXXXXXX | |
1916 | 16 XXXXXXXXXXXXXXXXXXXXX 16 | |
1917 | ------------------------ ------------------------" | |
1918 | :type 'boolean | |
1919 | :group 'ps-print-zebra) | |
1920 | ||
87a16a06 RS |
1921 | (defcustom ps-line-number nil |
1922 | "*Non-nil means print line number." | |
1923 | :type 'boolean | |
6e1b1da6 | 1924 | :group 'ps-print-miscellany) |
87a16a06 | 1925 | |
906d41a7 GM |
1926 | (defcustom ps-line-number-step 1 |
1927 | "*Specify the interval that line number is printed. | |
1928 | ||
1929 | For example, `ps-line-number-step' is set to 2, the printing will look like: | |
1930 | ||
1931 | 1 one line | |
1932 | one line | |
1933 | 3 one line | |
1934 | one line | |
98f2fbe7 | 1935 | 5 one line |
906d41a7 GM |
1936 | one line |
1937 | ... | |
1938 | ||
1939 | Valid values are: | |
1940 | ||
1941 | integer an integer that specifies the interval that line number is | |
1942 | printed. If it's lesser than or equal to zero, it's used the | |
1943 | value 1. | |
1944 | ||
1945 | `zebra' specifies that only the line number of the first line in a zebra | |
1946 | stripe is to be printed. | |
1947 | ||
1948 | Any other value is treated as `zebra'." | |
8e234846 GM |
1949 | :type '(choice :menu-tag "Line Number Step" |
1950 | :tag "Line Number Step" | |
906d41a7 GM |
1951 | (integer :tag "Step Interval") |
1952 | (const :tag "Synchronize Zebra" zebra)) | |
1953 | :group 'ps-print-miscellany) | |
1954 | ||
98f2fbe7 GM |
1955 | (defcustom ps-line-number-start 1 |
1956 | "*Specify the starting point in the interval given by `ps-line-number-step'. | |
1957 | ||
3556c6dd GM |
1958 | For example, if `ps-line-number-step' is set to 3 and `ps-line-number-start' is |
1959 | set to 3, the printing will look like: | |
98f2fbe7 GM |
1960 | |
1961 | one line | |
1962 | one line | |
1963 | 3 one line | |
1964 | one line | |
1965 | one line | |
1966 | 6 one line | |
1967 | one line | |
1968 | one line | |
1969 | 9 one line | |
1970 | one line | |
1971 | ... | |
1972 | ||
1973 | The values for `ps-line-number-start': | |
1974 | ||
1975 | * If `ps-line-number-step' is an integer, must be between 1 and the value | |
1976 | of `ps-line-number-step' inclusive. | |
1977 | ||
1978 | * If `ps-line-number-step' is set to `zebra', must be between 1 and the | |
1979 | value of `ps-zebra-strip-height' inclusive. Use this combination if you | |
1980 | wish that line number be relative to zebra stripes." | |
1981 | :type '(integer :tag "Start Step Interval") | |
1982 | :group 'ps-print-miscellany) | |
1983 | ||
87a16a06 RS |
1984 | (defcustom ps-print-background-image nil |
1985 | "*EPS image list to be printed on background. | |
1986 | ||
1987 | The elements are: | |
1988 | ||
1989 | (FILENAME X Y XSCALE YSCALE ROTATION PAGES...) | |
1990 | ||
1991 | FILENAME is a file name which contains an EPS image or some PostScript | |
1992 | programming like EPS. | |
1993 | FILENAME is ignored, if it doesn't exist or is read protected. | |
1994 | ||
1995 | X and Y are relative positions on paper to put the image. | |
1996 | If X and Y are nil, the image is centralized on paper. | |
1997 | ||
1998 | XSCALE and YSCALE are scale factor to be applied to image before printing. | |
1999 | If XSCALE and YSCALE are nil, the original size is used. | |
2000 | ||
2001 | ROTATION is the image rotation angle; if nil, the default is 0. | |
2002 | ||
2003 | PAGES designates the page to print background image. | |
2004 | PAGES may be a number or a cons cell (FROM . TO) designating FROM page | |
2005 | to TO page. | |
2006 | If PAGES is nil, print background image on all pages. | |
2007 | ||
2008 | X, Y, XSCALE, YSCALE and ROTATION may be a floating point number, | |
2009 | an integer number or a string. If it is a string, the string should contain | |
2010 | PostScript programming that returns a float or integer value. | |
2011 | ||
2012 | For example, if you wish to print an EPS image on all pages do: | |
2013 | ||
2014 | '((\"~/images/EPS-image.ps\"))" | |
98f2fbe7 GM |
2015 | :type '(repeat |
2016 | (list | |
2017 | (file :tag "EPS File") | |
2018 | (choice :tag "X" (const :tag "default" nil) number string) | |
2019 | (choice :tag "Y" (const :tag "default" nil) number string) | |
2020 | (choice :tag "X Scale" (const :tag "default" nil) number string) | |
2021 | (choice :tag "Y Scale" (const :tag "default" nil) number string) | |
2022 | (choice :tag "Rotation" (const :tag "default" nil) number string) | |
2023 | (repeat :tag "Pages" :inline t | |
2024 | (radio (integer :tag "Page") | |
2025 | (cons :tag "Range" | |
2026 | (integer :tag "From") | |
2027 | (integer :tag "To")))))) | |
bc0d41bd | 2028 | :group 'ps-print-background) |
87a16a06 RS |
2029 | |
2030 | (defcustom ps-print-background-text nil | |
2031 | "*Text list to be printed on background. | |
2032 | ||
2033 | The elements are: | |
2034 | ||
2035 | (STRING X Y FONT FONTSIZE GRAY ROTATION PAGES...) | |
2036 | ||
2037 | STRING is the text to be printed on background. | |
2038 | ||
2039 | X and Y are positions on paper to put the text. | |
2040 | If X and Y are nil, the text is positioned at lower left corner. | |
2041 | ||
2042 | FONT is a font name to be used on printing the text. | |
2043 | If nil, \"Times-Roman\" is used. | |
2044 | ||
2045 | FONTSIZE is font size to be used, if nil, 200 is used. | |
2046 | ||
2047 | GRAY is the text gray factor (should be very light like 0.8). | |
2048 | If nil, the default is 0.85. | |
2049 | ||
2050 | ROTATION is the text rotation angle; if nil, the angle is given by | |
2051 | the diagonal from lower left corner to upper right corner. | |
2052 | ||
2053 | PAGES designates the page to print background text. | |
2054 | PAGES may be a number or a cons cell (FROM . TO) designating FROM page | |
2055 | to TO page. | |
2056 | If PAGES is nil, print background text on all pages. | |
2057 | ||
2058 | X, Y, FONTSIZE, GRAY and ROTATION may be a floating point number, | |
2059 | an integer number or a string. If it is a string, the string should contain | |
2060 | PostScript programming that returns a float or integer value. | |
2061 | ||
2062 | For example, if you wish to print text \"Preliminary\" on all pages do: | |
2063 | ||
2064 | '((\"Preliminary\"))" | |
98f2fbe7 GM |
2065 | :type '(repeat |
2066 | (list | |
2067 | (string :tag "Text") | |
2068 | (choice :tag "X" (const :tag "default" nil) number string) | |
2069 | (choice :tag "Y" (const :tag "default" nil) number string) | |
2070 | (choice :tag "Font" (const :tag "default" nil) string) | |
2071 | (choice :tag "Fontsize" (const :tag "default" nil) number string) | |
2072 | (choice :tag "Gray" (const :tag "default" nil) number string) | |
2073 | (choice :tag "Rotation" (const :tag "default" nil) number string) | |
2074 | (repeat :tag "Pages" :inline t | |
2075 | (radio (integer :tag "Page") | |
2076 | (cons :tag "Range" | |
2077 | (integer :tag "From") | |
2078 | (integer :tag "To")))))) | |
bc0d41bd | 2079 | :group 'ps-print-background) |
bcc0d457 RS |
2080 | |
2081 | ;;; Horizontal layout | |
2082 | ||
2083 | ;; ------------------------------------------ | |
2084 | ;; | | | | | | | | | |
2085 | ;; | lm | text | ic | text | ic | text | rm | | |
2086 | ;; | | | | | | | | | |
2087 | ;; ------------------------------------------ | |
2088 | ||
e0af0d3e RS |
2089 | (defcustom ps-left-margin (/ (* 72 2.0) 2.54) ; 2 cm |
2090 | "*Left margin in points (1/72 inch)." | |
2091 | :type 'number | |
2092 | :group 'ps-print-horizontal) | |
bcc0d457 | 2093 | |
e0af0d3e RS |
2094 | (defcustom ps-right-margin (/ (* 72 2.0) 2.54) ; 2 cm |
2095 | "*Right margin in points (1/72 inch)." | |
2096 | :type 'number | |
2097 | :group 'ps-print-horizontal) | |
bcc0d457 | 2098 | |
e0af0d3e RS |
2099 | (defcustom ps-inter-column (/ (* 72 2.0) 2.54) ; 2 cm |
2100 | "*Horizontal space between columns in points (1/72 inch)." | |
2101 | :type 'number | |
2102 | :group 'ps-print-horizontal) | |
bcc0d457 RS |
2103 | |
2104 | ;;; Vertical layout | |
2105 | ||
2106 | ;; |--------| | |
2107 | ;; | tm | | |
2108 | ;; |--------| | |
2109 | ;; | header | | |
2110 | ;; |--------| | |
2111 | ;; | ho | | |
2112 | ;; |--------| | |
2113 | ;; | text | | |
2114 | ;; |--------| | |
2115 | ;; | bm | | |
2116 | ;; |--------| | |
2117 | ||
e0af0d3e RS |
2118 | (defcustom ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm |
2119 | "*Bottom margin in points (1/72 inch)." | |
2120 | :type 'number | |
2121 | :group 'ps-print-vertical) | |
bcc0d457 | 2122 | |
e0af0d3e RS |
2123 | (defcustom ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm |
2124 | "*Top margin in points (1/72 inch)." | |
2125 | :type 'number | |
2126 | :group 'ps-print-vertical) | |
bcc0d457 | 2127 | |
e0af0d3e RS |
2128 | (defcustom ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm |
2129 | "*Vertical space in points (1/72 inch) between the main text and the header." | |
2130 | :type 'number | |
2131 | :group 'ps-print-vertical) | |
bcc0d457 | 2132 | |
e0af0d3e | 2133 | (defcustom ps-header-line-pad 0.15 |
bcc0d457 | 2134 | "*Portion of a header title line height to insert between the header frame |
e0af0d3e RS |
2135 | and the text it contains, both in the vertical and horizontal directions." |
2136 | :type 'number | |
2137 | :group 'ps-print-vertical) | |
bcc0d457 RS |
2138 | |
2139 | ;;; Header setup | |
12d89a2e | 2140 | |
e0af0d3e | 2141 | (defcustom ps-print-header t |
86c10ecb RS |
2142 | "*Non-nil means print a header at the top of each page. |
2143 | By default, the header displays the buffer name, page number, and, if | |
2144 | the buffer is visiting a file, the file's directory. Headers are | |
ae7f6761 | 2145 | customizable by changing variables `ps-left-header' and |
e0af0d3e RS |
2146 | `ps-right-header'." |
2147 | :type 'boolean | |
6e1b1da6 | 2148 | :group 'ps-print-headers) |
e0af0d3e | 2149 | |
12b88fff RS |
2150 | (defcustom ps-print-only-one-header nil |
2151 | "*Non-nil means print only one header at the top of each page. | |
2152 | This is useful when printing more than one column, so it is possible | |
2153 | to have only one header over all columns or one header per column. | |
2154 | See also `ps-print-header'." | |
2155 | :type 'boolean | |
6e1b1da6 | 2156 | :group 'ps-print-headers) |
12b88fff | 2157 | |
e0af0d3e RS |
2158 | (defcustom ps-print-header-frame t |
2159 | "*Non-nil means draw a gaudy frame around the header." | |
2160 | :type 'boolean | |
6e1b1da6 | 2161 | :group 'ps-print-headers) |
e0af0d3e RS |
2162 | |
2163 | (defcustom ps-header-lines 2 | |
8bd22fcf | 2164 | "*Number of lines to display in page header, when generating PostScript." |
e0af0d3e | 2165 | :type 'integer |
6e1b1da6 | 2166 | :group 'ps-print-headers) |
bcc0d457 | 2167 | |
8e234846 GM |
2168 | (defcustom ps-switch-header 'duplex |
2169 | "*Specify if headers are switched or not. | |
2170 | ||
2171 | Valid values are: | |
2172 | ||
2173 | nil Never switch headers. | |
2174 | ||
2175 | t Always switch headers. | |
2176 | ||
2177 | duplex Switch headers only when duplexing is on, that is, when | |
2178 | `ps-spool-duplex' is non-nil. | |
2179 | ||
2180 | Any other value is treated as t." | |
2181 | :type '(choice :menu-tag "Switch Header" | |
2182 | :tag "Switch Header" | |
2183 | (const :tag "Never Switch" nil) | |
2184 | (const :tag "Always Switch" t) | |
2185 | (const :tag "Switch When Duplexing" duplex)) | |
2186 | :group 'ps-print-headers) | |
2187 | ||
e0af0d3e | 2188 | (defcustom ps-show-n-of-n t |
00aa16af | 2189 | "*Non-nil means show page numbers as N/M, meaning page N of M. |
8bd22fcf | 2190 | NOTE: page numbers are displayed as part of headers, |
6e1b1da6 | 2191 | see variable `ps-print-header'." |
e0af0d3e | 2192 | :type 'boolean |
6e1b1da6 | 2193 | :group 'ps-print-headers) |
12d89a2e | 2194 | |
edc9cd35 | 2195 | (defcustom ps-spool-config |
906d41a7 | 2196 | (if ps-windows-system |
edc9cd35 GM |
2197 | nil |
2198 | 'lpr-switches) | |
bc0d41bd KH |
2199 | "*Specify who is responsable for setting duplex and page size switches. |
2200 | ||
2201 | Valid values are: | |
2202 | ||
2203 | `lpr-switches' duplex and page size are configured by `ps-lpr-switches'. | |
2204 | Don't forget to set `ps-lpr-switches' to select duplex | |
2205 | printing for your printer. | |
2206 | ||
2207 | `setpagedevice' duplex and page size are configured by ps-print using the | |
2208 | setpagedevice PostScript operator. | |
2209 | ||
2210 | nil duplex and page size are configured by ps-print *not* using | |
2211 | the setpagedevice PostScript operator. | |
2212 | ||
2213 | Any other value is treated as nil. | |
2214 | ||
2215 | WARNING: The setpagedevice PostScript operator affects ghostview utility when | |
2216 | viewing file generated using landscape. Also on some printers, | |
2217 | setpagedevice affects zebra stripes; on other printers, setpagedevice | |
2218 | affects the left margin. | |
2219 | Besides all that, if your printer does not have the paper size | |
2220 | specified by setpagedevice, your printing will be aborted. | |
2221 | So, if you need to use setpagedevice, set `ps-spool-config' to | |
2222 | `setpagedevice', generate a test file and send it to your printer; if | |
2223 | the printed file isn't ok, set `ps-spool-config' to nil." | |
8e234846 GM |
2224 | :type '(choice :menu-tag "Spool Config" |
2225 | :tag "Spool Config" | |
bc0d41bd | 2226 | (const lpr-switches) (const setpagedevice) |
edc9cd35 | 2227 | (const :tag "nil" nil)) |
6e1b1da6 | 2228 | :group 'ps-print-headers) |
bc0d41bd KH |
2229 | |
2230 | (defcustom ps-spool-duplex nil ; Not many people have duplex printers, | |
2231 | ; so default to nil. | |
2232 | "*Non-nil generates PostScript for a two-sided printer. | |
2233 | For a duplex printer, the `ps-spool-*' and `ps-print-*' commands will insert | |
2234 | blank pages as needed between print jobs so that the next buffer printed will | |
2235 | start on the right page. Also, if headers are turned on, the headers will be | |
2236 | reversed on duplex printers so that the page numbers fall to the left on | |
0a5daee5 KH |
2237 | even-numbered pages. |
2238 | ||
2239 | See also `ps-spool-tumble'." | |
bc0d41bd | 2240 | :type 'boolean |
6e1b1da6 | 2241 | :group 'ps-print-headers) |
bc0d41bd KH |
2242 | |
2243 | (defcustom ps-spool-tumble nil | |
2244 | "*Specify how the page images on opposite sides of a sheet are oriented. | |
2245 | If `ps-spool-tumble' is nil, produces output suitable for binding on the left or | |
2246 | right. If `ps-spool-tumble' is non-nil, produces output suitable for binding at | |
2247 | the top or bottom. | |
2248 | ||
2249 | It has effect only when `ps-spool-duplex' is non-nil." | |
e0af0d3e | 2250 | :type 'boolean |
6e1b1da6 | 2251 | :group 'ps-print-headers) |
bcc0d457 RS |
2252 | |
2253 | ;;; Fonts | |
2254 | ||
e0af0d3e | 2255 | (defcustom ps-font-info-database |
bcc0d457 | 2256 | '((Courier ; the family key |
12b88fff RS |
2257 | (fonts (normal . "Courier") |
2258 | (bold . "Courier-Bold") | |
2259 | (italic . "Courier-Oblique") | |
2260 | (bold-italic . "Courier-BoldOblique")) | |
2261 | (size . 10.0) | |
2262 | (line-height . 10.55) | |
2263 | (space-width . 6.0) | |
2264 | (avg-char-width . 6.0)) | |
bcc0d457 | 2265 | (Helvetica ; the family key |
12b88fff RS |
2266 | (fonts (normal . "Helvetica") |
2267 | (bold . "Helvetica-Bold") | |
2268 | (italic . "Helvetica-Oblique") | |
2269 | (bold-italic . "Helvetica-BoldOblique")) | |
2270 | (size . 10.0) | |
2271 | (line-height . 11.56) | |
2272 | (space-width . 2.78) | |
2273 | (avg-char-width . 5.09243)) | |
bcc0d457 | 2274 | (Times |
12b88fff RS |
2275 | (fonts (normal . "Times-Roman") |
2276 | (bold . "Times-Bold") | |
2277 | (italic . "Times-Italic") | |
2278 | (bold-italic . "Times-BoldItalic")) | |
2279 | (size . 10.0) | |
2280 | (line-height . 11.0) | |
2281 | (space-width . 2.5) | |
334cc3b7 | 2282 | (avg-char-width . 4.71432)) |
bcc0d457 | 2283 | (Palatino |
12b88fff RS |
2284 | (fonts (normal . "Palatino-Roman") |
2285 | (bold . "Palatino-Bold") | |
2286 | (italic . "Palatino-Italic") | |
2287 | (bold-italic . "Palatino-BoldItalic")) | |
2288 | (size . 10.0) | |
2289 | (line-height . 12.1) | |
2290 | (space-width . 2.5) | |
2291 | (avg-char-width . 5.08676)) | |
bcc0d457 | 2292 | (Helvetica-Narrow |
12b88fff RS |
2293 | (fonts (normal . "Helvetica-Narrow") |
2294 | (bold . "Helvetica-Narrow-Bold") | |
2295 | (italic . "Helvetica-Narrow-Oblique") | |
2296 | (bold-italic . "Helvetica-Narrow-BoldOblique")) | |
2297 | (size . 10.0) | |
2298 | (line-height . 11.56) | |
2299 | (space-width . 2.2796) | |
2300 | (avg-char-width . 4.17579)) | |
bcc0d457 | 2301 | (NewCenturySchlbk |
12b88fff RS |
2302 | (fonts (normal . "NewCenturySchlbk-Roman") |
2303 | (bold . "NewCenturySchlbk-Bold") | |
2304 | (italic . "NewCenturySchlbk-Italic") | |
2305 | (bold-italic . "NewCenturySchlbk-BoldItalic")) | |
2306 | (size . 10.0) | |
334cc3b7 | 2307 | (line-height . 12.15) |
12b88fff RS |
2308 | (space-width . 2.78) |
2309 | (avg-char-width . 5.31162)) | |
bcc0d457 RS |
2310 | ;; got no bold for the next ones |
2311 | (AvantGarde-Book | |
12b88fff RS |
2312 | (fonts (normal . "AvantGarde-Book") |
2313 | (italic . "AvantGarde-BookOblique")) | |
2314 | (size . 10.0) | |
2315 | (line-height . 11.77) | |
2316 | (space-width . 2.77) | |
2317 | (avg-char-width . 5.45189)) | |
bcc0d457 | 2318 | (AvantGarde-Demi |
12b88fff RS |
2319 | (fonts (normal . "AvantGarde-Demi") |
2320 | (italic . "AvantGarde-DemiOblique")) | |
2321 | (size . 10.0) | |
2322 | (line-height . 12.72) | |
2323 | (space-width . 2.8) | |
2324 | (avg-char-width . 5.51351)) | |
bcc0d457 | 2325 | (Bookman-Demi |
12b88fff RS |
2326 | (fonts (normal . "Bookman-Demi") |
2327 | (italic . "Bookman-DemiItalic")) | |
2328 | (size . 10.0) | |
2329 | (line-height . 11.77) | |
2330 | (space-width . 3.4) | |
2331 | (avg-char-width . 6.05946)) | |
bcc0d457 | 2332 | (Bookman-Light |
12b88fff RS |
2333 | (fonts (normal . "Bookman-Light") |
2334 | (italic . "Bookman-LightItalic")) | |
2335 | (size . 10.0) | |
2336 | (line-height . 11.79) | |
2337 | (space-width . 3.2) | |
2338 | (avg-char-width . 5.67027)) | |
bcc0d457 RS |
2339 | ;; got no bold and no italic for the next ones |
2340 | (Symbol | |
12b88fff RS |
2341 | (fonts (normal . "Symbol")) |
2342 | (size . 10.0) | |
2343 | (line-height . 13.03) | |
2344 | (space-width . 2.5) | |
2345 | (avg-char-width . 3.24324)) | |
bcc0d457 | 2346 | (Zapf-Dingbats |
12b88fff RS |
2347 | (fonts (normal . "Zapf-Dingbats")) |
2348 | (size . 10.0) | |
2349 | (line-height . 9.63) | |
2350 | (space-width . 2.78) | |
2351 | (avg-char-width . 2.78)) | |
bcc0d457 | 2352 | (Zapf-Chancery-MediumItalic |
12b88fff RS |
2353 | (fonts (normal . "Zapf-Chancery-MediumItalic")) |
2354 | (size . 10.0) | |
2355 | (line-height . 11.45) | |
2356 | (space-width . 2.2) | |
2357 | (avg-char-width . 4.10811)) | |
87a16a06 | 2358 | ) |
bcc0d457 RS |
2359 | "*Font info database: font family (the key), name, bold, italic, bold-italic, |
2360 | reference size, line height, space width, average character width. | |
2361 | To get the info for another specific font (say Helvetica), do the following: | |
2362 | - create a new buffer | |
2363 | - generate the PostScript image to a file (C-u M-x ps-print-buffer) | |
8bd22fcf | 2364 | - open this file and delete the leading `%' (which is the PostScript |
bcc0d457 | 2365 | comment character) from the line |
1fd9b7fe | 2366 | `% 3 cm 20 cm moveto 10/Courier ReportFontInfo showpage' |
bcc0d457 | 2367 | to get the line |
1fd9b7fe | 2368 | `3 cm 20 cm moveto 10/Helvetica ReportFontInfo showpage' |
bcc0d457 | 2369 | - add the values to `ps-font-info-database'. |
c3d6d211 GM |
2370 | You can get all the fonts of YOUR printer using `ReportAllFontInfo'. |
2371 | ||
2372 | Note also that ps-print DOESN'T download any font to your printer, instead | |
2373 | it uses the fonts resident in your printer." | |
e0af0d3e | 2374 | :type '(repeat (list :tag "Font Definition" |
12b88fff | 2375 | (symbol :tag "Font Family") |
334cc3b7 AS |
2376 | (cons :format "%v" |
2377 | (const :format "" fonts) | |
2378 | (repeat :tag "Faces" | |
2379 | (cons (choice (const normal) | |
12b88fff RS |
2380 | (const bold) |
2381 | (const italic) | |
2382 | (const bold-italic) | |
2383 | (symbol :tag "Face")) | |
2384 | (string :tag "Font Name")))) | |
334cc3b7 AS |
2385 | (cons :format "%v" |
2386 | (const :format "" size) | |
12b88fff | 2387 | (number :tag "Reference Size")) |
334cc3b7 AS |
2388 | (cons :format "%v" |
2389 | (const :format "" line-height) | |
12b88fff | 2390 | (number :tag "Line Height")) |
334cc3b7 AS |
2391 | (cons :format "%v" |
2392 | (const :format "" space-width) | |
12b88fff | 2393 | (number :tag "Space Width")) |
334cc3b7 AS |
2394 | (cons :format "%v" |
2395 | (const :format "" avg-char-width) | |
12b88fff | 2396 | (number :tag "Average Character Width")))) |
e0af0d3e RS |
2397 | :group 'ps-print-font) |
2398 | ||
2399 | (defcustom ps-font-family 'Courier | |
d3ab8dac | 2400 | "*Font family name for ordinary text, when generating PostScript." |
e0af0d3e RS |
2401 | :type 'symbol |
2402 | :group 'ps-print-font) | |
2403 | ||
7d8b7e8e | 2404 | (defcustom ps-font-size '(7 . 8.5) |
d3ab8dac | 2405 | "*Font size, in points, for ordinary text, when generating PostScript." |
7d8b7e8e KH |
2406 | :type '(choice (number :tag "Text Size") |
2407 | (cons :tag "Landscape/Portrait" | |
2408 | (number :tag "Landscape Text Size") | |
2409 | (number :tag "Portrait Text Size"))) | |
e0af0d3e RS |
2410 | :group 'ps-print-font) |
2411 | ||
2412 | (defcustom ps-header-font-family 'Helvetica | |
d3ab8dac | 2413 | "*Font family name for text in the header, when generating PostScript." |
e0af0d3e RS |
2414 | :type 'symbol |
2415 | :group 'ps-print-font) | |
2416 | ||
7d8b7e8e | 2417 | (defcustom ps-header-font-size '(10 . 12) |
d3ab8dac | 2418 | "*Font size, in points, for text in the header, when generating PostScript." |
7d8b7e8e KH |
2419 | :type '(choice (number :tag "Header Size") |
2420 | (cons :tag "Landscape/Portrait" | |
2421 | (number :tag "Landscape Header Size") | |
2422 | (number :tag "Portrait Header Size"))) | |
e0af0d3e RS |
2423 | :group 'ps-print-font) |
2424 | ||
7d8b7e8e | 2425 | (defcustom ps-header-title-font-size '(12 . 14) |
d3ab8dac | 2426 | "*Font size, in points, for the top line of text in header, in PostScript." |
7d8b7e8e KH |
2427 | :type '(choice (number :tag "Header Title Size") |
2428 | (cons :tag "Landscape/Portrait" | |
2429 | (number :tag "Landscape Header Title Size") | |
2430 | (number :tag "Portrait Header Title Size"))) | |
e0af0d3e | 2431 | :group 'ps-print-font) |
bcc0d457 RS |
2432 | |
2433 | ;;; Colors | |
2434 | ||
87a16a06 | 2435 | ;; Printing color requires x-color-values. |
ea0c615d GM |
2436 | (defcustom ps-print-color-p |
2437 | (or (and (fboundp 'color-values) ; Emacs | |
2438 | (ps-e-color-values "Green")) | |
2439 | (fboundp 'x-color-values) ; Emacs | |
2440 | (fboundp 'color-instance-rgb-components)) | |
857686a6 | 2441 | ; XEmacs |
bc0d41bd | 2442 | "*Non-nil means print the buffer's text in color." |
e0af0d3e RS |
2443 | :type 'boolean |
2444 | :group 'ps-print-color) | |
12d89a2e | 2445 | |
e0af0d3e RS |
2446 | (defcustom ps-default-fg '(0.0 0.0 0.0) |
2447 | "*RGB values of the default foreground color. Defaults to black." | |
8e234846 GM |
2448 | :type '(choice :menu-tag "Default Foreground Gray/Color" |
2449 | :tag "Default Foreground Gray/Color" | |
6e1b1da6 GM |
2450 | (number :tag "Gray Scale" :value 0.0) |
2451 | (string :tag "Color Name" :value "black") | |
2452 | (list :tag "RGB Color" :value (0.0 0.0 0.0) | |
2453 | (number :tag "Red") | |
2454 | (number :tag "Green") | |
2455 | (number :tag "Blue"))) | |
e0af0d3e | 2456 | :group 'ps-print-color) |
12d89a2e | 2457 | |
e0af0d3e RS |
2458 | (defcustom ps-default-bg '(1.0 1.0 1.0) |
2459 | "*RGB values of the default background color. Defaults to white." | |
8e234846 GM |
2460 | :type '(choice :menu-tag "Default Background Gray/Color" |
2461 | :tag "Default Background Gray/Color" | |
6e1b1da6 GM |
2462 | (number :tag "Gray Scale" :value 1.0) |
2463 | (string :tag "Color Name" :value "white") | |
2464 | (list :tag "RGB Color" :value (1.0 1.0 1.0) | |
2465 | (number :tag "Red") | |
2466 | (number :tag "Green") | |
2467 | (number :tag "Blue"))) | |
e0af0d3e | 2468 | :group 'ps-print-color) |
12d89a2e | 2469 | |
e0af0d3e | 2470 | (defcustom ps-auto-font-detect t |
df5e6194 | 2471 | "*Non-nil means automatically detect bold/italic/underline face attributes. |
7f72c06f | 2472 | If nil, we rely solely on the lists `ps-bold-faces', `ps-italic-faces', |
e0af0d3e RS |
2473 | and `ps-underlined-faces'." |
2474 | :type 'boolean | |
2475 | :group 'ps-print-font) | |
12d89a2e | 2476 | |
e0af0d3e | 2477 | (defcustom ps-bold-faces |
090be653 RS |
2478 | (unless ps-print-color-p |
2479 | '(font-lock-function-name-face | |
2480 | font-lock-builtin-face | |
2481 | font-lock-variable-name-face | |
2482 | font-lock-keyword-face | |
2483 | font-lock-warning-face)) | |
86c10ecb | 2484 | "*A list of the \(non-bold\) faces that should be printed in bold font. |
8bd22fcf | 2485 | This applies to generating PostScript." |
e0af0d3e RS |
2486 | :type '(repeat face) |
2487 | :group 'ps-print-face) | |
12d89a2e | 2488 | |
e0af0d3e | 2489 | (defcustom ps-italic-faces |
090be653 RS |
2490 | (unless ps-print-color-p |
2491 | '(font-lock-variable-name-face | |
8bd22fcf | 2492 | font-lock-type-face |
090be653 RS |
2493 | font-lock-string-face |
2494 | font-lock-comment-face | |
2495 | font-lock-warning-face)) | |
86c10ecb | 2496 | "*A list of the \(non-italic\) faces that should be printed in italic font. |
8bd22fcf | 2497 | This applies to generating PostScript." |
e0af0d3e RS |
2498 | :type '(repeat face) |
2499 | :group 'ps-print-face) | |
12d89a2e | 2500 | |
e0af0d3e | 2501 | (defcustom ps-underlined-faces |
090be653 RS |
2502 | (unless ps-print-color-p |
2503 | '(font-lock-function-name-face | |
883212ce | 2504 | font-lock-constant-face |
090be653 | 2505 | font-lock-warning-face)) |
86c10ecb | 2506 | "*A list of the \(non-underlined\) faces that should be printed underlined. |
8bd22fcf | 2507 | This applies to generating PostScript." |
e0af0d3e RS |
2508 | :type '(repeat face) |
2509 | :group 'ps-print-face) | |
12d89a2e | 2510 | |
906d41a7 GM |
2511 | (defcustom ps-use-face-background nil |
2512 | "*Specify if face background should be used. | |
2513 | ||
2514 | Valid values are: | |
2515 | ||
2516 | t always use face background color. | |
2517 | nil never use face background color. | |
2518 | (face...) list of faces whose background color will be used. | |
2519 | ||
2520 | Any other value will be treated as t." | |
8e234846 GM |
2521 | :type '(choice :menu-tag "Use Face Background" |
2522 | :tag "Use Face Background" | |
906d41a7 GM |
2523 | (const :tag "Always Use Face Background" t) |
2524 | (const :tag "Never Use Face Background" nil) | |
2525 | (repeat :menu-tag "Face Background List" | |
2526 | :tag "Face Background List" | |
2527 | face)) | |
2528 | :group 'ps-print-face) | |
2529 | ||
e0af0d3e | 2530 | (defcustom ps-left-header |
12d89a2e | 2531 | (list 'ps-get-buffer-name 'ps-header-dirpart) |
bcc0d457 | 2532 | "*The items to display (each on a line) on the left part of the page header. |
8bd22fcf | 2533 | This applies to generating PostScript. |
12d89a2e | 2534 | |
86c10ecb | 2535 | The value should be a list of strings and symbols, each representing an |
12d89a2e RS |
2536 | entry in the PostScript array HeaderLinesLeft. |
2537 | ||
2538 | Strings are inserted unchanged into the array; those representing | |
2539 | PostScript string literals should be delimited with PostScript string | |
2540 | delimiters '(' and ')'. | |
2541 | ||
2542 | For symbols with bound functions, the function is called and should | |
2543 | return a string to be inserted into the array. For symbols with bound | |
2544 | values, the value should be a string to be inserted into the array. | |
2545 | In either case, function or variable, the string value has PostScript | |
e0af0d3e RS |
2546 | string delimiters added to it." |
2547 | :type '(repeat (choice string symbol)) | |
6e1b1da6 | 2548 | :group 'ps-print-headers) |
12d89a2e | 2549 | |
e0af0d3e | 2550 | (defcustom ps-right-header |
090be653 | 2551 | (list "/pagenumberstring load" 'time-stamp-mon-dd-yyyy 'time-stamp-hh:mm:ss) |
bcc0d457 | 2552 | "*The items to display (each on a line) on the right part of the page header. |
8bd22fcf | 2553 | This applies to generating PostScript. |
12d89a2e | 2554 | |
86c10ecb | 2555 | See the variable `ps-left-header' for a description of the format of |
e0af0d3e RS |
2556 | this variable." |
2557 | :type '(repeat (choice string symbol)) | |
6e1b1da6 | 2558 | :group 'ps-print-headers) |
ef2cbb24 | 2559 | |
e0af0d3e RS |
2560 | (defcustom ps-razzle-dazzle t |
2561 | "*Non-nil means report progress while formatting buffer." | |
2562 | :type 'boolean | |
6e1b1da6 | 2563 | :group 'ps-print-miscellany) |
12d89a2e | 2564 | |
a18ed129 | 2565 | (defcustom ps-adobe-tag "%!PS-Adobe-3.0\n" |
12d89a2e RS |
2566 | "*Contains the header line identifying the output as PostScript. |
2567 | By default, `ps-adobe-tag' contains the standard identifier. Some | |
a18ed129 RS |
2568 | printers require slightly different versions of this line." |
2569 | :type 'string | |
6e1b1da6 | 2570 | :group 'ps-print-miscellany) |
12d89a2e | 2571 | |
e0af0d3e | 2572 | (defcustom ps-build-face-reference t |
12d89a2e RS |
2573 | "*Non-nil means build the reference face lists. |
2574 | ||
d3ab8dac | 2575 | ps-print sets this value to nil after it builds its internal reference |
12d89a2e RS |
2576 | lists of bold and italic faces. By settings its value back to t, you |
2577 | can force ps-print to rebuild the lists the next time you invoke one | |
86c10ecb | 2578 | of the ...-with-faces commands. |
12d89a2e RS |
2579 | |
2580 | You should set this value back to t after you change the attributes of | |
2581 | any face, or create new faces. Most users shouldn't have to worry | |
e0af0d3e RS |
2582 | about its setting, though." |
2583 | :type 'boolean | |
2584 | :group 'ps-print-face) | |
12d89a2e | 2585 | |
e0af0d3e | 2586 | (defcustom ps-always-build-face-reference nil |
12d89a2e RS |
2587 | "*Non-nil means always rebuild the reference face lists. |
2588 | ||
2589 | If this variable is non-nil, ps-print will rebuild its internal | |
2590 | reference lists of bold and italic faces *every* time one of the | |
496725ad | 2591 | ...-with-faces commands is called. Most users shouldn't need to set this |
e0af0d3e RS |
2592 | variable." |
2593 | :type 'boolean | |
2594 | :group 'ps-print-face) | |
ef2cbb24 | 2595 | |
bc0d41bd KH |
2596 | (defcustom ps-banner-page-when-duplexing nil |
2597 | "*Non-nil means the very first page is skipped. | |
2598 | It's like the very first character of buffer (or region) is ^L (\\014)." | |
2599 | :type 'boolean | |
6e1b1da6 | 2600 | :group 'ps-print-headers) |
bc0d41bd | 2601 | |
98f2fbe7 GM |
2602 | (defcustom ps-postscript-code-directory |
2603 | (or (and (fboundp 'locate-data-directory) ; xemacs | |
8e234846 | 2604 | (locate-data-directory "ps-print")) |
98f2fbe7 | 2605 | data-directory) ; emacs |
41481e4b KH |
2606 | "*Directory where it's located the PostScript prologue file used by ps-print. |
2607 | By default, this directory is the same as in the variable `data-directory'." | |
2608 | :type 'directory | |
6e1b1da6 | 2609 | :group 'ps-print-miscellany) |
41481e4b | 2610 | |
0a5daee5 | 2611 | |
1fd9b7fe GM |
2612 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2613 | ;; Selected Pages | |
2614 | ||
2615 | ||
2616 | (defvar ps-last-selected-pages nil | |
2617 | "Latest `ps-selected-pages' value.") | |
2618 | ||
2619 | ||
2620 | (defun ps-restore-selected-pages () | |
2621 | "Restore latest `ps-selected-pages' value." | |
2622 | (interactive) | |
2623 | (setq ps-selected-pages ps-last-selected-pages)) | |
2624 | ||
2625 | ||
0a5daee5 KH |
2626 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2627 | ;; Customization | |
2628 | ||
2629 | ||
2630 | ;;;###autoload | |
2631 | (defun ps-print-customize () | |
2632 | "Customization of ps-print group." | |
2633 | (interactive) | |
2634 | (customize-group 'ps-print)) | |
2635 | ||
2636 | ||
ef2cbb24 | 2637 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12d89a2e | 2638 | ;; User commands |
ef2cbb24 | 2639 | |
0a5daee5 | 2640 | |
00aa16af | 2641 | ;;;###autoload |
ef2cbb24 | 2642 | (defun ps-print-buffer (&optional filename) |
12d89a2e | 2643 | "Generate and print a PostScript image of the buffer. |
ef2cbb24 | 2644 | |
5ac0cb14 RS |
2645 | Interactively, when you use a prefix argument (C-u), the command |
2646 | prompts the user for a file name, and saves the PostScript image | |
2647 | in that file instead of sending it to the printer. | |
ef2cbb24 | 2648 | |
5ac0cb14 | 2649 | Noninteractively, the argument FILENAME is treated as follows: if it |
ef2cbb24 | 2650 | is nil, send the image to the printer. If FILENAME is a string, save |
79080fa0 | 2651 | the PostScript image in a file with that name." |
00aa16af | 2652 | (interactive (list (ps-print-preprint current-prefix-arg))) |
87a16a06 | 2653 | (ps-print-without-faces (point-min) (point-max) filename)) |
ef2cbb24 RS |
2654 | |
2655 | ||
00aa16af | 2656 | ;;;###autoload |
ef2cbb24 | 2657 | (defun ps-print-buffer-with-faces (&optional filename) |
12d89a2e | 2658 | "Generate and print a PostScript image of the buffer. |
12d89a2e | 2659 | Like `ps-print-buffer', but includes font, color, and underline |
107e7c70 KH |
2660 | information in the generated image. This command works only if you |
2661 | are using a window system, so it has a way to determine color values." | |
00aa16af | 2662 | (interactive (list (ps-print-preprint current-prefix-arg))) |
87a16a06 | 2663 | (ps-print-with-faces (point-min) (point-max) filename)) |
ef2cbb24 | 2664 | |
ef2cbb24 | 2665 | |
00aa16af | 2666 | ;;;###autoload |
ef2cbb24 | 2667 | (defun ps-print-region (from to &optional filename) |
12d89a2e | 2668 | "Generate and print a PostScript image of the region. |
12d89a2e | 2669 | Like `ps-print-buffer', but prints just the current region." |
00aa16af | 2670 | (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg))) |
a18ed129 | 2671 | (ps-print-without-faces from to filename t)) |
ef2cbb24 | 2672 | |
ef2cbb24 | 2673 | |
00aa16af | 2674 | ;;;###autoload |
ef2cbb24 | 2675 | (defun ps-print-region-with-faces (from to &optional filename) |
12d89a2e | 2676 | "Generate and print a PostScript image of the region. |
12d89a2e | 2677 | Like `ps-print-region', but includes font, color, and underline |
107e7c70 KH |
2678 | information in the generated image. This command works only if you |
2679 | are using a window system, so it has a way to determine color values." | |
00aa16af | 2680 | (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg))) |
a18ed129 | 2681 | (ps-print-with-faces from to filename t)) |
ef2cbb24 | 2682 | |
ef2cbb24 | 2683 | |
00aa16af | 2684 | ;;;###autoload |
ef2cbb24 | 2685 | (defun ps-spool-buffer () |
12d89a2e | 2686 | "Generate and spool a PostScript image of the buffer. |
12d89a2e RS |
2687 | Like `ps-print-buffer' except that the PostScript image is saved in a |
2688 | local buffer to be sent to the printer later. | |
ef2cbb24 | 2689 | |
12d89a2e | 2690 | Use the command `ps-despool' to send the spooled images to the printer." |
ef2cbb24 | 2691 | (interactive) |
87a16a06 | 2692 | (ps-spool-without-faces (point-min) (point-max))) |
ef2cbb24 | 2693 | |
ef2cbb24 | 2694 | |
00aa16af | 2695 | ;;;###autoload |
ef2cbb24 | 2696 | (defun ps-spool-buffer-with-faces () |
12d89a2e | 2697 | "Generate and spool a PostScript image of the buffer. |
12d89a2e | 2698 | Like `ps-spool-buffer', but includes font, color, and underline |
107e7c70 | 2699 | information in the generated image. This command works only if you |
1cd7962f | 2700 | are using a window system, so it has a way to determine color values. |
ef2cbb24 | 2701 | |
12d89a2e | 2702 | Use the command `ps-despool' to send the spooled images to the printer." |
ef2cbb24 | 2703 | (interactive) |
87a16a06 | 2704 | (ps-spool-with-faces (point-min) (point-max))) |
ef2cbb24 | 2705 | |
ef2cbb24 | 2706 | |
00aa16af | 2707 | ;;;###autoload |
ef2cbb24 | 2708 | (defun ps-spool-region (from to) |
12d89a2e | 2709 | "Generate a PostScript image of the region and spool locally. |
12d89a2e | 2710 | Like `ps-spool-buffer', but spools just the current region. |
ef2cbb24 | 2711 | |
12d89a2e | 2712 | Use the command `ps-despool' to send the spooled images to the printer." |
ef2cbb24 | 2713 | (interactive "r") |
a18ed129 | 2714 | (ps-spool-without-faces from to t)) |
ef2cbb24 | 2715 | |
ef2cbb24 | 2716 | |
00aa16af | 2717 | ;;;###autoload |
ef2cbb24 | 2718 | (defun ps-spool-region-with-faces (from to) |
12d89a2e | 2719 | "Generate a PostScript image of the region and spool locally. |
12d89a2e | 2720 | Like `ps-spool-region', but includes font, color, and underline |
107e7c70 | 2721 | information in the generated image. This command works only if you |
1cd7962f | 2722 | are using a window system, so it has a way to determine color values. |
ef2cbb24 | 2723 | |
12d89a2e | 2724 | Use the command `ps-despool' to send the spooled images to the printer." |
ef2cbb24 | 2725 | (interactive "r") |
a18ed129 | 2726 | (ps-spool-with-faces from to t)) |
ef2cbb24 | 2727 | |
00aa16af | 2728 | ;;;###autoload |
ef2cbb24 RS |
2729 | (defun ps-despool (&optional filename) |
2730 | "Send the spooled PostScript to the printer. | |
2731 | ||
79080fa0 RS |
2732 | Interactively, when you use a prefix argument (C-u), the command |
2733 | prompts the user for a file name, and saves the spooled PostScript | |
2734 | image in that file instead of sending it to the printer. | |
ef2cbb24 | 2735 | |
298bfad9 | 2736 | Noninteractively, the argument FILENAME is treated as follows: if it |
ef2cbb24 | 2737 | is nil, send the image to the printer. If FILENAME is a string, save |
79080fa0 | 2738 | the PostScript image in a file with that name." |
00aa16af RS |
2739 | (interactive (list (ps-print-preprint current-prefix-arg))) |
2740 | (ps-do-despool filename)) | |
12d89a2e | 2741 | |
bcc0d457 RS |
2742 | ;;;###autoload |
2743 | (defun ps-line-lengths () | |
06fb6aab | 2744 | "Display the correspondence between a line length and a font size, |
bcc0d457 RS |
2745 | using the current ps-print setup. |
2746 | Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head" | |
2747 | (interactive) | |
2748 | (ps-line-lengths-internal)) | |
2749 | ||
2750 | ;;;###autoload | |
2751 | (defun ps-nb-pages-buffer (nb-lines) | |
06fb6aab RS |
2752 | "Display number of pages to print this buffer, for various font heights. |
2753 | The table depends on the current ps-print setup." | |
bcc0d457 RS |
2754 | (interactive (list (count-lines (point-min) (point-max)))) |
2755 | (ps-nb-pages nb-lines)) | |
2756 | ||
2757 | ;;;###autoload | |
2758 | (defun ps-nb-pages-region (nb-lines) | |
06fb6aab RS |
2759 | "Display number of pages to print the region, for various font heights. |
2760 | The table depends on the current ps-print setup." | |
bcc0d457 RS |
2761 | (interactive (list (count-lines (mark) (point)))) |
2762 | (ps-nb-pages nb-lines)) | |
2763 | ||
2764 | ;;;###autoload | |
2765 | (defun ps-setup () | |
496725ad | 2766 | "Return the current PostScript-generation setup." |
a18ed129 RS |
2767 | (format |
2768 | " | |
8e234846 | 2769 | ;;; ps-print version %s |
1fd9b7fe | 2770 | |
bc0d41bd KH |
2771 | \(setq ps-print-color-p %s |
2772 | ps-lpr-command %S | |
2773 | ps-lpr-switches %s | |
3556c6dd GM |
2774 | ps-printer-name %s |
2775 | ps-printer-name-option %s | |
bc0d41bd | 2776 | ps-print-region-function %s |
8e234846 | 2777 | ps-manual-feed %S |
bcc0d457 | 2778 | |
7d8b7e8e | 2779 | ps-paper-type %s |
8e234846 | 2780 | ps-warn-paper-type %s |
8bd22fcf | 2781 | ps-landscape-mode %s |
906d41a7 | 2782 | ps-print-upside-down %s |
8bd22fcf | 2783 | ps-number-of-columns %s |
bcc0d457 | 2784 | |
8bd22fcf | 2785 | ps-zebra-stripes %s |
01961237 | 2786 | ps-zebra-stripe-height %s |
8e234846 | 2787 | ps-zebra-stripe-follow %S |
6e1b1da6 | 2788 | ps-zebra-color %s |
8bd22fcf | 2789 | ps-line-number %s |
906d41a7 | 2790 | ps-line-number-step %s |
98f2fbe7 | 2791 | ps-line-number-start %S |
a18ed129 | 2792 | |
6e1b1da6 GM |
2793 | ps-default-fg %s |
2794 | ps-default-bg %s | |
2795 | ||
906d41a7 GM |
2796 | ps-use-face-background %s |
2797 | ||
7d8b7e8e | 2798 | ps-print-control-characters %s |
d3ab8dac | 2799 | |
7d8b7e8e | 2800 | ps-print-background-image %s |
857686a6 | 2801 | |
7d8b7e8e | 2802 | ps-print-background-text %s |
a18ed129 | 2803 | |
66e63857 GM |
2804 | ps-error-handler-message %s |
2805 | ps-user-defined-prologue %s | |
7d8b7e8e | 2806 | ps-print-prologue-header %s |
a18ed129 | 2807 | |
bc0d41bd KH |
2808 | ps-left-margin %s |
2809 | ps-right-margin %s | |
2810 | ps-inter-column %s | |
2811 | ps-bottom-margin %s | |
2812 | ps-top-margin %s | |
2813 | ps-header-offset %s | |
2814 | ps-header-line-pad %s | |
2815 | ps-print-header %s | |
2816 | ps-print-only-one-header %s | |
2817 | ps-print-header-frame %s | |
8e234846 | 2818 | ps-switch-header %s |
bc0d41bd KH |
2819 | ps-header-lines %s |
2820 | ps-show-n-of-n %s | |
2821 | ps-spool-config %s | |
2822 | ps-spool-duplex %s | |
2823 | ps-spool-tumble %s | |
2824 | ps-banner-page-when-duplexing %s | |
2825 | ||
8e234846 GM |
2826 | ps-n-up-printing %s |
2827 | ps-n-up-margin %s | |
2828 | ps-n-up-border-p %s | |
2829 | ps-n-up-filling %s | |
bcc0d457 | 2830 | |
7d8b7e8e KH |
2831 | ps-multibyte-buffer %s |
2832 | ps-font-family %s | |
a18ed129 | 2833 | ps-font-size %s |
7d8b7e8e | 2834 | ps-header-font-family %s |
a18ed129 | 2835 | ps-header-font-size %s |
1fd9b7fe GM |
2836 | ps-header-title-font-size %s |
2837 | ||
c3d6d211 | 2838 | ps-even-or-odd-pages %s |
1fd9b7fe GM |
2839 | ps-selected-pages %s |
2840 | ps-last-selected-pages %s) | |
2841 | ||
2842 | ;;; ps-print - end of settings | |
bcc0d457 | 2843 | " |
8e234846 | 2844 | ps-print-version |
a18ed129 RS |
2845 | ps-print-color-p |
2846 | ps-lpr-command | |
d3ab8dac | 2847 | (ps-print-quote ps-lpr-switches) |
3556c6dd GM |
2848 | (ps-print-quote ps-printer-name) |
2849 | (ps-print-quote ps-printer-name-option) | |
bc0d41bd | 2850 | (ps-print-quote ps-print-region-function) |
8e234846 | 2851 | ps-manual-feed |
d3ab8dac | 2852 | (ps-print-quote ps-paper-type) |
8e234846 | 2853 | ps-warn-paper-type |
a18ed129 | 2854 | ps-landscape-mode |
906d41a7 | 2855 | ps-print-upside-down |
a18ed129 | 2856 | ps-number-of-columns |
01961237 RS |
2857 | ps-zebra-stripes |
2858 | ps-zebra-stripe-height | |
8e234846 | 2859 | ps-zebra-stripe-follow |
6e1b1da6 | 2860 | (ps-print-quote ps-zebra-color) |
a18ed129 | 2861 | ps-line-number |
906d41a7 | 2862 | (ps-print-quote ps-line-number-step) |
98f2fbe7 | 2863 | ps-line-number-start |
6e1b1da6 GM |
2864 | (ps-print-quote ps-default-fg) |
2865 | (ps-print-quote ps-default-bg) | |
906d41a7 | 2866 | (ps-print-quote ps-use-face-background) |
d3ab8dac KH |
2867 | (ps-print-quote ps-print-control-characters) |
2868 | (ps-print-quote ps-print-background-image) | |
2869 | (ps-print-quote ps-print-background-text) | |
66e63857 GM |
2870 | (ps-print-quote ps-error-handler-message) |
2871 | (ps-print-quote ps-user-defined-prologue) | |
d3ab8dac | 2872 | (ps-print-quote ps-print-prologue-header) |
a18ed129 RS |
2873 | ps-left-margin |
2874 | ps-right-margin | |
2875 | ps-inter-column | |
2876 | ps-bottom-margin | |
2877 | ps-top-margin | |
2878 | ps-header-offset | |
2879 | ps-header-line-pad | |
2880 | ps-print-header | |
d3ab8dac | 2881 | ps-print-only-one-header |
a18ed129 | 2882 | ps-print-header-frame |
8e234846 | 2883 | (ps-print-quote ps-switch-header) |
a18ed129 RS |
2884 | ps-header-lines |
2885 | ps-show-n-of-n | |
bc0d41bd | 2886 | (ps-print-quote ps-spool-config) |
a18ed129 | 2887 | ps-spool-duplex |
bc0d41bd KH |
2888 | ps-spool-tumble |
2889 | ps-banner-page-when-duplexing | |
2890 | ps-n-up-printing | |
2891 | ps-n-up-margin | |
2892 | ps-n-up-border-p | |
2893 | (ps-print-quote ps-n-up-filling) | |
0a5daee5 | 2894 | (ps-print-quote ps-multibyte-buffer) ; see `ps-mule.el' |
d3ab8dac | 2895 | (ps-print-quote ps-font-family) |
7d8b7e8e | 2896 | (ps-print-quote ps-font-size) |
d3ab8dac | 2897 | (ps-print-quote ps-header-font-family) |
7d8b7e8e | 2898 | (ps-print-quote ps-header-font-size) |
1fd9b7fe | 2899 | (ps-print-quote ps-header-title-font-size) |
c3d6d211 | 2900 | (ps-print-quote ps-even-or-odd-pages) |
1fd9b7fe GM |
2901 | (ps-print-quote ps-selected-pages) |
2902 | (ps-print-quote ps-last-selected-pages))) | |
bcc0d457 | 2903 | |
0a5daee5 | 2904 | |
12d89a2e RS |
2905 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2906 | ;; Utility functions and variables: | |
2907 | ||
0a5daee5 | 2908 | |
d3ab8dac | 2909 | (defun ps-print-quote (sym) |
7d8b7e8e KH |
2910 | (cond ((null sym) |
2911 | nil) | |
2912 | ((or (symbolp sym) (listp sym)) | |
2913 | (format "'%S" sym)) | |
2914 | ((stringp sym) | |
2915 | (format "%S" sym)) | |
2916 | (t | |
d3ab8dac KH |
2917 | sym))) |
2918 | ||
3e9cb08f | 2919 | |
877cf6b4 GM |
2920 | (eval-and-compile |
2921 | (defvar ps-print-emacs-type | |
2922 | (cond ((string-match "XEmacs" emacs-version) 'xemacs) | |
2923 | ((string-match "Lucid" emacs-version) 'lucid) | |
2924 | ((string-match "Epoch" emacs-version) 'epoch) | |
2925 | (t 'emacs))) | |
2926 | ||
2927 | (if (memq ps-print-emacs-type '(lucid xemacs)) | |
2928 | (if (< emacs-minor-version 12) | |
2929 | (setq ps-print-color-p nil)) | |
2930 | (require 'faces)) ; face-font, face-underline-p, | |
12d89a2e RS |
2931 | ; x-font-regexp |
2932 | ||
3e9cb08f GM |
2933 | ;; Return t if the device (which can be changed during an emacs session) |
2934 | ;; can handle colors. | |
ea0c615d | 2935 | ;; This function is not yet implemented for GNU emacs. |
3e9cb08f GM |
2936 | (cond ((and (eq ps-print-emacs-type 'xemacs) |
2937 | (>= emacs-minor-version 12)) ; xemacs | |
2938 | (defun ps-color-device () | |
ea0c615d | 2939 | (eq (ps-x-device-class) 'color))) |
3e9cb08f GM |
2940 | |
2941 | (t ; emacs | |
2942 | (defun ps-color-device () | |
ea0c615d GM |
2943 | (if (fboundp 'color-values) |
2944 | (ps-e-color-values "Green") | |
2945 | t)))) | |
2946 | ||
3e9cb08f | 2947 | |
47b54c71 GM |
2948 | (defun ps-mapper (extent list) |
2949 | (nconc list | |
2950 | (list (list (ps-x-extent-start-position extent) 'push extent) | |
2951 | (list (ps-x-extent-end-position extent) 'pull extent))) | |
2952 | nil) | |
2953 | ||
2954 | (defun ps-extent-sorter (a b) | |
2955 | (< (ps-x-extent-priority a) (ps-x-extent-priority b))) | |
2956 | ||
2957 | (defun ps-xemacs-face-kind-p (face kind kind-regex) | |
2958 | (let* ((frame-font (or (ps-x-face-font-instance face) | |
2959 | (ps-x-face-font-instance 'default))) | |
2960 | (kind-cons | |
2961 | (and frame-font | |
2962 | (assq kind | |
2963 | (ps-x-font-instance-properties frame-font)))) | |
2964 | (kind-spec (cdr-safe kind-cons)) | |
2965 | (case-fold-search t)) | |
2966 | (and kind-spec (string-match kind-regex kind-spec)))) | |
2967 | ||
2968 | (defun ps-xemacs-color-name (color) | |
2969 | (if (ps-x-color-specifier-p color) | |
2970 | (ps-x-color-name color) | |
2971 | color)) | |
2972 | ||
3e9cb08f GM |
2973 | (cond ((eq ps-print-emacs-type 'emacs) ; emacs |
2974 | ||
2975 | (defun ps-color-values (x-color) | |
ea0c615d GM |
2976 | (cond |
2977 | ((fboundp 'color-values) | |
2978 | (ps-e-color-values x-color)) | |
2979 | ((fboundp 'x-color-values) | |
2980 | (ps-e-x-color-values x-color)) | |
2981 | (t | |
2982 | (error "No available function to determine X color values.")))) | |
3e9cb08f GM |
2983 | |
2984 | (defalias 'ps-face-foreground-name 'face-foreground) | |
2985 | (defalias 'ps-face-background-name 'face-background) | |
2986 | ||
2987 | (defun ps-face-bold-p (face) | |
2988 | (or (face-bold-p face) | |
2989 | (memq face ps-bold-faces))) | |
2990 | ||
2991 | (defun ps-face-italic-p (face) | |
2992 | (or (face-italic-p face) | |
2993 | (memq face ps-italic-faces))) | |
2994 | ) | |
2995 | ; xemacs | |
2996 | ; lucid | |
2997 | (t ; epoch | |
2998 | ||
2999 | (or (ps-x-find-coding-system 'raw-text-unix) | |
3000 | (ps-x-copy-coding-system 'no-conversion-unix 'raw-text-unix)) | |
3001 | ||
3e9cb08f GM |
3002 | (defun ps-color-values (x-color) |
3003 | (let ((color (ps-xemacs-color-name x-color))) | |
3004 | (cond | |
3005 | ((fboundp 'x-color-values) | |
ea0c615d | 3006 | (ps-e-x-color-values color)) |
3e9cb08f GM |
3007 | ((and (fboundp 'color-instance-rgb-components) |
3008 | (ps-color-device)) | |
3009 | (ps-x-color-instance-rgb-components | |
3010 | (if (ps-x-color-instance-p x-color) | |
3011 | x-color | |
3012 | (ps-x-make-color-instance color)))) | |
3013 | (t | |
3014 | (error "No available function to determine X color values."))))) | |
3015 | ||
3016 | (defun ps-face-foreground-name (face) | |
3017 | (ps-xemacs-color-name (face-foreground face))) | |
3018 | ||
3019 | (defun ps-face-background-name (face) | |
3020 | (ps-xemacs-color-name (face-background face))) | |
3021 | ||
3022 | (defun ps-face-bold-p (face) | |
3023 | (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold") | |
3024 | (memq face ps-bold-faces))) ; Kludge-compatible | |
3025 | ||
3026 | (defun ps-face-italic-p (face) | |
3027 | (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o") | |
3028 | (ps-xemacs-face-kind-p face 'SLANT "i\\|o") | |
3029 | (memq face ps-italic-faces))) ; Kludge-compatible | |
3030 | ))) | |
3031 | ||
3032 | ||
ea0c615d | 3033 | (defvar ps-print-color-scale 1.0) |
47b54c71 | 3034 | |
3e9cb08f GM |
3035 | (defun ps-color-scale (color) |
3036 | ;; Scale 16-bit X-COLOR-VALUE to PostScript color value in [0, 1] interval. | |
3037 | (mapcar #'(lambda (value) (/ value ps-print-color-scale)) | |
3038 | (ps-color-values color))) | |
3039 | ||
3040 | ||
3041 | (defun ps-face-underlined-p (face) | |
3042 | (or (face-underline-p face) | |
3043 | (memq face ps-underlined-faces))) | |
e65df0a1 | 3044 | |
857686a6 | 3045 | |
12d89a2e RS |
3046 | (require 'time-stamp) |
3047 | ||
bcc0d457 | 3048 | |
41481e4b KH |
3049 | (defun ps-prologue-file (filenumber) |
3050 | (save-excursion | |
906d41a7 GM |
3051 | (let* ((filename (format "%sps-prin%d.ps" |
3052 | ps-postscript-code-directory filenumber)) | |
3053 | (buffer | |
3054 | (or (find-file-noselect filename 'no-warn 'rawfile) | |
3055 | (error "ps-print PostScript prologue `%s' file was not found." | |
3056 | filename)))) | |
41481e4b KH |
3057 | (set-buffer buffer) |
3058 | (prog1 | |
3059 | (buffer-string) | |
3060 | (kill-buffer buffer))))) | |
bcc0d457 | 3061 | |
bcc0d457 | 3062 | |
41481e4b | 3063 | (defvar ps-mark-code-directory nil) |
bcc0d457 | 3064 | |
66e63857 GM |
3065 | (defvar ps-print-prologue-0 "" |
3066 | "ps-print PostScript error handler.") | |
3067 | ||
41481e4b KH |
3068 | (defvar ps-print-prologue-1 "" |
3069 | "ps-print PostScript prologue begin.") | |
bcc0d457 | 3070 | |
41481e4b KH |
3071 | (defvar ps-print-prologue-2 "" |
3072 | "ps-print PostScript prologue end.") | |
12d89a2e RS |
3073 | |
3074 | ;; Start Editing Here: | |
ef2cbb24 | 3075 | |
12d89a2e RS |
3076 | (defvar ps-source-buffer nil) |
3077 | (defvar ps-spool-buffer-name "*PostScript*") | |
3078 | (defvar ps-spool-buffer nil) | |
ef2cbb24 | 3079 | |
12d89a2e RS |
3080 | (defvar ps-output-head nil) |
3081 | (defvar ps-output-tail nil) | |
ef2cbb24 | 3082 | |
7da17ab6 | 3083 | (defvar ps-page-postscript 0) |
bc0d41bd | 3084 | (defvar ps-page-order 0) |
12d89a2e | 3085 | (defvar ps-page-count 0) |
ea0c615d | 3086 | (defvar ps-page-n-up 0) |
87a16a06 | 3087 | (defvar ps-showline-count 1) |
1fd9b7fe GM |
3088 | (defvar ps-first-page nil) |
3089 | (defvar ps-last-page nil) | |
ea0c615d | 3090 | (defvar ps-print-page-p t) |
87a16a06 | 3091 | |
857686a6 | 3092 | (defvar ps-control-or-escape-regexp nil) |
98f2fbe7 | 3093 | (defvar ps-n-up-on nil) |
857686a6 | 3094 | |
87a16a06 RS |
3095 | (defvar ps-background-pages nil) |
3096 | (defvar ps-background-all-pages nil) | |
3097 | (defvar ps-background-text-count 0) | |
3098 | (defvar ps-background-image-count 0) | |
ef2cbb24 | 3099 | |
12d89a2e | 3100 | (defvar ps-current-font 0) |
6e1b1da6 GM |
3101 | (defvar ps-default-foreground nil) |
3102 | (defvar ps-default-color nil) | |
3103 | (defvar ps-current-color nil) | |
12d89a2e RS |
3104 | (defvar ps-current-bg nil) |
3105 | ||
3106 | (defvar ps-razchunk 0) | |
3107 | ||
d3ab8dac | 3108 | (defvar ps-color-p nil) |
bcc0d457 RS |
3109 | (defvar ps-color-format |
3110 | (if (eq ps-print-emacs-type 'emacs) | |
12d89a2e | 3111 | |
12b88fff RS |
3112 | ;; Emacs understands the %f format; we'll use it to limit color RGB |
3113 | ;; values to three decimals to cut down some on the size of the | |
3114 | ;; PostScript output. | |
3115 | "%0.3f %0.3f %0.3f" | |
12d89a2e | 3116 | |
12b88fff | 3117 | ;; Lucid emacsen will have to make do with %s (princ) for floats. |
bcc0d457 | 3118 | "%s %s %s")) |
12d89a2e RS |
3119 | |
3120 | ;; These values determine how much print-height to deduct when headers | |
3121 | ;; are turned on. This is a pretty clumsy way of handling it, but | |
3122 | ;; it'll do for now. | |
12d89a2e | 3123 | |
bcc0d457 | 3124 | (defvar ps-header-pad 0 |
496725ad RS |
3125 | "Vertical and horizontal space between the header frame and the text. |
3126 | This is in units of points (1/72 inch).") | |
12d89a2e | 3127 | |
bcc0d457 | 3128 | ;; Define accessors to the dimensions list. |
12d89a2e | 3129 | |
bcc0d457 RS |
3130 | (defmacro ps-page-dimensions-get-width (dims) `(nth 0 ,dims)) |
3131 | (defmacro ps-page-dimensions-get-height (dims) `(nth 1 ,dims)) | |
bc0d41bd | 3132 | (defmacro ps-page-dimensions-get-media (dims) `(nth 2 ,dims)) |
12d89a2e | 3133 | |
87a16a06 | 3134 | (defvar ps-landscape-page-height nil) |
12d89a2e | 3135 | |
12d89a2e RS |
3136 | (defvar ps-print-width nil) |
3137 | (defvar ps-print-height nil) | |
3138 | ||
8bd22fcf KH |
3139 | (defvar ps-height-remaining nil) |
3140 | (defvar ps-width-remaining nil) | |
12d89a2e | 3141 | |
7d8b7e8e KH |
3142 | (defvar ps-font-size-internal nil) |
3143 | (defvar ps-header-font-size-internal nil) | |
3144 | (defvar ps-header-title-font-size-internal nil) | |
3145 | ||
87a16a06 RS |
3146 | \f |
3147 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
3148 | ;; Internal Variables | |
3149 | ||
3150 | ||
3151 | (defvar ps-print-face-extension-alist nil | |
a18ed129 | 3152 | "Alist of symbolic faces *WITH* extension features (box, outline, etc). |
87a16a06 RS |
3153 | An element of this list has the following form: |
3154 | ||
3155 | (FACE . [BITS FG BG]) | |
3156 | ||
3157 | FACE is a symbol denoting a face name | |
3158 | BITS is a bit vector, where each bit correspond | |
3159 | to a feature (bold, underline, etc) | |
3160 | (see documentation for `ps-print-face-map-alist') | |
3161 | FG foreground color (string or nil) | |
3162 | BG background color (string or nil) | |
3163 | ||
a18ed129 RS |
3164 | Don't change this list directly; instead, |
3165 | use `ps-extend-face' and `ps-extend-face-list'. | |
3166 | See documentation for `ps-extend-face' for valid extension symbol.") | |
3167 | ||
3168 | ||
3169 | (defvar ps-print-face-alist nil | |
3170 | "Alist of symbolic faces *WITHOUT* extension features (box, outline, etc). | |
3171 | ||
3172 | An element of this list has the same form as an element of | |
3173 | `ps-print-face-extension-alist'. | |
3174 | ||
3175 | Don't change this list directly; this list is used by `ps-face-attributes', | |
3176 | `ps-map-face' and `ps-build-reference-face-lists'.") | |
87a16a06 RS |
3177 | |
3178 | ||
3179 | (defconst ps-print-face-map-alist | |
3180 | '((bold . 1) | |
3181 | (italic . 2) | |
3182 | (underline . 4) | |
3183 | (strikeout . 8) | |
3184 | (overline . 16) | |
3185 | (shadow . 32) | |
3186 | (box . 64) | |
3187 | (outline . 128)) | |
3188 | "Alist of all features and the corresponding bit mask. | |
3189 | Each symbol correspond to one bit in a bit vector.") | |
3190 | ||
3191 | \f | |
3192 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
a18ed129 | 3193 | ;; Remapping Faces |
87a16a06 RS |
3194 | |
3195 | ||
3196 | ;;;###autoload | |
3197 | (defun ps-extend-face-list (face-extension-list &optional merge-p) | |
3198 | "Extend face in `ps-print-face-extension-alist'. | |
3199 | ||
a18ed129 RS |
3200 | If optional MERGE-P is non-nil, extensions in FACE-EXTENSION-LIST are merged |
3201 | with face extension in `ps-print-face-extension-alist'; otherwise, overrides. | |
87a16a06 RS |
3202 | |
3203 | The elements in FACE-EXTENSION-LIST is like those for `ps-extend-face'. | |
3204 | ||
3205 | See `ps-extend-face' for documentation." | |
3206 | (while face-extension-list | |
3207 | (ps-extend-face (car face-extension-list) merge-p) | |
3208 | (setq face-extension-list (cdr face-extension-list)))) | |
3209 | ||
3210 | ||
3211 | ;;;###autoload | |
3212 | (defun ps-extend-face (face-extension &optional merge-p) | |
3213 | "Extend face in `ps-print-face-extension-alist'. | |
3214 | ||
6bdb808e | 3215 | If optional MERGE-P is non-nil, extensions in FACE-EXTENSION list are merged |
a18ed129 | 3216 | with face extensions in `ps-print-face-extension-alist'; otherwise, overrides. |
87a16a06 RS |
3217 | |
3218 | The elements of FACE-EXTENSION list have the form: | |
3219 | ||
3220 | (FACE-NAME FOREGROUND BACKGROUND EXTENSION...) | |
3221 | ||
3222 | FACE-NAME is a face name symbol. | |
3223 | ||
3224 | FOREGROUND and BACKGROUND may be nil or a string that denotes the | |
3225 | foreground and background colors respectively. | |
3226 | ||
3227 | EXTENSION is one of the following symbols: | |
3228 | bold - use bold font. | |
3229 | italic - use italic font. | |
3230 | underline - put a line under text. | |
3231 | strikeout - like underline, but the line is in middle of text. | |
3232 | overline - like underline, but the line is over the text. | |
3233 | shadow - text will have a shadow. | |
3234 | box - text will be surrounded by a box. | |
a18ed129 | 3235 | outline - print characters as hollow outlines. |
87a16a06 RS |
3236 | |
3237 | If EXTENSION is any other symbol, it is ignored." | |
3238 | (let* ((face-name (nth 0 face-extension)) | |
3239 | (foreground (nth 1 face-extension)) | |
3240 | (background (nth 2 face-extension)) | |
3241 | (ps-face (cdr (assq face-name ps-print-face-extension-alist))) | |
3242 | (face-vector (or ps-face (vector 0 nil nil))) | |
3243 | (face-bit (ps-extension-bit face-extension))) | |
3244 | ;; extend face | |
3245 | (aset face-vector 0 (if merge-p | |
3246 | (logior (aref face-vector 0) face-bit) | |
3247 | face-bit)) | |
3248 | (and foreground (stringp foreground) (aset face-vector 1 foreground)) | |
3249 | (and background (stringp background) (aset face-vector 2 background)) | |
3250 | ;; if face does not exist, insert it | |
3251 | (or ps-face | |
3252 | (setq ps-print-face-extension-alist | |
3253 | (cons (cons face-name face-vector) | |
3254 | ps-print-face-extension-alist))))) | |
3255 | ||
3256 | ||
3257 | (defun ps-extension-bit (face-extension) | |
3258 | (let ((face-bit 0)) | |
3259 | ;; map valid symbol extension to bit vector | |
3260 | (setq face-extension (cdr (cdr face-extension))) | |
3261 | (while (setq face-extension (cdr face-extension)) | |
3262 | (setq face-bit (logior face-bit | |
3263 | (or (cdr (assq (car face-extension) | |
3264 | ps-print-face-map-alist)) | |
3265 | 0)))) | |
3266 | face-bit)) | |
3267 | ||
3268 | \f | |
857686a6 | 3269 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
bc0d41bd | 3270 | ;; Adapted from font-lock: (obsolete stuff) |
857686a6 RS |
3271 | ;; Originally face attributes were specified via `font-lock-face-attributes'. |
3272 | ;; Users then changed the default face attributes by setting that variable. | |
3273 | ;; However, we try and be back-compatible and respect its value if set except | |
3274 | ;; for faces where M-x customize has been used to save changes for the face. | |
3275 | ||
0a5daee5 | 3276 | |
857686a6 RS |
3277 | (defun ps-font-lock-face-attributes () |
3278 | (and (boundp 'font-lock-mode) (symbol-value 'font-lock-mode) | |
3279 | (boundp 'font-lock-face-attributes) | |
3e9cb08f | 3280 | (let ((face-attributes (symbol-value 'font-lock-face-attributes))) |
857686a6 | 3281 | (while face-attributes |
6bdb808e RS |
3282 | (let* ((face-attribute |
3283 | (car (prog1 face-attributes | |
3284 | (setq face-attributes (cdr face-attributes))))) | |
857686a6 RS |
3285 | (face (car face-attribute))) |
3286 | ;; Rustle up a `defface' SPEC from a | |
3287 | ;; `font-lock-face-attributes' entry. | |
3288 | (unless (get face 'saved-face) | |
3289 | (let ((foreground (nth 1 face-attribute)) | |
3290 | (background (nth 2 face-attribute)) | |
3291 | (bold-p (nth 3 face-attribute)) | |
3292 | (italic-p (nth 4 face-attribute)) | |
3293 | (underline-p (nth 5 face-attribute)) | |
3294 | face-spec) | |
3295 | (when foreground | |
3296 | (setq face-spec (cons ':foreground | |
3297 | (cons foreground face-spec)))) | |
3298 | (when background | |
3299 | (setq face-spec (cons ':background | |
3300 | (cons background face-spec)))) | |
3301 | (when bold-p | |
3302 | (setq face-spec (append '(:bold t) face-spec))) | |
3303 | (when italic-p | |
3304 | (setq face-spec (append '(:italic t) face-spec))) | |
3305 | (when underline-p | |
3306 | (setq face-spec (append '(:underline t) face-spec))) | |
3307 | (custom-declare-face face (list (list t face-spec)) nil) | |
3308 | ))))))) | |
3309 | ||
3310 | \f | |
87a16a06 RS |
3311 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3312 | ;; Internal functions and variables | |
3313 | ||
3314 | ||
3556c6dd GM |
3315 | (defvar ps-print-hook nil) |
3316 | (defvar ps-print-begin-sheet-hook nil) | |
3317 | (defvar ps-print-begin-page-hook nil) | |
3318 | (defvar ps-print-begin-column-hook nil) | |
12b88fff RS |
3319 | |
3320 | ||
a18ed129 | 3321 | (defun ps-print-without-faces (from to &optional filename region-p) |
857686a6 | 3322 | (ps-spool-without-faces from to region-p) |
87a16a06 RS |
3323 | (ps-do-despool filename)) |
3324 | ||
3325 | ||
a18ed129 | 3326 | (defun ps-spool-without-faces (from to &optional region-p) |
12b88fff | 3327 | (run-hooks 'ps-print-hook) |
712dc9e0 | 3328 | (ps-printing-region region-p from) |
87a16a06 RS |
3329 | (ps-generate (current-buffer) from to 'ps-generate-postscript)) |
3330 | ||
3331 | ||
a18ed129 | 3332 | (defun ps-print-with-faces (from to &optional filename region-p) |
857686a6 | 3333 | (ps-spool-with-faces from to region-p) |
87a16a06 RS |
3334 | (ps-do-despool filename)) |
3335 | ||
3336 | ||
a18ed129 | 3337 | (defun ps-spool-with-faces (from to &optional region-p) |
12b88fff | 3338 | (run-hooks 'ps-print-hook) |
712dc9e0 | 3339 | (ps-printing-region region-p from) |
87a16a06 RS |
3340 | (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces)) |
3341 | ||
3342 | ||
bc0d41bd | 3343 | (defun ps-count-lines (from to) |
a18ed129 | 3344 | (+ (count-lines from to) |
857686a6 RS |
3345 | (save-excursion |
3346 | (goto-char to) | |
3347 | (if (= (current-column) 0) 1 0)))) | |
87a16a06 RS |
3348 | |
3349 | ||
a18ed129 | 3350 | (defvar ps-printing-region nil |
bc0d41bd KH |
3351 | "Variable used to indicate if the region that ps-print is printing. |
3352 | It is a cons, the car of which is the line number where the region begins, and | |
3353 | its cdr is the total number of lines in the buffer. Formatting functions can | |
3354 | use this information to print the original line number (and not the number of | |
3355 | lines printed), and to indicate in the header that the printout is of a partial | |
3356 | file.") | |
3357 | ||
3358 | ||
3359 | (defvar ps-printing-region-p nil | |
3360 | "Non-nil means ps-print is printing a region.") | |
87a16a06 RS |
3361 | |
3362 | ||
712dc9e0 | 3363 | (defun ps-printing-region (region-p from) |
bc0d41bd KH |
3364 | (setq ps-printing-region-p region-p |
3365 | ps-printing-region | |
3366 | (cons (if region-p | |
712dc9e0 | 3367 | (ps-count-lines (point-min) from) |
bc0d41bd KH |
3368 | 1) |
3369 | (ps-count-lines (point-min) (point-max))))) | |
87a16a06 RS |
3370 | |
3371 | \f | |
12d89a2e RS |
3372 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3373 | ;; Internal functions | |
3374 | ||
0a5daee5 | 3375 | |
7ae35a2f | 3376 | (defsubst ps-font-alist (font-sym) |
12b88fff RS |
3377 | (get font-sym 'fonts)) |
3378 | ||
3379 | (defun ps-font (font-sym font-type) | |
3380 | "Font family name for text of `font-type', when generating PostScript." | |
7ae35a2f | 3381 | (let* ((font-list (ps-font-alist font-sym)) |
12b88fff | 3382 | (normal-font (cdr (assq 'normal font-list)))) |
6bdb808e RS |
3383 | (while (and font-list (not (eq font-type (car (car font-list))))) |
3384 | (setq font-list (cdr font-list))) | |
3385 | (or (cdr (car font-list)) normal-font))) | |
12b88fff RS |
3386 | |
3387 | (defun ps-fonts (font-sym) | |
7ae35a2f | 3388 | (mapcar 'cdr (ps-font-alist font-sym))) |
12b88fff RS |
3389 | |
3390 | (defun ps-font-number (font-sym font-type) | |
7ae35a2f | 3391 | (or (ps-alist-position font-type (ps-font-alist font-sym)) |
12b88fff RS |
3392 | 0)) |
3393 | ||
3394 | (defsubst ps-line-height (font-sym) | |
3395 | "The height of a line, for generating PostScript. | |
3396 | This is the value that ps-print uses to determine the height, | |
3397 | y-dimension, of the lines of text it has printed, and thus affects the | |
3398 | point at which page-breaks are placed. | |
3399 | The line-height is *not* the same as the point size of the font." | |
3400 | (get font-sym 'line-height)) | |
3401 | ||
3402 | (defsubst ps-title-line-height (font-sym) | |
3403 | "The height of a `title' line, for generating PostScript. | |
3404 | This is the value that ps-print uses to determine the height, | |
3405 | y-dimension, of the lines of text it has printed, and thus affects the | |
3406 | point at which page-breaks are placed. | |
3407 | The title-line-height is *not* the same as the point size of the font." | |
3408 | (get font-sym 'title-line-height)) | |
3409 | ||
3410 | (defsubst ps-space-width (font-sym) | |
3411 | "The width of a space character, for generating PostScript. | |
3412 | This value is used in expanding tab characters." | |
3413 | (get font-sym 'space-width)) | |
3414 | ||
3415 | (defsubst ps-avg-char-width (font-sym) | |
3416 | "The average width, in points, of a character, for generating PostScript. | |
3417 | This is the value that ps-print uses to determine the length, | |
3418 | x-dimension, of the text it has printed, and thus affects the point at | |
3419 | which long lines wrap around." | |
3420 | (get font-sym 'avg-char-width)) | |
3421 | ||
bcc0d457 | 3422 | (defun ps-line-lengths-internal () |
87a16a06 | 3423 | "Display the correspondence between a line length and a font size, |
bcc0d457 RS |
3424 | using the current ps-print setup. |
3425 | Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head" | |
df5e6194 GM |
3426 | (let* ((ps-font-size-internal |
3427 | (or ps-font-size-internal | |
3428 | (ps-get-font-size 'ps-font-size))) | |
3429 | (ps-header-font-size-internal | |
3430 | (or ps-header-font-size-internal | |
3431 | (ps-get-font-size 'ps-header-font-size))) | |
3432 | (ps-header-title-font-size-internal | |
3433 | (or ps-header-title-font-size-internal | |
3434 | (ps-get-font-size 'ps-header-title-font-size))) | |
3435 | (buf (get-buffer-create "*Line-lengths*")) | |
3436 | (ifs ps-font-size-internal) ; initial font size | |
3437 | (icw (ps-avg-char-width 'ps-font-for-text)) ; initial character width | |
3438 | (print-width (progn (ps-get-page-dimensions) | |
3439 | ps-print-width)) | |
3440 | (ps-setup (ps-setup)) ; setup for the current buffer | |
3441 | (fs-min 5) ; minimum font size | |
3442 | cw-min ; minimum character width | |
3443 | nb-cpl-max ; maximum nb of characters per line | |
3444 | (fs-max 14) ; maximum font size | |
3445 | cw-max ; maximum character width | |
3446 | nb-cpl-min ; minimum nb of characters per line | |
3447 | fs ; current font size | |
3448 | cw ; current character width | |
3449 | nb-cpl ; current nb of characters per line | |
3450 | ) | |
bcc0d457 RS |
3451 | (setq cw-min (/ (* icw fs-min) ifs) |
3452 | nb-cpl-max (floor (/ print-width cw-min)) | |
3453 | cw-max (/ (* icw fs-max) ifs) | |
8bd22fcf KH |
3454 | nb-cpl-min (floor (/ print-width cw-max)) |
3455 | nb-cpl nb-cpl-min) | |
bcc0d457 RS |
3456 | (set-buffer buf) |
3457 | (goto-char (point-max)) | |
df5e6194 | 3458 | (or (bobp) (insert "\n" (make-string 75 ?\;) "\n")) |
8bd22fcf | 3459 | (insert ps-setup |
df5e6194 | 3460 | "\nnb char per line / font size\n") |
bcc0d457 | 3461 | (while (<= nb-cpl nb-cpl-max) |
8bd22fcf KH |
3462 | (setq cw (/ print-width (float nb-cpl)) |
3463 | fs (/ (* ifs cw) icw)) | |
df5e6194 | 3464 | (insert (format "%16d %s\n" nb-cpl fs)) |
bcc0d457 RS |
3465 | (setq nb-cpl (1+ nb-cpl))) |
3466 | (insert "\n") | |
3467 | (display-buffer buf 'not-this-window))) | |
3468 | ||
3469 | (defun ps-nb-pages (nb-lines) | |
496725ad RS |
3470 | "Display correspondence between font size and the number of pages. |
3471 | The correspondence is based on having NB-LINES lines of text, | |
3472 | and on the current ps-print setup." | |
df5e6194 GM |
3473 | (let* ((ps-font-size-internal |
3474 | (or ps-font-size-internal | |
3475 | (ps-get-font-size 'ps-font-size))) | |
3476 | (ps-header-font-size-internal | |
3477 | (or ps-header-font-size-internal | |
3478 | (ps-get-font-size 'ps-header-font-size))) | |
3479 | (ps-header-title-font-size-internal | |
3480 | (or ps-header-title-font-size-internal | |
3481 | (ps-get-font-size 'ps-header-title-font-size))) | |
3482 | (buf (get-buffer-create "*Nb-Pages*")) | |
3483 | (ifs ps-font-size-internal) ; initial font size | |
3484 | (ilh (ps-line-height 'ps-font-for-text)) ; initial line height | |
3485 | (page-height (progn (ps-get-page-dimensions) | |
3486 | ps-print-height)) | |
3487 | (ps-setup (ps-setup)) ; setup for the current buffer | |
3488 | (fs-min 4) ; minimum font size | |
3489 | lh-min ; minimum line height | |
3490 | nb-lpp-max ; maximum nb of lines per page | |
3491 | nb-page-min ; minimum nb of pages | |
3492 | (fs-max 14) ; maximum font size | |
3493 | lh-max ; maximum line height | |
3494 | nb-lpp-min ; minimum nb of lines per page | |
3495 | nb-page-max ; maximum nb of pages | |
3496 | fs ; current font size | |
3497 | lh ; current line height | |
3498 | nb-lpp ; current nb of lines per page | |
3499 | nb-page ; current nb of pages | |
3500 | ) | |
bcc0d457 RS |
3501 | (setq lh-min (/ (* ilh fs-min) ifs) |
3502 | nb-lpp-max (floor (/ page-height lh-min)) | |
3503 | nb-page-min (ceiling (/ (float nb-lines) nb-lpp-max)) | |
3504 | lh-max (/ (* ilh fs-max) ifs) | |
3505 | nb-lpp-min (floor (/ page-height lh-max)) | |
8bd22fcf KH |
3506 | nb-page-max (ceiling (/ (float nb-lines) nb-lpp-min)) |
3507 | nb-page nb-page-min) | |
bcc0d457 RS |
3508 | (set-buffer buf) |
3509 | (goto-char (point-max)) | |
df5e6194 | 3510 | (or (bobp) (insert "\n" (make-string 75 ?\;) "\n")) |
8bd22fcf | 3511 | (insert ps-setup |
df5e6194 | 3512 | (format "\nThere are %d lines.\n\n" nb-lines) |
8bd22fcf | 3513 | "nb page / font size\n") |
bcc0d457 RS |
3514 | (while (<= nb-page nb-page-max) |
3515 | (setq nb-lpp (ceiling (/ nb-lines (float nb-page))) | |
3516 | lh (/ page-height nb-lpp) | |
3517 | fs (/ (* ifs lh) ilh)) | |
df5e6194 | 3518 | (insert (format "%7d %s\n" nb-page fs)) |
bcc0d457 RS |
3519 | (setq nb-page (1+ nb-page))) |
3520 | (insert "\n") | |
3521 | (display-buffer buf 'not-this-window))) | |
3522 | ||
6bdb808e RS |
3523 | ;; macros used in `ps-select-font' |
3524 | (defmacro ps-lookup (key) `(cdr (assq ,key font-entry))) | |
3525 | (defmacro ps-size-scale (key) `(/ (* (ps-lookup ,key) font-size) size)) | |
3526 | ||
12b88fff RS |
3527 | (defun ps-select-font (font-family sym font-size title-font-size) |
3528 | (let ((font-entry (cdr (assq font-family ps-font-info-database)))) | |
3529 | (or font-entry | |
3530 | (error "Don't have data to scale font %s. Known fonts families are %s" | |
3531 | font-family | |
3532 | (mapcar 'car ps-font-info-database))) | |
6bdb808e RS |
3533 | (let ((size (ps-lookup 'size))) |
3534 | (put sym 'fonts (ps-lookup 'fonts)) | |
3535 | (put sym 'space-width (ps-size-scale 'space-width)) | |
3536 | (put sym 'avg-char-width (ps-size-scale 'avg-char-width)) | |
3537 | (put sym 'line-height (ps-size-scale 'line-height)) | |
3538 | (put sym 'title-line-height | |
3539 | (/ (* (ps-lookup 'line-height) title-font-size) size))))) | |
bcc0d457 | 3540 | |
12d89a2e | 3541 | (defun ps-get-page-dimensions () |
bcc0d457 RS |
3542 | (let ((page-dimensions (cdr (assq ps-paper-type ps-page-dimensions-database))) |
3543 | page-width page-height) | |
3544 | (cond | |
3545 | ((null page-dimensions) | |
3546 | (error "`ps-paper-type' must be one of:\n%s" | |
3547 | (mapcar 'car ps-page-dimensions-database))) | |
3548 | ((< ps-number-of-columns 1) | |
12b88fff | 3549 | (error "The number of columns %d should be positive" |
8bd22fcf | 3550 | ps-number-of-columns))) |
bcc0d457 | 3551 | |
12b88fff | 3552 | (ps-select-font ps-font-family 'ps-font-for-text |
7d8b7e8e | 3553 | ps-font-size-internal ps-font-size-internal) |
12b88fff | 3554 | (ps-select-font ps-header-font-family 'ps-font-for-header |
7d8b7e8e KH |
3555 | ps-header-font-size-internal |
3556 | ps-header-title-font-size-internal) | |
bcc0d457 RS |
3557 | |
3558 | (setq page-width (ps-page-dimensions-get-width page-dimensions) | |
3559 | page-height (ps-page-dimensions-get-height page-dimensions)) | |
3560 | ||
3561 | ;; Landscape mode | |
3562 | (if ps-landscape-mode | |
3563 | ;; exchange width and height | |
3564 | (setq page-width (prog1 page-height (setq page-height page-width)))) | |
3565 | ||
3566 | ;; It is used to get the lower right corner (only in landscape mode) | |
3567 | (setq ps-landscape-page-height page-height) | |
3568 | ||
3569 | ;; | lm | text | ic | text | ic | text | rm | | |
3570 | ;; page-width == lm + n * pw + (n - 1) * ic + rm | |
3571 | ;; => pw == (page-width - lm -rm - (n - 1) * ic) / n | |
8bd22fcf KH |
3572 | (setq ps-print-width (/ (- page-width |
3573 | ps-left-margin ps-right-margin | |
3574 | (* (1- ps-number-of-columns) ps-inter-column)) | |
3575 | ps-number-of-columns)) | |
bcc0d457 RS |
3576 | (if (<= ps-print-width 0) |
3577 | (error "Bad horizontal layout: | |
3578 | page-width == %s | |
3579 | ps-left-margin == %s | |
3580 | ps-right-margin == %s | |
3581 | ps-inter-column == %s | |
3582 | ps-number-of-columns == %s | |
3583 | | lm | text | ic | text | ic | text | rm | | |
3584 | page-width == lm + n * print-width + (n - 1) * ic + rm | |
3585 | => print-width == %d !" | |
3586 | page-width | |
3587 | ps-left-margin | |
3588 | ps-right-margin | |
3589 | ps-inter-column | |
3590 | ps-number-of-columns | |
3591 | ps-print-width)) | |
3592 | ||
3593 | (setq ps-print-height | |
3594 | (- page-height ps-bottom-margin ps-top-margin)) | |
3595 | (if (<= ps-print-height 0) | |
3596 | (error "Bad vertical layout: | |
3597 | ps-top-margin == %s | |
3598 | ps-bottom-margin == %s | |
3599 | page-height == bm + print-height + tm | |
3600 | => print-height == %d !" | |
3601 | ps-top-margin | |
3602 | ps-bottom-margin | |
3603 | ps-print-height)) | |
3604 | ;; If headers are turned on, deduct the height of the header from | |
3605 | ;; the print height. | |
8bd22fcf | 3606 | (if ps-print-header |
12b88fff RS |
3607 | (setq ps-header-pad (* ps-header-line-pad |
3608 | (ps-title-line-height 'ps-font-for-header)) | |
8bd22fcf KH |
3609 | ps-print-height (- ps-print-height |
3610 | ps-header-offset | |
3611 | ps-header-pad | |
12b88fff RS |
3612 | (ps-title-line-height 'ps-font-for-header) |
3613 | (* (ps-line-height 'ps-font-for-header) | |
3614 | (1- ps-header-lines)) | |
8bd22fcf | 3615 | ps-header-pad))) |
bcc0d457 RS |
3616 | (if (<= ps-print-height 0) |
3617 | (error "Bad vertical layout: | |
3618 | ps-top-margin == %s | |
3619 | ps-bottom-margin == %s | |
3620 | ps-header-offset == %s | |
3621 | ps-header-pad == %s | |
3622 | header-height == %s | |
3623 | page-height == bm + print-height + tm - ho - hh | |
3624 | => print-height == %d !" | |
3625 | ps-top-margin | |
3626 | ps-bottom-margin | |
3627 | ps-header-offset | |
3628 | ps-header-pad | |
3629 | (+ ps-header-pad | |
12b88fff RS |
3630 | (ps-title-line-height 'ps-font-for-header) |
3631 | (* (ps-line-height 'ps-font-for-header) | |
3632 | (1- ps-header-lines)) | |
bcc0d457 RS |
3633 | ps-header-pad) |
3634 | ps-print-height)))) | |
ef2cbb24 | 3635 | |
edc9cd35 GM |
3636 | (defun ps-print-preprint (prefix-arg) |
3637 | (and prefix-arg | |
3638 | (or (numberp prefix-arg) | |
3639 | (listp prefix-arg)) | |
d3ab8dac KH |
3640 | (let* ((name (concat (file-name-nondirectory (or (buffer-file-name) |
3641 | (buffer-name))) | |
3642 | ".ps")) | |
8bd22fcf KH |
3643 | (prompt (format "Save PostScript to file: (default %s) " name)) |
3644 | (res (read-file-name prompt default-directory name nil))) | |
ea0c615d GM |
3645 | (while (cond ((file-directory-p res) |
3646 | (ding) | |
3647 | (setq prompt "It's a directory")) | |
3648 | ((not (file-writable-p res)) | |
d3ab8dac | 3649 | (ding) |
ea0c615d | 3650 | (setq prompt "File is unwritable")) |
d3ab8dac | 3651 | ((file-exists-p res) |
ea0c615d | 3652 | (setq prompt "File exists") |
d3ab8dac KH |
3653 | (not (y-or-n-p (format "File `%s' exists; overwrite? " |
3654 | res)))) | |
3655 | (t nil)) | |
3656 | (setq res (read-file-name | |
ea0c615d | 3657 | (format "%s; save PostScript to file: " prompt) |
d3ab8dac KH |
3658 | (file-name-directory res) nil nil |
3659 | (file-name-nondirectory res)))) | |
8bd22fcf KH |
3660 | (if (file-directory-p res) |
3661 | (expand-file-name name (file-name-as-directory res)) | |
3662 | res)))) | |
12d89a2e RS |
3663 | |
3664 | ;; The following functions implement a simple list-buffering scheme so | |
3665 | ;; that ps-print doesn't have to repeatedly switch between buffers | |
857686a6 RS |
3666 | ;; while spooling. The functions `ps-output' and `ps-output-string' build |
3667 | ;; up the lists; the function `ps-flush-output' takes the lists and | |
12d89a2e RS |
3668 | ;; insert its contents into the spool buffer (*PostScript*). |
3669 | ||
857686a6 RS |
3670 | (defvar ps-string-escape-codes |
3671 | (let ((table (make-vector 256 nil)) | |
3672 | (char ?\000)) | |
3673 | ;; control characters | |
3674 | (while (<= char ?\037) | |
3675 | (aset table char (format "\\%03o" char)) | |
3676 | (setq char (1+ char))) | |
3677 | ;; printable characters | |
3678 | (while (< char ?\177) | |
3679 | (aset table char (format "%c" char)) | |
3680 | (setq char (1+ char))) | |
3681 | ;; DEL and 8-bit characters | |
3682 | (while (<= char ?\377) | |
3683 | (aset table char (format "\\%o" char)) | |
3684 | (setq char (1+ char))) | |
3685 | ;; Override ASCII formatting characters with named escape code: | |
3686 | (aset table ?\n "\\n") ; [NL] linefeed | |
3687 | (aset table ?\r "\\r") ; [CR] carriage return | |
3688 | (aset table ?\t "\\t") ; [HT] horizontal tab | |
3689 | (aset table ?\b "\\b") ; [BS] backspace | |
3690 | (aset table ?\f "\\f") ; [NP] form feed | |
3691 | ;; Escape PostScript escape and string delimiter characters: | |
3692 | (aset table ?\\ "\\\\") | |
3693 | (aset table ?\( "\\(") | |
3694 | (aset table ?\) "\\)") | |
3695 | table) | |
3696 | "Vector used to map characters to PostScript string escape codes.") | |
3697 | ||
12d89a2e RS |
3698 | (defun ps-output-string-prim (string) |
3699 | (insert "(") ;insert start-string delimiter | |
3700 | (save-excursion ;insert string | |
e65df0a1 | 3701 | (insert (string-as-unibyte string))) |
12d89a2e | 3702 | ;; Find and quote special characters as necessary for PS |
c82b4a75 | 3703 | ;; This skips everything except control chars, non-ASCII chars, (, ) and \. |
b61e2c11 RS |
3704 | (while (progn (skip-chars-forward " -'*-[]-~") (not (eobp))) |
3705 | (let ((special (following-char))) | |
e65df0a1 KH |
3706 | (delete-char 1) |
3707 | (insert (aref ps-string-escape-codes special)))) | |
12d89a2e RS |
3708 | (goto-char (point-max)) |
3709 | (insert ")")) ;insert end-string delimiter | |
ef2cbb24 | 3710 | |
12d89a2e | 3711 | (defun ps-init-output-queue () |
1fd9b7fe | 3712 | (setq ps-output-head (list "") |
8bd22fcf | 3713 | ps-output-tail ps-output-head)) |
ef2cbb24 | 3714 | |
1fd9b7fe GM |
3715 | |
3716 | (defun ps-selected-pages () | |
3717 | (while (progn | |
3718 | (setq ps-first-page (car (car ps-selected-pages)) | |
3719 | ps-last-page (cdr (car ps-selected-pages)) | |
3720 | ps-selected-pages (cdr ps-selected-pages)) | |
3721 | (and ps-selected-pages | |
3722 | (< ps-last-page ps-page-postscript))))) | |
3723 | ||
3724 | ||
ea0c615d GM |
3725 | (defun ps-print-page-p () |
3726 | (setq ps-print-page-p | |
3727 | (and (cond ((null ps-first-page)) | |
3728 | ((<= ps-page-postscript ps-last-page) | |
3729 | (<= ps-first-page ps-page-postscript)) | |
3730 | (ps-selected-pages | |
3731 | (ps-selected-pages) | |
3732 | (and (<= ps-first-page ps-page-postscript) | |
3733 | (<= ps-page-postscript ps-last-page))) | |
3734 | (t | |
3735 | nil)) | |
3736 | (cond ((eq ps-even-or-odd-pages 'even) | |
3737 | (= (logand ps-page-postscript 1) 0)) | |
3738 | ((eq ps-even-or-odd-pages 'odd) | |
3739 | (= (logand ps-page-postscript 1) 1)) | |
3740 | (t) | |
3741 | )))) | |
1fd9b7fe GM |
3742 | |
3743 | ||
12d89a2e | 3744 | (defun ps-output (&rest args) |
ea0c615d | 3745 | (when ps-print-page-p |
1fd9b7fe GM |
3746 | (setcdr ps-output-tail args) |
3747 | (while (cdr ps-output-tail) | |
3748 | (setq ps-output-tail (cdr ps-output-tail))))) | |
ef2cbb24 | 3749 | |
12d89a2e RS |
3750 | (defun ps-output-string (string) |
3751 | (ps-output t string)) | |
ef2cbb24 | 3752 | |
87a16a06 RS |
3753 | (defun ps-output-list (the-list) |
3754 | (mapcar 'ps-output the-list)) | |
3755 | ||
e65df0a1 KH |
3756 | ;; Output strings in the list ARGS in the PostScript prologue part. |
3757 | (defun ps-output-prologue (args) | |
3758 | (ps-output 'prologue (if (stringp args) (list args) args))) | |
3759 | ||
12d89a2e RS |
3760 | (defun ps-flush-output () |
3761 | (save-excursion | |
3762 | (set-buffer ps-spool-buffer) | |
3763 | (goto-char (point-max)) | |
3764 | (while ps-output-head | |
3765 | (let ((it (car ps-output-head))) | |
e65df0a1 KH |
3766 | (cond |
3767 | ((eq t it) | |
3768 | (setq ps-output-head (cdr ps-output-head)) | |
3769 | (ps-output-string-prim (car ps-output-head))) | |
3770 | ((eq 'prologue it) | |
12d89a2e | 3771 | (setq ps-output-head (cdr ps-output-head)) |
e65df0a1 KH |
3772 | (save-excursion |
3773 | (search-backward "\nBeginDoc") | |
3774 | (forward-char 1) | |
3775 | (apply 'insert (car ps-output-head)))) | |
3776 | (t | |
3777 | (insert it)))) | |
12d89a2e RS |
3778 | (setq ps-output-head (cdr ps-output-head)))) |
3779 | (ps-init-output-queue)) | |
3780 | ||
3781 | (defun ps-insert-file (fname) | |
3782 | (ps-flush-output) | |
12d89a2e RS |
3783 | (save-excursion |
3784 | (set-buffer ps-spool-buffer) | |
3785 | (goto-char (point-max)) | |
3786 | (insert-file fname))) | |
06fb6aab | 3787 | |
12d89a2e RS |
3788 | ;; These functions insert the arrays that define the contents of the |
3789 | ;; headers. | |
ef2cbb24 | 3790 | |
12d89a2e RS |
3791 | (defun ps-generate-header-line (fonttag &optional content) |
3792 | (ps-output " [ " fonttag " ") | |
3793 | (cond | |
3794 | ;; Literal strings should be output as is -- the string must | |
3795 | ;; contain its own PS string delimiters, '(' and ')', if necessary. | |
3796 | ((stringp content) | |
3797 | (ps-output content)) | |
3798 | ||
3799 | ;; Functions are called -- they should return strings; they will be | |
3800 | ;; inserted as strings and the PS string delimiters added. | |
3801 | ((and (symbolp content) (fboundp content)) | |
3802 | (ps-output-string (funcall content))) | |
3803 | ||
3804 | ;; Variables will have their contents inserted. They should | |
3805 | ;; contain strings, and will be inserted as strings. | |
3806 | ((and (symbolp content) (boundp content)) | |
3807 | (ps-output-string (symbol-value content))) | |
3808 | ||
3809 | ;; Anything else will get turned into an empty string. | |
3810 | (t | |
3811 | (ps-output-string ""))) | |
3812 | (ps-output " ]\n")) | |
3813 | ||
3814 | (defun ps-generate-header (name contents) | |
3815 | (ps-output "/" name " [\n") | |
3816 | (if (> ps-header-lines 0) | |
3817 | (let ((count 1)) | |
3818 | (ps-generate-header-line "/h0" (car contents)) | |
3819 | (while (and (< count ps-header-lines) | |
3820 | (setq contents (cdr contents))) | |
3821 | (ps-generate-header-line "/h1" (car contents)) | |
8bd22fcf | 3822 | (setq count (1+ count))) |
12d89a2e RS |
3823 | (ps-output "] def\n")))) |
3824 | ||
bc0d41bd | 3825 | |
6e1b1da6 GM |
3826 | (defun ps-output-boolean (name bool) |
3827 | (ps-output (format "/%s %s def\n" name (if bool "true" "false")))) | |
ef2cbb24 | 3828 | |
06fb6aab | 3829 | |
87a16a06 RS |
3830 | (defun ps-background-pages (page-list func) |
3831 | (if page-list | |
3832 | (mapcar | |
bc0d41bd KH |
3833 | #'(lambda (pages) |
3834 | (let ((start (if (consp pages) (car pages) pages)) | |
3835 | (end (if (consp pages) (cdr pages) pages))) | |
3836 | (and (integerp start) (integerp end) (<= start end) | |
3837 | (add-to-list 'ps-background-pages (vector start end func))))) | |
87a16a06 RS |
3838 | page-list) |
3839 | (setq ps-background-all-pages (cons func ps-background-all-pages)))) | |
3840 | ||
3841 | ||
bc0d41bd KH |
3842 | (defconst ps-boundingbox-re |
3843 | "^%%BoundingBox:\ | |
3844 | \\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)") | |
3845 | ||
3846 | ||
87a16a06 RS |
3847 | (defun ps-get-boundingbox () |
3848 | (save-excursion | |
3849 | (set-buffer ps-spool-buffer) | |
3850 | (save-excursion | |
bc0d41bd | 3851 | (if (re-search-forward ps-boundingbox-re nil t) |
87a16a06 RS |
3852 | (vector (string-to-number ; lower x |
3853 | (buffer-substring (match-beginning 1) (match-end 1))) | |
3854 | (string-to-number ; lower y | |
3855 | (buffer-substring (match-beginning 2) (match-end 2))) | |
3856 | (string-to-number ; upper x | |
3857 | (buffer-substring (match-beginning 3) (match-end 3))) | |
3858 | (string-to-number ; upper y | |
3859 | (buffer-substring (match-beginning 4) (match-end 4)))) | |
3860 | (vector 0 0 0 0))))) | |
3861 | ||
3862 | ||
3863 | ;; Emacs understands the %f format; we'll use it to limit color RGB values | |
3864 | ;; to three decimals to cut down some on the size of the PostScript output. | |
3865 | ;; Lucid emacsen will have to make do with %s (princ) for floats. | |
3866 | ||
3867 | (defvar ps-float-format (if (eq ps-print-emacs-type 'emacs) | |
3868 | "%0.3f " ; emacs | |
3869 | "%s ")) ; Lucid emacsen | |
3870 | ||
3871 | ||
3872 | (defun ps-float-format (value &optional default) | |
3873 | (let ((literal (or value default))) | |
3874 | (if literal | |
3875 | (format (if (numberp literal) | |
3876 | ps-float-format | |
3877 | "%s ") | |
3878 | literal) | |
3879 | " "))) | |
3880 | ||
3881 | ||
3882 | (defun ps-background-text () | |
3883 | (mapcar | |
bc0d41bd KH |
3884 | #'(lambda (text) |
3885 | (setq ps-background-text-count (1+ ps-background-text-count)) | |
c3d6d211 | 3886 | (ps-output (format "/ShowBackText-%d{\n" ps-background-text-count)) |
bc0d41bd KH |
3887 | (ps-output-string (nth 0 text)) ; text |
3888 | (ps-output | |
3889 | "\n" | |
3890 | (ps-float-format (nth 4 text) 200.0) ; font size | |
3891 | (format "/%s " (or (nth 3 text) "Times-Roman")) ; font name | |
3892 | (ps-float-format (nth 6 text) | |
3893 | "PrintHeight PrintPageWidth atan") ; rotation | |
3894 | (ps-float-format (nth 5 text) 0.85) ; gray | |
3895 | (ps-float-format (nth 1 text) "0") ; x position | |
8e234846 | 3896 | (ps-float-format (nth 2 text) "0") ; y position |
c3d6d211 | 3897 | "\nShowBackText}def\n") |
bc0d41bd KH |
3898 | (ps-background-pages (nthcdr 7 text) ; page list |
3899 | (format "ShowBackText-%d\n" | |
3900 | ps-background-text-count))) | |
87a16a06 RS |
3901 | ps-print-background-text)) |
3902 | ||
3903 | ||
3904 | (defun ps-background-image () | |
3905 | (mapcar | |
bc0d41bd KH |
3906 | #'(lambda (image) |
3907 | (let ((image-file (expand-file-name (nth 0 image)))) | |
41481e4b KH |
3908 | (when (file-readable-p image-file) |
3909 | (setq ps-background-image-count (1+ ps-background-image-count)) | |
3910 | (ps-output | |
c3d6d211 | 3911 | (format "/ShowBackImage-%d{\n--back-- " |
41481e4b KH |
3912 | ps-background-image-count) |
3913 | (ps-float-format (nth 5 image) 0.0) ; rotation | |
3914 | (ps-float-format (nth 3 image) 1.0) ; x scale | |
3915 | (ps-float-format (nth 4 image) 1.0) ; y scale | |
3916 | (ps-float-format (nth 1 image) ; x position | |
3917 | "PrintPageWidth 2 div") | |
3918 | (ps-float-format (nth 2 image) ; y position | |
3919 | "PrintHeight 2 div BottomMargin add") | |
3920 | "\nBeginBackImage\n") | |
3921 | (ps-insert-file image-file) | |
3922 | ;; coordinate adjustment to centralize image | |
3923 | ;; around x and y position | |
3924 | (let ((box (ps-get-boundingbox))) | |
3925 | (save-excursion | |
3926 | (set-buffer ps-spool-buffer) | |
3927 | (save-excursion | |
3928 | (if (re-search-backward "^--back--" nil t) | |
3929 | (replace-match | |
3930 | (format "%s %s" | |
3931 | (ps-float-format | |
3932 | (- (+ (/ (- (aref box 2) (aref box 0)) 2.0) | |
3933 | (aref box 0)))) | |
3934 | (ps-float-format | |
3935 | (- (+ (/ (- (aref box 3) (aref box 1)) 2.0) | |
3936 | (aref box 1))))) | |
3937 | t))))) | |
c3d6d211 | 3938 | (ps-output "\nEndBackImage}def\n") |
41481e4b KH |
3939 | (ps-background-pages (nthcdr 6 image) ; page list |
3940 | (format "ShowBackImage-%d\n" | |
3941 | ps-background-image-count))))) | |
87a16a06 RS |
3942 | ps-print-background-image)) |
3943 | ||
3944 | ||
a18ed129 | 3945 | (defun ps-background (page-number) |
87a16a06 | 3946 | (let (has-local-background) |
bc0d41bd KH |
3947 | (mapcar #'(lambda (range) |
3948 | (and (<= (aref range 0) page-number) | |
3949 | (<= page-number (aref range 1)) | |
3950 | (if has-local-background | |
3951 | (ps-output (aref range 2)) | |
3952 | (setq has-local-background t) | |
c3d6d211 | 3953 | (ps-output "/printLocalBackground{\n" |
bc0d41bd | 3954 | (aref range 2))))) |
87a16a06 | 3955 | ps-background-pages) |
c3d6d211 | 3956 | (and has-local-background (ps-output "}def\n")))) |
87a16a06 RS |
3957 | |
3958 | ||
0140c600 EZ |
3959 | ;; Return a list of the distinct elements of LIST. |
3960 | ;; Elements are compared with `equal'. | |
3961 | (defun ps-remove-duplicates (list) | |
3962 | (let (new (tail list)) | |
3963 | (while tail | |
3964 | (or (member (car tail) new) | |
3965 | (setq new (cons (car tail) new))) | |
3966 | (setq tail (cdr tail))) | |
3967 | (nreverse new))) | |
3968 | ||
c82b4a75 | 3969 | |
6bdb808e RS |
3970 | ;; Find the first occurrence of ITEM in LIST. |
3971 | ;; Return the index of the matching item, or nil if not found. | |
3972 | ;; Elements are compared with `eq'. | |
7ae35a2f | 3973 | (defun ps-alist-position (item list) |
6bdb808e RS |
3974 | (let ((tail list) (index 0) found) |
3975 | (while tail | |
7ae35a2f | 3976 | (if (setq found (eq (car (car tail)) item)) |
6bdb808e RS |
3977 | (setq tail nil) |
3978 | (setq index (1+ index) | |
3979 | tail (cdr tail)))) | |
3980 | (and found index))) | |
3981 | ||
3982 | ||
bc0d41bd KH |
3983 | (defconst ps-n-up-database |
3984 | '((a4 | |
3985 | (1 nil 1 1 0) | |
3986 | (2 t 1 2 0) | |
3987 | (4 nil 2 2 0) | |
3988 | (6 t 2 3 1) | |
3989 | (8 t 2 4 0) | |
3990 | (9 nil 3 3 0) | |
3991 | (12 t 3 4 2) | |
3992 | (16 nil 4 4 0) | |
3993 | (18 t 3 6 0) | |
3994 | (20 nil 5 4 1) | |
3995 | (25 nil 5 5 0) | |
3996 | (30 nil 6 5 1) | |
3997 | (32 t 4 8 0) | |
3998 | (36 nil 6 6 0) | |
3999 | (42 nil 7 6 1) | |
4000 | (49 nil 7 7 0) | |
4001 | (50 t 5 10 0) | |
4002 | (56 nil 8 7 1) | |
4003 | (64 nil 8 8 0) | |
4004 | (72 nil 9 8 1) | |
4005 | (81 nil 9 9 0) | |
4006 | (90 nil 10 9 1) | |
4007 | (100 nil 10 10 0)) | |
4008 | (a3 | |
4009 | (1 nil 1 1 0) | |
4010 | (2 t 1 2 0) | |
4011 | (4 nil 2 2 0) | |
4012 | (6 t 2 3 1) | |
4013 | (8 t 2 4 0) | |
4014 | (9 nil 3 3 0) | |
4015 | (12 nil 4 3 1) | |
4016 | (16 nil 4 4 0) | |
4017 | (18 t 3 6 0) | |
4018 | (20 nil 5 4 1) | |
4019 | (25 nil 5 5 0) | |
4020 | (30 nil 6 5 1) | |
4021 | (32 t 4 8 0) | |
4022 | (36 nil 6 6 0) | |
4023 | (42 nil 7 6 1) | |
4024 | (49 nil 7 7 0) | |
4025 | (50 t 5 10 0) | |
4026 | (56 nil 8 7 1) | |
4027 | (64 nil 8 8 0) | |
4028 | (72 nil 9 8 1) | |
4029 | (81 nil 9 9 0) | |
4030 | (90 nil 10 9 1) | |
4031 | (100 nil 10 10 0)) | |
4032 | (letter | |
4033 | (1 nil 1 1 0) | |
8e234846 | 4034 | (2 t 1 2 0) ; adjusted by PostScript code |
bc0d41bd KH |
4035 | (4 nil 2 2 0) |
4036 | (6 t 2 3 0) | |
4037 | (9 nil 3 3 0) | |
4038 | (12 nil 4 3 1) | |
4039 | (16 nil 4 4 0) | |
4040 | (20 nil 5 4 1) | |
4041 | (25 nil 5 5 0) | |
4042 | (30 nil 6 5 1) | |
4043 | (36 nil 6 6 0) | |
4044 | (40 t 5 8 0) | |
4045 | (42 nil 7 6 1) | |
4046 | (49 nil 7 7 0) | |
4047 | (56 nil 8 7 1) | |
4048 | (64 nil 8 8 0) | |
4049 | (72 nil 9 8 1) | |
4050 | (81 nil 9 9 0) | |
4051 | (90 nil 10 9 1) | |
4052 | (100 nil 10 10 0)) | |
4053 | (legal | |
4054 | (1 nil 1 1 0) | |
4055 | (2 t 1 2 0) | |
4056 | (4 nil 2 2 0) | |
4057 | (6 nil 3 2 1) | |
4058 | (9 nil 3 3 0) | |
4059 | (10 t 2 5 0) | |
4060 | (12 nil 4 3 1) | |
4061 | (16 nil 4 4 0) | |
4062 | (20 nil 5 4 1) | |
4063 | (25 nil 5 5 0) | |
4064 | (30 nil 6 5 1) | |
4065 | (36 nil 6 6 0) | |
4066 | (42 nil 7 6 1) | |
4067 | (49 nil 7 7 0) | |
4068 | (56 nil 8 7 1) | |
4069 | (64 nil 8 8 0) | |
4070 | (70 t 5 14 0) | |
4071 | (72 nil 9 8 1) | |
4072 | (81 nil 9 9 0) | |
4073 | (90 nil 10 9 1) | |
4074 | (100 nil 10 10 0)) | |
4075 | (letter-small | |
4076 | (1 nil 1 1 0) | |
8e234846 | 4077 | (2 t 1 2 0) ; adjusted by PostScript code |
bc0d41bd KH |
4078 | (4 nil 2 2 0) |
4079 | (6 t 2 3 0) | |
4080 | (9 nil 3 3 0) | |
4081 | (12 t 3 4 1) | |
4082 | (15 t 3 5 0) | |
4083 | (16 nil 4 4 0) | |
4084 | (20 nil 5 4 1) | |
4085 | (25 nil 5 5 0) | |
4086 | (28 t 4 7 0) | |
4087 | (30 nil 6 5 1) | |
4088 | (36 nil 6 6 0) | |
4089 | (40 t 5 8 0) | |
4090 | (42 nil 7 6 1) | |
4091 | (49 nil 7 7 0) | |
4092 | (56 nil 8 7 1) | |
4093 | (60 t 6 10 0) | |
4094 | (64 nil 8 8 0) | |
4095 | (72 ni 9 8 1) | |
4096 | (81 nil 9 9 0) | |
4097 | (84 t 7 12 0) | |
4098 | (90 nil 10 9 1) | |
4099 | (100 nil 10 10 0)) | |
4100 | (tabloid | |
4101 | (1 nil 1 1 0) | |
4102 | (2 t 1 2 0) | |
4103 | (4 nil 2 2 0) | |
4104 | (6 t 2 3 1) | |
4105 | (8 t 2 4 0) | |
4106 | (9 nil 3 3 0) | |
4107 | (12 nil 4 3 1) | |
4108 | (16 nil 4 4 0) | |
4109 | (20 nil 5 4 1) | |
4110 | (25 nil 5 5 0) | |
4111 | (30 nil 6 5 1) | |
4112 | (36 nil 6 6 0) | |
4113 | (42 nil 7 6 1) | |
4114 | (49 nil 7 7 0) | |
4115 | (56 nil 8 7 1) | |
4116 | (64 nil 8 8 0) | |
4117 | (72 nil 9 8 1) | |
4118 | (81 nil 9 9 0) | |
4119 | (84 t 6 14 0) | |
4120 | (90 nil 10 9 1) | |
4121 | (100 nil 10 10 0)) | |
4122 | ;; Ledger paper size is a special case, it is the only paper size where the | |
4123 | ;; normal size is landscaped, that is, the height is smaller than width. | |
4124 | ;; So, we use the special value `pag' in the `landscape' field. | |
4125 | (ledger | |
4126 | (1 nil 1 1 0) | |
4127 | (2 pag 1 2 0) | |
4128 | (4 nil 2 2 0) | |
4129 | (6 pag 2 3 1) | |
4130 | (8 pag 2 4 0) | |
4131 | (9 nil 3 3 0) | |
4132 | (12 nil 4 3 1) | |
4133 | (16 nil 4 4 0) | |
4134 | (20 nil 5 4 1) | |
4135 | (25 nil 5 5 0) | |
4136 | (30 nil 6 5 1) | |
4137 | (36 nil 6 6 0) | |
4138 | (42 nil 7 6 1) | |
4139 | (49 nil 7 7 0) | |
4140 | (56 nil 8 7 1) | |
4141 | (64 nil 8 8 0) | |
4142 | (72 nil 9 8 1) | |
4143 | (81 nil 9 9 0) | |
4144 | (84 pag 6 14 0) | |
4145 | (90 nil 10 9 1) | |
4146 | (100 nil 10 10 0)) | |
4147 | (statement | |
4148 | (1 nil 1 1 0) | |
4149 | (2 t 1 2 0) | |
4150 | (4 nil 2 2 0) | |
4151 | (6 nil 3 2 1) | |
4152 | (9 nil 3 3 0) | |
4153 | (10 t 2 5 0) | |
4154 | (12 nil 4 3 1) | |
4155 | (16 nil 4 4 0) | |
4156 | (20 nil 5 4 1) | |
4157 | (21 t 3 7 0) | |
4158 | (25 nil 5 5 0) | |
4159 | (30 nil 6 5 1) | |
4160 | (36 nil 6 6 0) | |
4161 | (40 t 4 10 0) | |
4162 | (42 nil 7 6 1) | |
4163 | (49 nil 7 7 0) | |
4164 | (56 nil 8 7 1) | |
4165 | (60 t 5 12 0) | |
4166 | (64 nil 8 8 0) | |
4167 | (72 nil 9 8 1) | |
4168 | (81 nil 9 9 0) | |
4169 | (90 nil 10 9 1) | |
4170 | (100 nil 10 10 0)) | |
4171 | (executive | |
4172 | (1 nil 1 1 0) | |
8e234846 | 4173 | (2 t 1 2 0) ; adjusted by PostScript code |
bc0d41bd KH |
4174 | (4 nil 2 2 0) |
4175 | (6 t 2 3 0) | |
4176 | (9 nil 3 3 0) | |
4177 | (12 nil 4 3 1) | |
4178 | (16 nil 4 4 0) | |
4179 | (20 nil 5 4 1) | |
4180 | (25 nil 5 5 0) | |
4181 | (28 t 4 7 0) | |
4182 | (30 nil 6 5 1) | |
4183 | (36 nil 6 6 0) | |
4184 | (42 nil 7 6 1) | |
4185 | (45 t 5 9 0) | |
4186 | (49 nil 7 7 0) | |
4187 | (56 nil 8 7 1) | |
4188 | (60 t 6 10 0) | |
4189 | (64 nil 8 8 0) | |
4190 | (72 nil 9 8 1) | |
4191 | (81 nil 9 9 0) | |
4192 | (84 t 7 12 0) | |
4193 | (90 nil 10 9 1) | |
4194 | (100 nil 10 10 0)) | |
4195 | (a4small | |
4196 | (1 nil 1 1 0) | |
4197 | (2 t 1 2 0) | |
4198 | (4 nil 2 2 0) | |
4199 | (6 t 2 3 1) | |
4200 | (8 t 2 4 0) | |
4201 | (9 nil 3 3 0) | |
4202 | (12 nil 4 3 1) | |
4203 | (16 nil 4 4 0) | |
4204 | (18 t 3 6 0) | |
4205 | (20 nil 5 4 1) | |
4206 | (25 nil 5 5 0) | |
4207 | (30 nil 6 5 1) | |
4208 | (32 t 4 8 0) | |
4209 | (36 nil 6 6 0) | |
4210 | (42 nil 7 6 1) | |
4211 | (49 nil 7 7 0) | |
4212 | (50 t 5 10 0) | |
4213 | (56 nil 8 7 1) | |
4214 | (64 nil 8 8 0) | |
4215 | (72 nil 9 8 1) | |
4216 | (78 t 6 13 0) | |
4217 | (81 nil 9 9 0) | |
4218 | (90 nil 10 9 1) | |
4219 | (100 nil 10 10 0)) | |
4220 | (b4 | |
4221 | (1 nil 1 1 0) | |
4222 | (2 t 1 2 0) | |
4223 | (4 nil 2 2 0) | |
4224 | (6 t 2 3 1) | |
4225 | (8 t 2 4 0) | |
4226 | (9 nil 3 3 0) | |
4227 | (12 nil 4 3 1) | |
4228 | (16 nil 4 4 0) | |
4229 | (18 t 3 6 0) | |
4230 | (20 nil 5 4 1) | |
4231 | (25 nil 5 5 0) | |
4232 | (30 nil 6 5 1) | |
4233 | (32 t 4 8 0) | |
4234 | (36 nil 6 6 0) | |
4235 | (42 nil 7 6 1) | |
4236 | (49 nil 7 7 0) | |
4237 | (50 t 5 10 0) | |
4238 | (56 nil 8 7 1) | |
4239 | (64 nil 8 8 0) | |
4240 | (72 nil 9 8 1) | |
4241 | (81 nil 9 9 0) | |
4242 | (90 nil 10 9 1) | |
4243 | (100 nil 10 10 0)) | |
4244 | (b5 | |
4245 | (1 nil 1 1 0) | |
4246 | (2 t 1 2 0) | |
4247 | (4 nil 2 2 0) | |
4248 | (6 t 2 3 1) | |
4249 | (8 t 2 4 0) | |
4250 | (9 nil 3 3 0) | |
4251 | (12 nil 4 3 1) | |
4252 | (16 nil 4 4 0) | |
4253 | (18 t 3 6 0) | |
4254 | (20 nil 5 4 1) | |
4255 | (25 nil 5 5 0) | |
4256 | (30 nil 6 5 1) | |
4257 | (32 t 4 8 0) | |
4258 | (36 nil 6 6 0) | |
4259 | (42 nil 7 6 1) | |
4260 | (49 nil 7 7 0) | |
4261 | (50 t 5 10 0) | |
4262 | (56 nil 8 7 1) | |
4263 | (64 nil 8 8 0) | |
4264 | (72 nil 9 8 0) | |
4265 | (81 nil 9 9 0) | |
4266 | (90 nil 10 9 1) | |
4267 | (98 t 7 14 0) | |
4268 | (100 nil 10 10 0))) | |
4269 | "Alist which is the page matrix database used for N-up printing. | |
4270 | ||
4271 | Each element has the following form: | |
4272 | ||
4273 | (PAGE | |
4274 | (MAX LANDSCAPE LINES COLUMNS COL-MISSING) | |
4275 | ...) | |
4276 | ||
4277 | Where: | |
4278 | PAGE is the page size used (see `ps-paper-type'). | |
4279 | MAX is the maximum elements of this page matrix. | |
4280 | LANDSCAPE specifies if page matrix is landscaped, has the following valid | |
4281 | values: | |
4282 | nil the sheet is in portrait mode. | |
4283 | t the sheet is in landscape mode. | |
4284 | pag the sheet is in portrait mode and page is in landscape mode. | |
4285 | LINES is the number of lines of page matrix. | |
4286 | COLUMNS is the number of columns of page matrix. | |
4287 | COL-MISSING is the number of columns missing to fill the sheet.") | |
4288 | ||
4289 | ||
4290 | (defmacro ps-n-up-landscape (mat) `(nth 1 ,mat)) | |
4291 | (defmacro ps-n-up-lines (mat) `(nth 2 ,mat)) | |
4292 | (defmacro ps-n-up-columns (mat) `(nth 3 ,mat)) | |
4293 | (defmacro ps-n-up-missing (mat) `(nth 4 ,mat)) | |
4294 | ||
4295 | ||
4296 | (defun ps-n-up-printing () | |
4297 | ;; force `ps-n-up-printing' be in range 1 to 100. | |
4298 | (setq ps-n-up-printing (max (min ps-n-up-printing 100) 1)) | |
4299 | ;; find suitable page matrix for a given `ps-paper-type'. | |
4300 | (let ((the-list (cdr (assq ps-paper-type ps-n-up-database)))) | |
4301 | (and the-list | |
4302 | (while (> ps-n-up-printing (caar the-list)) | |
4303 | (setq the-list (cdr the-list)))) | |
4304 | (car the-list))) | |
4305 | ||
4306 | ||
4307 | (defconst ps-n-up-filling-database | |
4308 | '((left-top | |
4309 | "PageWidth" ; N-Up-XColumn | |
4310 | "0" ; N-Up-YColumn | |
4311 | "N-Up-End 1 sub PageWidth mul neg" ; N-Up-XLine | |
4312 | "LandscapePageHeight neg" ; N-Up-YLine | |
4313 | "N-Up-Lines" ; N-Up-Repeat | |
4314 | "N-Up-Columns" ; N-Up-End | |
4315 | "0" ; N-Up-XStart | |
4316 | "0") ; N-Up-YStart | |
4317 | (left-bottom | |
4318 | "PageWidth" ; N-Up-XColumn | |
4319 | "0" ; N-Up-YColumn | |
4320 | "N-Up-End 1 sub PageWidth mul neg" ; N-Up-XLine | |
4321 | "LandscapePageHeight" ; N-Up-YLine | |
4322 | "N-Up-Lines" ; N-Up-Repeat | |
4323 | "N-Up-Columns" ; N-Up-End | |
4324 | "0" ; N-Up-XStart | |
4325 | "N-Up-Repeat 1 sub LandscapePageHeight mul neg") ; N-Up-YStart | |
4326 | (right-top | |
4327 | "PageWidth neg" ; N-Up-XColumn | |
4328 | "0" ; N-Up-YColumn | |
4329 | "N-Up-End 1 sub PageWidth mul" ; N-Up-XLine | |
4330 | "LandscapePageHeight neg" ; N-Up-YLine | |
4331 | "N-Up-Lines" ; N-Up-Repeat | |
4332 | "N-Up-Columns" ; N-Up-End | |
4333 | "N-Up-End 1 sub PageWidth mul" ; N-Up-XStart | |
4334 | "0") ; N-Up-YStart | |
4335 | (right-bottom | |
4336 | "PageWidth neg" ; N-Up-XColumn | |
4337 | "0" ; N-Up-YColumn | |
4338 | "N-Up-End 1 sub PageWidth mul" ; N-Up-XLine | |
4339 | "LandscapePageHeight" ; N-Up-YLine | |
4340 | "N-Up-Lines" ; N-Up-Repeat | |
4341 | "N-Up-Columns" ; N-Up-End | |
4342 | "N-Up-End 1 sub PageWidth mul" ; N-Up-XStart | |
4343 | "N-Up-Repeat 1 sub LandscapePageHeight mul neg") ; N-Up-YStart | |
4344 | (top-left | |
4345 | "0" ; N-Up-XColumn | |
4346 | "LandscapePageHeight neg" ; N-Up-YColumn | |
4347 | "PageWidth" ; N-Up-XLine | |
4348 | "N-Up-End 1 sub LandscapePageHeight mul" ; N-Up-YLine | |
4349 | "N-Up-Columns" ; N-Up-Repeat | |
4350 | "N-Up-Lines" ; N-Up-End | |
4351 | "0" ; N-Up-XStart | |
4352 | "0") ; N-Up-YStart | |
4353 | (bottom-left | |
4354 | "0" ; N-Up-XColumn | |
4355 | "LandscapePageHeight" ; N-Up-YColumn | |
4356 | "PageWidth" ; N-Up-XLine | |
4357 | "N-Up-End 1 sub LandscapePageHeight mul neg" ; N-Up-YLine | |
4358 | "N-Up-Columns" ; N-Up-Repeat | |
4359 | "N-Up-Lines" ; N-Up-End | |
4360 | "0" ; N-Up-XStart | |
4361 | "N-Up-End 1 sub LandscapePageHeight mul neg") ; N-Up-YStart | |
4362 | (top-right | |
4363 | "0" ; N-Up-XColumn | |
4364 | "LandscapePageHeight neg" ; N-Up-YColumn | |
4365 | "PageWidth neg" ; N-Up-XLine | |
4366 | "N-Up-End 1 sub LandscapePageHeight mul" ; N-Up-YLine | |
4367 | "N-Up-Columns" ; N-Up-Repeat | |
4368 | "N-Up-Lines" ; N-Up-End | |
4369 | "N-Up-Repeat 1 sub PageWidth mul" ; N-Up-XStart | |
4370 | "0") ; N-Up-YStart | |
4371 | (bottom-right | |
4372 | "0" ; N-Up-XColumn | |
4373 | "LandscapePageHeight" ; N-Up-YColumn | |
4374 | "PageWidth neg" ; N-Up-XLine | |
4375 | "N-Up-End 1 sub LandscapePageHeight mul neg" ; N-Up-YLine | |
4376 | "N-Up-Columns" ; N-Up-Repeat | |
4377 | "N-Up-Lines" ; N-Up-End | |
4378 | "N-Up-Repeat 1 sub PageWidth mul" ; N-Up-XStart | |
4379 | "N-Up-End 1 sub LandscapePageHeight mul neg")) ; N-Up-YStart | |
4380 | "Alist for n-up printing initializations. | |
4381 | ||
4382 | Each element has the following form: | |
4383 | ||
4384 | (KIND XCOL YCOL XLIN YLIN REPEAT END XSTART YSTART) | |
4385 | ||
4386 | Where: | |
4387 | KIND is a valid value of `ps-n-up-filling'. | |
4388 | XCOL YCOL are the relative position for the next column. | |
4389 | XLIN YLIN are the relative position for the beginning of next line. | |
4390 | REPEAT is the number of repetions for external loop. | |
4391 | END is the number of repetions for internal loop and also the number of pages in | |
4392 | a row. | |
4393 | XSTART YSTART are the relative position for the first page in a sheet.") | |
4394 | ||
4395 | ||
4396 | (defun ps-n-up-filling () | |
4397 | (cdr (or (assq ps-n-up-filling ps-n-up-filling-database) | |
4398 | (assq 'left-top ps-n-up-filling-database)))) | |
4399 | ||
4400 | ||
4401 | (defmacro ps-n-up-xcolumn (init) `(nth 0 ,init)) | |
4402 | (defmacro ps-n-up-ycolumn (init) `(nth 1 ,init)) | |
4403 | (defmacro ps-n-up-xline (init) `(nth 2 ,init)) | |
4404 | (defmacro ps-n-up-yline (init) `(nth 3 ,init)) | |
4405 | (defmacro ps-n-up-repeat (init) `(nth 4 ,init)) | |
4406 | (defmacro ps-n-up-end (init) `(nth 5 ,init)) | |
4407 | (defmacro ps-n-up-xstart (init) `(nth 6 ,init)) | |
4408 | (defmacro ps-n-up-ystart (init) `(nth 7 ,init)) | |
4409 | ||
4410 | ||
66e63857 GM |
4411 | (defconst ps-error-handler-alist |
4412 | '((none . 0) | |
4413 | (paper . 1) | |
4414 | (system . 2) | |
4415 | (paper-and-system . 3)) | |
4416 | "Alist for error handler message") | |
4417 | ||
4418 | ||
ef2cbb24 | 4419 | (defun ps-begin-file () |
bcc0d457 | 4420 | (ps-get-page-dimensions) |
7da17ab6 | 4421 | (setq ps-page-postscript 0 |
bc0d41bd | 4422 | ps-page-order 0 |
ea0c615d GM |
4423 | ps-page-n-up 0 |
4424 | ps-print-page-p t | |
87a16a06 RS |
4425 | ps-background-text-count 0 |
4426 | ps-background-image-count 0 | |
4427 | ps-background-pages nil | |
4428 | ps-background-all-pages nil) | |
12d89a2e | 4429 | |
bc0d41bd KH |
4430 | (let ((dimensions (cdr (assq ps-paper-type ps-page-dimensions-database))) |
4431 | (tumble (if ps-landscape-mode (not ps-spool-tumble) ps-spool-tumble)) | |
4432 | (n-up (ps-n-up-printing)) | |
4433 | (n-up-filling (ps-n-up-filling))) | |
98f2fbe7 | 4434 | (and ps-n-up-on (setq tumble (not tumble))) |
bc0d41bd KH |
4435 | (ps-output |
4436 | ps-adobe-tag | |
4437 | "%%Title: " (buffer-name) ; Take job name from name of | |
8bd22fcf | 4438 | ; first buffer printed |
bc0d41bd KH |
4439 | "\n%%Creator: " (user-full-name) |
4440 | " (using ps-print v" ps-print-version | |
4441 | ")\n%%CreationDate: " | |
4442 | (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy) | |
4443 | "\n%%Orientation: " | |
4444 | (if ps-landscape-mode "Landscape" "Portrait") | |
4445 | "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font " | |
4446 | (mapconcat 'identity | |
4447 | (ps-remove-duplicates | |
4448 | (append (ps-fonts 'ps-font-for-text) | |
4449 | (list (ps-font 'ps-font-for-header 'normal) | |
4450 | (ps-font 'ps-font-for-header 'bold)))) | |
4451 | "\n%%+ font ") | |
4452 | "\n%%DocumentMedia: " (ps-page-dimensions-get-media dimensions) | |
4453 | (format " %d" (round (ps-page-dimensions-get-width dimensions))) | |
4454 | (format " %d" (round (ps-page-dimensions-get-height dimensions))) | |
4455 | " 0 () ()\n%%PageOrder: Ascend\n%%Pages: (atend)\n%%Requirements:" | |
4456 | (if ps-spool-duplex | |
8e234846 | 4457 | (if tumble " duplex(tumble)\n" " duplex\n") |
bc0d41bd KH |
4458 | "\n")) |
4459 | ||
66e63857 | 4460 | (ps-insert-string ps-print-prologue-header) |
bc0d41bd | 4461 | |
8e234846 GM |
4462 | (ps-output "%%EndComments\n%%BeginDefaults\n%%PageMedia: " |
4463 | (ps-page-dimensions-get-media dimensions) | |
4464 | "\n%%EndDefaults\n\n%%BeginPrologue\n\n" | |
6e1b1da6 GM |
4465 | "/languagelevel where{pop}{/languagelevel 1 def}ifelse\n" |
4466 | (format "/ErrorMessage %s def\n\n" | |
66e63857 GM |
4467 | (or (cdr (assoc ps-error-handler-message |
4468 | ps-error-handler-alist)) | |
4469 | 1)) ; send to paper | |
4470 | ps-print-prologue-0 | |
4471 | "\n%%BeginProcSet: UserDefinedPrologue\n\n") | |
4472 | ||
4473 | (ps-insert-string ps-user-defined-prologue) | |
4474 | ||
4475 | (ps-output "\n%%EndProcSet\n\n") | |
bc0d41bd | 4476 | |
bc0d41bd KH |
4477 | (ps-output-boolean "LandscapeMode " |
4478 | (or ps-landscape-mode | |
4479 | (eq (ps-n-up-landscape n-up) 'pag))) | |
906d41a7 | 4480 | (ps-output-boolean "UpsideDown " ps-print-upside-down) |
bc0d41bd KH |
4481 | (ps-output (format "/NumberOfColumns %d def\n" ps-number-of-columns) |
4482 | ||
4483 | (format "/LandscapePageHeight %s def\n" ps-landscape-page-height) | |
4484 | (format "/PrintPageWidth %s def\n" | |
4485 | (- (* (+ ps-print-width ps-inter-column) | |
4486 | ps-number-of-columns) | |
4487 | ps-inter-column)) | |
4488 | (format "/PrintWidth %s def\n" ps-print-width) | |
4489 | (format "/PrintHeight %s def\n" ps-print-height) | |
4490 | ||
4491 | (format "/LeftMargin %s def\n" ps-left-margin) | |
4492 | (format "/RightMargin %s def\n" ps-right-margin) | |
4493 | (format "/InterColumn %s def\n" ps-inter-column) | |
4494 | ||
4495 | (format "/BottomMargin %s def\n" ps-bottom-margin) | |
4496 | (format "/TopMargin %s def\n" ps-top-margin) ; not used | |
4497 | (format "/HeaderOffset %s def\n" ps-header-offset) | |
4498 | (format "/HeaderPad %s def\n" ps-header-pad)) | |
4499 | ||
4500 | (ps-output-boolean "PrintHeader " ps-print-header) | |
4501 | (ps-output-boolean "PrintOnlyOneHeader" ps-print-only-one-header) | |
4502 | (ps-output-boolean "PrintHeaderFrame " ps-print-header-frame) | |
8e234846 GM |
4503 | (ps-output-boolean "SwitchHeader " (if (eq ps-switch-header 'duplex) |
4504 | ps-spool-duplex | |
4505 | ps-switch-header)) | |
bc0d41bd | 4506 | (ps-output-boolean "ShowNofN " ps-show-n-of-n) |
bc0d41bd KH |
4507 | |
4508 | (let ((line-height (ps-line-height 'ps-font-for-text))) | |
4509 | (ps-output (format "/LineHeight %s def\n" line-height) | |
4510 | (format "/LinesPerColumn %d def\n" | |
4511 | (round (/ (+ ps-print-height | |
4512 | (* line-height 0.45)) | |
4513 | line-height))))) | |
4514 | ||
8e234846 | 4515 | (ps-output-boolean "WarnPaperSize " ps-warn-paper-type) |
bc0d41bd | 4516 | (ps-output-boolean "Zebra " ps-zebra-stripes) |
8e234846 | 4517 | (ps-output-boolean "ZebraFollow " ps-zebra-stripe-follow) |
bc0d41bd | 4518 | (ps-output-boolean "PrintLineNumber " ps-line-number) |
906d41a7 GM |
4519 | (ps-output-boolean "SyncLineZebra " (not (integerp ps-line-number-step))) |
4520 | (ps-output (format "/PrintLineStep %d def\n" | |
4521 | (if (integerp ps-line-number-step) | |
4522 | ps-line-number-step | |
98f2fbe7 GM |
4523 | ps-zebra-stripe-height)) |
4524 | (format "/PrintLineStart %d def\n" ps-line-number-start) | |
906d41a7 | 4525 | (format "/ZebraHeight %d def\n" ps-zebra-stripe-height) |
6e1b1da6 GM |
4526 | "/ZebraColor " |
4527 | (ps-format-color ps-zebra-color 0.95) | |
4528 | "def\n/BackgroundColor " | |
4529 | (ps-format-color ps-default-bg 1.0) | |
4530 | "def\n/UseSetpagedevice " | |
bc0d41bd | 4531 | (if (eq ps-spool-config 'setpagedevice) |
6e1b1da6 GM |
4532 | "/setpagedevice where{pop languagelevel 2 eq}{false}ifelse" |
4533 | "false") | |
4534 | " def\n\n/PageWidth " | |
bc0d41bd KH |
4535 | "PrintPageWidth LeftMargin add RightMargin add def\n\n" |
4536 | (format "/N-Up %d def\n" ps-n-up-printing)) | |
4537 | (ps-output-boolean "N-Up-Landscape" (eq (ps-n-up-landscape n-up) t)) | |
4538 | (ps-output-boolean "N-Up-Border " ps-n-up-border-p) | |
4539 | (ps-output (format "/N-Up-Lines %d def\n" (ps-n-up-lines n-up)) | |
4540 | (format "/N-Up-Columns %d def\n" (ps-n-up-columns n-up)) | |
4541 | (format "/N-Up-Missing %d def\n" (ps-n-up-missing n-up)) | |
6e1b1da6 GM |
4542 | (format "/N-Up-Margin %s def\n" ps-n-up-margin) |
4543 | "/N-Up-Repeat " | |
bc0d41bd KH |
4544 | (if ps-landscape-mode |
4545 | (ps-n-up-end n-up-filling) | |
4546 | (ps-n-up-repeat n-up-filling)) | |
4547 | " def\n/N-Up-End " | |
4548 | (if ps-landscape-mode | |
4549 | (ps-n-up-repeat n-up-filling) | |
4550 | (ps-n-up-end n-up-filling)) | |
4551 | " def\n/N-Up-XColumn " (ps-n-up-xcolumn n-up-filling) | |
4552 | " def\n/N-Up-YColumn " (ps-n-up-ycolumn n-up-filling) | |
4553 | " def\n/N-Up-XLine " (ps-n-up-xline n-up-filling) | |
4554 | " def\n/N-Up-YLine " (ps-n-up-yline n-up-filling) | |
4555 | " def\n/N-Up-XStart " (ps-n-up-xstart n-up-filling) | |
4556 | " def\n/N-Up-YStart " (ps-n-up-ystart n-up-filling) " def\n") | |
4557 | ||
4558 | (ps-background-text) | |
4559 | (ps-background-image) | |
4560 | (setq ps-background-all-pages (nreverse ps-background-all-pages) | |
4561 | ps-background-pages (nreverse ps-background-pages)) | |
4562 | ||
41481e4b | 4563 | (ps-output "\n" ps-print-prologue-1) |
bc0d41bd | 4564 | |
c3d6d211 | 4565 | (ps-output "\n/printGlobalBackground{\n") |
bc0d41bd | 4566 | (ps-output-list ps-background-all-pages) |
c3d6d211 | 4567 | (ps-output "}def\n/printLocalBackground{\n}def\n") |
bc0d41bd KH |
4568 | |
4569 | ;; Header fonts | |
c3d6d211 | 4570 | (ps-output (format "/h0 %s(%s)cvn DefFont\n" ; /h0 14 /Helvetica-Bold DefFont |
bc0d41bd KH |
4571 | ps-header-title-font-size-internal |
4572 | (ps-font 'ps-font-for-header 'bold)) | |
c3d6d211 | 4573 | (format "/h1 %s(%s)cvn DefFont\n" ; /h1 12 /Helvetica DefFont |
bc0d41bd KH |
4574 | ps-header-font-size-internal |
4575 | (ps-font 'ps-font-for-header 'normal))) | |
4576 | ||
41481e4b | 4577 | (ps-output "\n" ps-print-prologue-2 "\n") |
bc0d41bd KH |
4578 | |
4579 | ;; Text fonts | |
4580 | (let ((font (ps-font-alist 'ps-font-for-text)) | |
4581 | (i 0)) | |
4582 | (while font | |
c3d6d211 | 4583 | (ps-output (format "/f%d %s(%s)cvn DefFont\n" |
bc0d41bd KH |
4584 | i |
4585 | ps-font-size-internal | |
4586 | (ps-font 'ps-font-for-text (car (car font))))) | |
4587 | (setq font (cdr font) | |
4588 | i (1+ i)))) | |
4589 | ||
4590 | (let ((font-entry (cdr (assq ps-font-family ps-font-info-database)))) | |
4591 | (ps-output (format "/SpaceWidthRatio %f def\n" | |
4592 | (/ (ps-lookup 'space-width) (ps-lookup 'size))))) | |
4593 | ||
4594 | (ps-output "\n%%EndPrologue\n\n%%BeginSetup\n") | |
4595 | (unless (eq ps-spool-config 'lpr-switches) | |
4596 | (ps-output "\n%%BeginFeature: *Duplex " | |
4597 | (ps-boolean-capitalized ps-spool-duplex) | |
4598 | " *Tumble " | |
4599 | (ps-boolean-capitalized tumble) | |
c3d6d211 GM |
4600 | "\nUseSetpagedevice\n{BMark/Duplex " |
4601 | (ps-boolean-constant ps-spool-duplex) | |
4602 | "/Tumble " | |
4603 | (ps-boolean-constant tumble) | |
4604 | " EMark setpagedevice}\n{statusdict begin " | |
4605 | (ps-boolean-constant ps-spool-duplex) | |
4606 | " setduplexmode " | |
4607 | (ps-boolean-constant tumble) | |
4608 | " settumble end}ifelse\n%%EndFeature\n"))) | |
8e234846 GM |
4609 | (ps-output "\n%%BeginFeature: *ManualFeed " |
4610 | (ps-boolean-capitalized ps-manual-feed) | |
4611 | "\nBMark /ManualFeed " | |
4612 | (ps-boolean-constant ps-manual-feed) | |
4613 | " EMark setpagedevice\n%%EndFeature\n" | |
4614 | "\n/Lines 0 def\n/PageCount 0 def\n\nBeginDoc\n%%EndSetup\n") | |
47d2ac75 | 4615 | (and ps-banner-page-when-duplexing |
98f2fbe7 | 4616 | (ps-output "\n%%Page: banner 0\nsave showpage restore\n"))) |
bc0d41bd KH |
4617 | |
4618 | ||
6e1b1da6 GM |
4619 | (defun ps-format-color (color &optional default) |
4620 | (let ((the-color (if (stringp color) | |
4621 | (ps-color-scale color) | |
4622 | color))) | |
4623 | (if (and the-color (listp the-color)) | |
4624 | (concat "[" | |
4625 | (format ps-color-format | |
4626 | (nth 0 the-color) | |
4627 | (nth 1 the-color) | |
4628 | (nth 2 the-color)) | |
4629 | "] ") | |
4630 | (ps-float-format (if (numberp the-color) the-color default))))) | |
4631 | ||
4632 | ||
66e63857 GM |
4633 | (defun ps-insert-string (prologue) |
4634 | (let ((str (if (functionp prologue) | |
4635 | (funcall prologue) | |
4636 | prologue))) | |
4637 | (and (stringp str) | |
4638 | (ps-output str)))) | |
4639 | ||
4640 | ||
bc0d41bd KH |
4641 | (defun ps-boolean-capitalized (bool) |
4642 | (if bool "True" "False")) | |
4643 | ||
ef2cbb24 | 4644 | |
8e234846 GM |
4645 | (defun ps-boolean-constant (bool) |
4646 | (if bool "true" "false")) | |
4647 | ||
4648 | ||
12d89a2e RS |
4649 | (defun ps-header-dirpart () |
4650 | (let ((fname (buffer-file-name))) | |
4651 | (if fname | |
4652 | (if (string-equal (buffer-name) (file-name-nondirectory fname)) | |
68e684a0 | 4653 | (abbreviate-file-name (file-name-directory fname)) |
12d89a2e RS |
4654 | fname) |
4655 | ""))) | |
ef2cbb24 | 4656 | |
bc0d41bd | 4657 | |
12d89a2e | 4658 | (defun ps-get-buffer-name () |
bcc0d457 RS |
4659 | (cond |
4660 | ;; Indulge Jim this little easter egg: | |
4661 | ((string= (buffer-name) "ps-print.el") | |
4662 | "Hey, Cool! It's ps-print.el!!!") | |
4663 | ;; Indulge Jack this other little easter egg: | |
4664 | ((string= (buffer-name) "sokoban.el") | |
4665 | "Super! C'est sokoban.el!") | |
87a16a06 | 4666 | (t (concat |
bc0d41bd | 4667 | (and ps-printing-region-p "Subset of: ") |
87a16a06 RS |
4668 | (buffer-name) |
4669 | (and (buffer-modified-p) " (unsaved)"))))) | |
ef2cbb24 | 4670 | |
7d8b7e8e KH |
4671 | |
4672 | (defun ps-get-font-size (font-sym) | |
4673 | (let ((font-size (symbol-value font-sym))) | |
4674 | (cond ((numberp font-size) | |
4675 | font-size) | |
4676 | ((and (consp font-size) | |
4677 | (numberp (car font-size)) | |
4678 | (numberp (cdr font-size))) | |
4679 | (if ps-landscape-mode | |
4680 | (car font-size) | |
4681 | (cdr font-size))) | |
4682 | (t | |
4683 | (error "Invalid font size `%S' for `%S'" font-size font-sym))))) | |
4684 | ||
4685 | ||
12d89a2e | 4686 | (defun ps-begin-job () |
1fd9b7fe | 4687 | ;; prologue files |
906d41a7 GM |
4688 | (let ((last-char (aref ps-postscript-code-directory |
4689 | (1- (length ps-postscript-code-directory))))) | |
4690 | (or (eq last-char ?/) | |
4691 | (and ps-windows-system (eq last-char ?\\)) | |
4692 | (setq ps-postscript-code-directory | |
4693 | (concat ps-postscript-code-directory "/")))) | |
41481e4b | 4694 | (or (equal ps-mark-code-directory ps-postscript-code-directory) |
c3d6d211 GM |
4695 | (setq ps-print-prologue-0 (ps-prologue-file 0) |
4696 | ps-print-prologue-1 (ps-prologue-file 1) | |
4697 | ps-print-prologue-2 (ps-prologue-file 2) | |
4698 | ps-mark-code-directory ps-postscript-code-directory)) | |
1fd9b7fe GM |
4699 | ;; selected pages |
4700 | (let (new page) | |
4701 | (while ps-selected-pages | |
4702 | (setq page (car ps-selected-pages) | |
4703 | ps-selected-pages (cdr ps-selected-pages)) | |
4704 | (cond ((integerp page) | |
4705 | (and (> page 0) | |
4706 | (setq new (cons (cons page page) new)))) | |
4707 | ((consp page) | |
4708 | (and (integerp (car page)) (integerp (cdr page)) | |
4709 | (> (car page) 0) | |
4710 | (<= (car page) (cdr page)) | |
4711 | (setq new (cons page new)))))) | |
4712 | (setq ps-selected-pages (sort new #'(lambda (one other) | |
4713 | (< (car one) (car other)))) | |
4714 | ps-last-selected-pages ps-selected-pages | |
4715 | ps-first-page nil | |
4716 | ps-last-page nil)) | |
4717 | ;; face background | |
906d41a7 GM |
4718 | (or (listp ps-use-face-background) |
4719 | (setq ps-use-face-background t)) | |
1fd9b7fe | 4720 | ;; line number |
906d41a7 GM |
4721 | (and (integerp ps-line-number-step) |
4722 | (<= ps-line-number-step 0) | |
4723 | (setq ps-line-number-step 1)) | |
98f2fbe7 GM |
4724 | (setq ps-n-up-on (> ps-n-up-printing 1) |
4725 | ps-line-number-start (max 1 (min ps-line-number-start | |
4726 | (if (integerp ps-line-number-step) | |
4727 | ps-line-number-step | |
4728 | ps-zebra-stripe-height)))) | |
1fd9b7fe | 4729 | ;; spooling buffer |
7da17ab6 RS |
4730 | (save-excursion |
4731 | (set-buffer ps-spool-buffer) | |
4732 | (goto-char (point-max)) | |
4733 | (and (re-search-backward "^%%Trailer$" nil t) | |
4734 | (delete-region (match-beginning 0) (point-max)))) | |
1fd9b7fe | 4735 | ;; miscellaneous |
bc0d41bd | 4736 | (setq ps-showline-count (car ps-printing-region) |
7da17ab6 | 4737 | ps-page-count 0 |
7d8b7e8e KH |
4738 | ps-font-size-internal (ps-get-font-size 'ps-font-size) |
4739 | ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size) | |
4740 | ps-header-title-font-size-internal | |
4741 | (ps-get-font-size 'ps-header-title-font-size) | |
857686a6 | 4742 | ps-control-or-escape-regexp |
298bfad9 KH |
4743 | (cond ((eq ps-print-control-characters '8-bit) |
4744 | (string-as-unibyte "[\000-\037\177-\377]")) | |
4745 | ((eq ps-print-control-characters 'control-8-bit) | |
4746 | (string-as-unibyte "[\000-\037\177-\237]")) | |
4747 | ((eq ps-print-control-characters 'control) | |
4748 | "[\000-\037\177]") | |
6e1b1da6 GM |
4749 | (t "[\t\n\f]")) |
4750 | ps-default-foreground (ps-rgb-color ps-default-fg 0.0) | |
4751 | ps-default-color (and ps-print-color-p ps-default-foreground) | |
4752 | ps-current-color ps-default-color | |
4753 | ;; Set the color scale. We do it here instead of in the defvar so | |
4754 | ;; that ps-print can be dumped into emacs. This expression can't be | |
4755 | ;; evaluated at dump-time because X isn't initialized. | |
4756 | ps-color-p (and ps-print-color-p (ps-color-device)) | |
4757 | ps-print-color-scale (if ps-color-p | |
4758 | (float (car (ps-color-values "white"))) | |
4759 | 1.0))) | |
4760 | ||
4761 | ||
4762 | (defun ps-rgb-color (color default) | |
4763 | (cond ((and color (listp color)) color) | |
4764 | ((stringp color) (ps-color-scale color)) | |
4765 | ((numberp color) (list color color color)) | |
4766 | (t (list default default default)) | |
4767 | )) | |
4768 | ||
ef2cbb24 | 4769 | |
ea0c615d GM |
4770 | (defun ps-page-number () |
4771 | (if ps-print-only-one-header | |
4772 | (1+ (/ (1- ps-page-count) ps-number-of-columns)) | |
4773 | ps-page-count)) | |
87a16a06 RS |
4774 | |
4775 | ||
ef2cbb24 RS |
4776 | (defun ps-next-page () |
4777 | (ps-end-page) | |
12d89a2e RS |
4778 | (ps-flush-output) |
4779 | (ps-begin-page)) | |
4780 | ||
bc0d41bd KH |
4781 | |
4782 | (defun ps-header-sheet () | |
4783 | ;; Print only when a new sheet begins. | |
ea0c615d GM |
4784 | (setq ps-page-order (1+ ps-page-order)) |
4785 | (and (> ps-page-order 1) | |
4786 | (ps-output "EndSheet\n")) | |
4787 | (ps-output (if ps-n-up-on | |
4788 | (format "\n%%%%Page: (%d \\(%d\\)) %d\n" | |
4789 | ps-page-order ps-page-postscript ps-page-order) | |
4790 | (format "\n%%%%Page: %d %d\n" | |
4791 | ps-page-postscript ps-page-order)) | |
4792 | (format "%d BeginSheet\nBeginDSCPage\n" | |
4793 | ps-n-up-printing))) | |
4794 | ||
4795 | ||
4796 | (defun ps-header-page () | |
7da17ab6 RS |
4797 | ;; set total line and page number when printing has finished |
4798 | ;; (see `ps-generate') | |
ea0c615d GM |
4799 | (if (zerop (mod ps-page-count ps-number-of-columns)) |
4800 | (progn | |
4801 | (setq ps-page-postscript (1+ ps-page-postscript)) | |
4802 | (when (ps-print-page-p) | |
4803 | (if (zerop (mod ps-page-n-up ps-n-up-printing)) | |
4804 | ;; Print only when a new sheet begins. | |
4805 | (progn | |
4806 | (ps-header-sheet) | |
4807 | (run-hooks 'ps-print-begin-sheet-hook)) | |
4808 | ;; Print only when a new page begins. | |
4809 | (ps-output "BeginDSCPage\n") | |
4810 | (run-hooks 'ps-print-begin-page-hook)) | |
4811 | (ps-background ps-page-postscript) | |
4812 | (setq ps-page-n-up (1+ ps-page-n-up)))) | |
4813 | ;; Print only when a new column begins. | |
4814 | (ps-output "BeginDSCPage\n") | |
4815 | (run-hooks 'ps-print-begin-column-hook)) | |
4816 | (setq ps-page-count (1+ ps-page-count))) | |
a18ed129 | 4817 | |
8bd22fcf | 4818 | (defun ps-begin-page () |
12d89a2e | 4819 | (ps-get-page-dimensions) |
8bd22fcf | 4820 | (setq ps-width-remaining ps-print-width |
298bfad9 | 4821 | ps-height-remaining ps-print-height) |
12d89a2e | 4822 | |
a18ed129 | 4823 | (ps-header-page) |
12d89a2e | 4824 | |
87a16a06 | 4825 | (ps-output (format "/LineNumber %d def\n" ps-showline-count) |
ea0c615d | 4826 | (format "/PageNumber %d def\n" (ps-page-number))) |
12d89a2e | 4827 | |
090be653 RS |
4828 | (when ps-print-header |
4829 | (ps-generate-header "HeaderLinesLeft" ps-left-header) | |
4830 | (ps-generate-header "HeaderLinesRight" ps-right-header) | |
4831 | (ps-output (format "%d SetHeaderLines\n" ps-header-lines))) | |
12d89a2e RS |
4832 | |
4833 | (ps-output "BeginPage\n") | |
87a16a06 RS |
4834 | (ps-set-font ps-current-font) |
4835 | (ps-set-bg ps-current-bg) | |
298bfad9 KH |
4836 | (ps-set-color ps-current-color) |
4837 | (ps-mule-begin-page)) | |
ef2cbb24 RS |
4838 | |
4839 | (defun ps-end-page () | |
a18ed129 | 4840 | (ps-output "EndPage\nEndDSCPage\n")) |
12d89a2e | 4841 | |
ef2cbb24 | 4842 | (defun ps-next-line () |
87a16a06 | 4843 | (setq ps-showline-count (1+ ps-showline-count)) |
12b88fff RS |
4844 | (let ((lh (ps-line-height 'ps-font-for-text))) |
4845 | (if (< ps-height-remaining lh) | |
4846 | (ps-next-page) | |
4847 | (setq ps-width-remaining ps-print-width | |
4848 | ps-height-remaining (- ps-height-remaining lh)) | |
4849 | (ps-output "HL\n")))) | |
ef2cbb24 RS |
4850 | |
4851 | (defun ps-continue-line () | |
12b88fff RS |
4852 | (let ((lh (ps-line-height 'ps-font-for-text))) |
4853 | (if (< ps-height-remaining lh) | |
4854 | (ps-next-page) | |
4855 | (setq ps-width-remaining ps-print-width | |
4856 | ps-height-remaining (- ps-height-remaining lh)) | |
4857 | (ps-output "SL\n")))) | |
12d89a2e RS |
4858 | |
4859 | (defun ps-find-wrappoint (from to char-width) | |
4860 | (let ((avail (truncate (/ ps-width-remaining char-width))) | |
4861 | (todo (- to from))) | |
4862 | (if (< todo avail) | |
4863 | (cons to (* todo char-width)) | |
4864 | (cons (+ from avail) ps-width-remaining)))) | |
4865 | ||
4866 | (defun ps-basic-plot-string (from to &optional bg-color) | |
12b88fff RS |
4867 | (let* ((wrappoint (ps-find-wrappoint from to |
4868 | (ps-avg-char-width 'ps-font-for-text))) | |
12d89a2e | 4869 | (to (car wrappoint)) |
298bfad9 KH |
4870 | (string (buffer-substring-no-properties from to))) |
4871 | (ps-mule-prepare-ascii-font string) | |
12d89a2e | 4872 | (ps-output-string string) |
bcc0d457 | 4873 | (ps-output " S\n") |
12d89a2e RS |
4874 | wrappoint)) |
4875 | ||
4876 | (defun ps-basic-plot-whitespace (from to &optional bg-color) | |
12b88fff RS |
4877 | (let* ((wrappoint (ps-find-wrappoint from to |
4878 | (ps-space-width 'ps-font-for-text))) | |
12d89a2e | 4879 | (to (car wrappoint))) |
12d89a2e RS |
4880 | (ps-output (format "%d W\n" (- to from))) |
4881 | wrappoint)) | |
4882 | ||
4883 | (defun ps-plot (plotfunc from to &optional bg-color) | |
ef2cbb24 | 4884 | (while (< from to) |
12d89a2e RS |
4885 | (let* ((wrappoint (funcall plotfunc from to bg-color)) |
4886 | (plotted-to (car wrappoint)) | |
4887 | (plotted-width (cdr wrappoint))) | |
8bd22fcf KH |
4888 | (setq from plotted-to |
4889 | ps-width-remaining (- ps-width-remaining plotted-width)) | |
12d89a2e RS |
4890 | (if (< from to) |
4891 | (ps-continue-line)))) | |
ef2cbb24 RS |
4892 | (if ps-razzle-dazzle |
4893 | (let* ((q-todo (- (point-max) (point-min))) | |
12d89a2e | 4894 | (q-done (- (point) (point-min))) |
ef2cbb24 | 4895 | (chunkfrac (/ q-todo 8)) |
857686a6 | 4896 | (chunksize (min chunkfrac 1000))) |
ef2cbb24 | 4897 | (if (> (- q-done ps-razchunk) chunksize) |
8bd22fcf | 4898 | (progn |
ef2cbb24 | 4899 | (setq ps-razchunk q-done) |
8bd22fcf KH |
4900 | (message "Formatting...%3d%%" |
4901 | (if (< q-todo 100) | |
4902 | (/ (* 100 q-done) q-todo) | |
4903 | (/ q-done (/ q-todo 100))) | |
4904 | )))))) | |
12d89a2e | 4905 | |
298bfad9 KH |
4906 | (defvar ps-last-font nil) |
4907 | ||
12d89a2e | 4908 | (defun ps-set-font (font) |
e65df0a1 KH |
4909 | (setq ps-last-font (format "f%d" (setq ps-current-font font))) |
4910 | (ps-output (format "/%s F\n" ps-last-font))) | |
12d89a2e | 4911 | |
12d89a2e RS |
4912 | (defun ps-set-bg (color) |
4913 | (if (setq ps-current-bg color) | |
8bd22fcf KH |
4914 | (ps-output (format ps-color-format |
4915 | (nth 0 color) (nth 1 color) (nth 2 color)) | |
12d89a2e RS |
4916 | " true BG\n") |
4917 | (ps-output "false BG\n"))) | |
4918 | ||
4919 | (defun ps-set-color (color) | |
6e1b1da6 | 4920 | (setq ps-current-color (or color ps-default-foreground)) |
8bd22fcf KH |
4921 | (ps-output (format ps-color-format |
4922 | (nth 0 ps-current-color) | |
043620f4 KH |
4923 | (nth 1 ps-current-color) (nth 2 ps-current-color)) |
4924 | " FG\n")) | |
12d89a2e | 4925 | |
12d89a2e | 4926 | |
87a16a06 | 4927 | (defvar ps-current-effect 0) |
12d89a2e | 4928 | |
87a16a06 RS |
4929 | |
4930 | (defun ps-plot-region (from to font &optional fg-color bg-color effects) | |
12d89a2e RS |
4931 | (if (not (equal font ps-current-font)) |
4932 | (ps-set-font font)) | |
06fb6aab | 4933 | |
12d89a2e RS |
4934 | ;; Specify a foreground color only if one's specified and it's |
4935 | ;; different than the current. | |
4936 | (if (not (equal fg-color ps-current-color)) | |
4937 | (ps-set-color fg-color)) | |
06fb6aab | 4938 | |
12d89a2e RS |
4939 | (if (not (equal bg-color ps-current-bg)) |
4940 | (ps-set-bg bg-color)) | |
06fb6aab | 4941 | |
87a16a06 RS |
4942 | ;; Specify effects (underline, overline, box, etc) |
4943 | (cond | |
4944 | ((not (integerp effects)) | |
4945 | (ps-output "0 EF\n") | |
4946 | (setq ps-current-effect 0)) | |
4947 | ((/= effects ps-current-effect) | |
4948 | (ps-output (number-to-string effects) " EF\n") | |
4949 | (setq ps-current-effect effects))) | |
ef2cbb24 | 4950 | |
12d89a2e | 4951 | ;; Starting at the beginning of the specified region... |
ef2cbb24 RS |
4952 | (save-excursion |
4953 | (goto-char from) | |
12d89a2e RS |
4954 | |
4955 | ;; ...break the region up into chunks separated by tabs, linefeeds, | |
87a16a06 | 4956 | ;; pagefeeds, control characters, and plot each chunk. |
ef2cbb24 | 4957 | (while (< from to) |
857686a6 | 4958 | (if (re-search-forward ps-control-or-escape-regexp to t) |
024ced4d | 4959 | ;; region with some control characters or some multi-byte characters |
12b88fff | 4960 | (let* ((match-point (match-beginning 0)) |
ea0c615d | 4961 | (match (char-after match-point)) |
3e9cb08f | 4962 | (composition (ps-e-find-composition from (1+ match-point)))) |
9d4d60c1 KH |
4963 | (if composition |
4964 | (if (and (nth 2 composition) | |
4965 | (<= (car composition) match-point)) | |
4966 | (progn | |
4967 | (setq match-point (car composition) | |
4968 | match 0) | |
4969 | (goto-char (nth 1 composition))) | |
4970 | (setq composition nil))) | |
e65df0a1 | 4971 | (when (< from match-point) |
298bfad9 | 4972 | (ps-mule-set-ascii-font) |
e65df0a1 | 4973 | (ps-plot 'ps-basic-plot-string from match-point bg-color)) |
857686a6 RS |
4974 | (cond |
4975 | ((= match ?\t) ; tab | |
be415ea7 | 4976 | (let ((linestart (line-beginning-position))) |
857686a6 RS |
4977 | (forward-char -1) |
4978 | (setq from (+ linestart (current-column))) | |
e65df0a1 | 4979 | (when (re-search-forward "[ \t]+" to t) |
298bfad9 | 4980 | (ps-mule-set-ascii-font) |
e65df0a1 KH |
4981 | (ps-plot 'ps-basic-plot-whitespace |
4982 | from (+ linestart (current-column)) | |
4983 | bg-color)))) | |
857686a6 RS |
4984 | |
4985 | ((= match ?\n) ; newline | |
4986 | (ps-next-line)) | |
4987 | ||
4988 | ((= match ?\f) ; form feed | |
12b88fff RS |
4989 | ;; do not skip page if previous character is NEWLINE and |
4990 | ;; it is a beginning of page. | |
df5e6194 | 4991 | (or (and (equal (char-after (1- match-point)) ?\n) |
12b88fff RS |
4992 | (= ps-height-remaining ps-print-height)) |
4993 | (ps-next-page))) | |
e65df0a1 | 4994 | |
9d4d60c1 KH |
4995 | (composition ; a composite sequence |
4996 | (ps-plot 'ps-mule-plot-composition match-point (point) bg-color)) | |
4997 | ||
024ced4d | 4998 | ((> match 255) ; a multi-byte character |
9d4d60c1 | 4999 | (let* ((charset (char-charset match)) |
3e9cb08f | 5000 | (composition (ps-e-find-composition match-point to)) |
9d4d60c1 | 5001 | (stop (if (nth 2 composition) (car composition) to))) |
e65df0a1 | 5002 | (or (eq charset 'composition) |
9d4d60c1 | 5003 | (while (and (< (point) stop) (eq (charset-after) charset)) |
298bfad9 | 5004 | (forward-char 1))) |
e65df0a1 | 5005 | (ps-plot 'ps-mule-plot-string match-point (point) bg-color))) |
3556c6dd | 5006 | ; characters from ^@ to ^_ and |
857686a6 RS |
5007 | (t ; characters from 127 to 255 |
5008 | (ps-control-character match))) | |
87a16a06 | 5009 | (setq from (point))) |
024ced4d | 5010 | ;; region without control characters nor multi-byte characters |
298bfad9 | 5011 | (ps-mule-set-ascii-font) |
87a16a06 RS |
5012 | (ps-plot 'ps-basic-plot-string from to bg-color) |
5013 | (setq from to))))) | |
5014 | ||
857686a6 RS |
5015 | (defvar ps-string-control-codes |
5016 | (let ((table (make-vector 256 nil)) | |
5017 | (char ?\000)) | |
5018 | ;; control character | |
5019 | (while (<= char ?\037) | |
5020 | (aset table char (format "^%c" (+ char ?@))) | |
5021 | (setq char (1+ char))) | |
5022 | ;; printable character | |
5023 | (while (< char ?\177) | |
5024 | (aset table char (format "%c" char)) | |
5025 | (setq char (1+ char))) | |
5026 | ;; DEL | |
5027 | (aset table char "^?") | |
5028 | ;; 8-bit character | |
5029 | (while (<= (setq char (1+ char)) ?\377) | |
5030 | (aset table char (format "\\%o" char))) | |
5031 | table) | |
5032 | "Vector used to map characters to a printable string.") | |
5033 | ||
5034 | (defun ps-control-character (char) | |
5035 | (let* ((str (aref ps-string-control-codes char)) | |
5036 | (from (1- (point))) | |
87a16a06 RS |
5037 | (len (length str)) |
5038 | (to (+ from len)) | |
12b88fff RS |
5039 | (char-width (ps-avg-char-width 'ps-font-for-text)) |
5040 | (wrappoint (ps-find-wrappoint from to char-width))) | |
87a16a06 RS |
5041 | (if (< (car wrappoint) to) |
5042 | (ps-continue-line)) | |
12b88fff | 5043 | (setq ps-width-remaining (- ps-width-remaining (* len char-width))) |
36243805 | 5044 | (ps-mule-prepare-ascii-font str) |
87a16a06 RS |
5045 | (ps-output-string str) |
5046 | (ps-output " S\n"))) | |
ef2cbb24 | 5047 | |
87a16a06 | 5048 | |
a18ed129 RS |
5049 | (defun ps-face-attributes (face) |
5050 | "Return face attribute vector. | |
87a16a06 | 5051 | |
a18ed129 RS |
5052 | If FACE is not in `ps-print-face-extension-alist' or in |
5053 | `ps-print-face-alist', insert it on `ps-print-face-alist' and | |
5054 | return the attribute vector. | |
87a16a06 RS |
5055 | |
5056 | If FACE is not a valid face name, it is used default face." | |
df5e6194 GM |
5057 | (cond |
5058 | ((symbolp face) | |
5059 | (cdr (or (assq face ps-print-face-extension-alist) | |
5060 | (assq face ps-print-face-alist) | |
5061 | (let* ((the-face (if (facep face) face 'default)) | |
5062 | (new-face (ps-screen-to-bit-face the-face))) | |
5063 | (or (and (eq the-face 'default) | |
5064 | (assq the-face ps-print-face-alist)) | |
5065 | (setq ps-print-face-alist | |
5066 | (cons new-face ps-print-face-alist))) | |
5067 | new-face)))) | |
5068 | ((eq (car face) 'foreground-color) | |
5069 | (vector 0 (cdr face) nil)) | |
5070 | ((eq (car face) 'background-color) | |
5071 | (vector 0 nil (cdr face))) | |
5072 | (t | |
5073 | (vector 0 nil nil)))) | |
87a16a06 | 5074 | |
043620f4 | 5075 | |
906d41a7 GM |
5076 | (defun ps-face-background (face background) |
5077 | (and (or (eq ps-use-face-background t) | |
5078 | (cond ((symbolp face) | |
5079 | (memq face ps-use-face-background)) | |
5080 | ((listp face) | |
df5e6194 GM |
5081 | (or (memq (car face) '(foreground-color background-color)) |
5082 | (let (ok) | |
5083 | (while face | |
5084 | (if (or (memq (car face) ps-use-face-background) | |
5085 | (memq (car face) | |
5086 | '(foreground-color background-color))) | |
5087 | (setq face nil | |
5088 | ok t) | |
5089 | (setq face (cdr face)))) | |
5090 | ok))) | |
906d41a7 GM |
5091 | (t |
5092 | nil) | |
5093 | )) | |
5094 | background)) | |
5095 | ||
5096 | ||
043620f4 | 5097 | (defun ps-face-attribute-list (face-or-list) |
df5e6194 GM |
5098 | (cond |
5099 | ;; simple face | |
5100 | ((not (listp face-or-list)) | |
5101 | (ps-face-attributes face-or-list)) | |
5102 | ;; only foreground color, not a `real' face | |
5103 | ((eq (car face-or-list) 'foreground-color) | |
5104 | (vector 0 (cdr face-or-list) nil)) | |
5105 | ;; only background color, not a `real' face | |
5106 | ((eq (car face-or-list) 'background-color) | |
5107 | (vector 0 nil (cdr face-or-list))) | |
5108 | ;; list of faces | |
5109 | (t | |
5110 | (let ((effects 0) | |
5111 | foreground background face-attr face) | |
5112 | (while face-or-list | |
5113 | (setq face (car face-or-list) | |
5114 | face-or-list (cdr face-or-list) | |
5115 | face-attr (ps-face-attributes face) | |
5116 | effects (logior effects (aref face-attr 0))) | |
5117 | (or foreground (setq foreground (aref face-attr 1))) | |
5118 | (or background | |
5119 | (setq background (ps-face-background face (aref face-attr 2))))) | |
5120 | (vector effects foreground background))))) | |
043620f4 | 5121 | |
87a16a06 | 5122 | |
12b88fff RS |
5123 | (defconst ps-font-type (vector nil 'bold 'italic 'bold-italic)) |
5124 | ||
5125 | ||
12d89a2e | 5126 | (defun ps-plot-with-face (from to face) |
12b88fff RS |
5127 | (cond |
5128 | ((null face) ; print text with null face | |
87a16a06 | 5129 | (ps-plot-region from to 0)) |
12b88fff RS |
5130 | ((eq face 'emacs--invisible--face)) ; skip invisible text!!! |
5131 | (t ; otherwise, text has a valid face | |
5132 | (let* ((face-bit (ps-face-attribute-list face)) | |
5133 | (effect (aref face-bit 0)) | |
5134 | (foreground (aref face-bit 1)) | |
906d41a7 | 5135 | (background (ps-face-background face (aref face-bit 2))) |
d3ab8dac | 5136 | (fg-color (if (and ps-color-p foreground) |
6e1b1da6 | 5137 | (ps-color-scale foreground) |
12b88fff | 5138 | ps-default-color)) |
d3ab8dac | 5139 | (bg-color (and ps-color-p background |
6e1b1da6 | 5140 | (ps-color-scale background)))) |
12b88fff RS |
5141 | (ps-plot-region |
5142 | from to | |
5143 | (ps-font-number 'ps-font-for-text | |
5144 | (or (aref ps-font-type (logand effect 3)) | |
5145 | face)) | |
5146 | fg-color bg-color (lsh effect -2))))) | |
87a16a06 | 5147 | (goto-char to)) |
12d89a2e RS |
5148 | |
5149 | ||
043620f4 KH |
5150 | ;; Ensure that face-list is fbound. |
5151 | (or (fboundp 'face-list) (defalias 'face-list 'list-faces)) | |
12d89a2e | 5152 | |
a18ed129 | 5153 | |
12d89a2e | 5154 | (defun ps-build-reference-face-lists () |
857686a6 RS |
5155 | ;; Ensure that face database is updated with faces on |
5156 | ;; `font-lock-face-attributes' (obsolete stuff) | |
5157 | (ps-font-lock-face-attributes) | |
5158 | ;; Now, rebuild reference face lists | |
a18ed129 | 5159 | (setq ps-print-face-alist nil) |
12d89a2e | 5160 | (if ps-auto-font-detect |
a18ed129 RS |
5161 | (mapcar 'ps-map-face (face-list)) |
5162 | (mapcar 'ps-set-face-bold ps-bold-faces) | |
5163 | (mapcar 'ps-set-face-italic ps-italic-faces) | |
5164 | (mapcar 'ps-set-face-underline ps-underlined-faces)) | |
12d89a2e | 5165 | (setq ps-build-face-reference nil)) |
ef2cbb24 | 5166 | |
a18ed129 RS |
5167 | |
5168 | (defun ps-set-face-bold (face) | |
5169 | (ps-set-face-attribute face 1)) | |
5170 | ||
5171 | (defun ps-set-face-italic (face) | |
5172 | (ps-set-face-attribute face 2)) | |
5173 | ||
5174 | (defun ps-set-face-underline (face) | |
5175 | (ps-set-face-attribute face 4)) | |
5176 | ||
5177 | ||
5178 | (defun ps-set-face-attribute (face effect) | |
5179 | (let ((face-bit (cdr (ps-map-face face)))) | |
5180 | (aset face-bit 0 (logior (aref face-bit 0) effect)))) | |
5181 | ||
5182 | ||
5183 | (defun ps-map-face (face) | |
5184 | (let* ((face-map (ps-screen-to-bit-face face)) | |
5185 | (ps-face-bit (cdr (assq (car face-map) ps-print-face-alist)))) | |
5186 | (if ps-face-bit | |
5187 | ;; if face exists, merge both | |
5188 | (let ((face-bit (cdr face-map))) | |
5189 | (aset ps-face-bit 0 (logior (aref ps-face-bit 0) (aref face-bit 0))) | |
5190 | (or (aref ps-face-bit 1) (aset ps-face-bit 1 (aref face-bit 1))) | |
5191 | (or (aref ps-face-bit 2) (aset ps-face-bit 2 (aref face-bit 2)))) | |
5192 | ;; if face does not exist, insert it | |
5193 | (setq ps-print-face-alist (cons face-map ps-print-face-alist))) | |
5194 | face-map)) | |
5195 | ||
5196 | ||
5197 | (defun ps-screen-to-bit-face (face) | |
5198 | (cons face | |
5199 | (vector (logior (if (ps-face-bold-p face) 1 0) ; bold | |
5200 | (if (ps-face-italic-p face) 2 0) ; italic | |
5201 | (if (ps-face-underlined-p face) 4 0)) ; underline | |
8e234846 GM |
5202 | (ps-face-foreground-name face) |
5203 | (ps-face-background-name face)))) | |
a18ed129 RS |
5204 | |
5205 | ||
3e9cb08f | 5206 | ;; to avoid compilation gripes |
ea0c615d GM |
5207 | (defun ps-print-ensure-fontified (start end) |
5208 | (cond | |
5209 | ((and (boundp 'jit-lock-mode) (symbol-value 'jit-lock-mode)) | |
5210 | (defalias 'ps-jitify 'jit-lock-fontify-now) ; avoid compilation gripes | |
5211 | (ps-jitify start end)) | |
5212 | ((and (boundp 'lazy-lock-mode) (symbol-value 'lazy-lock-mode)) | |
5213 | (defalias 'ps-lazify 'lazy-lock-fontify-region) ; avoid compilation gripes | |
5214 | (ps-lazify start end)))) | |
043620f4 | 5215 | |
043620f4 | 5216 | |
ef2cbb24 | 5217 | (defun ps-generate-postscript-with-faces (from to) |
87a16a06 | 5218 | ;; Some initialization... |
857686a6 | 5219 | (setq ps-current-effect 0) |
87a16a06 | 5220 | |
00aa16af | 5221 | ;; Build the reference lists of faces if necessary. |
8e234846 GM |
5222 | (when (or ps-always-build-face-reference |
5223 | ps-build-face-reference) | |
5224 | (message "Collecting face information...") | |
5225 | (ps-build-reference-face-lists)) | |
00aa16af | 5226 | ;; Generate some PostScript. |
ef2cbb24 RS |
5227 | (save-restriction |
5228 | (narrow-to-region from to) | |
d3ab8dac | 5229 | (ps-print-ensure-fontified from to) |
12d89a2e RS |
5230 | (let ((face 'default) |
5231 | (position to)) | |
87a16a06 | 5232 | (cond |
8e234846 | 5233 | ((memq ps-print-emacs-type '(xemacs lucid)) |
87a16a06 RS |
5234 | ;; Build the list of extents... |
5235 | (let ((a (cons 'dummy nil)) | |
5236 | record type extent extent-list) | |
3e9cb08f | 5237 | (ps-x-map-extents 'ps-mapper nil from to a) |
8bd22fcf KH |
5238 | (setq a (sort (cdr a) 'car-less-than-car) |
5239 | extent-list nil) | |
87a16a06 RS |
5240 | |
5241 | ;; Loop through the extents... | |
5242 | (while a | |
8bd22fcf | 5243 | (setq record (car a) |
87a16a06 | 5244 | |
8bd22fcf KH |
5245 | position (car record) |
5246 | record (cdr record) | |
87a16a06 | 5247 | |
8bd22fcf KH |
5248 | type (car record) |
5249 | record (cdr record) | |
87a16a06 | 5250 | |
8bd22fcf | 5251 | extent (car record)) |
87a16a06 RS |
5252 | |
5253 | ;; Plot up to this record. | |
5254 | ;; XEmacs 19.12: for some reason, we're getting into a | |
5255 | ;; situation in which some of the records have | |
5256 | ;; positions less than 'from'. Since we've narrowed | |
ea0c615d GM |
5257 | ;; the buffer, this'll generate errors. This is a hack, |
5258 | ;; but don't call ps-plot-with-face unless from > point-min. | |
3e9cb08f GM |
5259 | (and (>= from (point-min)) |
5260 | (ps-plot-with-face from (min position (point-max)) face)) | |
87a16a06 RS |
5261 | |
5262 | (cond | |
5263 | ((eq type 'push) | |
3e9cb08f | 5264 | (and (ps-x-extent-face extent) |
d3ab8dac KH |
5265 | (setq extent-list (sort (cons extent extent-list) |
5266 | 'ps-extent-sorter)))) | |
87a16a06 RS |
5267 | |
5268 | ((eq type 'pull) | |
5269 | (setq extent-list (sort (delq extent extent-list) | |
5270 | 'ps-extent-sorter)))) | |
5271 | ||
d3ab8dac | 5272 | (setq face (if extent-list |
3e9cb08f | 5273 | (ps-x-extent-face (car extent-list)) |
d3ab8dac | 5274 | 'default) |
8bd22fcf KH |
5275 | from position |
5276 | a (cdr a))))) | |
87a16a06 RS |
5277 | |
5278 | ((eq ps-print-emacs-type 'emacs) | |
5279 | (let ((property-change from) | |
e65df0a1 KH |
5280 | (overlay-change from) |
5281 | (save-buffer-invisibility-spec buffer-invisibility-spec) | |
c82b4a75 | 5282 | (buffer-invisibility-spec nil)) |
87a16a06 | 5283 | (while (< from to) |
d3ab8dac | 5284 | (and (< property-change to) ; Don't search for property change |
12d89a2e | 5285 | ; unless previous search succeeded. |
d3ab8dac KH |
5286 | (setq property-change (next-property-change from nil to))) |
5287 | (and (< overlay-change to) ; Don't search for overlay change | |
12d89a2e | 5288 | ; unless previous search succeeded. |
d3ab8dac KH |
5289 | (setq overlay-change (min (next-overlay-change from) to))) |
5290 | (setq position (min property-change overlay-change)) | |
87a16a06 RS |
5291 | ;; The code below is not quite correct, |
5292 | ;; because a non-nil overlay invisible property | |
5293 | ;; which is inactive according to the current value | |
5294 | ;; of buffer-invisibility-spec nonetheless overrides | |
5295 | ;; a face text property. | |
5296 | (setq face | |
5297 | (cond ((let ((prop (get-text-property from 'invisible))) | |
5298 | ;; Decide whether this invisible property | |
5299 | ;; really makes the text invisible. | |
e65df0a1 | 5300 | (if (eq save-buffer-invisibility-spec t) |
87a16a06 | 5301 | (not (null prop)) |
e65df0a1 KH |
5302 | (or (memq prop save-buffer-invisibility-spec) |
5303 | (assq prop save-buffer-invisibility-spec)))) | |
12b88fff | 5304 | 'emacs--invisible--face) |
87a16a06 RS |
5305 | ((get-text-property from 'face)) |
5306 | (t 'default))) | |
5307 | (let ((overlays (overlays-at from)) | |
5308 | (face-priority -1)) ; text-property | |
d3ab8dac KH |
5309 | (while (and overlays |
5310 | (not (eq face 'emacs--invisible--face))) | |
87a16a06 | 5311 | (let* ((overlay (car overlays)) |
87a16a06 | 5312 | (overlay-invisible (overlay-get overlay 'invisible)) |
d3ab8dac | 5313 | (overlay-priority (or (overlay-get overlay 'priority) |
87a16a06 | 5314 | 0))) |
d3ab8dac | 5315 | (and (> overlay-priority face-priority) |
e65df0a1 KH |
5316 | (setq face |
5317 | (cond ((if (eq save-buffer-invisibility-spec t) | |
5318 | (not (null overlay-invisible)) | |
5319 | (or (memq overlay-invisible | |
5320 | save-buffer-invisibility-spec) | |
5321 | (assq overlay-invisible | |
5322 | save-buffer-invisibility-spec))) | |
c82b4a75 | 5323 | 'emacs--invisible--face) |
d3ab8dac KH |
5324 | ((overlay-get overlay 'face)) |
5325 | (t face)) | |
8bd22fcf | 5326 | face-priority overlay-priority))) |
87a16a06 RS |
5327 | (setq overlays (cdr overlays)))) |
5328 | ;; Plot up to this record. | |
5329 | (ps-plot-with-face from position face) | |
5330 | (setq from position))))) | |
5331 | (ps-plot-with-face from to face)))) | |
ef2cbb24 RS |
5332 | |
5333 | (defun ps-generate-postscript (from to) | |
12d89a2e | 5334 | (ps-plot-region from to 0 nil)) |
ef2cbb24 RS |
5335 | |
5336 | (defun ps-generate (buffer from to genfunc) | |
87a16a06 RS |
5337 | (save-excursion |
5338 | (let ((from (min to from)) | |
5339 | (to (max to from)) | |
5340 | ;; This avoids trouble if chars with read-only properties | |
5341 | ;; are copied into ps-spool-buffer. | |
5342 | (inhibit-read-only t)) | |
5343 | (save-restriction | |
5344 | (narrow-to-region from to) | |
857686a6 RS |
5345 | (and ps-razzle-dazzle |
5346 | (message "Formatting...%3d%%" (setq ps-razchunk 0))) | |
8bd22fcf KH |
5347 | (setq ps-source-buffer buffer |
5348 | ps-spool-buffer (get-buffer-create ps-spool-buffer-name)) | |
87a16a06 RS |
5349 | (ps-init-output-queue) |
5350 | (let (safe-marker completed-safely needs-begin-file) | |
5351 | (unwind-protect | |
00aa16af RS |
5352 | (progn |
5353 | (set-buffer ps-spool-buffer) | |
7da17ab6 | 5354 | (set-buffer-multibyte nil) |
915293a2 | 5355 | |
87a16a06 RS |
5356 | ;; Get a marker and make it point to the current end of the |
5357 | ;; buffer, If an error occurs, we'll delete everything from | |
5358 | ;; the end of this marker onwards. | |
5359 | (setq safe-marker (make-marker)) | |
5360 | (set-marker safe-marker (point-max)) | |
5361 | ||
5362 | (goto-char (point-min)) | |
8bd22fcf KH |
5363 | (or (looking-at (regexp-quote ps-adobe-tag)) |
5364 | (setq needs-begin-file t)) | |
ea0c615d GM |
5365 | |
5366 | (set-buffer ps-source-buffer) | |
87a16a06 | 5367 | (save-excursion |
ea0c615d GM |
5368 | (let ((ps-print-page-p t) |
5369 | ps-even-or-odd-pages) | |
70f57a72 GM |
5370 | (ps-begin-job) |
5371 | (when needs-begin-file | |
5372 | (ps-begin-file) | |
5373 | (ps-mule-initialize)) | |
5374 | (ps-mule-begin-job from to) | |
ea0c615d GM |
5375 | (ps-selected-pages))) |
5376 | (ps-begin-page) | |
87a16a06 RS |
5377 | (funcall genfunc from to) |
5378 | (ps-end-page) | |
ea0c615d | 5379 | (ps-end-job needs-begin-file) |
87a16a06 RS |
5380 | |
5381 | ;; Setting this variable tells the unwind form that the | |
8bd22fcf | 5382 | ;; the PostScript was generated without error. |
87a16a06 RS |
5383 | (setq completed-safely t)) |
5384 | ||
5385 | ;; Unwind form: If some bad mojo occurred while generating | |
8bd22fcf | 5386 | ;; PostScript, delete all the PostScript that was generated. |
87a16a06 RS |
5387 | ;; This protects the previously spooled files from getting |
5388 | ;; corrupted. | |
8bd22fcf KH |
5389 | (and (markerp safe-marker) (not completed-safely) |
5390 | (progn | |
5391 | (set-buffer ps-spool-buffer) | |
5392 | (delete-region (marker-position safe-marker) (point-max)))))) | |
87a16a06 | 5393 | |
857686a6 | 5394 | (and ps-razzle-dazzle (message "Formatting...done")))))) |
ef2cbb24 | 5395 | |
e65df0a1 | 5396 | |
ea0c615d GM |
5397 | (defun ps-end-job (needs-begin-file) |
5398 | (let ((ps-print-page-p t)) | |
5399 | (ps-flush-output) | |
5400 | (save-excursion | |
5401 | (let ((pages-per-sheet (mod ps-page-n-up ps-n-up-printing)) | |
5402 | (total-lines (cdr ps-printing-region)) | |
5403 | (total-pages (ps-page-number)) | |
5404 | case-fold-search) | |
5405 | (set-buffer ps-spool-buffer) | |
5406 | ;; Back to the PS output buffer to set the last page n-up printing | |
5407 | (goto-char (point-max)) | |
5408 | (and (> pages-per-sheet 0) | |
5409 | (re-search-backward "^[0-9]+ BeginSheet$" nil t) | |
5410 | (replace-match (format "%d BeginSheet" pages-per-sheet) t)) | |
5411 | ;; Back to the PS output buffer to set the page count | |
5412 | (goto-char (point-min)) | |
5413 | (and (re-search-forward "^/Lines 0 def\n/PageCount 0 def$" nil t) | |
5414 | (replace-match (format "/Lines %d def\n/PageCount %d def" | |
5415 | total-lines total-pages) t)))) | |
5416 | ;; Set dummy page | |
5417 | (and ps-spool-duplex (= (mod ps-page-order 2) 1) | |
5418 | (let ((ps-n-up-printing 0)) | |
5419 | (ps-header-sheet) | |
5420 | (ps-output "/PrintHeader false def\n/ColumnIndex 0 def\n" | |
5421 | "/PrintLineNumber false def\nBeginPage\n") | |
5422 | (ps-end-page))) | |
5423 | ;; Set end of PostScript file | |
5424 | (ps-output "EndSheet\n\n%%Trailer\n%%Pages: " | |
5425 | (number-to-string | |
5426 | (if (and needs-begin-file | |
5427 | ps-banner-page-when-duplexing) | |
5428 | (1+ ps-page-order) | |
5429 | ps-page-order)) | |
5430 | "\n\nEndDoc\n\n%%EOF\n") | |
5431 | (ps-flush-output)) | |
5432 | ;; disable selected pages | |
1fd9b7fe | 5433 | (setq ps-selected-pages nil)) |
7d8b7e8e KH |
5434 | |
5435 | ||
857686a6 | 5436 | ;; Permit dynamic evaluation at print time of `ps-lpr-switches'. |
ef2cbb24 | 5437 | (defun ps-do-despool (filename) |
12d89a2e | 5438 | (if (or (not (boundp 'ps-spool-buffer)) |
bcc0d457 | 5439 | (not (symbol-value 'ps-spool-buffer))) |
12d89a2e | 5440 | (message "No spooled PostScript to print") |
ef2cbb24 RS |
5441 | (if filename |
5442 | (save-excursion | |
857686a6 | 5443 | (and ps-razzle-dazzle (message "Saving...")) |
12d89a2e | 5444 | (set-buffer ps-spool-buffer) |
ef2cbb24 | 5445 | (setq filename (expand-file-name filename)) |
7ffaf659 EZ |
5446 | (let ((coding-system-for-write 'raw-text-unix)) |
5447 | (write-region (point-min) (point-max) filename)) | |
857686a6 | 5448 | (and ps-razzle-dazzle (message "Wrote %s" filename))) |
ef2cbb24 | 5449 | ;; Else, spool to the printer |
857686a6 | 5450 | (and ps-razzle-dazzle (message "Printing...")) |
ef2cbb24 | 5451 | (save-excursion |
12d89a2e | 5452 | (set-buffer ps-spool-buffer) |
200127fd | 5453 | (let* ((coding-system-for-write 'raw-text-unix) |
298bfad9 KH |
5454 | (ps-printer-name (or ps-printer-name |
5455 | (and (boundp 'printer-name) | |
5456 | printer-name))) | |
200127fd | 5457 | (ps-lpr-switches |
3556c6dd GM |
5458 | (append ps-lpr-switches |
5459 | (and (stringp ps-printer-name) | |
5460 | (string< "" ps-printer-name) | |
5461 | (list (concat | |
5462 | (and (stringp ps-printer-name-option) | |
5463 | ps-printer-name-option) | |
5464 | ps-printer-name)))))) | |
52cf535f AI |
5465 | (apply (or ps-print-region-function 'call-process-region) |
5466 | (point-min) (point-max) ps-lpr-command nil | |
5467 | (and (fboundp 'start-process) 0) | |
5468 | nil | |
5469 | (ps-flatten-list ; dynamic evaluation | |
5470 | (mapcar 'ps-eval-switch ps-lpr-switches))))) | |
857686a6 | 5471 | (and ps-razzle-dazzle (message "Printing...done"))) |
12d89a2e RS |
5472 | (kill-buffer ps-spool-buffer))) |
5473 | ||
857686a6 RS |
5474 | ;; Dynamic evaluation |
5475 | (defun ps-eval-switch (arg) | |
5476 | (cond ((stringp arg) arg) | |
5477 | ((functionp arg) (apply arg nil)) | |
5478 | ((symbolp arg) (symbol-value arg)) | |
5479 | ((consp arg) (apply (car arg) (cdr arg))) | |
5480 | (t nil))) | |
5481 | ||
5482 | ;; `ps-flatten-list' is defined here (copied from "message.el" and | |
5483 | ;; enhanced to handle dotted pairs as well) until we can get some | |
5484 | ;; sensible autoloads, or `flatten-list' gets put somewhere decent. | |
5485 | ||
5486 | ;; (ps-flatten-list '((a . b) c (d . e) (f g h) i . j)) | |
5487 | ;; => (a b c d e f g h i j) | |
5488 | ||
5489 | (defun ps-flatten-list (&rest list) | |
5490 | (ps-flatten-list-1 list)) | |
5491 | ||
5492 | (defun ps-flatten-list-1 (list) | |
5493 | (cond ((null list) nil) | |
5494 | ((consp list) (append (ps-flatten-list-1 (car list)) | |
5495 | (ps-flatten-list-1 (cdr list)))) | |
5496 | (t (list list)))) | |
5497 | ||
12d89a2e RS |
5498 | (defun ps-kill-emacs-check () |
5499 | (let (ps-buffer) | |
8bd22fcf KH |
5500 | (and (setq ps-buffer (get-buffer ps-spool-buffer-name)) |
5501 | (buffer-modified-p ps-buffer) | |
5502 | (y-or-n-p "Unprinted PostScript waiting; print now? ") | |
5503 | (ps-despool)) | |
5504 | (and (setq ps-buffer (get-buffer ps-spool-buffer-name)) | |
5505 | (buffer-modified-p ps-buffer) | |
5506 | (not (yes-or-no-p "Unprinted PostScript waiting; exit anyway? ")) | |
5507 | (error "Unprinted PostScript")))) | |
12d89a2e | 5508 | |
d3ab8dac KH |
5509 | (cond ((fboundp 'add-hook) |
5510 | (funcall 'add-hook 'kill-emacs-hook 'ps-kill-emacs-check)) | |
5511 | (kill-emacs-hook | |
5512 | (message "Won't override existing `kill-emacs-hook'")) | |
5513 | (t | |
5514 | (setq kill-emacs-hook 'ps-kill-emacs-check))) | |
ef2cbb24 | 5515 | |
298bfad9 KH |
5516 | \f |
5517 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
12d89a2e | 5518 | ;;; Sample Setup Code: |
ef2cbb24 | 5519 | |
0a5daee5 | 5520 | |
12d89a2e | 5521 | ;; This stuff is for anybody that's brave enough to look this far, |
87a16a06 RS |
5522 | ;; and able to figure out how to use it. It isn't really part of |
5523 | ;; ps-print, but I'll leave it here in hopes it might be useful: | |
ef2cbb24 | 5524 | |
298bfad9 KH |
5525 | ;; WARNING!!! The following code is *sample* code only. |
5526 | ;; Don't use it unless you understand what it does! | |
043620f4 | 5527 | |
87a16a06 RS |
5528 | (defmacro ps-prsc () |
5529 | `(if (eq ps-print-emacs-type 'emacs) [f22] 'f22)) | |
5530 | (defmacro ps-c-prsc () | |
5531 | `(if (eq ps-print-emacs-type 'emacs) [C-f22] '(control f22))) | |
5532 | (defmacro ps-s-prsc () | |
5533 | `(if (eq ps-print-emacs-type 'emacs) [S-f22] '(shift f22))) | |
00aa16af | 5534 | |
a18ed129 RS |
5535 | ;; A hook to bind to `rmail-mode-hook' to locally bind prsc and set the |
5536 | ;; `ps-left-headers' specially for mail messages. | |
5537 | (defun ps-rmail-mode-hook () | |
5538 | (local-set-key (ps-prsc) 'ps-rmail-print-message-from-summary) | |
5539 | (setq ps-header-lines 3 | |
5540 | ps-left-header | |
5541 | ;; The left headers will display the message's subject, its | |
5542 | ;; author, and the name of the folder it was in. | |
5543 | '(ps-article-subject ps-article-author buffer-name))) | |
5544 | ||
5545 | ;; See `ps-gnus-print-article-from-summary'. This function does the | |
5546 | ;; same thing for rmail. | |
5547 | (defun ps-rmail-print-message-from-summary () | |
5548 | (interactive) | |
5549 | (ps-print-message-from-summary 'rmail-summary-buffer "RMAIL")) | |
5550 | ||
5551 | ;; Used in `ps-rmail-print-article-from-summary', | |
5552 | ;; `ps-gnus-print-article-from-summary' and `ps-vm-print-message-from-summary'. | |
5553 | (defun ps-print-message-from-summary (summary-buffer summary-default) | |
5554 | (let ((ps-buf (or (and (boundp summary-buffer) | |
5555 | (symbol-value summary-buffer)) | |
5556 | summary-default))) | |
5557 | (and (get-buffer ps-buf) | |
5558 | (save-excursion | |
5559 | (set-buffer ps-buf) | |
5560 | (ps-spool-buffer-with-faces))))) | |
5561 | ||
12d89a2e | 5562 | ;; Look in an article or mail message for the Subject: line. To be |
87a16a06 | 5563 | ;; placed in `ps-left-headers'. |
12d89a2e | 5564 | (defun ps-article-subject () |
ef2cbb24 | 5565 | (save-excursion |
12d89a2e | 5566 | (goto-char (point-min)) |
45a870d9 | 5567 | (if (re-search-forward "^Subject:[ \t]+\\(.*\\)$" nil t) |
edc9cd35 | 5568 | (buffer-substring (match-beginning 1) (match-end 1)) |
12d89a2e RS |
5569 | "Subject ???"))) |
5570 | ||
5571 | ;; Look in an article or mail message for the From: line. Sorta-kinda | |
5572 | ;; understands RFC-822 addresses and can pull the real name out where | |
87a16a06 | 5573 | ;; it's provided. To be placed in `ps-left-headers'. |
12d89a2e RS |
5574 | (defun ps-article-author () |
5575 | (save-excursion | |
5576 | (goto-char (point-min)) | |
a97592dd | 5577 | (if (re-search-forward "^From:[ \t]+\\(.*\\)$" nil t) |
edc9cd35 | 5578 | (let ((fromstring (buffer-substring (match-beginning 1) (match-end 1)))) |
12d89a2e RS |
5579 | (cond |
5580 | ||
5581 | ;; Try first to match addresses that look like | |
5582 | ;; thompson@wg2.waii.com (Jim Thompson) | |
5583 | ((string-match ".*[ \t]+(\\(.*\\))" fromstring) | |
5584 | (substring fromstring (match-beginning 1) (match-end 1))) | |
5585 | ||
5586 | ;; Next try to match addresses that look like | |
edc9cd35 GM |
5587 | ;; Jim Thompson <thompson@wg2.waii.com> or |
5588 | ;; "Jim Thompson" <thompson@wg2.waii.com> | |
5589 | ((string-match "\\(\"?\\)\\(.*\\)\\1[ \t]+<.*>" fromstring) | |
5590 | (substring fromstring (match-beginning 2) (match-end 2))) | |
12d89a2e RS |
5591 | |
5592 | ;; Couldn't find a real name -- show the address instead. | |
5593 | (t fromstring))) | |
5594 | "From ???"))) | |
5595 | ||
a18ed129 | 5596 | ;; A hook to bind to `gnus-article-prepare-hook'. This will set the |
87a16a06 RS |
5597 | ;; `ps-left-headers' specially for gnus articles. Unfortunately, |
5598 | ;; `gnus-article-mode-hook' is called only once, the first time the *Article* | |
12d89a2e RS |
5599 | ;; buffer enters that mode, so it would only work for the first time |
5600 | ;; we ran gnus. The second time, this hook wouldn't get set up. The | |
87a16a06 | 5601 | ;; only alternative is `gnus-article-prepare-hook'. |
12d89a2e | 5602 | (defun ps-gnus-article-prepare-hook () |
8bd22fcf KH |
5603 | (setq ps-header-lines 3 |
5604 | ps-left-header | |
12d89a2e RS |
5605 | ;; The left headers will display the article's subject, its |
5606 | ;; author, and the newsgroup it was in. | |
8bd22fcf | 5607 | '(ps-article-subject ps-article-author gnus-newsgroup-name))) |
12d89a2e | 5608 | |
a18ed129 RS |
5609 | ;; A hook to bind to `vm-mode-hook' to locally bind prsc and set the |
5610 | ;; `ps-left-headers' specially for mail messages. | |
12d89a2e | 5611 | (defun ps-vm-mode-hook () |
00aa16af | 5612 | (local-set-key (ps-prsc) 'ps-vm-print-message-from-summary) |
8bd22fcf KH |
5613 | (setq ps-header-lines 3 |
5614 | ps-left-header | |
12d89a2e RS |
5615 | ;; The left headers will display the message's subject, its |
5616 | ;; author, and the name of the folder it was in. | |
8bd22fcf | 5617 | '(ps-article-subject ps-article-author buffer-name))) |
12d89a2e RS |
5618 | |
5619 | ;; Every now and then I forget to switch from the *Summary* buffer to | |
5620 | ;; the *Article* before hitting prsc, and a nicely formatted list of | |
5621 | ;; article subjects shows up at the printer. This function, bound to | |
5622 | ;; prsc for the gnus *Summary* buffer means I don't have to switch | |
5623 | ;; buffers first. | |
87a16a06 | 5624 | ;; sb: Updated for Gnus 5. |
12d89a2e RS |
5625 | (defun ps-gnus-print-article-from-summary () |
5626 | (interactive) | |
a18ed129 | 5627 | (ps-print-message-from-summary 'gnus-article-buffer "*Article*")) |
ef2cbb24 | 5628 | |
87a16a06 | 5629 | ;; See `ps-gnus-print-article-from-summary'. This function does the |
12d89a2e RS |
5630 | ;; same thing for vm. |
5631 | (defun ps-vm-print-message-from-summary () | |
5632 | (interactive) | |
a18ed129 | 5633 | (ps-print-message-from-summary 'vm-mail-buffer "")) |
ef2cbb24 | 5634 | |
87a16a06 | 5635 | ;; A hook to bind to bind to `gnus-summary-setup-buffer' to locally bind |
12d89a2e RS |
5636 | ;; prsc. |
5637 | (defun ps-gnus-summary-setup () | |
00aa16af | 5638 | (local-set-key (ps-prsc) 'ps-gnus-print-article-from-summary)) |
12d89a2e RS |
5639 | |
5640 | ;; Look in an article or mail message for the Subject: line. To be | |
87a16a06 | 5641 | ;; placed in `ps-left-headers'. |
12d89a2e RS |
5642 | (defun ps-info-file () |
5643 | (save-excursion | |
5644 | (goto-char (point-min)) | |
a97592dd | 5645 | (if (re-search-forward "File:[ \t]+\\([^, \t\n]*\\)" nil t) |
edc9cd35 | 5646 | (buffer-substring (match-beginning 1) (match-end 1)) |
12d89a2e RS |
5647 | "File ???"))) |
5648 | ||
5649 | ;; Look in an article or mail message for the Subject: line. To be | |
87a16a06 | 5650 | ;; placed in `ps-left-headers'. |
12d89a2e RS |
5651 | (defun ps-info-node () |
5652 | (save-excursion | |
5653 | (goto-char (point-min)) | |
a97592dd | 5654 | (if (re-search-forward "Node:[ \t]+\\([^,\t\n]*\\)" nil t) |
edc9cd35 | 5655 | (buffer-substring (match-beginning 1) (match-end 1)) |
12d89a2e RS |
5656 | "Node ???"))) |
5657 | ||
5658 | (defun ps-info-mode-hook () | |
5659 | (setq ps-left-header | |
5660 | ;; The left headers will display the node name and file name. | |
8bd22fcf | 5661 | '(ps-info-node ps-info-file))) |
12d89a2e | 5662 | |
043620f4 KH |
5663 | ;; WARNING! The following function is a *sample* only, and is *not* |
5664 | ;; meant to be used as a whole unless you understand what the effects | |
87a16a06 RS |
5665 | ;; will be! (In fact, this is a copy of Jim's setup for ps-print -- |
5666 | ;; I'd be very surprised if it was useful to *anybody*, without | |
043620f4 KH |
5667 | ;; modification.) |
5668 | ||
12d89a2e | 5669 | (defun ps-jts-ps-setup () |
00aa16af RS |
5670 | (global-set-key (ps-prsc) 'ps-spool-buffer-with-faces) ;f22 is prsc |
5671 | (global-set-key (ps-s-prsc) 'ps-spool-region-with-faces) | |
5672 | (global-set-key (ps-c-prsc) 'ps-despool) | |
12d89a2e RS |
5673 | (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook) |
5674 | (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup) | |
5675 | (add-hook 'vm-mode-hook 'ps-vm-mode-hook) | |
00aa16af | 5676 | (add-hook 'vm-mode-hooks 'ps-vm-mode-hook) |
12d89a2e | 5677 | (add-hook 'Info-mode-hook 'ps-info-mode-hook) |
8bd22fcf KH |
5678 | (setq ps-spool-duplex t |
5679 | ps-print-color-p nil | |
5680 | ps-lpr-command "lpr" | |
5681 | ps-lpr-switches '("-Jjct,duplex_long")) | |
bcc0d457 RS |
5682 | 'ps-jts-ps-setup) |
5683 | ||
5684 | ;; WARNING! The following function is a *sample* only, and is *not* | |
5685 | ;; meant to be used as a whole unless it corresponds to your needs. | |
5686 | ;; (In fact, this is a copy of Jack's setup for ps-print -- | |
5687 | ;; I would not be that surprised if it was useful to *anybody*, | |
5688 | ;; without modification.) | |
5689 | ||
5690 | (defun ps-jack-setup () | |
87a16a06 | 5691 | (setq ps-print-color-p nil |
bcc0d457 | 5692 | ps-lpr-command "lpr" |
8bd22fcf | 5693 | ps-lpr-switches nil |
bcc0d457 | 5694 | |
87a16a06 RS |
5695 | ps-paper-type 'a4 |
5696 | ps-landscape-mode t | |
bcc0d457 RS |
5697 | ps-number-of-columns 2 |
5698 | ||
5699 | ps-left-margin (/ (* 72 1.0) 2.54) ; 1.0 cm | |
5700 | ps-right-margin (/ (* 72 1.0) 2.54) ; 1.0 cm | |
5701 | ps-inter-column (/ (* 72 1.0) 2.54) ; 1.0 cm | |
5702 | ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm | |
5703 | ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm | |
5704 | ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm | |
5705 | ps-header-line-pad .15 | |
5706 | ps-print-header t | |
5707 | ps-print-header-frame t | |
5708 | ps-header-lines 2 | |
5709 | ps-show-n-of-n t | |
5710 | ps-spool-duplex nil | |
5711 | ||
5712 | ps-font-family 'Courier | |
5713 | ps-font-size 5.5 | |
5714 | ps-header-font-family 'Helvetica | |
5715 | ps-header-font-size 6 | |
5716 | ps-header-title-font-size 8) | |
5717 | 'ps-jack-setup) | |
12d89a2e | 5718 | |
298bfad9 KH |
5719 | \f |
5720 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
5721 | ;; To make this file smaller, some commands go in a separate file. | |
5722 | ;; But autoload them here to make the separation invisible. | |
5723 | ||
5724 | (autoload 'ps-mule-prepare-ascii-font "ps-mule" | |
5725 | "Setup special ASCII font for STRING. | |
5726 | STRING should contain only ASCII characters.") | |
5727 | ||
5728 | (autoload 'ps-mule-set-ascii-font "ps-mule" | |
5729 | "Adjust current font if current charset is not ASCII.") | |
5730 | ||
5731 | (autoload 'ps-mule-plot-string "ps-mule" | |
5732 | "Generate PostScript code for ploting characters in the region FROM and TO. | |
5733 | ||
5734 | It is assumed that all characters in this region belong to the same charset. | |
5735 | ||
5736 | Optional argument BG-COLOR specifies background color. | |
5737 | ||
5738 | Returns the value: | |
5739 | ||
5740 | (ENDPOS . RUN-WIDTH) | |
5741 | ||
5742 | Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of | |
5743 | the sequence.") | |
5744 | ||
5745 | (autoload 'ps-mule-initialize "ps-mule" | |
5746 | "Initialize global data for printing multi-byte characters.") | |
5747 | ||
5748 | (autoload 'ps-mule-begin-job "ps-mule" | |
5749 | "Start printing job for multi-byte chars between FROM and TO. | |
5750 | This checks if all multi-byte characters in the region are printable or not.") | |
5751 | ||
5752 | (autoload 'ps-mule-begin-page "ps-mule" | |
5753 | "Initialize multi-byte charset for printing current page.") | |
5754 | ||
5755 | \f | |
5756 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
5757 | ||
12d89a2e | 5758 | (provide 'ps-print) |
b87c5d3d | 5759 | |
12d89a2e | 5760 | ;;; ps-print.el ends here |