Add "Package:" file headers to denote built-in packages.
[emacs.git] / lisp / ps-print.el
blob244308c4d0f5d3dd25bc10b098cf052447a9158f
1 ;;; ps-print.el --- print text from the buffer as PostScript
3 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
4 ;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 ;; Free Software Foundation, Inc.
7 ;; Author: Jim Thompson (was <thompson@wg2.waii.com>)
8 ;; Jacques Duthen (was <duthen@cegelec-red.fr>)
9 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
10 ;; Kenichi Handa <handa@m17n.org> (multi-byte characters)
11 ;; Maintainer: Kenichi Handa <handa@m17n.org> (multi-byte characters)
12 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
13 ;; Keywords: wp, print, PostScript
14 ;; Version: 7.3.5
15 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
16 ;; Package: ps-print
18 (defconst ps-print-version "7.3.5"
19 "ps-print.el, v 7.3.5 <2009/12/23 vinicius>
21 Vinicius's last change version -- this file may have been edited as part of
22 Emacs without changes to the version number. When reporting bugs, please also
23 report the version of Emacs, if any, that ps-print was distributed with.
25 Please send all bug fixes and enhancements to
26 Vinicius Jose Latorre <viniciusjl@ig.com.br>.")
28 ;; This file is part of GNU Emacs.
30 ;; GNU Emacs is free software: you can redistribute it and/or modify
31 ;; it under the terms of the GNU General Public License as published by
32 ;; the Free Software Foundation, either version 3 of the License, or
33 ;; (at your option) any later version.
35 ;; GNU Emacs is distributed in the hope that it will be useful,
36 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
37 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 ;; GNU General Public License for more details.
40 ;; You should have received a copy of the GNU General Public License
41 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
43 ;;; Commentary:
45 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 ;; About ps-print
48 ;; --------------
50 ;; This package provides printing of Emacs buffers on PostScript printers; the
51 ;; buffer's bold and italic text attributes are preserved in the printer
52 ;; output. ps-print is intended for use with Emacs or XEmacs, together with a
53 ;; fontifying package such as font-lock or hilit.
55 ;; ps-print uses the same face attributes defined through font-lock or hilit to
56 ;; print a PostScript file, but some faces are better seeing on the screen than
57 ;; on paper, specially when you have a black/white PostScript printer.
59 ;; ps-print allows a remap of face to another one that it is better to print,
60 ;; for example, the face font-lock-comment-face (if you are using font-lock)
61 ;; could have bold or italic attribute when printing, besides foreground color.
62 ;; This remap improves printing look (see How Ps-Print Maps Faces).
65 ;; Using ps-print
66 ;; --------------
68 ;; ps-print provides eight commands for generating PostScript images of Emacs
69 ;; buffers:
71 ;; ps-print-buffer
72 ;; ps-print-buffer-with-faces
73 ;; ps-print-region
74 ;; ps-print-region-with-faces
75 ;; ps-spool-buffer
76 ;; ps-spool-buffer-with-faces
77 ;; ps-spool-region
78 ;; ps-spool-region-with-faces
80 ;; These commands all perform essentially the same function: they generate
81 ;; PostScript images suitable for printing on a PostScript printer or
82 ;; displaying with GhostScript. These commands are collectively referred to as
83 ;; "ps-print- commands".
85 ;; The word "print" or "spool" in the command name determines when the
86 ;; PostScript image is sent to the printer:
88 ;; print - The PostScript image is immediately sent to the printer;
90 ;; spool - The PostScript image is saved temporarily in an Emacs
91 ;; buffer. Many images may be spooled locally before
92 ;; printing them. To send the spooled images to the
93 ;; printer, use the command `ps-despool'.
95 ;; The spooling mechanism was designed for printing lots of small files (mail
96 ;; messages or netnews articles) to save paper that would otherwise be wasted
97 ;; on banner pages, and to make it easier to find your output at the printer
98 ;; (it's easier to pick up one 50-page printout than to find 50 single-page
99 ;; printouts).
101 ;; ps-print has a hook in the `kill-emacs-hook' so that you won't accidentally
102 ;; quit from Emacs while you have unprinted PostScript waiting in the spool
103 ;; buffer. If you do attempt to exit with spooled PostScript, you'll be asked
104 ;; if you want to print it, and if you decline, you'll be asked to confirm the
105 ;; exit; this is modeled on the confirmation that Emacs uses for modified
106 ;; buffers.
108 ;; The word "buffer" or "region" in the command name determines how much of the
109 ;; buffer is printed:
111 ;; buffer - Print the entire buffer.
113 ;; region - Print just the current region.
115 ;; The -with-faces suffix on the command name means that the command will
116 ;; include font, color, and underline information in the PostScript image, so
117 ;; the printed image can look as pretty as the buffer. The ps-print- commands
118 ;; without the -with-faces suffix don't include font, color, or underline
119 ;; information; images printed with these commands aren't as pretty, but are
120 ;; faster to generate.
122 ;; Two ps-print- command examples:
124 ;; ps-print-buffer - print the entire buffer, without font,
125 ;; color, or underline information, and
126 ;; send it immediately to the printer.
128 ;; ps-spool-region-with-faces - print just the current region; include
129 ;; font, color, and underline information,
130 ;; and spool the image in Emacs to send to
131 ;; the printer later.
134 ;; Invoking Ps-Print
135 ;; -----------------
137 ;; To print your buffer, type
139 ;; M-x ps-print-buffer
141 ;; or substitute one of the other seven ps-print- commands. The command will
142 ;; generate the PostScript image and print or spool it as specified. By giving
143 ;; the command a prefix argument
145 ;; C-u M-x ps-print-buffer
147 ;; it will save the PostScript image to a file instead of sending it to the
148 ;; printer; you will be prompted for the name of the file to save the image to.
149 ;; The prefix argument is ignored by the commands that spool their images, but
150 ;; you may save the spooled images to a file by giving a prefix argument to
151 ;; `ps-despool':
153 ;; C-u M-x ps-despool
155 ;; When invoked this way, `ps-despool' will prompt you for the name of the file
156 ;; to save to.
158 ;; Any of the `ps-print-' commands can be bound to keys; I recommend binding
159 ;; `ps-spool-buffer-with-faces', `ps-spool-region-with-faces', and
160 ;; `ps-despool'. Here are the bindings I use on my Sun 4 keyboard:
162 ;; (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc
163 ;; (global-set-key '(shift f22) 'ps-spool-region-with-faces)
164 ;; (global-set-key '(control f22) 'ps-despool)
167 ;; The Printer Interface
168 ;; ---------------------
170 ;; The variables `ps-lpr-command' and `ps-lpr-switches' determine what command
171 ;; is used to send the PostScript images to the printer, and what arguments to
172 ;; give the command. These are analogous to `lpr-command' and `lpr-switches'.
174 ;; Make sure that they contain appropriate values for your system;
175 ;; see the usage notes below and the documentation of these variables.
177 ;; The variable `ps-printer-name' determines the name of a local printer for
178 ;; printing PostScript files.
180 ;; The variable `ps-printer-name-option' determines the option used by some
181 ;; utilities to indicate the printer name, it's used only when
182 ;; `ps-printer-name' is a non-empty string. If you're using lpr utility to
183 ;; print, for example, `ps-printer-name-option' should be set to "-P".
185 ;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values from
186 ;; the variables `lpr-command' and `lpr-switches'. If you have
187 ;; `lpr-command' set to invoke a pretty-printer such as `enscript', then
188 ;; ps-print won't work properly. `ps-lpr-command' must name a program
189 ;; that does not format the files it prints.
190 ;; `ps-printer-name' takes its initial value from the variable
191 ;; `printer-name'. `ps-printer-name-option' tries to guess which system
192 ;; Emacs is running and takes its initial value in accordance with this
193 ;; guess.
195 ;; The variable `ps-print-region-function' specifies a function to print the
196 ;; region on a PostScript printer.
197 ;; See definition of `call-process-region' for calling conventions. The fourth
198 ;; and the sixth arguments are both nil.
200 ;; The variable `ps-manual-feed' indicates if the printer will manually feed
201 ;; paper. If it's nil, automatic feeding takes place. If it's non-nil, manual
202 ;; feeding takes place. The default is nil (automatic feeding).
204 ;; The variable `ps-end-with-control-d' specifies whether C-d (\x04) should be
205 ;; inserted at end of PostScript generated. Non-nil means do so. The default
206 ;; is nil (don't insert).
208 ;; If you're using Emacs for Windows 95/98/NT or MS-DOS, don't forget to
209 ;; customize the following variables: `ps-printer-name',
210 ;; `ps-printer-name-option', `ps-lpr-command', `ps-lpr-switches' and
211 ;; `ps-spool-config'. See these variables documentation in the code or by
212 ;; typing, for example, C-h v ps-printer-name RET.
215 ;; The Page Layout
216 ;; ---------------
218 ;; All dimensions are floats in PostScript points.
219 ;; 1 inch == 2.54 cm == 72 points
220 ;; 1 cm == (/ 1 2.54) inch == (/ 72 2.54) points
222 ;; The variable `ps-paper-type' determines the size of paper ps-print formats
223 ;; for; it should contain one of the symbols: `a4' `a3' `letter' `legal'
224 ;; `letter-small' `tabloid' `ledger' `statement' `executive' `a4small' `b4'
225 ;; `b5'.
227 ;; If variable `ps-warn-paper-type' is nil, it's *not* given an error if
228 ;; PostScript printer doesn't have a paper with the size indicated by
229 ;; `ps-paper-type', instead it uses the default paper size. If variable
230 ;; `ps-warn-paper-type' is non-nil, it's given an error if PostScript printer
231 ;; doesn't have a paper with the size indicated by `ps-paper-type'. It's used
232 ;; when `ps-spool-config' is set to `setpagedevice' (see section Duplex
233 ;; Printers). The default value is non-nil (it gives an error).
235 ;; The variable `ps-landscape-mode' determines the orientation of the printing
236 ;; on the page: nil means `portrait' mode, non-nil means `landscape' mode.
237 ;; There is no oblique mode yet, though this is easy to do in ps.
239 ;; In landscape mode, the text is NOT scaled: you may print 70 lines in
240 ;; portrait mode and only 50 lines in landscape mode. The margins represent
241 ;; margins in the printed paper: the top margin is the margin between the top
242 ;; of the page and the printed header, whatever the orientation is.
244 ;; The variable `ps-number-of-columns' determines the number of columns both in
245 ;; landscape and portrait mode.
246 ;; You can use:
247 ;; - (the standard) one column portrait mode.
248 ;; - (my favorite) two columns landscape mode (which spares trees).
249 ;; but also:
250 ;; - one column landscape mode for files with very long lines.
251 ;; - multi-column portrait or landscape mode.
253 ;; The variable `ps-print-upside-down' determines other orientation for
254 ;; printing page: nil means `normal' printing, non-nil means `upside-down'
255 ;; printing (that is, the page is rotated by 180 grades). The default value is
256 ;; nil (`normal' printing).
258 ;; The `upside-down' orientation can be used in portrait or landscape mode.
260 ;; The variable `ps-selected-pages' specifies which pages to print. If it's
261 ;; nil, all pages are printed. If it's a list, the list element may be an
262 ;; integer or a cons cell (FROM . TO) designating FROM page to TO page; any
263 ;; invalid element is ignored, that is, an integer lesser than one or if FROM
264 ;; is greater than TO. Otherwise, it's treated as nil. The default value is
265 ;; nil (print all pages). After ps-print processing `ps-selected-pages' is set
266 ;; to nil. But the latest `ps-selected-pages' is saved in
267 ;; `ps-last-selected-pages' (see it for documentation). So you can restore the
268 ;; latest selected pages by using `ps-last-selected-pages' or by calling
269 ;; `ps-restore-selected-pages' command (see it for documentation).
271 ;; The variable `ps-even-or-odd-pages' specifies if it prints even/odd pages.
273 ;; Valid values are:
275 ;; nil print all pages.
277 ;; even-page print only even pages.
279 ;; odd-page print only odd pages.
281 ;; even-sheet print only even sheets.
283 ;; odd-sheet print only odd sheets.
285 ;; Any other value is treated as nil. The default value is nil.
287 ;; See `ps-even-or-odd-pages' for more detailed documentation.
290 ;; Horizontal layout
291 ;; -----------------
293 ;; The horizontal layout is determined by the variables
294 ;; `ps-left-margin' `ps-inter-column' `ps-right-margin'
295 ;; as follows:
297 ;; ------------------------------------------
298 ;; | | | | | | | |
299 ;; | lm | text | ic | text | ic | text | rm |
300 ;; | | | | | | | |
301 ;; ------------------------------------------
303 ;; If `ps-number-of-columns' is 1, `ps-inter-column' is not relevant.
304 ;; Usually, lm = rm > 0 and ic = lm
305 ;; If (ic < 0), the text of adjacent columns can overlap.
308 ;; Vertical layout
309 ;; ---------------
311 ;; The vertical layout is determined by the variables
312 ;; `ps-bottom-margin' `ps-top-margin' `ps-header-offset' `ps-footer-offset'
313 ;; as follows:
315 ;; |--------| |--------| |--------| |--------|
316 ;; | tm | | tm | | tm | | tm |
317 ;; |--------| |--------| |--------| |--------|
318 ;; | header | | | | header | | |
319 ;; |--------| | | |--------| | |
320 ;; | ho | | | | ho | | |
321 ;; |--------| | | |--------| | |
322 ;; | | | | | | | |
323 ;; | text | or | text | or | text | or | text |
324 ;; | | | | | | | |
325 ;; | | |--------| |--------| | |
326 ;; | | | fo | | fo | | |
327 ;; | | |--------| |--------| | |
328 ;; | | | footer | | footer | | |
329 ;; |--------| |--------| |--------| |--------|
330 ;; | bm | | bm | | bm | | bm |
331 ;; |--------| |--------| |--------| |--------|
333 ;; If `ps-print-header' is nil, `ps-header-offset' is not relevant.
334 ;; If `ps-print-footer' is nil, `ps-footer-offset' is not relevant.
335 ;; The margins represent margins in the printed paper:
336 ;; the top margin is the margin between the top of the page and the printed
337 ;; header, whatever the orientation is;
338 ;; the bottom margin is the margin between the bottom of the page and the
339 ;; printed footer, whatever the orientation is.
342 ;; Headers & Footers
343 ;; -----------------
345 ;; ps-print can print headers at the top of each column or at the top of each
346 ;; page; the default headers contain the following four items: on the left, the
347 ;; name of the buffer and, if the buffer is visiting a file, the file's
348 ;; directory; on the right, the page number and date of printing. The default
349 ;; headers look something like this:
351 ;; ps-print.el 1/21
352 ;; /home/jct/emacs-lisp/ps/new 94/12/31
354 ;; When printing on duplex printers, left and right are reversed so that the
355 ;; page numbers are toward the outside (cf. `ps-spool-duplex').
357 ;; Headers are configurable:
358 ;; To turn them off completely, set `ps-print-header' to nil.
359 ;; To turn off the header's gaudy framing box,
360 ;; set `ps-print-header-frame' to nil.
362 ;; The variable `ps-header-frame-alist' specifies header frame properties
363 ;; alist. Valid frame properties are:
365 ;; fore-color Specify the foreground frame color.
366 ;; It should be a float number between 0.0 (black color)
367 ;; and 1.0 (white color), a string which is a color name,
368 ;; or a list of 3 float numbers which corresponds to the
369 ;; Red Green Blue color scale, each float number between
370 ;; 0.0 (dark color) and 1.0 (bright color).
371 ;; The default is 0 ("black").
373 ;; back-color Specify the background frame color (similar to
374 ;; fore-color). The default is 0.9 ("gray90").
376 ;; shadow-color Specify the shadow color (similar to fore-color).
377 ;; The default is 0 ("black").
379 ;; border-color Specify the border color (similar to fore-color).
380 ;; The default is 0 ("black").
382 ;; border-width Specify the border width.
383 ;; The default is 0.4.
385 ;; Any other property is ignored.
387 ;; Don't change this alist directly, instead use customization, or `ps-value',
388 ;; `ps-get', `ps-put' and `ps-del' functions (see them for documentation).
390 ;; To print only one header at the top of each page, set
391 ;; `ps-print-only-one-header' to t.
393 ;; To switch headers, set `ps-switch-header' to:
395 ;; nil Never switch headers.
397 ;; t Always switch headers.
399 ;; duplex Switch headers only when duplexing is on, that is, when
400 ;; `ps-spool-duplex' is non-nil (see Duplex Printers).
402 ;; Any other value is treated as t. The default value is `duplex'.
404 ;; The font family and size of text in the header are determined by the
405 ;; variables `ps-header-font-family', `ps-header-font-size' and
406 ;; `ps-header-title-font-size' (see below).
408 ;; The variable `ps-header-line-pad' determines the portion of a header title
409 ;; line height to insert between the header frame and the text it contains,
410 ;; both in the vertical and horizontal directions: .5 means half a line.
412 ;; Page numbers are printed in `n/m' format, indicating page n of m pages; to
413 ;; omit the total page count and just print the page number, set
414 ;; `ps-show-n-of-n' to nil.
416 ;; The amount of information in the header can be changed by changing the
417 ;; number of lines. To show less, set `ps-header-lines' to 1, and the header
418 ;; will show only the buffer name and page number. To show more, set
419 ;; `ps-header-lines' to 3, and the header will show the time of printing below
420 ;; the date.
422 ;; To change the content of the headers, change the variables `ps-left-header'
423 ;; and `ps-right-header'.
424 ;; These variables are lists, specifying top-to-bottom the text to display on
425 ;; the left or right side of the header. Each element of the list should be a
426 ;; string or a symbol. Strings are inserted directly into the PostScript
427 ;; arrays, and should contain the PostScript string delimiters '(' and ')'.
429 ;; Symbols in the header format lists can either represent functions or
430 ;; variables. Functions are called, and should return a string to show in the
431 ;; header. Variables should contain strings to display in the header. In
432 ;; either case, function or variable, the PostScript string delimiters are
433 ;; added by ps-print, and should not be part of the returned value.
435 ;; Here's an example: say we want the left header to display the text
437 ;; Moe
438 ;; Larry
439 ;; Curly
441 ;; where we have a function to return "Moe"
443 ;; (defun moe-func ()
444 ;; "Moe")
446 ;; a variable specifying "Larry"
448 ;; (setq larry-var "Larry")
450 ;; and a literal for "Curly". Here's how `ps-left-header' should be set:
452 ;; (setq ps-left-header (list 'moe-func 'larry-var "(Curly)"))
454 ;; Note that Curly has the PostScript string delimiters inside his quotes --
455 ;; those aren't misplaced lisp delimiters!
457 ;; Without them, PostScript would attempt to call the undefined function Curly,
458 ;; which would result in a PostScript error.
460 ;; Since most printers don't report PostScript errors except by aborting the
461 ;; print job, this kind of error can be hard to track down.
463 ;; Consider yourself warned!
465 ;; ps-print also print footers. The footer variables are: `ps-print-footer',
466 ;; `ps-footer-offset', `ps-print-footer-frame', `ps-footer-font-family',
467 ;; `ps-footer-font-size', `ps-footer-line-pad', `ps-footer-lines',
468 ;; `ps-left-footer', `ps-right-footer' and `ps-footer-frame-alist'. These
469 ;; variables are similar to those one that control headers.
471 ;; The variables `ps-print-only-one-header' and `ps-switch-header' also control
472 ;; the footer (The same way that control header).
474 ;; As a footer example, if you want to have a centered page number in the
475 ;; footer but without headers, set:
477 ;; (setq ps-print-header nil
478 ;; ps-print-footer t
479 ;; ps-print-footer-frame nil
480 ;; ps-footer-lines 1
481 ;; ps-right-footer nil
482 ;; ps-left-footer
483 ;; (list (concat "{pagenumberstring dup stringwidth pop"
484 ;; " 2 div PrintWidth 2 div exch sub 0 rmoveto}")))
487 ;; PostScript Prologue Header
488 ;; --------------------------
490 ;; It is possible to add PostScript prologue header comments besides that
491 ;; ps-print generates by setting the variable `ps-print-prologue-header'.
493 ;; `ps-print-prologue-header' may be a string or a symbol function which
494 ;; returns a string. Note that this string is inserted on PostScript prologue
495 ;; header section which is used to define some document characteristic through
496 ;; PostScript special comments, like "%%Requirements: jog\n".
498 ;; By default `ps-print-prologue-header' is nil.
500 ;; ps-print always inserts the %%Requirements: comment, so if you need to
501 ;; insert more requirements put them first in `ps-print-prologue-header' using
502 ;; the "%%+" comment. For example, if you need to set numcopies to 3 and jog
503 ;; on requirements and set %%LanguageLevel: to 2, do:
505 ;; (setq ps-print-prologue-header
506 ;; "%%+ numcopies(3) jog\n%%LanguageLevel: 2\n")
508 ;; The duplex requirement is inserted by ps-print (see section Duplex
509 ;; Printers).
511 ;; Do not forget to terminate the string with "\n".
513 ;; For more information about PostScript document comments, see:
514 ;; PostScript Language Reference Manual (2nd edition)
515 ;; Adobe Systems Incorporated
516 ;; Appendix G: Document Structuring Conventions -- Version 3.0
518 ;; It is also possible to add an user defined PostScript prologue code before
519 ;; all generated prologue code by setting the variable
520 ;; `ps-user-defined-prologue'.
522 ;; `ps-user-defined-prologue' may be a string or a symbol function which
523 ;; returns a string. Note that this string is inserted after `ps-adobe-tag'
524 ;; and PostScript prologue comments, and before ps-print PostScript prologue
525 ;; code section. That is, this string is inserted after error handler
526 ;; initialization and before ps-print settings.
528 ;; By default `ps-user-defined-prologue' is nil.
530 ;; It's strongly recommended only insert PostScript code and/or comments
531 ;; specific for your printing system particularities. For example, some
532 ;; special initialization that only your printing system needs.
534 ;; Do not insert code for duplex printing, n-up printing or error handler,
535 ;; ps-print handles this in a suitable way.
537 ;; For more information about PostScript, see:
538 ;; PostScript Language Reference Manual (2nd edition)
539 ;; Adobe Systems Incorporated
541 ;; As an example for `ps-user-defined-prologue' setting:
543 ;; ;; Setting for HP PostScript printer
544 ;; (setq ps-user-defined-prologue
545 ;; (concat "<</DeferredMediaSelection true /PageSize [612 792] "
546 ;; "/MediaPosition 2 /MediaType (Plain)>> setpagedevice"))
549 ;; PostScript Error Handler
550 ;; ------------------------
552 ;; ps-print instruments generated PostScript code with an error handler.
554 ;; The variable `ps-error-handler-message' specifies where the error handler
555 ;; message should be sent.
557 ;; Valid values are:
559 ;; none catch the error and *DON'T* send any message.
561 ;; paper catch the error and print on paper the error message.
562 ;; This is the default value.
564 ;; system catch the error and send back the error message to
565 ;; printing system. This is useful only if printing
566 ;; system send back an email reporting the error, or if
567 ;; there is some other alternative way to report back the
568 ;; error from the system to you.
570 ;; paper-and-system catch the error, print on paper the error message and
571 ;; send back the error message to printing system.
573 ;; Any other value is treated as `paper'.
576 ;; Duplex Printers
577 ;; ---------------
579 ;; If you have a duplex-capable printer (one that prints both sides of the
580 ;; paper), set `ps-spool-duplex' to t.
581 ;; ps-print will insert blank pages to make sure each buffer starts on the
582 ;; correct side of the paper.
584 ;; The variable `ps-spool-config' specifies who is the responsible for setting
585 ;; duplex and page size. Valid values are:
587 ;; lpr-switches duplex and page size are configured by `ps-lpr-switches'.
588 ;; Don't forget to set `ps-lpr-switches' to select duplex
589 ;; printing for your printer.
591 ;; setpagedevice duplex and page size are configured by ps-print using the
592 ;; setpagedevice PostScript operator.
594 ;; nil duplex and page size are configured by ps-print *not* using
595 ;; the setpagedevice PostScript operator.
597 ;; Any other value is treated as nil.
599 ;; The default value is `lpr-switches'.
601 ;; WARNING: The setpagedevice PostScript operator affects ghostview utility
602 ;; when viewing file generated using landscape. Also on some
603 ;; printers, setpagedevice affects zebra stripes; on other printers,
604 ;; setpagedevice affects the left margin.
605 ;; Besides all that, if your printer does not have the paper size
606 ;; specified by setpagedevice, your printing will be aborted.
607 ;; So, if you need to use setpagedevice, set `ps-spool-config' to
608 ;; `setpagedevice', generate a test file and send it to your printer;
609 ;; if the printed file isn't ok, set `ps-spool-config' to nil.
611 ;; The variable `ps-spool-tumble' specifies how the page images on opposite
612 ;; sides of a sheet are oriented with respect to each other. If
613 ;; `ps-spool-tumble' is nil, produces output suitable for binding on the left
614 ;; or right. If `ps-spool-tumble' is non-nil, produces output suitable for
615 ;; binding at the top or bottom. It has effect only when `ps-spool-duplex' is
616 ;; non-nil. The default value is nil.
618 ;; Some printer system prints a header page and forces the first page be
619 ;; printed on header page back, when using duplex. If your printer system has
620 ;; this behavior, set variable `ps-banner-page-when-duplexing' to t.
622 ;; When `ps-banner-page-when-duplexing' is non-nil, it prints a blank page as
623 ;; the very first printed page. So, it behaves as the very first character of
624 ;; buffer (or region) is ^L (\014).
626 ;; The default for `ps-banner-page-when-duplexing' is nil (*don't* skip the
627 ;; very first page).
630 ;; N-up Printing
631 ;; -------------
633 ;; The variable `ps-n-up-printing' specifies the number of pages per sheet of
634 ;; paper. The value specified must be between 1 and 100. The default is 1.
636 ;; NOTE: some PostScript printer may crash printing if `ps-n-up-printing' is
637 ;; set to a high value (for example, 23). If this happens, set a lower value.
639 ;; The variable `ps-n-up-margin' specifies the margin in points between the
640 ;; sheet border and the n-up printing. The default is 1 cm (or 0.3937 inches,
641 ;; or 28.35 points).
643 ;; If variable `ps-n-up-border-p' is non-nil a border is drawn around each
644 ;; page. The default is t.
646 ;; The variable `ps-n-up-filling' specifies how page matrix is filled on each
647 ;; sheet of paper. Following are the valid values for `ps-n-up-filling' with a
648 ;; filling example using a 3x4 page matrix:
650 ;; left-top 1 2 3 4 left-bottom 9 10 11 12
651 ;; 5 6 7 8 5 6 7 8
652 ;; 9 10 11 12 1 2 3 4
654 ;; right-top 4 3 2 1 right-bottom 12 11 10 9
655 ;; 8 7 6 5 8 7 6 5
656 ;; 12 11 10 9 4 3 2 1
658 ;; top-left 1 4 7 10 bottom-left 3 6 9 12
659 ;; 2 5 8 11 2 5 8 11
660 ;; 3 6 9 12 1 4 7 10
662 ;; top-right 10 7 4 1 bottom-right 12 9 6 3
663 ;; 11 8 5 2 11 8 5 2
664 ;; 12 9 6 3 10 7 4 1
666 ;; Any other value is treated as `left-top'.
668 ;; The default value is left-top.
671 ;; Control And 8-bit Characters
672 ;; ----------------------------
674 ;; The variable `ps-print-control-characters' specifies whether you want to see
675 ;; a printable form for control and 8-bit characters, that is, instead of
676 ;; sending, for example, a ^D (\004) to printer, it is sent the string "^D".
678 ;; Valid values for `ps-print-control-characters' are:
680 ;; 8-bit This is the value to use when you want an ASCII encoding of
681 ;; any control or non-ASCII character. Control characters are
682 ;; encoded as "^D", and non-ASCII characters have an
683 ;; octal encoding.
685 ;; control-8-bit This is the value to use when you want an ASCII encoding of
686 ;; any control character, whether it is 7 or 8-bit.
687 ;; European 8-bits accented characters are printed according
688 ;; the current font.
690 ;; control Only ASCII control characters have an ASCII encoding.
691 ;; European 8-bits accented characters are printed according
692 ;; the current font.
694 ;; nil No ASCII encoding. Any character is printed according the
695 ;; current font.
697 ;; Any other value is treated as nil.
699 ;; The default is `control-8-bit'.
701 ;; Characters TAB, NEWLINE and FORMFEED are always treated by ps-print engine.
704 ;; Printing Multi-byte Buffer
705 ;; --------------------------
707 ;; See ps-mule.el for documentation.
710 ;; Line Number
711 ;; -----------
713 ;; The variable `ps-line-number' specifies whether to number each line;
714 ;; non-nil means do so. The default is nil (don't number each line).
716 ;; The variable `ps-line-number-color' specifies the color for line number.
717 ;; See `ps-zebra-color' for documentation. The default is "black" (or 0.0, or
718 ;; '(0.0 0.0 0.0)).
720 ;; The variable `ps-line-number-font' specifies the font for line number.
721 ;; The default is "Times-Italic".
723 ;; The variable `ps-line-number-font-size' specifies the font size in points
724 ;; for line number. See `ps-font-size' for documentation. The default is 6.
726 ;; The variable `ps-line-number-step' specifies the interval that line number
727 ;; is printed. For example, if `ps-line-number-step' is set to 2, the printing
728 ;; will look like:
730 ;; 1 one line
731 ;; one line
732 ;; 3 one line
733 ;; one line
734 ;; 5 one line
735 ;; one line
736 ;; ...
738 ;; Valid values are:
740 ;; integer an integer that specifies the interval that line number is
741 ;; printed. If it's lesser than or equal to zero, it's used the
742 ;; value 1.
744 ;; `zebra' specifies that only the line number of the first line in a
745 ;; zebra stripe is to be printed.
747 ;; Any other value is treated as `zebra'.
748 ;; The default value is 1, so each line number is printed.
750 ;; The variable `ps-line-number-start' specifies the starting point in the
751 ;; interval given by `ps-line-number-step'. For example, if
752 ;; `ps-line-number-step' is set to 3 and `ps-line-number-start' is set to 3,
753 ;; the printing will look like:
755 ;; one line
756 ;; one line
757 ;; 3 one line
758 ;; one line
759 ;; one line
760 ;; 6 one line
761 ;; one line
762 ;; one line
763 ;; 9 one line
764 ;; one line
765 ;; ...
767 ;; The values for `ps-line-number-start':
769 ;; * If `ps-line-number-step' is an integer, must be between 1 and the value
770 ;; of `ps-line-number-step' inclusive.
772 ;; * If `ps-line-number-step' is set to `zebra', must be between 1 and the
773 ;; value of `ps-zebra-stripe-height' inclusive.
775 ;; The default value is 1, so the line number of the first line of each
776 ;; interval is printed.
779 ;; Zebra Stripes
780 ;; -------------
782 ;; Zebra stripes are a kind of background that appear "underneath" the text and
783 ;; can make the text easier to read. They look like this:
785 ;; XXXXXXXXXXXXXXXXXXXXXXXX
786 ;; XXXXXXXXXXXXXXXXXXXXXXXX
787 ;; XXXXXXXXXXXXXXXXXXXXXXXX
791 ;; XXXXXXXXXXXXXXXXXXXXXXXX
792 ;; XXXXXXXXXXXXXXXXXXXXXXXX
793 ;; XXXXXXXXXXXXXXXXXXXXXXXX
795 ;; The blocks of X's represent rectangles filled with a light gray color.
796 ;; Each rectangle extends all the way across the page.
798 ;; The height, in lines, of each rectangle is controlled by the variable
799 ;; `ps-zebra-stripe-height', which is 3 by default. The distance between
800 ;; stripes equals the height of a stripe.
802 ;; The variable `ps-zebra-stripes' controls whether to print zebra stripes.
803 ;; Non-nil means yes, nil means no. The default is nil.
805 ;; The variable `ps-zebra-color' controls the zebra stripes gray scale or RGB
806 ;; color. It should be a float number between 0.0 (black color) and 1.0 (white
807 ;; color), a string which is a color name, or a list of 3 numbers which
808 ;; corresponds to the Red Green Blue color scale.
809 ;; The default is 0.95 (or "gray95", or '(0.95 0.95 0.95)).
811 ;; The variable `ps-zebra-stripe-follow' specifies how zebra stripes continue
812 ;; on next page. Visually, valid values are (the character `+' at right of
813 ;; each column indicates that a line is printed):
815 ;; `nil' `follow' `full' `full-follow'
816 ;; Current Page -------- ----------- --------- ----------------
817 ;; 1 XXXXX + 1 XXXXXXXX + 1 XXXXXX + 1 XXXXXXXXXXXXX +
818 ;; 2 XXXXX + 2 XXXXXXXX + 2 XXXXXX + 2 XXXXXXXXXXXXX +
819 ;; 3 XXXXX + 3 XXXXXXXX + 3 XXXXXX + 3 XXXXXXXXXXXXX +
820 ;; 4 + 4 + 4 + 4 +
821 ;; 5 + 5 + 5 + 5 +
822 ;; 6 + 6 + 6 + 6 +
823 ;; 7 XXXXX + 7 XXXXXXXX + 7 XXXXXX + 7 XXXXXXXXXXXXX +
824 ;; 8 XXXXX + 8 XXXXXXXX + 8 XXXXXX + 8 XXXXXXXXXXXXX +
825 ;; 9 XXXXX + 9 XXXXXXXX + 9 XXXXXX + 9 XXXXXXXXXXXXX +
826 ;; 10 + 10 +
827 ;; 11 + 11 +
828 ;; -------- ----------- --------- ----------------
829 ;; Next Page -------- ----------- --------- ----------------
830 ;; 12 XXXXX + 12 + 10 XXXXXX + 10 +
831 ;; 13 XXXXX + 13 XXXXXXXX + 11 XXXXXX + 11 +
832 ;; 14 XXXXX + 14 XXXXXXXX + 12 XXXXXX + 12 +
833 ;; 15 + 15 XXXXXXXX + 13 + 13 XXXXXXXXXXXXX +
834 ;; 16 + 16 + 14 + 14 XXXXXXXXXXXXX +
835 ;; 17 + 17 + 15 + 15 XXXXXXXXXXXXX +
836 ;; 18 XXXXX + 18 + 16 XXXXXX + 16 +
837 ;; 19 XXXXX + 19 XXXXXXXX + 17 XXXXXX + 17 +
838 ;; 20 XXXXX + 20 XXXXXXXX + 18 XXXXXX + 18 +
839 ;; 21 + 21 XXXXXXXX +
840 ;; 22 + 22 +
841 ;; -------- ----------- --------- ----------------
843 ;; Any other value is treated as nil.
845 ;; See also section How Ps-Print Has A Text And/Or Image On Background.
848 ;; Hooks
849 ;; -----
851 ;; ps-print has the following hook variables:
853 ;; `ps-print-hook'
854 ;; It is evaluated once before any printing process. This is the right
855 ;; place to initialize ps-print global data.
856 ;; For an example, see section Adding a New Font Family.
858 ;; `ps-print-begin-sheet-hook'
859 ;; It is evaluated on each beginning of sheet of paper.
860 ;; If `ps-n-up-printing' is equal to 1, `ps-print-begin-page-hook' is never
861 ;; evaluated.
863 ;; `ps-print-begin-page-hook'
864 ;; It is evaluated on each beginning of page, except in the beginning of
865 ;; page that `ps-print-begin-sheet-hook' is evaluated.
867 ;; `ps-print-begin-column-hook'
868 ;; It is evaluated on each beginning of column, except in the beginning of
869 ;; column that `ps-print-begin-page-hook' is evaluated or that
870 ;; `ps-print-begin-sheet-hook' is evaluated.
873 ;; Font Managing
874 ;; -------------
876 ;; ps-print now knows rather precisely some fonts: the variable
877 ;; `ps-font-info-database' contains information for a list of font families
878 ;; (currently mainly `Courier' `Helvetica' `Times' `Palatino'
879 ;; `Helvetica-Narrow' `NewCenturySchlbk'). Each font family contains the font
880 ;; names for standard, bold, italic and bold-italic characters, a reference
881 ;; size (usually 10) and the corresponding line height, width of a space and
882 ;; average character width.
884 ;; The variable `ps-font-family' determines which font family is to be used for
885 ;; ordinary text. If its value does not correspond to a known font family, an
886 ;; error message is printed into the `*Messages*' buffer, which lists the
887 ;; currently available font families.
889 ;; The variable `ps-font-size' determines the size (in points) of the font for
890 ;; ordinary text, when generating PostScript. Its value is a float or a cons
891 ;; of floats which has the following form:
893 ;; (LANDSCAPE-SIZE . PORTRAIT-SIZE)
895 ;; Similarly, the variable `ps-header-font-family' determines which font family
896 ;; is to be used for text in the header.
898 ;; The variable `ps-header-font-size' determines the font size, in points, for
899 ;; text in the header (similar to `ps-font-size').
901 ;; The variable `ps-header-title-font-size' determines the font size, in
902 ;; points, for the top line of text in the header (similar to `ps-font-size').
904 ;; The variable `ps-line-spacing' determines the line spacing, in points, for
905 ;; ordinary text, when generating PostScript (similar to `ps-font-size'). The
906 ;; default value is 0 (zero = no line spacing).
908 ;; The variable `ps-paragraph-spacing' determines the paragraph spacing, in
909 ;; points, for ordinary text, when generating PostScript (similar to
910 ;; `ps-font-size'). The default value is 0 (zero = no paragraph spacing).
912 ;; To get all lines with some spacing set both `ps-line-spacing' and
913 ;; `ps-paragraph-spacing' variables.
915 ;; The variable `ps-paragraph-regexp' specifies the paragraph delimiter. It
916 ;; should be a regexp or nil. The default value is "[ \t]*$", that is, an
917 ;; empty line or a line containing only spaces and tabs.
919 ;; The variable `ps-begin-cut-regexp' and `ps-end-cut-regexp' specify the start
920 ;; and end of a region to cut out when printing.
922 ;; As an example, variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' may
923 ;; be set to "^Local Variables:" and "^End:", respectively, in order to leave
924 ;; out some special printing instructions from the actual print. Special
925 ;; printing instructions may be appended to the end of the file just like any
926 ;; other buffer-local variables. See section "Local Variables in Files" on
927 ;; Emacs manual for more information.
929 ;; Variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' control together
930 ;; what actually gets printed. Both variables may be set to nil in which case
931 ;; no cutting occurs. By default, both variables are set to nil.
934 ;; Adding a New Font Family
935 ;; ------------------------
937 ;; To use a new font family, you MUST first teach ps-print this font, i.e., add
938 ;; its information to `ps-font-info-database', otherwise ps-print cannot
939 ;; correctly place line and page breaks.
941 ;; For example, assuming `Helvetica' is unknown, you first need to do the
942 ;; following ONLY ONCE:
944 ;; - create a new buffer
945 ;; - generate the PostScript image to a file (C-u M-x ps-print-buffer)
946 ;; - open this file and find the line:
947 ;; `% 3 cm 20 cm moveto 10/Courier ReportFontInfo showpage'
948 ;; - delete the leading `%' (which is the PostScript comment character)
949 ;; - replace in this line `Courier' by the new font (say `Helvetica') to get
950 ;; the line:
951 ;; `3 cm 20 cm moveto 10/Helvetica ReportFontInfo showpage'
952 ;; - send this file to the printer (or to ghostscript).
953 ;; You should read the following on the output page:
955 ;; For Helvetica 10 point, the line height is 11.56, the space width is 2.78
956 ;; and a crude estimate of average character width is 5.09243
958 ;; - Add these values to the `ps-font-info-database':
959 ;; (setq ps-font-info-database
960 ;; (append
961 ;; '((Helvetica ; the family key
962 ;; (fonts (normal . "Helvetica")
963 ;; (bold . "Helvetica-Bold")
964 ;; (italic . "Helvetica-Oblique")
965 ;; (bold-italic . "Helvetica-BoldOblique"))
966 ;; (size . 10.0)
967 ;; (line-height . 11.56)
968 ;; (space-width . 2.78)
969 ;; (avg-char-width . 5.09243)))
970 ;; ps-font-info-database))
971 ;; - Now you can use this font family with any size:
972 ;; (setq ps-font-family 'Helvetica)
973 ;; - if you want to use this family in another emacs session, you must put into
974 ;; your `~/.emacs':
975 ;; (require 'ps-print)
976 ;; (setq ps-font-info-database (append ...)))
977 ;; if you don't want to load ps-print, you have to copy the whole value:
978 ;; (setq ps-font-info-database '(<your stuff> <the standard stuff>))
979 ;; or, use `ps-print-hook' (see section Hooks):
980 ;; (add-hook 'ps-print-hook
981 ;; '(lambda ()
982 ;; (or (assq 'Helvetica ps-font-info-database)
983 ;; (setq ps-font-info-database (append ...)))))
985 ;; You can create new `mixed' font families like:
986 ;; (my-mixed-family
987 ;; (fonts (normal . "Courier-Bold")
988 ;; (bold . "Helvetica")
989 ;; (italic . "ZapfChancery-MediumItalic")
990 ;; (bold-italic . "NewCenturySchlbk-BoldItalic")
991 ;; (w3-table-hack-x-face . "LineDrawNormal"))
992 ;; (size . 10.0)
993 ;; (line-height . 10.55)
994 ;; (space-width . 6.0)
995 ;; (avg-char-width . 6.0))
997 ;; Now you can use your new font family with any size:
998 ;; (setq ps-font-family 'my-mixed-family)
1000 ;; Note that on above example the `w3-table-hack-x-face' entry refers to a face
1001 ;; symbol, so when printing this face it'll be used the font `LineDrawNormal'.
1002 ;; If the face `w3-table-hack-x-face' is remapped to use bold and/or italic
1003 ;; attribute, the corresponding entry (bold, italic or bold-italic) will be
1004 ;; used instead of `w3-table-hack-x-face' entry.
1006 ;; Note also that the font family entry order is irrelevant, so the above
1007 ;; example could also be written:
1008 ;; (my-mixed-family
1009 ;; (size . 10.0)
1010 ;; (fonts (w3-table-hack-x-face . "LineDrawNormal")
1011 ;; (bold . "Helvetica")
1012 ;; (bold-italic . "NewCenturySchlbk-BoldItalic")
1013 ;; (italic . "ZapfChancery-MediumItalic")
1014 ;; (normal . "Courier-Bold"))
1015 ;; (avg-char-width . 6.0)
1016 ;; (space-width . 6.0)
1017 ;; (line-height . 10.55))
1019 ;; Despite the note above, it is recommended that some convention about
1020 ;; entry order be used.
1022 ;; You can get information on all the fonts resident in YOUR printer
1023 ;; by uncommenting the line:
1024 ;; % 3 cm 20 cm moveto ReportAllFontInfo showpage
1026 ;; The PostScript file should be sent to YOUR PostScript printer.
1027 ;; If you send it to ghostscript or to another PostScript printer, you may get
1028 ;; slightly different results.
1029 ;; Anyway, as ghostscript fonts are autoload, you won't get much font info.
1031 ;; Note also that ps-print DOESN'T download any font to your printer, instead
1032 ;; it uses the fonts resident in your printer.
1035 ;; How Ps-Print Deals With Faces
1036 ;; -----------------------------
1038 ;; The ps-print-*-with-faces commands attempt to determine which faces should
1039 ;; be printed in bold or italic, but their guesses aren't always right. For
1040 ;; example, you might want to map colors into faces so that blue faces print in
1041 ;; bold, and red faces in italic.
1043 ;; It is possible to force ps-print to consider specific faces bold, italic or
1044 ;; underline, no matter what font they are displayed in, by setting the
1045 ;; variables `ps-bold-faces', `ps-italic-faces' and `ps-underlined-faces'.
1046 ;; These variables contain lists of faces that ps-print should consider bold,
1047 ;; italic or underline; to set them, put code like the following into your
1048 ;; .emacs file:
1050 ;; (setq ps-bold-faces '(my-blue-face))
1051 ;; (setq ps-italic-faces '(my-red-face))
1052 ;; (setq ps-underlined-faces '(my-green-face))
1054 ;; Faces like bold-italic that are both bold and italic should go in *both*
1055 ;; lists.
1057 ;; ps-print keeps internal lists of which fonts are bold and which are italic;
1058 ;; these lists are built the first time you invoke ps-print.
1059 ;; For the sake of efficiency, the lists are built only once; the same lists
1060 ;; are referred in later invocations of ps-print.
1062 ;; Because these lists are built only once, it's possible for them to get out
1063 ;; of sync, if a face changes, or if new faces are added. To get the lists
1064 ;; back in sync, you can set the variable `ps-build-face-reference' to t, and
1065 ;; the lists will be rebuilt the next time ps-print is invoked. If you need
1066 ;; that the lists always be rebuilt when ps-print is invoked, set the variable
1067 ;; `ps-always-build-face-reference' to t.
1069 ;; If you need to print without worrying about face background color, set the
1070 ;; variable `ps-use-face-background' which specifies if face background should
1071 ;; be used. Valid values are:
1073 ;; t always use face background color.
1074 ;; nil never use face background color.
1075 ;; (face...) list of faces whose background color will be used.
1077 ;; Any other value will be treated as t.
1078 ;; The default value is nil.
1081 ;; How Ps-Print Deals With Color
1082 ;; -----------------------------
1084 ;; ps-print detects faces with foreground and background colors defined and
1085 ;; embeds color information in the PostScript image.
1086 ;; The default foreground and background colors are defined by the variables
1087 ;; `ps-default-fg' and `ps-default-bg'.
1088 ;; On black/white printers, colors are displayed in gray scale.
1089 ;; To turn off color output, set `ps-print-color-p' to nil.
1090 ;; You can also set `ps-print-color-p' to 'black-white to have a better looking
1091 ;; on black/white printers. See also `ps-black-white-faces' for documentation.
1093 ;; ps-print also detects if the text foreground and background colors are
1094 ;; equals when `ps-fg-validate-p' is non-nil. In this case, if these colors
1095 ;; are used, no text will appear. You can use `ps-fg-list' to give a list of
1096 ;; foreground colors to be used when text foreground and background colors are
1097 ;; equals. It'll be used the first foreground color in `ps-fg-list' which is
1098 ;; different from the background color. If `ps-fg-list' is nil, the default
1099 ;; foreground color is used.
1102 ;; How Ps-Print Maps Faces
1103 ;; -----------------------
1105 ;; As ps-print uses PostScript to print buffers, it is possible to have other
1106 ;; attributes associated with faces. So the new attributes used by ps-print
1107 ;; are:
1109 ;; strikeout - like underline, but the line is in middle of text.
1110 ;; overline - like underline, but the line is over the text.
1111 ;; shadow - text will have a shadow.
1112 ;; box - text will be surrounded by a box.
1113 ;; outline - print characters as hollow outlines.
1115 ;; See the documentation for `ps-extend-face'.
1117 ;; Let's, for example, remap `font-lock-keyword-face' to another foreground
1118 ;; color and bold attribute:
1120 ;; (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE)
1122 ;; If you want to use a new face, define it first with `defface', and then call
1123 ;; `ps-extend-face' to specify how to print it.
1126 ;; How Ps-Print Has A Text And/Or Image On Background
1127 ;; --------------------------------------------------
1129 ;; ps-print can print texts and/or EPS PostScript images on background; it is
1130 ;; possible to define the following text attributes: font name, font size,
1131 ;; initial position, angle, gray scale and pages to print.
1133 ;; It has the following EPS PostScript images attributes: file name containing
1134 ;; the image, initial position, X and Y scales, angle and pages to print.
1136 ;; See documentation for `ps-print-background-text' and
1137 ;; `ps-print-background-image'.
1139 ;; For example, if we wish to print text "preliminary" on all pages and text
1140 ;; "special" on page 5 and from page 11 to page 17, we could specify:
1142 ;; (setq ps-print-background-text
1143 ;; '(("preliminary")
1144 ;; ("special"
1145 ;; "LeftMargin" "BottomMargin PrintHeight add" ; X and Y position
1146 ;; ; (upper left corner)
1147 ;; nil nil nil
1148 ;; "PrintHeight neg PrintPageWidth atan" ; angle
1149 ;; 5 (11 . 17)) ; page list
1150 ;; ))
1152 ;; Similarly, we could print image "~/images/EPS-image1.ps" on all pages and
1153 ;; image "~/images/EPS-image2.ps" on page 5 and from page 11 to page 17, we
1154 ;; specify:
1156 ;; (setq ps-print-background-image
1157 ;; '(("~/images/EPS-image1.ps"
1158 ;; "LeftMargin" "BottomMargin") ; X and Y position (lower left corner)
1159 ;; ("~/images/EPS-image2.ps"
1160 ;; "LeftMargin" "BottomMargin PrintHeight 2 div add" ; X and Y pos.
1161 ;; ; (upper left corner)
1162 ;; nil nil nil
1163 ;; 5 (11 . 17)) ; page list
1164 ;; ))
1166 ;; If it is not possible to read (or does not exist) an image file, that file
1167 ;; is ignored.
1169 ;; The printing order is:
1171 ;; 1. Print background color
1172 ;; 2. Print zebra stripes
1173 ;; 3. Print background texts that it should be on all pages
1174 ;; 4. Print background images that it should be on all pages
1175 ;; 5. Print background texts only for current page (if any)
1176 ;; 6. Print background images only for current page (if any)
1177 ;; 7. Print header
1178 ;; 8. Print buffer text (with faces, if specified) and line number
1181 ;; Utilities
1182 ;; ---------
1184 ;; Some tools are provided to help you customize your font setup.
1186 ;; `ps-setup' returns (some part of) the current setup.
1188 ;; To avoid wrapping too many lines, you may want to adjust the left and right
1189 ;; margins and the font size. On UN*X systems, do:
1190 ;; pr -t file | awk '{printf "%3d %s\n", length($0), $0}' | sort -r | head
1191 ;; to determine the longest lines of your file.
1192 ;; Then, the command `ps-line-lengths' will give you the correspondence between
1193 ;; a line length (number of characters) and the maximum font size which doesn't
1194 ;; wrap such a line with the current ps-print setup.
1196 ;; The commands `ps-nb-pages-buffer' and `ps-nb-pages-region' display the
1197 ;; correspondence between a number of pages and the maximum font size which
1198 ;; allow the number of lines of the current buffer or of its current region to
1199 ;; fit in this number of pages.
1201 ;; NOTE: line folding is not taken into account in this process and could
1202 ;; change the results.
1204 ;; The command `ps-print-customize' activates a customization buffer for
1205 ;; ps-print options.
1208 ;; New since version 1.5
1209 ;; ---------------------
1211 ;; Color output capability.
1212 ;; Automatic detection of font attributes (bold, italic).
1213 ;; Configurable headers with page numbers.
1214 ;; Slightly faster.
1215 ;; Support for different paper sizes.
1216 ;; Better conformance to PostScript Document Structure Conventions.
1219 ;; New since version 2.8
1220 ;; ---------------------
1222 ;; [vinicius] Vinicius Jose Latorre <viniciusjl@ig.com.br>
1224 ;; 2007-10-27
1225 ;; `ps-fg-validate-p', `ps-fg-list'
1227 ;; 2004-02-29
1228 ;; `ps-time-stamp-yyyy-mm-dd', `ps-time-stamp-iso8601'
1230 ;; 2001-06-19
1231 ;; `ps-time-stamp-locale-default'
1233 ;; 2001-05-30
1234 ;; Handle before-string and after-string overlay properties.
1236 ;; 2001-04-07
1237 ;; `ps-line-number-color', `ps-print-footer', `ps-footer-offset',
1238 ;; `ps-print-footer-frame', `ps-footer-font-family',
1239 ;; `ps-footer-font-size', `ps-footer-line-pad', `ps-footer-lines',
1240 ;; `ps-left-footer', `ps-right-footer', `ps-footer-frame-alist' and
1241 ;; `ps-header-frame-alist'.
1243 ;; 2001-03-28
1244 ;; `ps-line-spacing', `ps-paragraph-spacing', `ps-paragraph-regexp',
1245 ;; `ps-begin-cut-regexp' and `ps-end-cut-regexp'.
1247 ;; 2000-11-22
1248 ;; `ps-line-number-font', `ps-line-number-font-size' and
1249 ;; `ps-end-with-control-d'.
1251 ;; 2000-08-21
1252 ;; `ps-even-or-odd-pages'
1254 ;; 2000-06-17
1255 ;; `ps-manual-feed', `ps-warn-paper-type', `ps-print-upside-down',
1256 ;; `ps-selected-pages', `ps-last-selected-pages',
1257 ;; `ps-restore-selected-pages', `ps-switch-header',
1258 ;; `ps-line-number-step', `ps-line-number-start',
1259 ;; `ps-zebra-stripe-follow' and `ps-use-face-background'.
1261 ;; 2000-03-10
1262 ;; PostScript error handler.
1263 ;; `ps-user-defined-prologue' and `ps-error-handler-message'.
1265 ;; 1999-12-11
1266 ;; `ps-print-customize'.
1268 ;; 1999-07-03
1269 ;; Better customization.
1270 ;; `ps-banner-page-when-duplexing' and `ps-zebra-color'.
1272 ;; 1999-05-13
1273 ;; N-up printing.
1274 ;; Hook: `ps-print-begin-sheet-hook'.
1276 ;; [kenichi] 1999-05-09 Ken'ichi Handa <handa@m17n.org>
1278 ;; `ps-print-region-function'
1280 ;; [vinicius] Vinicius Jose Latorre <viniciusjl@ig.com.br>
1282 ;; 1999-03-01
1283 ;; PostScript tumble and setpagedevice.
1285 ;; 1998-09-22
1286 ;; PostScript prologue header comment insertion.
1287 ;; Skip invisible text better.
1289 ;; [kenichi] 1998-08-19 Ken'ichi Handa <handa@m17n.org>
1291 ;; Multi-byte buffer handling.
1293 ;; [vinicius] Vinicius Jose Latorre <viniciusjl@ig.com.br>
1295 ;; 1998-03-06
1296 ;; Skip invisible text.
1298 ;; 1997-11-30
1299 ;; Hooks: `ps-print-hook', `ps-print-begin-page-hook' and
1300 ;; `ps-print-begin-column-hook'.
1301 ;; Put one header per page over the columns.
1302 ;; Better database font management.
1303 ;; Better control characters handling.
1305 ;; 1997-11-21
1306 ;; Dynamic evaluation at print time of `ps-lpr-switches'.
1307 ;; Handle control characters.
1308 ;; Face remapping.
1309 ;; New face attributes.
1310 ;; Line number.
1311 ;; Zebra stripes.
1312 ;; Text and/or image on background.
1314 ;; [jack] 1996-05-17 Jacques Duthen <duthen@cegelec-red.fr>
1316 ;; Font family and float size for text and header.
1317 ;; Landscape mode.
1318 ;; Multiple columns.
1319 ;; Tools for page setup.
1322 ;; Known bugs and limitations of ps-print
1323 ;; --------------------------------------
1325 ;; Although color printing will work in XEmacs 19.12, it doesn't work well; in
1326 ;; particular, bold or italic fonts don't print in the right background color.
1328 ;; Invisible properties aren't correctly ignored in XEmacs 19.12.
1330 ;; Automatic font-attribute detection doesn't work well, especially with
1331 ;; hilit19 and older versions of get-create-face. Users having problems with
1332 ;; auto-font detection should use the lists `ps-italic-faces', `ps-bold-faces'
1333 ;; and `ps-underlined-faces' and/or turn off automatic detection by setting
1334 ;; `ps-auto-font-detect' to nil.
1336 ;; Automatic font-attribute detection doesn't work with XEmacs 19.12 in tty
1337 ;; mode; use the lists `ps-italic-faces', `ps-bold-faces' and
1338 ;; `ps-underlined-faces' instead.
1340 ;; Still too slow; could use some hand-optimization.
1342 ;; Default background color isn't working.
1344 ;; Faces are always treated as opaque.
1346 ;; Epoch, Lucid and Emacs 22 not supported. At all.
1348 ;; Fixed-pitch fonts work better for line folding, but are not required.
1350 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care of folding
1351 ;; lines.
1354 ;; Things to change
1355 ;; ----------------
1357 ;; Avoid page break inside a paragraph.
1359 ;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy).
1361 ;; Improve the memory management for big files (hard?).
1363 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' should take care of folding
1364 ;; lines.
1367 ;; Acknowledgments
1368 ;; ---------------
1370 ;; Thanks to Eduard Wiebe <usenet@pusto.de> for fixing face
1371 ;; background/foreground extraction.
1373 ;; Thanks to Friedrich Delgado Friedrichs <friedel@nomaden.org> for new label
1374 ;; printer page sizes.
1376 ;; Thanks to Michael Piotrowski <mxp@dynalabs.de> for improving the DSC
1377 ;; compliance of the generated PostScript.
1379 ;; Thanks to Adam Doppelt <adoppelt@avogadro.com> for face mapping suggestion
1380 ;; for black/white PostScript printers.
1382 ;; Thanks to Toni Ronkko <tronkko@hytti.uku.fi> for line and paragraph spacing,
1383 ;; region to cut out when printing and footer suggestions.
1385 ;; Thanks to Pavel Janik ml <Pavel@Janik.cz> for documentation correction.
1387 ;; Thanks to Corinne Ilvedson <cilvedson@draper.com> for line number font size
1388 ;; suggestion.
1390 ;; Thanks to Gord Wait <Gord_Wait@spectrumsignal.com> for
1391 ;; `ps-user-defined-prologue' example setting for HP PostScript printer.
1393 ;; Thanks to Paul Furnanz <pfurnanz@synopsys.com> for XEmacs compatibility
1394 ;; suggestion for `ps-postscript-code-directory' variable.
1396 ;; Thanks to David X Callaway <dxc@xprt.net> for helping debugging PostScript
1397 ;; level 1 compatibility.
1399 ;; Thanks to Colin Marquardt <colin.marquardt@usa.alcatel.com> for:
1400 ;; - upside-down, line number step, line number start and zebra stripe
1401 ;; follow suggestions.
1402 ;; - `ps-time-stamp-yyyy-mm-dd' and `ps-time-stamp-iso8601' suggestion.
1403 ;; - and for XEmacs beta-tests.
1405 ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for user defined PostScript
1406 ;; prologue code suggestion, for odd/even printing suggestion and for
1407 ;; `ps-prologue-file' enhancement.
1409 ;; Thanks to Ken'ichi Handa <handa@m17n.org> for multi-byte buffer handling.
1411 ;; Thanks to Matthew O Persico <Matthew.Persico@lazard.com> for line number on
1412 ;; empty columns.
1414 ;; Thanks to Theodore Jump <tjump@cais.com> for adjust PostScript code order on
1415 ;; last page.
1417 ;; Thanks to Roland Ducournau <ducour@lirmm.fr> for
1418 ;; `ps-print-control-characters' variable documentation.
1420 ;; Thanks to Marcus G Daniels <marcus@cathcart.sysc.pdx.edu> for a better
1421 ;; database font management.
1423 ;; Thanks to Martin Boyer <gamin@videotron.ca> for some ideas on putting one
1424 ;; header per page over the columns and correct line numbers when printing a
1425 ;; region.
1427 ;; Thanks to Steven L Baur <steve@miranova.com> for dynamic evaluation at
1428 ;; print time of `ps-lpr-switches'.
1430 ;; Thanks to Kevin Rodgers <kevinr@ihs.com> for handling control characters
1431 ;; (his code was severely modified, but the main idea was kept).
1433 ;; Thanks to some suggestions on:
1434 ;; * Face color map: Marco Melgazzi <marco@techie.com>
1435 ;; * XEmacs compatibility: William J. Henney <will@astrosmo.unam.mx>
1436 ;; * Check `ps-paper-type': Sudhakar Frederick <sfrederi@asc.corp.mot.com>
1438 ;; Thanks to Jacques Duthen <duthen@cegelec-red.fr> (Jack) for version 3.4 I
1439 ;; started from. [vinicius]
1441 ;; Thanks to Jim Thompson <?@?> for the 2.8 version I started from. [jack]
1443 ;; Thanks to Kevin Rodgers <kevinr@ihs.com> for adding support for color and
1444 ;; the invisible property.
1446 ;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing the
1447 ;; initial port to Emacs 19. His code is no longer part of ps-print, but his
1448 ;; work is still appreciated.
1450 ;; Thanks to Remi Houdaille and Michel Train <michel@metasoft.fdn.org> for
1451 ;; adding underline support. Their code also is no longer part of ps-print,
1452 ;; but their efforts are not forgotten.
1454 ;; Thanks also to all of you who mailed code to add features to ps-print;
1455 ;; although I didn't use your code, I still appreciate your sharing it with me.
1457 ;; Thanks to all who mailed comments, encouragement, and criticism.
1458 ;; Thanks also to all who responded to my survey; I had too many responses to
1459 ;; reply to them all, but I greatly appreciate your interest.
1461 ;; Jim
1462 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1464 ;;; Code:
1467 (require 'lpr)
1470 (or (featurep 'lisp-float-type)
1471 (error "`ps-print' requires floating point support"))
1474 (if (featurep 'xemacs)
1476 (unless (and (boundp 'emacs-major-version)
1477 (>= emacs-major-version 23))
1478 (error "`ps-print' only supports Emacs 23 and higher")))
1481 (defconst ps-windows-system
1482 (memq system-type '(ms-dos windows-nt)))
1483 (defconst ps-lp-system
1484 (memq system-type '(usg-unix-v hpux irix)))
1487 ;; Load XEmacs/Emacs definitions
1488 (eval-and-compile (require 'ps-def))
1491 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1492 ;; User Variables:
1495 ;;; Interface to the command system
1497 (defgroup postscript nil
1498 "Support for printing and PostScript."
1499 :tag "PostScript"
1500 :version "20"
1501 :group 'external)
1503 (defgroup ps-print nil
1504 "PostScript generator for Emacs."
1505 :link '(emacs-library-link :tag "Source Lisp File" "ps-print.el")
1506 :prefix "ps-"
1507 :version "20"
1508 :group 'wp
1509 :group 'postscript)
1511 (defgroup ps-print-horizontal nil
1512 "Horizontal page layout."
1513 :prefix "ps-"
1514 :tag "Horizontal"
1515 :version "20"
1516 :group 'ps-print)
1518 (defgroup ps-print-vertical nil
1519 "Vertical page layout."
1520 :prefix "ps-"
1521 :tag "Vertical"
1522 :version "20"
1523 :group 'ps-print)
1525 (defgroup ps-print-headers nil
1526 "Headers & footers layout."
1527 :prefix "ps-"
1528 :tag "Header & Footer"
1529 :version "20"
1530 :group 'ps-print)
1532 (defgroup ps-print-font nil
1533 "Fonts customization."
1534 :prefix "ps-"
1535 :tag "Font"
1536 :version "20"
1537 :group 'ps-print)
1539 (defgroup ps-print-color nil
1540 "Color customization."
1541 :prefix "ps-"
1542 :tag "Color"
1543 :version "20"
1544 :group 'ps-print)
1546 (defgroup ps-print-face nil
1547 "Faces customization."
1548 :prefix "ps-"
1549 :tag "PS Faces"
1550 :version "20"
1551 :group 'ps-print
1552 :group 'faces)
1554 (defgroup ps-print-n-up nil
1555 "N-up customization."
1556 :prefix "ps-"
1557 :tag "N-Up"
1558 :version "20"
1559 :group 'ps-print)
1561 (defgroup ps-print-zebra nil
1562 "Zebra customization."
1563 :prefix "ps-"
1564 :tag "Zebra"
1565 :version "20"
1566 :group 'ps-print)
1568 (defgroup ps-print-background nil
1569 "Background customization."
1570 :prefix "ps-"
1571 :tag "Background"
1572 :version "20"
1573 :group 'ps-print)
1575 (defgroup ps-print-printer '((lpr custom-group))
1576 "Printer customization."
1577 :prefix "ps-"
1578 :tag "Printer"
1579 :version "20"
1580 :group 'ps-print)
1582 (defgroup ps-print-page nil
1583 "Page customization."
1584 :prefix "ps-"
1585 :tag "Page"
1586 :version "20"
1587 :group 'ps-print)
1589 (defgroup ps-print-miscellany nil
1590 "Miscellany customization."
1591 :prefix "ps-"
1592 :tag "Miscellany"
1593 :version "20"
1594 :group 'ps-print)
1597 (defcustom ps-error-handler-message 'paper
1598 "Specify where the error handler message should be sent.
1600 Valid values are:
1602 `none' catch the error and *DON'T* send any message.
1604 `paper' catch the error and print on paper the error message.
1606 `system' catch the error and send back the error message to
1607 printing system. This is useful only if printing system
1608 send back an email reporting the error, or if there is
1609 some other alternative way to report back the error from
1610 the system to you.
1612 `paper-and-system' catch the error, print on paper the error message and
1613 send back the error message to printing system.
1615 Any other value is treated as `paper'."
1616 :type '(choice :menu-tag "Error Handler Message"
1617 :tag "Error Handler Message"
1618 (const none) (const paper)
1619 (const system) (const paper-and-system))
1620 :version "20"
1621 :group 'ps-print-miscellany)
1623 (defcustom ps-user-defined-prologue nil
1624 "User defined PostScript prologue code inserted before all prologue code.
1626 `ps-user-defined-prologue' may be a string or a symbol function which returns a
1627 string. Note that this string is inserted after `ps-adobe-tag' and PostScript
1628 prologue comments, and before ps-print PostScript prologue code section. That
1629 is, this string is inserted after error handler initialization and before
1630 ps-print settings.
1632 It's strongly recommended only insert PostScript code and/or comments specific
1633 for your printing system particularities. For example, some special
1634 initialization that only your printing system needs.
1636 Do not insert code for duplex printing, n-up printing or error handler,
1637 ps-print handles this in a suitable way.
1639 For more information about PostScript, see:
1640 PostScript Language Reference Manual (2nd edition)
1641 Adobe Systems Incorporated
1643 As an example for `ps-user-defined-prologue' setting:
1645 ;; Setting for HP PostScript printer
1646 (setq ps-user-defined-prologue
1647 (concat \"<</DeferredMediaSelection true /PageSize [612 792] \"
1648 \"/MediaPosition 2 /MediaType (Plain)>> setpagedevice\"))"
1649 :type '(choice :menu-tag "User Defined Prologue"
1650 :tag "User Defined Prologue"
1651 (const :tag "none" nil) string symbol)
1652 :version "20"
1653 :group 'ps-print-miscellany)
1655 (defcustom ps-print-prologue-header nil
1656 "PostScript prologue header comments besides that ps-print generates.
1658 `ps-print-prologue-header' may be a string or a symbol function which returns a
1659 string. Note that this string is inserted on PostScript prologue header
1660 section which is used to define some document characteristic through PostScript
1661 special comments, like \"%%Requirements: jog\\n\".
1663 ps-print always inserts the %%Requirements: comment, so if you need to insert
1664 more requirements put them first in `ps-print-prologue-header' using the
1665 \"%%+\" comment. For example, if you need to set numcopies to 3 and jog on
1666 requirements and set %%LanguageLevel: to 2, do:
1668 (setq ps-print-prologue-header
1669 \"%%+ numcopies(3) jog\\n%%LanguageLevel: 2\\n\")
1671 The duplex requirement is inserted by ps-print (see `ps-spool-duplex').
1673 Do not forget to terminate the string with \"\\n\".
1675 For more information about PostScript document comments, see:
1676 PostScript Language Reference Manual (2nd edition)
1677 Adobe Systems Incorporated
1678 Appendix G: Document Structuring Conventions -- Version 3.0"
1679 :type '(choice :menu-tag "Prologue Header"
1680 :tag "Prologue Header"
1681 (const :tag "none" nil) string symbol)
1682 :version "20"
1683 :group 'ps-print-miscellany)
1685 (defcustom ps-printer-name (and (boundp 'printer-name)
1686 (symbol-value 'printer-name))
1687 "The name of a local printer for printing PostScript files.
1689 On Unix-like systems, a string value should be a name understood by lpr's -P
1690 option; a value of nil means use the value of `printer-name' instead.
1692 On MS-DOS and MS-Windows systems, a string value is taken as the name of the
1693 printer device or port to which PostScript files are written, provided
1694 `ps-lpr-command' is \"\". By default it is the same as `printer-name'; typical
1695 non-default settings would be \"LPT1\" to \"LPT3\" for parallel printers, or
1696 \"COM1\" to \"COM4\" or \"AUX\" for serial printers, or \"\\\\hostname\\printer\"
1697 for a shared network printer. You can also set it to a name of a file, in
1698 which case the output gets appended to that file. \(Note that `ps-print'
1699 package already has facilities for printing to a file, so you might as well use
1700 them instead of changing the setting of this variable.\) If you want to
1701 silently discard the printed output, set this to \"NUL\".
1703 Set to t, if the utility given by `ps-lpr-command' needs an empty printer name.
1705 Any other value is treated as t, that is, an empty printer name.
1707 See also `ps-printer-name-option' for documentation."
1708 :type '(choice :menu-tag "Printer Name"
1709 :tag "Printer Name"
1710 (const :tag "Same as printer-name" nil)
1711 (const :tag "No Printer Name" t)
1712 (file :tag "Print to file")
1713 (string :tag "Pipe to ps-lpr-command"))
1714 :version "20"
1715 :group 'ps-print-printer)
1717 (defcustom ps-printer-name-option
1718 (cond (ps-windows-system
1719 "/D:")
1720 (ps-lp-system
1721 "-d")
1723 "-P" ))
1724 "Option for `ps-printer-name' variable (see it).
1726 On Unix-like systems, if `lpr' is in use, this should be the string
1727 \"-P\"; if `lp' is in use, this should be the string \"-d\".
1729 On MS-DOS and MS-Windows systems, if `print' is in use, this should be
1730 the string \"/D:\".
1732 For any other printing utility, see its documentation.
1734 Set this to \"\" or nil, if the utility given by `ps-lpr-command'
1735 needs an empty printer name option--that is, pass the printer name
1736 with no special option preceding it.
1738 Any value that is not a string is treated as nil.
1740 This variable is used only when `ps-printer-name' is a non-empty string."
1741 :type '(choice :menu-tag "Printer Name Option"
1742 :tag "Printer Name Option"
1743 (const :tag "None" nil)
1744 (string :tag "Option"))
1745 :version "21.1"
1746 :group 'ps-print-printer)
1748 (defcustom ps-lpr-command lpr-command
1749 "Name of program for printing a PostScript file.
1751 On MS-DOS and MS-Windows systems, if the value is an empty string then Emacs
1752 will write directly to the printer port named by `ps-printer-name'. The
1753 programs `print' and `nprint' (the standard print programs on Windows NT and
1754 Novell Netware respectively) are handled specially, using `ps-printer-name' as
1755 the destination for output; any other program is treated like `lpr' except that
1756 an explicit filename is given as the last argument."
1757 :type 'string
1758 :version "20"
1759 :group 'ps-print-printer)
1761 (defcustom ps-lpr-switches lpr-switches
1762 "List of extra switches to pass to `ps-lpr-command'.
1764 The list element can be:
1766 string it should be an option for `ps-lpr-command' (which see).
1767 For example: \"-o Duplex=DuplexNoTumble\"
1769 symbol it can be a function or variable symbol. If it's a function
1770 symbol, it should be a function with no argument. The result
1771 of the function or the variable value should be a string or a
1772 list of strings.
1774 list the header should be a symbol function and the tail is the
1775 arguments for this function. This function should return a
1776 string or a list of strings.
1778 Any other value is silently ignored.
1780 It is recommended to set `ps-printer-name' (which see) instead of including an
1781 explicit switch on this list.
1783 See `ps-lpr-command'."
1784 :type '(repeat :tag "PostScript lpr Switches"
1785 (choice :menu-tag "PostScript lpr Switch"
1786 :tag "PostScript lpr Switch"
1787 string symbol (repeat sexp)))
1788 :version "20"
1789 :group 'ps-print-printer)
1791 (defcustom ps-print-region-function nil
1792 "Specify a function to print the region on a PostScript printer.
1793 See definition of `call-process-region' for calling conventions. The fourth
1794 and the sixth arguments are both nil."
1795 :type '(choice (const nil) function)
1796 :version "20"
1797 :group 'ps-print-printer)
1799 (defcustom ps-manual-feed nil
1800 "Non-nil means the printer will manually feed paper.
1802 If it's nil, automatic feeding takes place."
1803 :type 'boolean
1804 :version "20"
1805 :group 'ps-print-printer)
1807 (defcustom ps-end-with-control-d (and ps-windows-system t)
1808 "Non-nil means insert C-d at end of PostScript file generated."
1809 :version "21.1"
1810 :type 'boolean
1811 :version "20"
1812 :group 'ps-print-printer)
1814 ;;; Page layout
1816 ;; All page dimensions are in PostScript points.
1817 ;; 1 inch == 2.54 cm == 72 points
1818 ;; 1 cm == (/ 1 2.54) inch == (/ 72 2.54) points
1820 ;; Letter 8.5 inch x 11.0 inch
1821 ;; Legal 8.5 inch x 14.0 inch
1822 ;; A4 8.26 inch x 11.69 inch = 21.0 cm x 29.7 cm
1824 ;; LetterSmall 7.68 inch x 10.16 inch
1825 ;; Tabloid 11.0 inch x 17.0 inch
1826 ;; Ledger 17.0 inch x 11.0 inch
1827 ;; Statement 5.5 inch x 8.5 inch
1828 ;; Executive 7.5 inch x 10.0 inch
1829 ;; A3 11.69 inch x 16.5 inch = 29.7 cm x 42.0 cm
1830 ;; A4Small 7.47 inch x 10.85 inch
1831 ;; B4 10.125 inch x 14.33 inch
1832 ;; B5 7.16 inch x 10.125 inch
1834 ;;;###autoload
1835 (defcustom ps-page-dimensions-database
1836 (purecopy
1837 (list (list 'a4 (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54) "A4")
1838 (list 'a3 (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54) "A3")
1839 (list 'letter (* 72 8.5) (* 72 11.0) "Letter")
1840 (list 'legal (* 72 8.5) (* 72 14.0) "Legal")
1841 (list 'letter-small (* 72 7.68) (* 72 10.16) "LetterSmall")
1842 (list 'tabloid (* 72 11.0) (* 72 17.0) "Tabloid")
1843 (list 'ledger (* 72 17.0) (* 72 11.0) "Ledger")
1844 (list 'statement (* 72 5.5) (* 72 8.5) "Statement")
1845 (list 'executive (* 72 7.5) (* 72 10.0) "Executive")
1846 (list 'a4small (* 72 7.47) (* 72 10.85) "A4Small")
1847 (list 'b4 (* 72 10.125) (* 72 14.33) "B4")
1848 (list 'b5 (* 72 7.16) (* 72 10.125) "B5")
1849 ;; page sizes for label printer
1850 ;; NOTE: the page sizes below don't have n-up > 1.
1851 '(addresslarge 236.0 99.0 "AddressLarge")
1852 '(addresssmall 236.0 68.0 "AddressSmall")
1853 '(cuthanging13 90.0 222.0 "CutHanging13")
1854 '(cuthanging15 90.0 114.0 "CutHanging15")
1855 '(diskette 181.0 136.0 "Diskette")
1856 '(eurofilefolder 139.0 112.0 "EuropeanFilefolder")
1857 '(eurofoldernarrow 526.0 107.0 "EuroFolderNarrow")
1858 '(eurofolderwide 526.0 136.0 "EuroFolderWide")
1859 '(euronamebadge 189.0 108.0 "EuroNameBadge")
1860 '(euronamebadgelarge 223.0 136.0 "EuroNameBadgeLarge")
1861 '(filefolder 230.0 37.0 "FileFolder")
1862 '(jewelry 76.0 136.0 "Jewelry")
1863 '(mediabadge 180.0 136.0 "MediaBadge")
1864 '(multipurpose 126.0 68.0 "MultiPurpose")
1865 '(retaillabel 90.0 104.0 "RetailLabel")
1866 '(shipping 271.0 136.0 "Shipping")
1867 '(slide35mm 26.0 104.0 "Slide35mm")
1868 '(spine8mm 187.0 26.0 "Spine8mm")
1869 '(topcoated 425.19685 136.0 "TopCoatedPaper")
1870 '(topcoatedpaper 396.0 136.0 "TopcoatedPaper150")
1871 '(vhsface 205.0 127.0 "VHSFace")
1872 '(vhsspine 400.0 50.0 "VHSSpine")
1873 '(zipdisk 156.0 136.0 "ZipDisk")))
1874 "List associating a symbolic paper type to its width, height and doc media.
1875 See `ps-paper-type'."
1876 :type '(repeat (list :tag "Paper Type"
1877 (symbol :tag "Symbol Name")
1878 (number :tag "Width in points")
1879 (number :tag "Height in points")
1880 (string :tag "Media")))
1881 :version "20"
1882 :group 'ps-print-page)
1884 ;;;###autoload
1885 (defcustom ps-paper-type 'letter
1886 "Specify the size of paper to format for.
1887 Should be one of the paper types defined in `ps-page-dimensions-database', for
1888 example `letter', `legal' or `a4'."
1889 :type '(symbol :validate (lambda (wid)
1890 (if (assq (widget-value wid)
1891 ps-page-dimensions-database)
1893 (widget-put wid :error "Unknown paper size")
1894 wid)))
1895 :version "20"
1896 :group 'ps-print-page)
1898 (defcustom ps-warn-paper-type t
1899 "Non-nil means give an error if paper size is not equal to `ps-paper-type'.
1901 It's used when `ps-spool-config' is set to `setpagedevice'."
1902 :type 'boolean
1903 :version "20"
1904 :group 'ps-print-page)
1906 (defcustom ps-landscape-mode nil
1907 "Non-nil means print in landscape mode."
1908 :type 'boolean
1909 :version "20"
1910 :group 'ps-print-page)
1912 (defcustom ps-print-upside-down nil
1913 "Non-nil means print upside-down (that is, rotated by 180 degrees)."
1914 :type 'boolean
1915 :version "21.1"
1916 :group 'ps-print-page)
1918 (defcustom ps-selected-pages nil
1919 "Specify which pages to print.
1921 If nil, print all pages.
1923 If a list, the lists element may be an integer or a cons cell (FROM . TO)
1924 designating FROM page to TO page; any invalid element is ignored, that is, an
1925 integer lesser than one or if FROM is greater than TO.
1927 Otherwise, it's treated as nil.
1929 After ps-print processing `ps-selected-pages' is set to nil. But the
1930 latest `ps-selected-pages' is saved in `ps-last-selected-pages' (which
1931 see). So you can restore the latest selected pages by using
1932 `ps-last-selected-pages' or with the `ps-restore-selected-pages'
1933 command (which see).
1935 See also `ps-even-or-odd-pages'."
1936 :type '(repeat :tag "Selected Pages"
1937 (radio :tag "Page"
1938 (integer :tag "Number")
1939 (cons :tag "Range"
1940 (integer :tag "From")
1941 (integer :tag "To"))))
1942 :version "20"
1943 :group 'ps-print-page)
1945 (defcustom ps-even-or-odd-pages nil
1946 "Specify if it prints even/odd pages.
1948 Valid values are:
1950 nil print all pages.
1952 `even-page' print only even pages.
1954 `odd-page' print only odd pages.
1956 `even-sheet' print only even sheets.
1957 That is, if `ps-n-up-printing' is 1, it behaves as `even-page';
1958 but for values greater than 1, it'll print only the even sheet
1959 of paper.
1961 `odd-sheet' print only odd sheets.
1962 That is, if `ps-n-up-printing' is 1, it behaves as `odd-page';
1963 but for values greater than 1, it'll print only the odd sheet
1964 of paper.
1966 Any other value is treated as nil.
1968 If you set `ps-selected-pages' (see it for documentation), first the pages are
1969 filtered by `ps-selected-pages' and then by `ps-even-or-odd-pages'. For
1970 example, if we have:
1972 (setq ps-selected-pages '(1 4 (6 . 10) (12 . 16) 20))
1974 Combining with `ps-even-or-odd-pages' and `ps-n-up-printing', we have:
1976 `ps-n-up-printing' = 1:
1977 `ps-even-or-odd-pages' PAGES PRINTED
1978 nil 1, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 20
1979 even-page 4, 6, 8, 10, 12, 14, 16, 20
1980 odd-page 1, 7, 9, 13, 15
1981 even-sheet 4, 6, 8, 10, 12, 14, 16, 20
1982 odd-sheet 1, 7, 9, 13, 15
1984 `ps-n-up-printing' = 2:
1985 `ps-even-or-odd-pages' PAGES PRINTED
1986 nil 1/4, 6/7, 8/9, 10/12, 13/14, 15/16, 20
1987 even-page 4/6, 8/10, 12/14, 16/20
1988 odd-page 1/7, 9/13, 15
1989 even-sheet 6/7, 10/12, 15/16
1990 odd-sheet 1/4, 8/9, 13/14, 20
1992 So even-page/odd-page are about page parity and even-sheet/odd-sheet are about
1993 sheet parity."
1994 :type '(choice :menu-tag "Print Even/Odd Pages"
1995 :tag "Print Even/Odd Pages"
1996 (const :tag "All Pages" nil)
1997 (const :tag "Only Even Pages" even-page)
1998 (const :tag "Only Odd Pages" odd-page)
1999 (const :tag "Only Even Sheets" even-sheet)
2000 (const :tag "Only Odd Sheets" odd-sheet))
2001 :version "20"
2002 :group 'ps-print-page)
2004 (defcustom ps-print-control-characters 'control-8-bit
2005 "Specify the printable form for control and 8-bit characters.
2006 That is, instead of sending, for example, a ^D (\\004) to printer,
2007 it is sent the string \"^D\".
2009 Valid values are:
2011 `8-bit' This is the value to use when you want an ASCII encoding of
2012 any control or non-ASCII character. Control characters are
2013 encoded as \"^D\", and non-ASCII characters have an
2014 octal encoding.
2016 `control-8-bit' This is the value to use when you want an ASCII encoding of
2017 any control character, whether it is 7 or 8-bit.
2018 European 8-bits accented characters are printed according
2019 the current font.
2021 `control' Only ASCII control characters have an ASCII encoding.
2022 European 8-bits accented characters are printed according
2023 the current font.
2025 nil No ASCII encoding. Any character is printed according the
2026 current font.
2028 Any other value is treated as nil."
2029 :type '(choice :menu-tag "Control Char"
2030 :tag "Control Char"
2031 (const 8-bit) (const control-8-bit)
2032 (const control) (const :tag "nil" nil))
2033 :version "20"
2034 :group 'ps-print-miscellany)
2036 (defcustom ps-n-up-printing 1
2037 "Specify the number of pages per sheet paper."
2038 :type '(integer
2039 :tag "N Up Printing"
2040 :validate
2041 (lambda (wid)
2042 (if (and (< 0 (widget-value wid))
2043 (<= (widget-value wid) 100))
2045 (widget-put
2046 wid :error
2047 "Number of pages per sheet paper must be between 1 and 100.")
2048 wid)))
2049 :version "20"
2050 :group 'ps-print-n-up)
2052 (defcustom ps-n-up-margin (/ (* 72 1.0) 2.54) ; 1 cm
2053 "Specify the margin in points between the sheet border and n-up printing."
2054 :type 'number
2055 :version "20"
2056 :group 'ps-print-n-up)
2058 (defcustom ps-n-up-border-p t
2059 "Non-nil means a border is drawn around each page."
2060 :type 'boolean
2061 :version "20"
2062 :group 'ps-print-n-up)
2064 (defcustom ps-n-up-filling 'left-top
2065 "Specify how page matrix is filled on each sheet of paper.
2067 Following are the valid values for `ps-n-up-filling' with a filling example
2068 using a 3x4 page matrix:
2070 `left-top' 1 2 3 4 `left-bottom' 9 10 11 12
2071 5 6 7 8 5 6 7 8
2072 9 10 11 12 1 2 3 4
2074 `right-top' 4 3 2 1 `right-bottom' 12 11 10 9
2075 8 7 6 5 8 7 6 5
2076 12 11 10 9 4 3 2 1
2078 `top-left' 1 4 7 10 `bottom-left' 3 6 9 12
2079 2 5 8 11 2 5 8 11
2080 3 6 9 12 1 4 7 10
2082 `top-right' 10 7 4 1 `bottom-right' 12 9 6 3
2083 11 8 5 2 11 8 5 2
2084 12 9 6 3 10 7 4 1
2086 Any other value is treated as `left-top'."
2087 :type '(choice :menu-tag "N-Up Filling"
2088 :tag "N-Up Filling"
2089 (const left-top) (const left-bottom)
2090 (const right-top) (const right-bottom)
2091 (const top-left) (const bottom-left)
2092 (const top-right) (const bottom-right))
2093 :version "20"
2094 :group 'ps-print-n-up)
2096 (defcustom ps-number-of-columns (if ps-landscape-mode 2 1)
2097 "Specify the number of columns."
2098 :type 'number
2099 :version "20"
2100 :group 'ps-print-miscellany)
2102 (defcustom ps-zebra-stripes nil
2103 "Non-nil means print zebra stripes.
2104 See also documentation for `ps-zebra-stripe-height' and `ps-zebra-color'."
2105 :type 'boolean
2106 :version "20"
2107 :group 'ps-print-zebra)
2109 (defcustom ps-zebra-stripe-height 3
2110 "Number of zebra stripe lines.
2111 See also documentation for `ps-zebra-stripes' and `ps-zebra-color'."
2112 :type 'number
2113 :version "20"
2114 :group 'ps-print-zebra)
2116 (defcustom ps-zebra-color 0.95
2117 "Zebra stripe gray scale or RGB color.
2118 See also documentation for `ps-zebra-stripes' and `ps-zebra-stripe-height'."
2119 :type '(choice :menu-tag "Zebra Gray/Color"
2120 :tag "Zebra Gray/Color"
2121 (number :tag "Gray Scale" :value 0.95)
2122 (string :tag "Color Name" :value "gray95")
2123 (list :tag "RGB Color" :value (0.95 0.95 0.95)
2124 (number :tag "Red")
2125 (number :tag "Green")
2126 (number :tag "Blue")))
2127 :version "20"
2128 :group 'ps-print-zebra)
2130 (defcustom ps-zebra-stripe-follow nil
2131 "Specify how zebra stripes continue on next page.
2133 Visually, valid values are (the character `+' at right of each column indicates
2134 that a line is printed):
2136 `nil' `follow' `full' `full-follow'
2137 Current Page -------- ----------- --------- ----------------
2138 1 XXXXX + 1 XXXXXXXX + 1 XXXXXX + 1 XXXXXXXXXXXXX +
2139 2 XXXXX + 2 XXXXXXXX + 2 XXXXXX + 2 XXXXXXXXXXXXX +
2140 3 XXXXX + 3 XXXXXXXX + 3 XXXXXX + 3 XXXXXXXXXXXXX +
2141 4 + 4 + 4 + 4 +
2142 5 + 5 + 5 + 5 +
2143 6 + 6 + 6 + 6 +
2144 7 XXXXX + 7 XXXXXXXX + 7 XXXXXX + 7 XXXXXXXXXXXXX +
2145 8 XXXXX + 8 XXXXXXXX + 8 XXXXXX + 8 XXXXXXXXXXXXX +
2146 9 XXXXX + 9 XXXXXXXX + 9 XXXXXX + 9 XXXXXXXXXXXXX +
2147 10 + 10 +
2148 11 + 11 +
2149 -------- ----------- --------- ----------------
2150 Next Page -------- ----------- --------- ----------------
2151 12 XXXXX + 12 + 10 XXXXXX + 10 +
2152 13 XXXXX + 13 XXXXXXXX + 11 XXXXXX + 11 +
2153 14 XXXXX + 14 XXXXXXXX + 12 XXXXXX + 12 +
2154 15 + 15 XXXXXXXX + 13 + 13 XXXXXXXXXXXXX +
2155 16 + 16 + 14 + 14 XXXXXXXXXXXXX +
2156 17 + 17 + 15 + 15 XXXXXXXXXXXXX +
2157 18 XXXXX + 18 + 16 XXXXXX + 16 +
2158 19 XXXXX + 19 XXXXXXXX + 17 XXXXXX + 17 +
2159 20 XXXXX + 20 XXXXXXXX + 18 XXXXXX + 18 +
2160 21 + 21 XXXXXXXX +
2161 22 + 22 +
2162 -------- ----------- --------- ----------------
2164 Any other value is treated as nil."
2165 :type '(choice :menu-tag "Zebra Stripe Follow"
2166 :tag "Zebra Stripe Follow"
2167 (const :tag "Always Restart" nil)
2168 (const :tag "Continue on Next Page" follow)
2169 (const :tag "Print Only Full Stripe" full)
2170 (const :tag "Continue on Full Stripe" full-follow))
2171 :version "20"
2172 :group 'ps-print-zebra)
2174 (defcustom ps-line-number nil
2175 "Non-nil means print line number."
2176 :type 'boolean
2177 :version "20"
2178 :group 'ps-print-miscellany)
2180 (defcustom ps-line-number-step 1
2181 "Specify the interval that line number is printed.
2183 For example, `ps-line-number-step' is set to 2, the printing will look like:
2185 1 one line
2186 one line
2187 3 one line
2188 one line
2189 5 one line
2190 one line
2193 Valid values are:
2195 integer an integer that specifies the interval that line number is
2196 printed. If it's lesser than or equal to zero, it's used the
2197 value 1.
2199 `zebra' specifies that only the line number of the first line in a
2200 zebra stripe is to be printed.
2202 Any other value is treated as `zebra'."
2203 :type '(choice :menu-tag "Line Number Step"
2204 :tag "Line Number Step"
2205 (integer :tag "Step Interval")
2206 (const :tag "Synchronize Zebra" zebra))
2207 :version "20"
2208 :group 'ps-print-miscellany)
2210 (defcustom ps-line-number-start 1
2211 "Specify the starting point in the interval given by `ps-line-number-step'.
2213 For example, if `ps-line-number-step' is set to 3 and `ps-line-number-start' is
2214 set to 3, the printing will look like:
2216 one line
2217 one line
2218 3 one line
2219 one line
2220 one line
2221 6 one line
2222 one line
2223 one line
2224 9 one line
2225 one line
2228 The values for `ps-line-number-start':
2230 * If `ps-line-number-step' is an integer, must be between 1 and the value of
2231 `ps-line-number-step' inclusive.
2233 * If `ps-line-number-step' is set to `zebra', must be between 1 and the
2234 value of `ps-zebra-strip-height' inclusive. Use this combination if you
2235 wish that line number be relative to zebra stripes."
2236 :type '(integer :tag "Start Step Interval")
2237 :version "20"
2238 :group 'ps-print-miscellany)
2240 (defcustom ps-print-background-image nil
2241 "EPS image list to be printed on background.
2243 The elements are:
2245 (FILENAME X Y XSCALE YSCALE ROTATION PAGES...)
2247 FILENAME is a file name which contains an EPS image or some PostScript
2248 programming like EPS.
2249 FILENAME is ignored, if it doesn't exist or is read protected.
2251 X and Y are relative positions on paper to put the image.
2252 If X and Y are nil, the image is centered on paper.
2254 XSCALE and YSCALE are scale factor to be applied to image before printing.
2255 If XSCALE and YSCALE are nil, the original size is used.
2257 ROTATION is the image rotation angle; if nil, the default is 0.
2259 PAGES designates the page to print background image.
2260 PAGES may be a number or a cons cell (FROM . TO) designating FROM page to TO
2261 page.
2262 If PAGES is nil, print background image on all pages.
2264 X, Y, XSCALE, YSCALE and ROTATION may be a floating point number, an integer
2265 number or a string. If it is a string, the string should contain PostScript
2266 programming that returns a float or integer value.
2268 For example, if you wish to print an EPS image on all pages do:
2270 '((\"~/images/EPS-image.ps\"))"
2271 :type '(repeat
2272 (list
2273 (file :tag "EPS File")
2274 (choice :tag "X" (const :tag "default" nil) number string)
2275 (choice :tag "Y" (const :tag "default" nil) number string)
2276 (choice :tag "X Scale" (const :tag "default" nil) number string)
2277 (choice :tag "Y Scale" (const :tag "default" nil) number string)
2278 (choice :tag "Rotation" (const :tag "default" nil) number string)
2279 (repeat :tag "Pages" :inline t
2280 (radio (integer :tag "Page")
2281 (cons :tag "Range"
2282 (integer :tag "From")
2283 (integer :tag "To"))))))
2284 :version "20"
2285 :group 'ps-print-background)
2287 (defcustom ps-print-background-text nil
2288 "Text list to be printed on background.
2290 The elements are:
2292 (STRING X Y FONT FONTSIZE GRAY ROTATION PAGES...)
2294 STRING is the text to be printed on background.
2296 X and Y are positions on paper to put the text.
2297 If X and Y are nil, the text is positioned at lower left corner.
2299 FONT is a font name to be used on printing the text.
2300 If nil, \"Times-Roman\" is used.
2302 FONTSIZE is font size to be used, if nil, 200 is used.
2304 GRAY is the text gray factor (should be very light like 0.8).
2305 If nil, the default is 0.85.
2307 ROTATION is the text rotation angle; if nil, the angle is given by the diagonal
2308 from lower left corner to upper right corner.
2310 PAGES designates the page to print background text.
2311 PAGES may be a number or a cons cell (FROM . TO) designating FROM page to TO
2312 page.
2313 If PAGES is nil, print background text on all pages.
2315 X, Y, FONTSIZE, GRAY and ROTATION may be a floating point number, an integer
2316 number or a string. If it is a string, the string should contain PostScript
2317 programming that returns a float or integer value.
2319 For example, if you wish to print text \"Preliminary\" on all pages do:
2321 '((\"Preliminary\"))"
2322 :type '(repeat
2323 (list
2324 (string :tag "Text")
2325 (choice :tag "X" (const :tag "default" nil) number string)
2326 (choice :tag "Y" (const :tag "default" nil) number string)
2327 (choice :tag "Font" (const :tag "default" nil) string)
2328 (choice :tag "Fontsize" (const :tag "default" nil) number string)
2329 (choice :tag "Gray" (const :tag "default" nil) number string)
2330 (choice :tag "Rotation" (const :tag "default" nil) number string)
2331 (repeat :tag "Pages" :inline t
2332 (radio (integer :tag "Page")
2333 (cons :tag "Range"
2334 (integer :tag "From")
2335 (integer :tag "To"))))))
2336 :version "20"
2337 :group 'ps-print-background)
2339 ;;; Horizontal layout
2341 ;; ------------------------------------------
2342 ;; | | | | | | | |
2343 ;; | lm | text | ic | text | ic | text | rm |
2344 ;; | | | | | | | |
2345 ;; ------------------------------------------
2347 (defcustom ps-left-margin (/ (* 72 2.0) 2.54) ; 2 cm
2348 "Left margin in points (1/72 inch)."
2349 :type 'number
2350 :version "20"
2351 :group 'ps-print-horizontal)
2353 (defcustom ps-right-margin (/ (* 72 2.0) 2.54) ; 2 cm
2354 "Right margin in points (1/72 inch)."
2355 :type 'number
2356 :version "20"
2357 :group 'ps-print-horizontal)
2359 (defcustom ps-inter-column (/ (* 72 2.0) 2.54) ; 2 cm
2360 "Horizontal space between columns in points (1/72 inch)."
2361 :type 'number
2362 :version "20"
2363 :group 'ps-print-horizontal)
2365 ;;; Vertical layout
2367 ;; |--------|
2368 ;; | tm |
2369 ;; |--------|
2370 ;; | header |
2371 ;; |--------|
2372 ;; | ho |
2373 ;; |--------|
2374 ;; | text |
2375 ;; |--------|
2376 ;; | bm |
2377 ;; |--------|
2379 (defcustom ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
2380 "Bottom margin in points (1/72 inch)."
2381 :type 'number
2382 :version "20"
2383 :group 'ps-print-vertical)
2385 (defcustom ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
2386 "Top margin in points (1/72 inch)."
2387 :type 'number
2388 :version "20"
2389 :group 'ps-print-vertical)
2391 (defcustom ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
2392 "Vertical space in points (1/72 inch) between the main text and the header."
2393 :type 'number
2394 :version "20"
2395 :group 'ps-print-vertical)
2397 (defcustom ps-header-line-pad 0.15
2398 "Portion of a header title line height to insert.
2399 The insertion is done between the header frame and the text it contains,
2400 both in the vertical and horizontal directions."
2401 :type 'number
2402 :version "20"
2403 :group 'ps-print-vertical)
2405 (defcustom ps-footer-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
2406 "Vertical space in points (1/72 inch) between the main text and the footer."
2407 :type 'number
2408 :version "20"
2409 :group 'ps-print-vertical)
2411 (defcustom ps-footer-line-pad 0.15
2412 "Portion of a footer title line height to insert.
2413 The insertion is done between the footer frame and the text it contains,
2414 both in the vertical and horizontal directions."
2415 :type 'number
2416 :version "20"
2417 :group 'ps-print-vertical)
2419 ;;; Header/Footer setup
2421 (defcustom ps-print-header t
2422 "Non-nil means print a header at the top of each page.
2423 By default, the header displays the buffer name, page number, and, if the
2424 buffer is visiting a file, the file's directory. Headers are customizable by
2425 changing variables `ps-left-header' and `ps-right-header'."
2426 :type 'boolean
2427 :version "20"
2428 :group 'ps-print-headers)
2430 (defcustom ps-print-header-frame t
2431 "Non-nil means draw a gaudy frame around the header."
2432 :type 'boolean
2433 :version "20"
2434 :group 'ps-print-headers)
2436 (defcustom ps-header-frame-alist
2437 '((fore-color . 0.0)
2438 (back-color . 0.9)
2439 (border-width . 0.4)
2440 (border-color . 0.0)
2441 (shadow-color . 0.0))
2442 "Specify header frame properties alist.
2444 Valid frame properties are:
2446 `fore-color' Specify the foreground frame color.
2447 It should be a float number between 0.0 (black color)
2448 and 1.0 (white color), a string which is a color name,
2449 or a list of 3 float numbers which corresponds to the
2450 Red Green Blue color scale, each float number between
2451 0.0 (dark color) and 1.0 (bright color).
2453 `back-color' Specify the background frame color (similar to
2454 `fore-color').
2456 `shadow-color' Specify the shadow color (similar to `fore-color').
2458 `border-color' Specify the border color (similar to `fore-color').
2460 `border-width' Specify the border width.
2462 Any other property is ignored.
2464 Don't change this alist directly, instead use customization, or `ps-value',
2465 `ps-get', `ps-put' and `ps-del' functions (see them for documentation)."
2466 :version "21.1"
2467 :type '(repeat
2468 (choice :menu-tag "Header Frame Element"
2469 :tag ""
2470 (cons :tag "Foreground Color" :format "%v"
2471 (const :format "" fore-color)
2472 (choice :menu-tag "Foreground Color"
2473 :tag "Foreground Color"
2474 (number :tag "Gray Scale" :value 0.0)
2475 (string :tag "Color Name" :value "black")
2476 (list :tag "RGB Color" :value (0.0 0.0 0.0)
2477 (number :tag "Red")
2478 (number :tag "Green")
2479 (number :tag "Blue"))))
2480 (cons :tag "Background Color" :format "%v"
2481 (const :format "" back-color)
2482 (choice :menu-tag "Background Color"
2483 :tag "Background Color"
2484 (number :tag "Gray Scale" :value 0.9)
2485 (string :tag "Color Name" :value "gray90")
2486 (list :tag "RGB Color" :value (0.9 0.9 0.9)
2487 (number :tag "Red")
2488 (number :tag "Green")
2489 (number :tag "Blue"))))
2490 (cons :tag "Border Width" :format "%v"
2491 (const :format "" border-width)
2492 (number :tag "Border Width" :value 0.4))
2493 (cons :tag "Border Color" :format "%v"
2494 (const :format "" border-color)
2495 (choice :menu-tag "Border Color"
2496 :tag "Border Color"
2497 (number :tag "Gray Scale" :value 0.0)
2498 (string :tag "Color Name" :value "black")
2499 (list :tag "RGB Color" :value (0.0 0.0 0.0)
2500 (number :tag "Red")
2501 (number :tag "Green")
2502 (number :tag "Blue"))))
2503 (cons :tag "Shadow Color" :format "%v"
2504 (const :format "" shadow-color)
2505 (choice :menu-tag "Shadow Color"
2506 :tag "Shadow Color"
2507 (number :tag "Gray Scale" :value 0.0)
2508 (string :tag "Color Name" :value "black")
2509 (list :tag "RGB Color" :value (0.0 0.0 0.0)
2510 (number :tag "Red")
2511 (number :tag "Green")
2512 (number :tag "Blue"))))))
2513 :version "20"
2514 :group 'ps-print-headers)
2516 (defcustom ps-header-lines 2
2517 "Number of lines to display in page header, when generating PostScript."
2518 :type 'integer
2519 :version "20"
2520 :group 'ps-print-headers)
2522 (defcustom ps-print-footer nil
2523 "Non-nil means print a footer at the bottom of each page.
2524 By default, the footer displays page number.
2525 Footers are customizable by changing variables `ps-left-footer' and
2526 `ps-right-footer'."
2527 :type 'boolean
2528 :version "21.1"
2529 :group 'ps-print-headers)
2531 (defcustom ps-print-footer-frame t
2532 "Non-nil means draw a gaudy frame around the footer."
2533 :type 'boolean
2534 :version "21.1"
2535 :group 'ps-print-headers)
2537 (defcustom ps-footer-frame-alist
2538 '((fore-color . 0.0)
2539 (back-color . 0.9)
2540 (border-width . 0.4)
2541 (border-color . 0.0)
2542 (shadow-color . 0.0))
2543 "Specify footer frame properties alist.
2545 Don't change this alist directly, instead use customization, or `ps-value',
2546 `ps-get', `ps-put' and `ps-del' functions (see them for documentation).
2548 See also `ps-header-frame-alist' for documentation."
2549 :type '(repeat
2550 (choice :menu-tag "Header Frame Element"
2551 :tag ""
2552 (cons :tag "Foreground Color" :format "%v"
2553 (const :format "" fore-color)
2554 (choice :menu-tag "Foreground Color"
2555 :tag "Foreground Color"
2556 (number :tag "Gray Scale" :value 0.0)
2557 (string :tag "Color Name" :value "black")
2558 (list :tag "RGB Color" :value (0.0 0.0 0.0)
2559 (number :tag "Red")
2560 (number :tag "Green")
2561 (number :tag "Blue"))))
2562 (cons :tag "Background Color" :format "%v"
2563 (const :format "" back-color)
2564 (choice :menu-tag "Background Color"
2565 :tag "Background Color"
2566 (number :tag "Gray Scale" :value 0.9)
2567 (string :tag "Color Name" :value "gray90")
2568 (list :tag "RGB Color" :value (0.9 0.9 0.9)
2569 (number :tag "Red")
2570 (number :tag "Green")
2571 (number :tag "Blue"))))
2572 (cons :tag "Border Width" :format "%v"
2573 (const :format "" border-width)
2574 (number :tag "Border Width" :value 0.4))
2575 (cons :tag "Border Color" :format "%v"
2576 (const :format "" border-color)
2577 (choice :menu-tag "Border Color"
2578 :tag "Border Color"
2579 (number :tag "Gray Scale" :value 0.0)
2580 (string :tag "Color Name" :value "black")
2581 (list :tag "RGB Color" :value (0.0 0.0 0.0)
2582 (number :tag "Red")
2583 (number :tag "Green")
2584 (number :tag "Blue"))))
2585 (cons :tag "Shadow Color" :format "%v"
2586 (const :format "" shadow-color)
2587 (choice :menu-tag "Shadow Color"
2588 :tag "Shadow Color"
2589 (number :tag "Gray Scale" :value 0.0)
2590 (string :tag "Color Name" :value "black")
2591 (list :tag "RGB Color" :value (0.0 0.0 0.0)
2592 (number :tag "Red")
2593 (number :tag "Green")
2594 (number :tag "Blue"))))))
2595 :version "21.1"
2596 :group 'ps-print-headers)
2598 (defcustom ps-footer-lines 2
2599 "Number of lines to display in page footer, when generating PostScript."
2600 :type 'integer
2601 :version "21.1"
2602 :group 'ps-print-headers)
2604 (defcustom ps-print-only-one-header nil
2605 "Non-nil means print only one header/footer at the top/bottom of each page.
2606 This is useful when printing more than one column, so it is possible to have
2607 only one header/footer over all columns or one header/footer per column.
2608 See also `ps-print-header' and `ps-print-footer'."
2609 :type 'boolean
2610 :version "20"
2611 :group 'ps-print-headers)
2613 (defcustom ps-switch-header 'duplex
2614 "Specify if headers/footers are switched or not.
2616 Valid values are:
2618 nil Never switch headers/footers.
2620 t Always switch headers/footers.
2622 duplex Switch headers/footers only when duplexing is on, that is, when
2623 `ps-spool-duplex' is non-nil.
2625 Any other value is treated as t.
2627 See also `ps-print-header' and `ps-print-footer'."
2628 :type '(choice :menu-tag "Switch Header/Footer"
2629 :tag "Switch Header/Footer"
2630 (const :tag "Never Switch" nil)
2631 (const :tag "Always Switch" t)
2632 (const :tag "Switch When Duplexing" duplex))
2633 :version "20"
2634 :group 'ps-print-headers)
2636 (defcustom ps-show-n-of-n t
2637 "Non-nil means show page numbers as N/M, meaning page N of M.
2638 NOTE: page numbers are displayed as part of headers,
2639 see variable `ps-print-header'."
2640 :type 'boolean
2641 :version "20"
2642 :group 'ps-print-headers)
2644 (defcustom ps-spool-config
2645 (if ps-windows-system
2647 'lpr-switches)
2648 "Specify who is responsible for setting duplex and page size.
2650 Valid values are:
2652 `lpr-switches' duplex and page size are configured by `ps-lpr-switches'.
2653 Don't forget to set `ps-lpr-switches' to select duplex
2654 printing for your printer.
2656 `setpagedevice' duplex and page size are configured by ps-print using the
2657 setpagedevice PostScript operator.
2659 nil duplex and page size are configured by ps-print *not* using
2660 the setpagedevice PostScript operator.
2662 Any other value is treated as nil.
2664 WARNING: The setpagedevice PostScript operator affects ghostview utility when
2665 viewing file generated using landscape. Also on some printers,
2666 setpagedevice affects zebra stripes; on other printers, setpagedevice
2667 affects the left margin.
2668 Besides all that, if your printer does not have the paper size
2669 specified by setpagedevice, your printing will be aborted.
2670 So, if you need to use setpagedevice, set `ps-spool-config' to
2671 `setpagedevice', generate a test file and send it to your printer; if
2672 the printed file isn't OK, set `ps-spool-config' to nil."
2673 :type '(choice :menu-tag "Spool Config"
2674 :tag "Spool Config"
2675 (const lpr-switches) (const setpagedevice)
2676 (const :tag "nil" nil))
2677 :version "20"
2678 :group 'ps-print-headers)
2680 (defcustom ps-spool-duplex nil ; Not many people have duplex printers,
2681 ; so default to nil.
2682 "Non-nil generates PostScript for a two-sided printer.
2683 For a duplex printer, the `ps-spool-*' and `ps-print-*' commands will insert
2684 blank pages as needed between print jobs so that the next buffer printed will
2685 start on the right page. Also, if headers are turned on, the headers will be
2686 reversed on duplex printers so that the page numbers fall to the left on
2687 even-numbered pages.
2689 See also `ps-spool-tumble'."
2690 :type 'boolean
2691 :version "20"
2692 :group 'ps-print-headers)
2694 (defcustom ps-spool-tumble nil
2695 "Specify how the page images on opposite sides of a sheet are oriented.
2696 If `ps-spool-tumble' is nil, produces output suitable for binding on the left
2697 or right. If `ps-spool-tumble' is non-nil, produces output suitable for
2698 binding at the top or bottom.
2700 It has effect only when `ps-spool-duplex' is non-nil."
2701 :type 'boolean
2702 :version "20"
2703 :group 'ps-print-headers)
2705 ;;; Fonts
2707 (defcustom ps-font-info-database
2708 '((Courier ; the family key
2709 (fonts (normal . "Courier")
2710 (bold . "Courier-Bold")
2711 (italic . "Courier-Oblique")
2712 (bold-italic . "Courier-BoldOblique"))
2713 (size . 10.0)
2714 (line-height . 10.55)
2715 (space-width . 6.0)
2716 (avg-char-width . 6.0))
2717 (Helvetica ; the family key
2718 (fonts (normal . "Helvetica")
2719 (bold . "Helvetica-Bold")
2720 (italic . "Helvetica-Oblique")
2721 (bold-italic . "Helvetica-BoldOblique"))
2722 (size . 10.0)
2723 (line-height . 11.56)
2724 (space-width . 2.78)
2725 (avg-char-width . 5.09243))
2726 (Times
2727 (fonts (normal . "Times-Roman")
2728 (bold . "Times-Bold")
2729 (italic . "Times-Italic")
2730 (bold-italic . "Times-BoldItalic"))
2731 (size . 10.0)
2732 (line-height . 11.0)
2733 (space-width . 2.5)
2734 (avg-char-width . 4.71432))
2735 (Palatino
2736 (fonts (normal . "Palatino-Roman")
2737 (bold . "Palatino-Bold")
2738 (italic . "Palatino-Italic")
2739 (bold-italic . "Palatino-BoldItalic"))
2740 (size . 10.0)
2741 (line-height . 12.1)
2742 (space-width . 2.5)
2743 (avg-char-width . 5.08676))
2744 (Helvetica-Narrow
2745 (fonts (normal . "Helvetica-Narrow")
2746 (bold . "Helvetica-Narrow-Bold")
2747 (italic . "Helvetica-Narrow-Oblique")
2748 (bold-italic . "Helvetica-Narrow-BoldOblique"))
2749 (size . 10.0)
2750 (line-height . 11.56)
2751 (space-width . 2.2796)
2752 (avg-char-width . 4.17579))
2753 (NewCenturySchlbk
2754 (fonts (normal . "NewCenturySchlbk-Roman")
2755 (bold . "NewCenturySchlbk-Bold")
2756 (italic . "NewCenturySchlbk-Italic")
2757 (bold-italic . "NewCenturySchlbk-BoldItalic"))
2758 (size . 10.0)
2759 (line-height . 12.15)
2760 (space-width . 2.78)
2761 (avg-char-width . 5.31162))
2762 ;; got no bold for the next ones
2763 (AvantGarde-Book
2764 (fonts (normal . "AvantGarde-Book")
2765 (italic . "AvantGarde-BookOblique"))
2766 (size . 10.0)
2767 (line-height . 11.77)
2768 (space-width . 2.77)
2769 (avg-char-width . 5.45189))
2770 (AvantGarde-Demi
2771 (fonts (normal . "AvantGarde-Demi")
2772 (italic . "AvantGarde-DemiOblique"))
2773 (size . 10.0)
2774 (line-height . 12.72)
2775 (space-width . 2.8)
2776 (avg-char-width . 5.51351))
2777 (Bookman-Demi
2778 (fonts (normal . "Bookman-Demi")
2779 (italic . "Bookman-DemiItalic"))
2780 (size . 10.0)
2781 (line-height . 11.77)
2782 (space-width . 3.4)
2783 (avg-char-width . 6.05946))
2784 (Bookman-Light
2785 (fonts (normal . "Bookman-Light")
2786 (italic . "Bookman-LightItalic"))
2787 (size . 10.0)
2788 (line-height . 11.79)
2789 (space-width . 3.2)
2790 (avg-char-width . 5.67027))
2791 ;; got no bold and no italic for the next ones
2792 (Symbol
2793 (fonts (normal . "Symbol"))
2794 (size . 10.0)
2795 (line-height . 13.03)
2796 (space-width . 2.5)
2797 (avg-char-width . 3.24324))
2798 (Zapf-Dingbats
2799 (fonts (normal . "Zapf-Dingbats"))
2800 (size . 10.0)
2801 (line-height . 9.63)
2802 (space-width . 2.78)
2803 (avg-char-width . 2.78))
2804 (ZapfChancery-MediumItalic
2805 (fonts (normal . "ZapfChancery-MediumItalic"))
2806 (size . 10.0)
2807 (line-height . 11.45)
2808 (space-width . 2.2)
2809 (avg-char-width . 4.10811))
2810 ;; We keep this wrong entry name (but with correct font name) for
2811 ;; backward compatibility.
2812 (Zapf-Chancery-MediumItalic
2813 (fonts (normal . "ZapfChancery-MediumItalic"))
2814 (size . 10.0)
2815 (line-height . 11.45)
2816 (space-width . 2.2)
2817 (avg-char-width . 4.10811))
2819 "Font info database.
2820 Each element comprises: font family (the key), name, bold, italic, bold-italic,
2821 reference size, line height, space width, average character width.
2822 To get the info for another specific font (say Helvetica), do the following:
2823 - create a new buffer
2824 - generate the PostScript image to a file (C-u M-x ps-print-buffer)
2825 - open this file and delete the leading `%' (which is the PostScript comment
2826 character) from the line
2827 `% 3 cm 20 cm moveto 10/Courier ReportFontInfo showpage'
2828 to get the line
2829 `3 cm 20 cm moveto 10/Helvetica ReportFontInfo showpage'
2830 - add the values to `ps-font-info-database'.
2831 You can get all the fonts of YOUR printer using `ReportAllFontInfo'.
2833 Note also that ps-print DOESN'T download any font to your printer, instead it
2834 uses the fonts resident in your printer."
2835 :type '(repeat
2836 (list :tag "Font Definition"
2837 (symbol :tag "Font Family")
2838 (cons :format "%v"
2839 (const :format "" fonts)
2840 (repeat :tag "Faces"
2841 (cons (choice :menu-tag "Font Weight/Slant"
2842 :tag "Font Weight/Slant"
2843 (const normal)
2844 (const bold)
2845 (const italic)
2846 (const bold-italic)
2847 (symbol :tag "Face"))
2848 (string :tag "Font Name"))))
2849 (cons :format "%v"
2850 (const :format "" size)
2851 (number :tag "Reference Size"))
2852 (cons :format "%v"
2853 (const :format "" line-height)
2854 (number :tag "Line Height"))
2855 (cons :format "%v"
2856 (const :format "" space-width)
2857 (number :tag "Space Width"))
2858 (cons :format "%v"
2859 (const :format "" avg-char-width)
2860 (number :tag "Average Character Width"))))
2861 :version "20"
2862 :group 'ps-print-font)
2864 (defcustom ps-font-family 'Courier
2865 "Font family name for ordinary text, when generating PostScript."
2866 :type 'symbol
2867 :version "20"
2868 :group 'ps-print-font)
2870 (defcustom ps-font-size '(7 . 8.5)
2871 "Font size, in points, for ordinary text, when generating PostScript.
2872 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE)."
2873 :type '(choice :menu-tag "Ordinary Text Font Size"
2874 :tag "Ordinary Text Font Size"
2875 (number :tag "Text Size")
2876 (cons :tag "Landscape/Portrait"
2877 (number :tag "Landscape Text Size")
2878 (number :tag "Portrait Text Size")))
2879 :version "20"
2880 :group 'ps-print-font)
2882 (defcustom ps-header-font-family 'Helvetica
2883 "Font family name for text in the header, when generating PostScript."
2884 :type 'symbol
2885 :version "20"
2886 :group 'ps-print-font)
2888 (defcustom ps-header-font-size '(10 . 12)
2889 "Font size, in points, for text in the header, when generating PostScript.
2890 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE)."
2891 :type '(choice :menu-tag "Header Font Size"
2892 :tag "Header Font Size"
2893 (number :tag "Header Size")
2894 (cons :tag "Landscape/Portrait"
2895 (number :tag "Landscape Header Size")
2896 (number :tag "Portrait Header Size")))
2897 :version "20"
2898 :group 'ps-print-font)
2900 (defcustom ps-header-title-font-size '(12 . 14)
2901 "Font size, in points, for the top line of text in header, in PostScript.
2902 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE)."
2903 :type '(choice :menu-tag "Header Title Font Size"
2904 :tag "Header Title Font Size"
2905 (number :tag "Header Title Size")
2906 (cons :tag "Landscape/Portrait"
2907 (number :tag "Landscape Header Title Size")
2908 (number :tag "Portrait Header Title Size")))
2909 :version "20"
2910 :group 'ps-print-font)
2912 (defcustom ps-footer-font-family 'Helvetica
2913 "Font family name for text in the footer, when generating PostScript."
2914 :type 'symbol
2915 :version "21.1"
2916 :group 'ps-print-font)
2918 (defcustom ps-footer-font-size '(10 . 12)
2919 "Font size, in points, for text in the footer, when generating PostScript.
2920 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE)."
2921 :type '(choice :menu-tag "Footer Font Size"
2922 :tag "Footer Font Size"
2923 (number :tag "Footer Size")
2924 (cons :tag "Landscape/Portrait"
2925 (number :tag "Landscape Footer Size")
2926 (number :tag "Portrait Footer Size")))
2927 :version "21.1"
2928 :group 'ps-print-font)
2930 (defcustom ps-line-number-color "black"
2931 "Specify color for line-number, when generating PostScript."
2932 :type '(choice :menu-tag "Line Number Color"
2933 :tag "Line Number Color"
2934 (number :tag "Gray Scale" :value 0)
2935 (string :tag "Color Name" :value "black")
2936 (list :tag "RGB Color" :value (0 0 0)
2937 (number :tag "Red")
2938 (number :tag "Green")
2939 (number :tag "Blue")))
2940 :version "21.1"
2941 :group 'ps-print-font
2942 :group 'ps-print-miscellany)
2944 (defcustom ps-line-number-font "Times-Italic"
2945 "Font for line-number, when generating PostScript."
2946 :type 'string
2947 :version "20"
2948 :group 'ps-print-font
2949 :group 'ps-print-miscellany)
2951 (defcustom ps-line-number-font-size 6
2952 "Font size, in points, for line number, when generating PostScript.
2953 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE)."
2954 :type '(choice :menu-tag "Line Number Font Size"
2955 :tag "Line Number Font Size"
2956 (number :tag "Font Size")
2957 (cons :tag "Landscape/Portrait"
2958 (number :tag "Landscape Font Size")
2959 (number :tag "Portrait Font Size")))
2960 :version "20"
2961 :group 'ps-print-font
2962 :group 'ps-print-miscellany)
2964 ;;; Colors
2966 ;; Printing color requires x-color-values.
2967 ;; XEmacs change: Need autoload for the "Options->Printing->Color Printing"
2968 ;; widget to work.
2969 ;;;###autoload
2970 (defcustom ps-print-color-p
2971 (or (fboundp 'x-color-values) ; Emacs
2972 (fboundp 'color-instance-rgb-components))
2973 ; XEmacs
2974 "Specify how buffer's text color is printed.
2976 Valid values are:
2978 nil Do not print colors.
2980 t Print colors.
2982 black-white Print colors on black/white printer.
2983 See also `ps-black-white-faces'.
2985 Any other value is treated as t."
2986 :type '(choice :menu-tag "Print Color"
2987 :tag "Print Color"
2988 (const :tag "Do NOT Print Color" nil)
2989 (const :tag "Print Always Color" t)
2990 (const :tag "Print Black/White Color" black-white))
2991 :version "20"
2992 :group 'ps-print-color)
2994 (defcustom ps-default-fg nil
2995 "RGB values of the default foreground color.
2997 The `ps-default-fg' variable contains the default foreground color used by
2998 ps-print, that is, if there is a face in a text that doesn't have a foreground
2999 color, the `ps-default-fg' color should be used.
3001 Valid values are:
3003 t The foreground color of Emacs session will be used.
3005 frame-parameter The foreground-color frame parameter will be used.
3007 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that
3008 indicate the gray color.
3010 COLOR-NAME It's a string which contains the color name. For example:
3011 \"yellow\".
3013 LIST It's a list of RGB values, that is a list of three real values
3014 of the form:
3016 (RED GREEN BLUE)
3018 Where RED, GREEN and BLUE are reals between 0.0 (no color) and
3019 1.0 (full color).
3021 Any other value is ignored and black color will be used.
3023 This variable is used only when `ps-print-color-p' (which see) is neither nil
3024 nor black-white."
3025 :type '(choice :menu-tag "Default Foreground Gray/Color"
3026 :tag "Default Foreground Gray/Color"
3027 (const :tag "Session Foreground" t)
3028 (const :tag "Frame Foreground" frame-parameter)
3029 (number :tag "Gray Scale" :value 0.0)
3030 (string :tag "Color Name" :value "black")
3031 (list :tag "RGB Color" :value (0.0 0.0 0.0)
3032 (number :tag "Red")
3033 (number :tag "Green")
3034 (number :tag "Blue")))
3035 :version "20"
3036 :group 'ps-print-color)
3038 (defcustom ps-default-bg nil
3039 "RGB values of the default background color.
3041 The `ps-default-bg' variable contains the default background color used by
3042 ps-print, that is, if there is a face in a text that doesn't have a background
3043 color, the `ps-default-bg' color should be used.
3045 Valid values are:
3047 t The background color of Emacs session will be used.
3049 frame-parameter The background-color frame parameter will be used.
3051 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that
3052 indicate the gray color.
3054 COLOR-NAME It's a string which contains the color name. For example:
3055 \"yellow\".
3057 LIST It's a list of RGB values, that is a list of three real values
3058 of the form:
3060 (RED GREEN BLUE)
3062 Where RED, GREEN and BLUE are reals between 0.0 (no color) and
3063 1.0 (full color).
3065 Any other value is ignored and white color will be used.
3067 This variable is used only when `ps-print-color-p' (which see) is neither nil
3068 nor black-white.
3070 See also `ps-use-face-background'."
3071 :type '(choice :menu-tag "Default Background Gray/Color"
3072 :tag "Default Background Gray/Color"
3073 (const :tag "Session Background" t)
3074 (const :tag "Frame Background" frame-parameter)
3075 (number :tag "Gray Scale" :value 1.0)
3076 (string :tag "Color Name" :value "white")
3077 (list :tag "RGB Color" :value (1.0 1.0 1.0)
3078 (number :tag "Red")
3079 (number :tag "Green")
3080 (number :tag "Blue")))
3081 :version "20"
3082 :group 'ps-print-color)
3084 (defcustom ps-fg-list nil
3085 "Specify foreground color list.
3087 This list is used to chose a text foreground color which is different than the
3088 background color. It'll be used the first foreground color in `ps-fg-list'
3089 which is different from the background color.
3091 If this list is nil, the default foreground color is used. See
3092 `ps-default-fg'.
3094 The list element valid values are:
3096 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that
3097 indicate the gray color.
3099 COLOR-NAME It's a string which contains the color name. For example:
3100 \"yellow\".
3102 LIST It's a list of RGB values, that is a list of three real values
3103 of the form:
3105 (RED GREEN BLUE)
3107 Where RED, GREEN and BLUE are reals between 0.0 (no color) and
3108 1.0 (full color).
3110 Any other value is ignored and black color will be used.
3112 This variable is used only when `ps-fg-validate-p' (which see) is non-nil and
3113 when `ps-print-color-p' (which see) is neither nil nor black-white."
3114 :type '(repeat
3115 (choice :menu-tag "Foreground Gray/Color"
3116 :tag "Foreground Gray/Color"
3117 (number :tag "Gray Scale" :value 0.0)
3118 (string :tag "Color Name" :value "black")
3119 (list :tag "RGB Color" :value (0.0 0.0 0.0)
3120 (number :tag "Red")
3121 (number :tag "Green")
3122 (number :tag "Blue"))))
3123 :version "22"
3124 :group 'ps-print-color)
3126 (defcustom ps-fg-validate-p t
3127 "Non-nil means validate if foreground color is different than background.
3129 If text foreground and background colors are equals, no text will appear.
3131 See also `ps-fg-list'."
3132 :type 'boolean
3133 :version "22"
3134 :group 'ps-print-color)
3136 (defcustom ps-auto-font-detect t
3137 "Non-nil means automatically detect bold/italic/underline face attributes.
3138 If nil, we rely solely on the lists `ps-bold-faces', `ps-italic-faces', and
3139 `ps-underlined-faces'."
3140 :type 'boolean
3141 :version "20"
3142 :group 'ps-print-font)
3144 (defcustom ps-black-white-faces
3145 '((font-lock-builtin-face "black" nil bold )
3146 (font-lock-comment-face "gray20" nil italic)
3147 (font-lock-constant-face "black" nil bold )
3148 (font-lock-function-name-face "black" nil bold )
3149 (font-lock-keyword-face "black" nil bold )
3150 (font-lock-string-face "black" nil italic)
3151 (font-lock-type-face "black" nil italic)
3152 (font-lock-variable-name-face "black" nil bold italic)
3153 (font-lock-warning-face "black" nil bold italic))
3154 "Specify list of face attributes to print colors on black/white printers.
3156 The list elements are the same as defined on `ps-extend-face' (which see).
3158 This variable is used only when `ps-print-color-p' is set to `black-white'."
3159 :version "21.1"
3160 :type '(repeat
3161 (list :tag "Face Specification"
3162 (face :tag "Face Symbol")
3163 (choice :menu-tag "Foreground Color"
3164 :tag "Foreground Color"
3165 (const :tag "Black" nil)
3166 (string :tag "Color Name"))
3167 (choice :menu-tag "Background Color"
3168 :tag "Background Color"
3169 (const :tag "None" nil)
3170 (string :tag "Color Name"))
3171 (repeat :inline t
3172 (choice :menu-tag "Attribute"
3173 (const bold)
3174 (const italic)
3175 (const underline)
3176 (const strikeout)
3177 (const overline)
3178 (const shadow)
3179 (const box)
3180 (const outline)))))
3181 :version "20"
3182 :group 'ps-print-face)
3184 (defcustom ps-bold-faces
3185 (unless ps-print-color-p
3186 '(font-lock-function-name-face
3187 font-lock-builtin-face
3188 font-lock-variable-name-face
3189 font-lock-keyword-face
3190 font-lock-warning-face))
3191 "A list of the \(non-bold\) faces that should be printed in bold font.
3192 This applies to generating PostScript."
3193 :type '(repeat face)
3194 :version "20"
3195 :group 'ps-print-face)
3197 (defcustom ps-italic-faces
3198 (unless ps-print-color-p
3199 '(font-lock-variable-name-face
3200 font-lock-type-face
3201 font-lock-string-face
3202 font-lock-comment-face
3203 font-lock-warning-face))
3204 "A list of the \(non-italic\) faces that should be printed in italic font.
3205 This applies to generating PostScript."
3206 :type '(repeat face)
3207 :version "20"
3208 :group 'ps-print-face)
3210 (defcustom ps-underlined-faces
3211 (unless ps-print-color-p
3212 '(font-lock-function-name-face
3213 font-lock-constant-face
3214 font-lock-warning-face))
3215 "A list of the \(non-underlined\) faces that should be printed underlined.
3216 This applies to generating PostScript."
3217 :type '(repeat face)
3218 :version "20"
3219 :group 'ps-print-face)
3221 (defcustom ps-use-face-background nil
3222 "Specify if face background should be used.
3224 Valid values are:
3226 t always use face background color.
3227 nil never use face background color.
3228 (face...) list of faces whose background color will be used.
3230 Any other value will be treated as t."
3231 :type '(choice :menu-tag "Use Face Background"
3232 :tag "Use Face Background"
3233 (const :tag "Always Use Face Background" t)
3234 (const :tag "Never Use Face Background" nil)
3235 (repeat :menu-tag "Face Background List"
3236 :tag "Face Background List"
3237 face))
3238 :version "20"
3239 :group 'ps-print-face)
3241 (defcustom ps-left-header
3242 (list 'ps-get-buffer-name 'ps-header-dirpart)
3243 "The items to display (each on a line) on the left part of the page header.
3244 This applies to generating PostScript.
3246 The value should be a list of strings and symbols, each representing an entry
3247 in the PostScript array HeaderLinesLeft.
3249 Strings are inserted unchanged into the array; those representing
3250 PostScript string literals should be delimited with PostScript string
3251 delimiters '(' and ')'.
3253 For symbols with bound functions, the function is called and should return a
3254 string to be inserted into the array. For symbols with bound values, the value
3255 should be a string to be inserted into the array. In either case, function or
3256 variable, the string value has PostScript string delimiters added to it.
3258 If symbols are unbounded, they are silently ignored."
3259 :type '(repeat (choice :menu-tag "Left Header"
3260 :tag "Left Header"
3261 string symbol))
3262 :version "20"
3263 :group 'ps-print-headers)
3265 (defcustom ps-right-header
3266 (list "/pagenumberstring load"
3267 'ps-time-stamp-locale-default 'ps-time-stamp-hh:mm:ss)
3268 "The items to display (each on a line) on the right part of the page header.
3269 This applies to generating PostScript.
3271 See the variable `ps-left-header' for a description of the format of this
3272 variable.
3274 There are the following basic functions implemented:
3276 `ps-time-stamp-locale-default' Return the locale's \"preferred\" date
3277 as, for example, \"06/18/01\".
3279 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\".
3281 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\".
3283 `ps-time-stamp-yyyy-mm-dd' Return date as \"2001-06-18\" (ISO
3284 date).
3286 `ps-time-stamp-iso8601' Alias for `ps-time-stamp-yyyy-mm-dd'.
3288 You can also create your own time stamp function by using `format-time-string'
3289 \(which see)."
3290 :type '(repeat (choice :menu-tag "Right Header"
3291 :tag "Right Header"
3292 string symbol))
3293 :version "20"
3294 :group 'ps-print-headers)
3296 (defcustom ps-left-footer
3297 (list 'ps-get-buffer-name 'ps-header-dirpart)
3298 "The items to display (each on a line) on the left part of the page footer.
3299 This applies to generating PostScript.
3301 The value should be a list of strings and symbols, each representing an entry
3302 in the PostScript array FooterLinesLeft.
3304 Strings are inserted unchanged into the array; those representing PostScript
3305 string literals should be delimited with PostScript string delimiters '(' and
3306 ')'.
3308 For symbols with bound functions, the function is called and should return a
3309 string to be inserted into the array. For symbols with bound values, the value
3310 should be a string to be inserted into the array. In either case, function or
3311 variable, the string value has PostScript string delimiters added to it.
3313 If symbols are unbounded, they are silently ignored."
3314 :type '(repeat (choice :menu-tag "Left Footer"
3315 :tag "Left Footer"
3316 string symbol))
3317 :version "21.1"
3318 :group 'ps-print-headers)
3320 (defcustom ps-right-footer
3321 (list "/pagenumberstring load"
3322 'ps-time-stamp-locale-default 'ps-time-stamp-hh:mm:ss)
3323 "The items to display (each on a line) on the right part of the page footer.
3324 This applies to generating PostScript.
3326 See the variable `ps-left-footer' for a description of the format of this
3327 variable.
3329 There are the following basic functions implemented:
3331 `ps-time-stamp-locale-default' Return the locale's \"preferred\" date
3332 as, for example, \"06/18/01\".
3334 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\".
3336 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\".
3338 `ps-time-stamp-yyyy-mm-dd' Return date as \"2001-06-18\" (ISO
3339 date).
3341 `ps-time-stamp-iso8601' Alias for `ps-time-stamp-yyyy-mm-dd'.
3343 You can also create your own time stamp function by using `format-time-string'
3344 \(which see)."
3345 :type '(repeat (choice :menu-tag "Right Footer"
3346 :tag "Right Footer"
3347 string symbol))
3348 :version "21.1"
3349 :group 'ps-print-headers)
3351 (defcustom ps-razzle-dazzle t
3352 "Non-nil means report progress while formatting buffer."
3353 :type 'boolean
3354 :version "20"
3355 :group 'ps-print-miscellany)
3357 (defcustom ps-adobe-tag "%!PS-Adobe-3.0\n"
3358 "Contains the header line identifying the output as PostScript.
3359 By default, `ps-adobe-tag' contains the standard identifier. Some printers
3360 require slightly different versions of this line."
3361 :type 'string
3362 :version "20"
3363 :group 'ps-print-miscellany)
3365 (defcustom ps-build-face-reference t
3366 "Non-nil means build the reference face lists.
3368 ps-print sets this value to nil after it builds its internal reference lists of
3369 bold and italic faces. By setting its value back to t, you can force ps-print
3370 to rebuild the lists the next time you invoke one of the ...-with-faces
3371 commands.
3373 You should set this value back to t after you change the attributes of any
3374 face, or create new faces. Most users shouldn't have to worry about its
3375 setting, though."
3376 :type 'boolean
3377 :version "20"
3378 :group 'ps-print-face)
3380 (defcustom ps-always-build-face-reference nil
3381 "Non-nil means always rebuild the reference face lists.
3383 If this variable is non-nil, ps-print will rebuild its internal reference lists
3384 of bold and italic faces *every* time one of the ...-with-faces commands is
3385 called. Most users shouldn't need to set this variable."
3386 :type 'boolean
3387 :version "20"
3388 :group 'ps-print-face)
3390 (defcustom ps-banner-page-when-duplexing nil
3391 "Non-nil means the very first page is skipped.
3392 It's like the very first character of buffer (or region) is ^L (\\014)."
3393 :type 'boolean
3394 :version "20"
3395 :group 'ps-print-headers)
3397 (defcustom ps-postscript-code-directory
3398 (or (if (featurep 'xemacs)
3399 (cond ((fboundp 'locate-data-directory) ; XEmacs
3400 (funcall 'locate-data-directory "ps-print"))
3401 ((boundp 'data-directory) ; XEmacs
3402 (symbol-value 'data-directory))
3403 (t ; don't know what to do
3404 nil))
3405 data-directory) ; Emacs
3406 (error "`ps-postscript-code-directory' isn't set properly"))
3407 "Directory where it's located the PostScript prologue file used by ps-print.
3408 By default, this directory is the same as in the variable `data-directory'."
3409 :type 'directory
3410 :version "20"
3411 :group 'ps-print-miscellany)
3413 (defcustom ps-line-spacing 0
3414 "Specify line spacing, in points, for ordinary text.
3416 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE).
3418 See also `ps-paragraph-spacing' and `ps-paragraph-regexp'.
3420 To get all lines with some spacing set both `ps-line-spacing' and
3421 `ps-paragraph-spacing' variables."
3422 :type '(choice :menu-tag "Line Spacing For Ordinary Text"
3423 :tag "Line Spacing For Ordinary Text"
3424 (number :tag "Line Spacing")
3425 (cons :tag "Landscape/Portrait"
3426 (number :tag "Landscape Line Spacing")
3427 (number :tag "Portrait Line Spacing")))
3428 :version "21.1"
3429 :group 'ps-print-miscellany)
3431 (defcustom ps-paragraph-spacing 0
3432 "Specify paragraph spacing, in points, for ordinary text.
3434 Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE).
3436 See also `ps-line-spacing' and `ps-paragraph-regexp'.
3438 To get all lines with some spacing set both `ps-line-spacing' and
3439 `ps-paragraph-spacing' variables."
3440 :type '(choice :menu-tag "Paragraph Spacing For Ordinary Text"
3441 :tag "Paragraph Spacing For Ordinary Text"
3442 (number :tag "Paragraph Spacing")
3443 (cons :tag "Landscape/Portrait"
3444 (number :tag "Landscape Paragraph Spacing")
3445 (number :tag "Portrait Paragraph Spacing")))
3446 :version "21.1"
3447 :group 'ps-print-miscellany)
3449 (defcustom ps-paragraph-regexp "[ \t]*$"
3450 "Specify paragraph delimiter.
3452 It should be a regexp or nil.
3454 See also `ps-paragraph-spacing'."
3455 :type '(choice :menu-tag "Paragraph Delimiter"
3456 (const :tag "No Delimiter" nil)
3457 (regexp :tag "Delimiter Regexp"))
3458 :version "21.1"
3459 :group 'ps-print-miscellany)
3461 (defcustom ps-begin-cut-regexp nil
3462 "Specify regexp which is start of a region to cut out when printing.
3464 As an example, variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' may be
3465 set to \"^Local Variables:\" and \"^End:\", respectively, in order to leave out
3466 some special printing instructions from the actual print. Special printing
3467 instructions may be appended to the end of the file just like any other
3468 buffer-local variables. See section \"Local Variables in Files\" on Emacs
3469 manual for more information.
3471 Variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' control together what
3472 actually gets printed. Both variables may be set to nil in which case no
3473 cutting occurs."
3474 :type '(choice (const :tag "No Delimiter" nil)
3475 (regexp :tag "Delimiter Regexp"))
3476 :version "21.1"
3477 :group 'ps-print-miscellany)
3479 (defcustom ps-end-cut-regexp nil
3480 "Specify regexp which is end of the region to cut out when printing.
3482 See `ps-begin-cut-regexp' for more information."
3483 :type '(choice (const :tag "No Delimiter" nil)
3484 (regexp :tag "Delimiter Regexp"))
3485 :version "21.1"
3486 :group 'ps-print-miscellany)
3489 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3490 ;; Selected Pages
3493 (defvar ps-last-selected-pages nil
3494 "Latest `ps-selected-pages' value.")
3497 (defun ps-restore-selected-pages ()
3498 "Restore latest `ps-selected-pages' value."
3499 (interactive)
3500 (setq ps-selected-pages ps-last-selected-pages))
3503 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3504 ;; Customization
3507 ;;;###autoload
3508 (defun ps-print-customize ()
3509 "Customization of ps-print group."
3510 (interactive)
3511 (customize-group 'ps-print))
3514 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3515 ;; User commands
3518 ;;;###autoload
3519 (defun ps-print-buffer (&optional filename)
3520 "Generate and print a PostScript image of the buffer.
3522 Interactively, when you use a prefix argument (\\[universal-argument]), the command prompts the
3523 user for a file name, and saves the PostScript image in that file instead of
3524 sending it to the printer.
3526 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3527 send the image to the printer. If FILENAME is a string, save the PostScript
3528 image in a file with that name."
3529 (interactive (list (ps-print-preprint current-prefix-arg)))
3530 (ps-print-without-faces (point-min) (point-max) filename))
3533 ;;;###autoload
3534 (defun ps-print-buffer-with-faces (&optional filename)
3535 "Generate and print a PostScript image of the buffer.
3536 Like `ps-print-buffer', but includes font, color, and underline information in
3537 the generated image. This command works only if you are using a window system,
3538 so it has a way to determine color values."
3539 (interactive (list (ps-print-preprint current-prefix-arg)))
3540 (ps-print-with-faces (point-min) (point-max) filename))
3543 ;;;###autoload
3544 (defun ps-print-region (from to &optional filename)
3545 "Generate and print a PostScript image of the region.
3546 Like `ps-print-buffer', but prints just the current region."
3547 (interactive (ps-print-preprint-region current-prefix-arg))
3548 (ps-print-without-faces from to filename t))
3551 ;;;###autoload
3552 (defun ps-print-region-with-faces (from to &optional filename)
3553 "Generate and print a PostScript image of the region.
3554 Like `ps-print-region', but includes font, color, and underline information in
3555 the generated image. This command works only if you are using a window system,
3556 so it has a way to determine color values."
3557 (interactive (ps-print-preprint-region current-prefix-arg))
3558 (ps-print-with-faces from to filename t))
3561 ;;;###autoload
3562 (defun ps-spool-buffer ()
3563 "Generate and spool a PostScript image of the buffer.
3564 Like `ps-print-buffer' except that the PostScript image is saved in a local
3565 buffer to be sent to the printer later.
3567 Use the command `ps-despool' to send the spooled images to the printer."
3568 (interactive)
3569 (ps-spool-without-faces (point-min) (point-max)))
3572 ;;;###autoload
3573 (defun ps-spool-buffer-with-faces ()
3574 "Generate and spool a PostScript image of the buffer.
3575 Like `ps-spool-buffer', but includes font, color, and underline information in
3576 the generated image. This command works only if you are using a window system,
3577 so it has a way to determine color values.
3579 Use the command `ps-despool' to send the spooled images to the printer."
3580 (interactive)
3581 (ps-spool-with-faces (point-min) (point-max)))
3584 ;;;###autoload
3585 (defun ps-spool-region (from to)
3586 "Generate a PostScript image of the region and spool locally.
3587 Like `ps-spool-buffer', but spools just the current region.
3589 Use the command `ps-despool' to send the spooled images to the printer."
3590 (interactive "r")
3591 (ps-spool-without-faces from to t))
3594 ;;;###autoload
3595 (defun ps-spool-region-with-faces (from to)
3596 "Generate a PostScript image of the region and spool locally.
3597 Like `ps-spool-region', but includes font, color, and underline information in
3598 the generated image. This command works only if you are using a window system,
3599 so it has a way to determine color values.
3601 Use the command `ps-despool' to send the spooled images to the printer."
3602 (interactive "r")
3603 (ps-spool-with-faces from to t))
3605 ;;;###autoload
3606 (defun ps-despool (&optional filename)
3607 "Send the spooled PostScript to the printer.
3609 Interactively, when you use a prefix argument (\\[universal-argument]), the command prompts the
3610 user for a file name, and saves the spooled PostScript image in that file
3611 instead of sending it to the printer.
3613 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3614 send the image to the printer. If FILENAME is a string, save the PostScript
3615 image in a file with that name."
3616 (interactive (list (ps-print-preprint current-prefix-arg)))
3617 (ps-do-despool filename))
3619 ;;;###autoload
3620 (defun ps-line-lengths ()
3621 "Display the correspondence between a line length and a font size.
3622 Done using the current ps-print setup.
3623 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
3624 (interactive)
3625 (ps-line-lengths-internal))
3627 ;;;###autoload
3628 (defun ps-nb-pages-buffer (nb-lines)
3629 "Display number of pages to print this buffer, for various font heights.
3630 The table depends on the current ps-print setup."
3631 (interactive (ps-count-lines-preprint (point-min) (point-max)))
3632 (ps-nb-pages nb-lines))
3634 ;;;###autoload
3635 (defun ps-nb-pages-region (nb-lines)
3636 "Display number of pages to print the region, for various font heights.
3637 The table depends on the current ps-print setup."
3638 (interactive (ps-count-lines-preprint (mark) (point)))
3639 (ps-nb-pages nb-lines))
3641 (defvar ps-prefix-quote nil
3642 "Used for `ps-print-quote' (which see).")
3644 ;;;###autoload
3645 (defun ps-setup ()
3646 "Return the current PostScript-generation setup."
3647 (let (ps-prefix-quote)
3648 (mapconcat
3649 #'ps-print-quote
3650 (list
3651 (concat "\n;;; (" (if (featurep 'xemacs) "XEmacs" "Emacs")
3652 ") ps-print version " ps-print-version "\n")
3653 ";; internal vars"
3654 (ps-comment-string "emacs-version " emacs-version)
3655 (ps-comment-string "ps-windows-system " ps-windows-system)
3656 (ps-comment-string "ps-lp-system " ps-lp-system)
3658 '(25 . ps-print-color-p)
3659 '(25 . ps-lpr-command)
3660 '(25 . ps-lpr-switches)
3661 '(25 . ps-printer-name)
3662 '(25 . ps-printer-name-option)
3663 '(25 . ps-print-region-function)
3664 '(25 . ps-manual-feed)
3665 '(25 . ps-end-with-control-d)
3667 '(23 . ps-paper-type)
3668 '(23 . ps-warn-paper-type)
3669 '(23 . ps-landscape-mode)
3670 '(23 . ps-print-upside-down)
3671 '(23 . ps-number-of-columns)
3673 '(23 . ps-zebra-stripes)
3674 '(23 . ps-zebra-stripe-height)
3675 '(23 . ps-zebra-stripe-follow)
3676 '(23 . ps-zebra-color)
3677 '(23 . ps-line-number)
3678 '(23 . ps-line-number-step)
3679 '(23 . ps-line-number-start)
3681 '(17 . ps-razzle-dazzle)
3682 '(17 . ps-default-bg)
3683 '(17 . ps-default-fg)
3684 '(17 . ps-fg-validate-p)
3685 '(17 . ps-fg-list)
3687 '(23 . ps-use-face-background)
3689 '(28 . ps-print-control-characters)
3691 '(26 . ps-print-background-image)
3693 '(25 . ps-print-background-text)
3695 '(29 . ps-error-handler-message)
3696 '(29 . ps-user-defined-prologue)
3697 '(29 . ps-print-prologue-header)
3698 '(29 . ps-postscript-code-directory)
3699 '(29 . ps-adobe-tag)
3701 '(30 . ps-left-margin)
3702 '(30 . ps-right-margin)
3703 '(30 . ps-inter-column)
3704 '(30 . ps-bottom-margin)
3705 '(30 . ps-top-margin)
3706 '(30 . ps-print-only-one-header)
3707 '(30 . ps-switch-header)
3708 '(30 . ps-print-header)
3709 '(30 . ps-header-lines)
3710 '(30 . ps-header-offset)
3711 '(30 . ps-header-line-pad)
3712 '(30 . ps-print-header-frame)
3713 '(30 . ps-header-frame-alist)
3714 '(30 . ps-print-footer)
3715 '(30 . ps-footer-lines)
3716 '(30 . ps-footer-offset)
3717 '(30 . ps-footer-line-pad)
3718 '(30 . ps-print-footer-frame)
3719 '(30 . ps-footer-frame-alist)
3720 '(30 . ps-show-n-of-n)
3721 '(30 . ps-spool-config)
3722 '(30 . ps-spool-duplex)
3723 '(30 . ps-spool-tumble)
3724 '(30 . ps-banner-page-when-duplexing)
3725 '(30 . ps-left-header)
3726 '(30 . ps-right-header)
3727 '(30 . ps-left-footer)
3728 '(30 . ps-right-footer)
3730 '(23 . ps-n-up-printing)
3731 '(23 . ps-n-up-margin)
3732 '(23 . ps-n-up-border-p)
3733 '(23 . ps-n-up-filling)
3735 '(26 . ps-multibyte-buffer)
3736 '(26 . ps-font-family)
3737 '(26 . ps-font-size)
3738 '(26 . ps-header-font-family)
3739 '(26 . ps-header-font-size)
3740 '(26 . ps-header-title-font-size)
3741 '(26 . ps-footer-font-family)
3742 '(26 . ps-footer-font-size)
3743 '(26 . ps-line-number-color)
3744 '(26 . ps-line-number-font)
3745 '(26 . ps-line-number-font-size)
3746 '(26 . ps-line-spacing)
3747 '(26 . ps-paragraph-spacing)
3748 '(26 . ps-paragraph-regexp)
3749 '(26 . ps-begin-cut-regexp)
3750 '(26 . ps-end-cut-regexp)
3752 '(23 . ps-even-or-odd-pages)
3753 '(23 . ps-selected-pages)
3754 '(23 . ps-last-selected-pages)
3756 '(31 . ps-build-face-reference)
3757 '(31 . ps-always-build-face-reference)
3759 '(20 . ps-auto-font-detect)
3760 '(20 . ps-bold-faces)
3761 '(20 . ps-italic-faces)
3762 '(20 . ps-underlined-faces)
3763 '(20 . ps-black-white-faces)
3764 " )\n
3765 \;; The following customized variables have long lists and are seldom modified:
3766 \;; ps-page-dimensions-database
3767 \;; ps-font-info-database
3769 \;;; ps-print - end of settings\n")
3770 "\n")))
3773 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3774 ;; Utility functions and variables:
3777 (defun ps-print-quote (elt)
3778 "Quote ELT for printing (used for showing settings).
3780 If ELT is nil, return an empty string.
3781 If ELT is string, return it.
3782 Otherwise, ELT should be a cons (LEN . SYM) where SYM is a variable symbol and
3783 LEN is the field length where SYM name will be inserted. The variable
3784 `ps-prefix-quote' is used to form the string, if `ps-prefix-quote' is nil, it's
3785 used \"(setq \" as prefix; otherwise, it's used \" \". So, the string
3786 generated is:
3788 * If `ps-prefix-quote' is nil:
3789 \"(setq SYM-NAME SYM-VALUE\"
3790 |<------->|
3793 * If `ps-prefix-quote' is non-nil:
3794 \" SYM-NAME SYM-VALUE\"
3795 |<------->|
3798 If `ps-prefix-quote' is nil, it's set to t after generating string."
3799 (cond
3800 ((stringp elt) elt)
3801 ((and (consp elt) (integerp (car elt))
3802 (symbolp (cdr elt)) (boundp (cdr elt)))
3803 (let* ((col (car elt))
3804 (sym (cdr elt))
3805 (key (symbol-name sym))
3806 (len (length key))
3807 (val (symbol-value sym)))
3808 (concat (if ps-prefix-quote
3810 (setq ps-prefix-quote t)
3811 "(setq ")
3813 (if (> col len)
3814 (make-string (- col len) ?\s)
3815 " ")
3816 (ps-value-string val))))
3817 (t "")
3821 (defun ps-value-string (val)
3822 "Return a string representation of VAL. Used by `ps-print-quote'."
3823 (cond ((null val)
3824 "nil")
3825 ((eq val t)
3826 "t")
3827 ((or (symbolp val) (listp val))
3828 (format "'%S" val))
3830 (format "%S" val))))
3833 (defun ps-comment-string (str value)
3834 "Return a comment string like \";; STR = VALUE\"."
3835 (format ";; %s = %s" str (ps-value-string value)))
3838 (defun ps-value (alist-sym key)
3839 "Return value from association list ALIST-SYM which car is `eq' to KEY."
3840 (cdr (assq key (symbol-value alist-sym))))
3843 (defun ps-get (alist-sym key)
3844 "Return element from association list ALIST-SYM which car is `eq' to KEY."
3845 (assq key (symbol-value alist-sym)))
3848 (defun ps-put (alist-sym key value)
3849 "Store element (KEY . VALUE) into association list ALIST-SYM.
3850 If KEY already exists in ALIST-SYM, modify cdr to VALUE.
3851 It can be retrieved with `(ps-get ALIST-SYM KEY)'."
3852 (let ((elt: (assq key (symbol-value alist-sym)))) ; to avoid name conflict
3853 (if elt:
3854 (setcdr elt: value)
3855 (setq elt: (cons key value))
3856 (set alist-sym (cons elt: (symbol-value alist-sym))))
3857 elt:))
3860 (defun ps-del (alist-sym key)
3861 "Delete by side effect element KEY from association list ALIST-SYM."
3862 (let ((a:list: (symbol-value alist-sym)) ; to avoid name conflict
3863 old)
3864 (while a:list:
3865 (if (eq key (car (car a:list:)))
3866 (progn
3867 (if old
3868 (setcdr old (cdr a:list:))
3869 (set alist-sym (cdr a:list:)))
3870 (setq a:list: nil))
3871 (setq old a:list:
3872 a:list: (cdr a:list:)))))
3873 (symbol-value alist-sym))
3876 (defun ps-time-stamp-locale-default ()
3877 "Return the locale's \"preferred\" date as, for example, \"06/18/01\"."
3878 (format-time-string "%x"))
3881 (defun ps-time-stamp-mon-dd-yyyy ()
3882 "Return date as \"Jun 18 2001\"."
3883 (format-time-string "%b %d %Y"))
3886 (defun ps-time-stamp-yyyy-mm-dd ()
3887 "Return date as \"2001-06-18\" (ISO date)."
3888 (format-time-string "%Y-%m-%d"))
3891 ;; Alias for `ps-time-stamp-yyyy-mm-dd' (which see).
3892 (defalias 'ps-time-stamp-iso8601 'ps-time-stamp-yyyy-mm-dd)
3895 (defun ps-time-stamp-hh:mm:ss ()
3896 "Return time as \"17:28:31\"."
3897 (format-time-string "%T"))
3900 (defvar ps-print-color-scale 1.0)
3902 (defun ps-color-scale (color)
3903 ;; Scale 16-bit X-COLOR-VALUE to PostScript color value in [0, 1] interval.
3904 (mapcar #'(lambda (value) (/ value ps-print-color-scale))
3905 (ps-color-values color)))
3908 (defun ps-face-underlined-p (face)
3909 (or (face-underline-p face)
3910 (memq face ps-underlined-faces)))
3913 (defun ps-prologue-file (filenumber)
3914 "If prologue FILENUMBER exists and is readable, return contents as string.
3916 Note: No major/minor-mode is activated and no local variables are evaluated for
3917 FILENUMBER, but proper EOL-conversion and character interpretation is
3918 done!"
3919 (let ((filename (convert-standard-filename
3920 (expand-file-name (format "ps-prin%d.ps" filenumber)
3921 ps-postscript-code-directory))))
3922 (if (and (file-exists-p filename)
3923 (file-readable-p filename))
3924 (with-temp-buffer
3925 (insert-file-contents filename)
3926 (buffer-string))
3927 (error "ps-print PostScript prologue `%s' file was not found"
3928 filename))))
3931 (defvar ps-mark-code-directory nil)
3933 (defvar ps-print-prologue-0 ""
3934 "ps-print PostScript error handler.")
3936 (defvar ps-print-prologue-1 ""
3937 "ps-print PostScript prologue.")
3939 ;; Start Editing Here:
3941 (defvar ps-source-buffer nil)
3942 (defvar ps-spool-buffer-name "*PostScript*")
3943 (defvar ps-spool-buffer nil)
3945 (defvar ps-output-head nil)
3946 (defvar ps-output-tail nil)
3948 (defvar ps-page-postscript 0) ; page number
3949 (defvar ps-page-order 0) ; PostScript page counter
3950 (defvar ps-page-sheet 0) ; sheet counter
3951 (defvar ps-page-column 0) ; column counter
3952 (defvar ps-page-printed 0) ; total pages printed
3953 (defvar ps-page-n-up 0) ; n-up counter
3954 (defvar ps-lines-printed 0) ; total lines printed
3955 (defvar ps-showline-count 1) ; line number counter
3956 (defvar ps-first-page nil)
3957 (defvar ps-last-page nil)
3958 (defvar ps-print-page-p t)
3960 (defvar ps-control-or-escape-regexp nil)
3961 (defvar ps-n-up-on nil)
3963 (defvar ps-background-pages nil)
3964 (defvar ps-background-all-pages nil)
3965 (defvar ps-background-text-count 0)
3966 (defvar ps-background-image-count 0)
3968 (defvar ps-current-font 0)
3969 (defvar ps-default-foreground nil)
3970 (defvar ps-default-background nil)
3971 (defvar ps-default-color nil)
3972 (defvar ps-current-color nil)
3973 (defvar ps-current-bg nil)
3974 (defvar ps-foreground-list nil)
3976 (defvar ps-zebra-stripe-full-p nil)
3977 (defvar ps-razchunk 0)
3979 (defvar ps-color-p nil)
3981 ;; These values determine how much print-height to deduct when headers/footers
3982 ;; are turned on. This is a pretty clumsy way of handling it, but it'll do for
3983 ;; now.
3985 (defvar ps-header-pad 0
3986 "Vertical and horizontal space between the header frame and the text.
3987 This is in units of points (1/72 inch).")
3989 (defvar ps-footer-pad 0
3990 "Vertical and horizontal space between the footer frame and the text.
3991 This is in units of points (1/72 inch).")
3993 ;; Define accessors to the dimensions list.
3995 (defmacro ps-page-dimensions-get-width (dims) `(nth 0 ,dims))
3996 (defmacro ps-page-dimensions-get-height (dims) `(nth 1 ,dims))
3997 (defmacro ps-page-dimensions-get-media (dims) `(nth 2 ,dims))
3999 (defvar ps-landscape-page-height nil)
4001 (defvar ps-print-width nil)
4002 (defvar ps-print-height nil)
4004 (defvar ps-height-remaining nil)
4005 (defvar ps-width-remaining nil)
4007 (defvar ps-font-size-internal nil)
4008 (defvar ps-header-font-size-internal nil)
4009 (defvar ps-header-title-font-size-internal nil)
4010 (defvar ps-footer-font-size-internal nil)
4011 (defvar ps-line-spacing-internal nil)
4012 (defvar ps-paragraph-spacing-internal nil)
4015 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4016 ;; Internal Variables
4019 (defvar ps-black-white-faces-alist nil
4020 "Alist of symbolic faces used for black/white PostScript printers.
4021 An element of this list has the same form as `ps-print-face-extension-alist'
4022 \(which see).
4024 Don't change this list directly; instead,
4025 use `ps-extend-face' and `ps-extend-face-list'.
4026 See documentation for `ps-extend-face' for valid extension symbol.
4027 See also documentation for `ps-print-color-p'.")
4030 (defvar ps-print-face-extension-alist nil
4031 "Alist of symbolic faces *WITH* extension features (box, outline, etc).
4032 An element of this list has the following form:
4034 (FACE . [BITS FG BG])
4036 FACE is a symbol denoting a face name
4037 BITS is a bit vector, where each bit correspond
4038 to a feature (bold, underline, etc)
4039 (see documentation for `ps-print-face-map-alist')
4040 FG foreground color (string or nil)
4041 BG background color (string or nil)
4043 Don't change this list directly; instead,
4044 use `ps-extend-face' and `ps-extend-face-list'.
4045 See documentation for `ps-extend-face' for valid extension symbol.")
4048 (defvar ps-print-face-alist nil
4049 "Alist of symbolic faces *WITHOUT* extension features (box, outline, etc).
4051 An element of this list has the same form as an element of
4052 `ps-print-face-extension-alist'.
4054 Don't change this list directly; this list is used by `ps-face-attributes',
4055 `ps-map-face' and `ps-build-reference-face-lists'.")
4058 (defconst ps-print-face-map-alist
4059 '((bold . 1)
4060 (italic . 2)
4061 (underline . 4)
4062 (strikeout . 8)
4063 (overline . 16)
4064 (shadow . 32)
4065 (box . 64)
4066 (outline . 128))
4067 "Alist of all features and the corresponding bit mask.
4068 Each symbol correspond to one bit in a bit vector.")
4071 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4072 ;; Remapping Faces
4075 ;;;###autoload
4076 (defun ps-extend-face-list (face-extension-list &optional merge-p alist-sym)
4077 "Extend face in ALIST-SYM.
4079 If optional MERGE-P is non-nil, extensions in FACE-EXTENSION-LIST are merged
4080 with face extension in ALIST-SYM; otherwise, overrides.
4082 If optional ALIST-SYM is nil, `ps-print-face-extension-alist' is used;
4083 otherwise, it should be an alist symbol.
4085 The elements in FACE-EXTENSION-LIST are like those for `ps-extend-face'.
4087 See `ps-extend-face' for documentation."
4088 (while face-extension-list
4089 (ps-extend-face (car face-extension-list) merge-p alist-sym)
4090 (setq face-extension-list (cdr face-extension-list))))
4093 ;;;###autoload
4094 (defun ps-extend-face (face-extension &optional merge-p alist-sym)
4095 "Extend face in ALIST-SYM.
4097 If optional MERGE-P is non-nil, extensions in FACE-EXTENSION list are merged
4098 with face extensions in ALIST-SYM; otherwise, overrides.
4100 If optional ALIST-SYM is nil, `ps-print-face-extension-alist' is used;
4101 otherwise, it should be an alist symbol.
4103 The elements of FACE-EXTENSION list have the form:
4105 (FACE-NAME FOREGROUND BACKGROUND EXTENSION...)
4107 FACE-NAME is a face name symbol.
4109 FOREGROUND and BACKGROUND may be nil or a string that denotes the
4110 foreground and background colors respectively.
4112 EXTENSION is one of the following symbols:
4113 bold - use bold font.
4114 italic - use italic font.
4115 underline - put a line under text.
4116 strikeout - like underline, but the line is in middle of text.
4117 overline - like underline, but the line is over the text.
4118 shadow - text will have a shadow.
4119 box - text will be surrounded by a box.
4120 outline - print characters as hollow outlines.
4122 If EXTENSION is any other symbol, it is ignored."
4123 (or alist-sym
4124 (setq alist-sym 'ps-print-face-extension-alist))
4125 (let* ((background (nth 2 face-extension))
4126 (foreground (nth 1 face-extension))
4127 (face-name (nth 0 face-extension))
4128 (ps-face (cdr (assq face-name (symbol-value alist-sym))))
4129 (face-vector (or ps-face (vector 0 nil nil)))
4130 (face-bit (ps-extension-bit face-extension)))
4131 ;; extend face
4132 (aset face-vector 0 (if merge-p
4133 (logior (aref face-vector 0) face-bit)
4134 face-bit))
4135 (and (or (not merge-p) (and foreground (stringp foreground)))
4136 (aset face-vector 1 foreground))
4137 (and (or (not merge-p) (and background (stringp background)))
4138 (aset face-vector 2 background))
4139 ;; if face does not exist, insert it
4140 (or ps-face
4141 (set alist-sym (cons (cons face-name face-vector)
4142 (symbol-value alist-sym))))))
4145 (defun ps-extension-bit (face-extension)
4146 (let ((face-bit 0))
4147 ;; map valid symbol extension to bit vector
4148 (setq face-extension (cdr (cdr face-extension)))
4149 (while (setq face-extension (cdr face-extension))
4150 (setq face-bit (logior face-bit
4151 (or (cdr (assq (car face-extension)
4152 ps-print-face-map-alist))
4153 0))))
4154 face-bit))
4157 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4158 ;; Adapted from font-lock: (obsolete stuff)
4159 ;; Originally face attributes were specified via `font-lock-face-attributes'.
4160 ;; Users then changed the default face attributes by setting that variable.
4161 ;; However, we try and be back-compatible and respect its value if set except
4162 ;; for faces where M-x customize has been used to save changes for the face.
4165 (defun ps-font-lock-face-attributes ()
4166 (and (boundp 'font-lock-mode) (symbol-value 'font-lock-mode)
4167 (boundp 'font-lock-face-attributes)
4168 (let ((face-attributes (symbol-value 'font-lock-face-attributes)))
4169 (while face-attributes
4170 (let* ((face-attribute
4171 (car (prog1 face-attributes
4172 (setq face-attributes (cdr face-attributes)))))
4173 (face (car face-attribute)))
4174 ;; Rustle up a `defface' SPEC from a
4175 ;; `font-lock-face-attributes' entry.
4176 (unless (get face 'saved-face)
4177 (let ((foreground (nth 1 face-attribute))
4178 (background (nth 2 face-attribute))
4179 (bold-p (nth 3 face-attribute))
4180 (italic-p (nth 4 face-attribute))
4181 (underline-p (nth 5 face-attribute))
4182 face-spec)
4183 (when foreground
4184 (setq face-spec (cons ':foreground
4185 (cons foreground face-spec))))
4186 (when background
4187 (setq face-spec (cons ':background
4188 (cons background face-spec))))
4189 (when bold-p
4190 (setq face-spec (append '(:weight bold) face-spec)))
4191 (when italic-p
4192 (setq face-spec (append '(:slant italic) face-spec)))
4193 (when underline-p
4194 (setq face-spec (append '(:underline t) face-spec)))
4195 (custom-declare-face face (list (list t face-spec)) nil)
4196 )))))))
4199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4200 ;; Internal functions and variables
4203 (defun ps-message-log-max ()
4204 (and (not (string= (buffer-name) "*Messages*"))
4205 (boundp 'message-log-max)
4206 message-log-max))
4209 (defvar ps-print-hook nil)
4210 (defvar ps-print-begin-sheet-hook nil)
4211 (defvar ps-print-begin-page-hook nil)
4212 (defvar ps-print-begin-column-hook nil)
4215 (defun ps-print-without-faces (from to &optional filename region-p)
4216 (ps-spool-without-faces from to region-p)
4217 (ps-do-despool filename))
4220 (defun ps-spool-without-faces (from to &optional region-p)
4221 (let ((message-log-max (ps-message-log-max))) ; to print *Messages* buffer
4222 (run-hooks 'ps-print-hook)
4223 (ps-printing-region region-p from to)
4224 (ps-generate (current-buffer) from to 'ps-generate-postscript)))
4227 (defun ps-print-with-faces (from to &optional filename region-p)
4228 (ps-spool-with-faces from to region-p)
4229 (ps-do-despool filename))
4232 (defun ps-spool-with-faces (from to &optional region-p)
4233 (let ((message-log-max (ps-message-log-max))) ; to print *Messages* buffer
4234 (run-hooks 'ps-print-hook)
4235 (ps-printing-region region-p from to)
4236 (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces)))
4239 (defun ps-count-lines-preprint (from to)
4240 (or (and from to)
4241 (error "The mark is not set now"))
4242 (let ((message-log-max (ps-message-log-max))) ; to count lines of *Messages*
4243 (list (count-lines from to))))
4246 (defun ps-count-lines (from to)
4247 (+ (count-lines from to)
4248 (save-excursion
4249 (goto-char to)
4250 (if (= (current-column) 0) 1 0))))
4253 (defvar ps-printing-region nil
4254 "Variable used to indicate the region that ps-print is printing.
4255 It is a cons, the car of which is the line number where the region begins, and
4256 its cdr is the total number of lines in the buffer. Formatting functions can
4257 use this information to print the original line number (and not the number of
4258 lines printed), and to indicate in the header that the printout is of a partial
4259 file.")
4262 (defvar ps-printing-region-p nil
4263 "Non-nil means ps-print is printing a region.")
4266 (defun ps-printing-region (region-p from to)
4267 (setq ps-printing-region-p region-p
4268 ps-printing-region
4269 (cons (if region-p
4270 (ps-count-lines (point-min) (min from to))
4272 (ps-count-lines (point-min) (point-max)))))
4275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4276 ;; Internal functions
4279 (defsubst ps-font-alist (font-sym)
4280 (get font-sym 'fonts))
4282 (defun ps-font (font-sym font-type)
4283 "Font family name for text of `font-type', when generating PostScript."
4284 (let* ((font-list (ps-font-alist font-sym))
4285 (normal-font (cdr (assq 'normal font-list))))
4286 (while (and font-list (not (eq font-type (car (car font-list)))))
4287 (setq font-list (cdr font-list)))
4288 (or (cdr (car font-list)) normal-font)))
4290 (defsubst ps-fonts (font-sym)
4291 (mapcar 'cdr (ps-font-alist font-sym)))
4293 (defsubst ps-font-number (font-sym font-type)
4294 (or (ps-alist-position font-type (ps-font-alist font-sym))
4297 (defsubst ps-line-height (font-sym)
4298 "The height of a line, for generating PostScript.
4299 This is the value that ps-print uses to determine the height,
4300 y-dimension, of the lines of text it has printed, and thus affects the
4301 point at which page-breaks are placed.
4302 The line-height is *not* the same as the point size of the font."
4303 (get font-sym 'line-height))
4305 (defsubst ps-title-line-height (font-sym)
4306 "The height of a `title' line, for generating PostScript.
4307 This is the value that ps-print uses to determine the height,
4308 y-dimension, of the lines of text it has printed, and thus affects the
4309 point at which page-breaks are placed.
4310 The title-line-height is *not* the same as the point size of the font."
4311 (get font-sym 'title-line-height))
4313 (defsubst ps-space-width (font-sym)
4314 "The width of a space character, for generating PostScript.
4315 This value is used in expanding tab characters."
4316 (get font-sym 'space-width))
4318 (defsubst ps-avg-char-width (font-sym)
4319 "The average width, in points, of a character, for generating PostScript.
4320 This is the value that ps-print uses to determine the length,
4321 x-dimension, of the text it has printed, and thus affects the point at
4322 which long lines wrap around."
4323 (get font-sym 'avg-char-width))
4325 (defun ps-line-lengths-internal ()
4326 "Display the correspondence between a line length and a font size.
4327 Done using the current ps-print setup.
4328 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
4329 (let* ((ps-font-size-internal
4330 (or ps-font-size-internal
4331 (ps-get-font-size 'ps-font-size)))
4332 (ps-header-font-size-internal
4333 (or ps-header-font-size-internal
4334 (ps-get-font-size 'ps-header-font-size)))
4335 (ps-header-title-font-size-internal
4336 (or ps-header-title-font-size-internal
4337 (ps-get-font-size 'ps-header-title-font-size)))
4338 (buf (get-buffer-create "*Line-lengths*"))
4339 (ifs ps-font-size-internal) ; initial font size
4340 (icw (ps-avg-char-width 'ps-font-for-text)) ; initial character width
4341 (print-width (progn (ps-get-page-dimensions)
4342 ps-print-width))
4343 (ps-setup (ps-setup)) ; setup for the current buffer
4344 (fs-min 5) ; minimum font size
4345 cw-min ; minimum character width
4346 nb-cpl-max ; maximum nb of characters per line
4347 (fs-max 14) ; maximum font size
4348 cw-max ; maximum character width
4349 nb-cpl-min ; minimum nb of characters per line
4350 fs ; current font size
4351 cw ; current character width
4352 nb-cpl ; current nb of characters per line
4354 (setq cw-min (/ (* icw fs-min) ifs)
4355 nb-cpl-max (floor (/ print-width cw-min))
4356 cw-max (/ (* icw fs-max) ifs)
4357 nb-cpl-min (floor (/ print-width cw-max))
4358 nb-cpl nb-cpl-min)
4359 (set-buffer buf)
4360 (goto-char (point-max))
4361 (or (bobp) (insert "\n" (make-string 75 ?\;) "\n"))
4362 (insert ps-setup
4363 "\nnb char per line / font size\n")
4364 (while (<= nb-cpl nb-cpl-max)
4365 (setq cw (/ print-width (float nb-cpl))
4366 fs (/ (* ifs cw) icw))
4367 (insert (format "%16d %s\n" nb-cpl fs))
4368 (setq nb-cpl (1+ nb-cpl)))
4369 (insert "\n")
4370 (display-buffer buf 'not-this-window)))
4372 (defun ps-nb-pages (nb-lines)
4373 "Display correspondence between font size and the number of pages.
4374 The correspondence is based on having NB-LINES lines of text,
4375 and on the current ps-print setup."
4376 (let* ((ps-font-size-internal
4377 (or ps-font-size-internal
4378 (ps-get-font-size 'ps-font-size)))
4379 (ps-header-font-size-internal
4380 (or ps-header-font-size-internal
4381 (ps-get-font-size 'ps-header-font-size)))
4382 (ps-header-title-font-size-internal
4383 (or ps-header-title-font-size-internal
4384 (ps-get-font-size 'ps-header-title-font-size)))
4385 (ps-line-spacing-internal
4386 (or ps-line-spacing-internal
4387 (ps-get-size ps-line-spacing "line spacing")))
4388 (buf (get-buffer-create "*Nb-Pages*"))
4389 (ils ps-line-spacing-internal) ; initial line spacing
4390 (ifs ps-font-size-internal) ; initial font size
4391 (ilh (ps-line-height 'ps-font-for-text)) ; initial line height
4392 (page-height (progn (ps-get-page-dimensions)
4393 ps-print-height))
4394 (ps-setup (ps-setup)) ; setup for the current buffer
4395 (fs-min 4) ; minimum font size
4396 lh-min ; minimum line height
4397 nb-lpp-max ; maximum nb of lines per page
4398 nb-page-min ; minimum nb of pages
4399 (fs-max 14) ; maximum font size
4400 lh-max ; maximum line height
4401 nb-lpp-min ; minimum nb of lines per page
4402 nb-page-max ; maximum nb of pages
4403 fs ; current font size
4404 lh ; current line height
4405 nb-lpp ; current nb of lines per page
4406 nb-page ; current nb of pages
4408 (setq lh-min (/ (- (* (+ ilh ils) fs-min) ils) ifs)
4409 nb-lpp-max (floor (/ page-height lh-min))
4410 nb-page-min (ceiling (/ (float nb-lines) nb-lpp-max))
4411 lh-max (/ (- (* (+ ilh ils) fs-max) ils) ifs)
4412 nb-lpp-min (floor (/ page-height lh-max))
4413 nb-page-max (ceiling (/ (float nb-lines) nb-lpp-min))
4414 nb-page nb-page-min)
4415 (set-buffer buf)
4416 (goto-char (point-max))
4417 (or (bobp) (insert "\n" (make-string 75 ?\;) "\n"))
4418 (insert ps-setup
4419 (format "\nThere are %d lines.\n\n" nb-lines)
4420 "nb page / font size\n")
4421 (while (<= nb-page nb-page-max)
4422 (setq nb-lpp (ceiling (/ nb-lines (float nb-page)))
4423 lh (/ page-height nb-lpp)
4424 fs (/ (* ifs lh) ilh))
4425 (insert (format "%7d %s\n" nb-page fs))
4426 (setq nb-page (1+ nb-page)))
4427 (insert "\n")
4428 (display-buffer buf 'not-this-window)))
4430 ;; macros used in `ps-select-font'
4431 (defmacro ps-lookup (key) `(cdr (assq ,key font-entry)))
4432 (defmacro ps-size-scale (key) `(/ (* (ps-lookup ,key) font-size) size))
4434 (defun ps-select-font (font-family sym font-size title-font-size)
4435 (let ((font-entry (cdr (assq font-family ps-font-info-database))))
4436 (or font-entry
4437 (error "Don't have data to scale font %s. Known fonts families are %s"
4438 font-family
4439 (mapcar 'car ps-font-info-database)))
4440 (let ((size (ps-lookup 'size)))
4441 (put sym 'fonts (ps-lookup 'fonts))
4442 (put sym 'space-width (ps-size-scale 'space-width))
4443 (put sym 'avg-char-width (ps-size-scale 'avg-char-width))
4444 (put sym 'line-height (ps-size-scale 'line-height))
4445 (put sym 'title-line-height
4446 (/ (* (ps-lookup 'line-height) title-font-size) size)))))
4448 (defun ps-get-page-dimensions ()
4449 (let ((page-dimensions (cdr (assq ps-paper-type ps-page-dimensions-database)))
4450 page-width page-height)
4451 (cond
4452 ((null page-dimensions)
4453 (error "`ps-paper-type' must be one of:\n%s"
4454 (mapcar 'car ps-page-dimensions-database)))
4455 ((< ps-number-of-columns 1)
4456 (error "The number of columns %d should be positive"
4457 ps-number-of-columns)))
4459 (ps-select-font ps-font-family 'ps-font-for-text
4460 ps-font-size-internal ps-font-size-internal)
4461 (ps-select-font ps-header-font-family 'ps-font-for-header
4462 ps-header-font-size-internal
4463 ps-header-title-font-size-internal)
4464 (ps-select-font ps-footer-font-family 'ps-font-for-footer
4465 ps-footer-font-size-internal ps-footer-font-size-internal)
4467 (setq page-width (ps-page-dimensions-get-width page-dimensions)
4468 page-height (ps-page-dimensions-get-height page-dimensions))
4470 ;; Landscape mode
4471 (if ps-landscape-mode
4472 ;; exchange width and height
4473 (setq page-width (prog1 page-height (setq page-height page-width))))
4475 ;; It is used to get the lower right corner (only in landscape mode)
4476 (setq ps-landscape-page-height page-height)
4478 ;; | lm | text | ic | text | ic | text | rm |
4479 ;; page-width == lm + n * pw + (n - 1) * ic + rm
4480 ;; => pw == (page-width - lm -rm - (n - 1) * ic) / n
4481 (setq ps-print-width (/ (- page-width
4482 ps-left-margin ps-right-margin
4483 (* (1- ps-number-of-columns) ps-inter-column))
4484 ps-number-of-columns))
4485 (if (<= ps-print-width 0)
4486 (error "Bad horizontal layout:
4487 page-width == %s
4488 ps-left-margin == %s
4489 ps-right-margin == %s
4490 ps-inter-column == %s
4491 ps-number-of-columns == %s
4492 | lm | text | ic | text | ic | text | rm |
4493 page-width == lm + n * print-width + (n - 1) * ic + rm
4494 => print-width == %d !"
4495 page-width
4496 ps-left-margin
4497 ps-right-margin
4498 ps-inter-column
4499 ps-number-of-columns
4500 ps-print-width))
4502 (setq ps-print-height
4503 (- page-height ps-bottom-margin ps-top-margin))
4504 (if (<= ps-print-height 0)
4505 (error "Bad vertical layout:
4506 ps-top-margin == %s
4507 ps-bottom-margin == %s
4508 page-height == bm + print-height + tm
4509 => print-height == %d !"
4510 ps-top-margin
4511 ps-bottom-margin
4512 ps-print-height))
4513 ;; If headers are turned on, deduct the height of the header from the print
4514 ;; height.
4515 (if ps-print-header
4516 (setq ps-header-pad (* ps-header-line-pad
4517 (ps-title-line-height 'ps-font-for-header))
4518 ps-print-height (- ps-print-height
4519 ps-header-offset
4520 ps-header-pad
4521 (ps-title-line-height 'ps-font-for-header)
4522 (* (ps-line-height 'ps-font-for-header)
4523 (1- ps-header-lines))
4524 ps-header-pad)))
4525 (if (<= ps-print-height 0)
4526 (error "Bad vertical layout (header):
4527 ps-top-margin == %s
4528 ps-bottom-margin == %s
4529 ps-header-offset == %s
4530 ps-header-pad == %s
4531 header-height == %s
4532 page-height == bm + print-height + tm - ho - hh
4533 => print-height == %d !"
4534 ps-top-margin
4535 ps-bottom-margin
4536 ps-header-offset
4537 ps-header-pad
4538 (+ ps-header-pad
4539 (ps-title-line-height 'ps-font-for-header)
4540 (* (ps-line-height 'ps-font-for-header)
4541 (1- ps-header-lines))
4542 ps-header-pad)
4543 ps-print-height))
4544 ;; If footers are turned on, deduct the height of the footer from the print
4545 ;; height.
4546 (if ps-print-footer
4547 (setq ps-footer-pad (* ps-footer-line-pad
4548 (ps-title-line-height 'ps-font-for-footer))
4549 ps-print-height (- ps-print-height
4550 ps-footer-offset
4551 ps-footer-pad
4552 (* (ps-line-height 'ps-font-for-footer)
4553 (1- ps-footer-lines))
4554 ps-footer-pad)))
4555 (if (<= ps-print-height 0)
4556 (error "Bad vertical layout (footer):
4557 ps-top-margin == %s
4558 ps-bottom-margin == %s
4559 ps-footer-offset == %s
4560 ps-footer-pad == %s
4561 footer-height == %s
4562 page-height == bm + print-height + tm - fo - fh
4563 => print-height == %d !"
4564 ps-top-margin
4565 ps-bottom-margin
4566 ps-footer-offset
4567 ps-footer-pad
4568 (+ ps-footer-pad
4569 (* (ps-line-height 'ps-font-for-footer)
4570 (1- ps-footer-lines))
4571 ps-footer-pad)
4572 ps-print-height))
4573 ;; ps-zebra-stripe-follow is `full' or `full-follow'
4574 (if ps-zebra-stripe-full-p
4575 (let* ((line-height (ps-line-height 'ps-font-for-text))
4576 (zebra (* (+ line-height ps-line-spacing-internal)
4577 ps-zebra-stripe-height)))
4578 (setq ps-print-height (- (* (floor ps-print-height zebra) zebra)
4579 line-height))
4580 (if (<= ps-print-height 0)
4581 (error "Bad vertical layout (full zebra stripe follow):
4582 ps-zebra-stripe-follow == %s
4583 ps-zebra-stripe-height == %s
4584 font-text-height == %s
4585 line-spacing == %s
4586 page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
4587 => print-height == %d !"
4588 ps-zebra-stripe-follow
4589 ps-zebra-stripe-height
4590 (ps-line-height 'ps-font-for-text)
4591 ps-line-spacing-internal
4592 ps-print-height))))))
4595 (defun ps-print-preprint-region (prefix-arg)
4596 (or (ps-mark-active-p)
4597 (error "The mark is not set now"))
4598 (list (point) (mark) (ps-print-preprint prefix-arg)))
4601 (defun ps-print-preprint (prefix-arg)
4602 (and prefix-arg
4603 (or (numberp prefix-arg)
4604 (listp prefix-arg))
4605 (let* ((name (concat (file-name-nondirectory (or (buffer-file-name)
4606 (buffer-name)))
4607 ".ps"))
4608 (prompt (format "Save PostScript to file (default %s): " name))
4609 (res (read-file-name prompt default-directory name nil)))
4610 (while (cond ((file-directory-p res)
4611 (ding)
4612 (setq prompt "It's a directory"))
4613 ((not (file-writable-p res))
4614 (ding)
4615 (setq prompt "File is unwritable"))
4616 ((file-exists-p res)
4617 (setq prompt "File exists")
4618 (not (y-or-n-p (format "File `%s' exists; overwrite? "
4619 res))))
4620 (t nil))
4621 (setq res (read-file-name
4622 (format "%s; save PostScript to file: " prompt)
4623 (file-name-directory res) nil nil
4624 (file-name-nondirectory res))))
4625 (if (file-directory-p res)
4626 (expand-file-name name (file-name-as-directory res))
4627 res))))
4629 ;; The following functions implement a simple list-buffering scheme so
4630 ;; that ps-print doesn't have to repeatedly switch between buffers
4631 ;; while spooling. The functions `ps-output' and `ps-output-string' build
4632 ;; up the lists; the function `ps-flush-output' takes the lists and
4633 ;; insert its contents into the spool buffer (*PostScript*).
4635 (defvar ps-string-escape-codes
4636 (let ((table (make-vector 256 nil))
4637 (char ?\000))
4638 ;; control characters
4639 (while (<= char ?\037)
4640 (aset table char (format "\\%03o" char))
4641 (setq char (1+ char)))
4642 ;; printable characters
4643 (while (< char ?\177)
4644 (aset table char (format "%c" char))
4645 (setq char (1+ char)))
4646 ;; DEL and 8-bit characters
4647 (while (<= char ?\377)
4648 (aset table char (format "\\%o" char))
4649 (setq char (1+ char)))
4650 ;; Override ASCII formatting characters with named escape code:
4651 (aset table ?\n "\\n") ; [NL] linefeed
4652 (aset table ?\r "\\r") ; [CR] carriage return
4653 (aset table ?\t "\\t") ; [HT] horizontal tab
4654 (aset table ?\b "\\b") ; [BS] backspace
4655 (aset table ?\f "\\f") ; [NP] form feed
4656 ;; Escape PostScript escape and string delimiter characters:
4657 (aset table ?\\ "\\\\")
4658 (aset table ?\( "\\(")
4659 (aset table ?\) "\\)")
4660 table)
4661 "Vector used to map characters to PostScript string escape codes.")
4663 (defsubst ps-output-string-prim (string)
4664 (insert "(") ;insert start-string delimiter
4665 (save-excursion ;insert string
4666 (insert (string-as-unibyte string)))
4667 ;; Find and quote special characters as necessary for PS
4668 ;; This skips everything except control chars, non-ASCII chars, (, ) and \.
4669 (while (progn (skip-chars-forward " -'*-[]-~") (not (eobp)))
4670 (let ((special (following-char)))
4671 (delete-char 1)
4672 (insert
4673 (if (and (<= 0 special) (<= special 255))
4674 (aref ps-string-escape-codes special)
4675 ;; insert hexadecimal representation if character code is out of range
4676 (format "\\%04X" special)
4677 ))))
4678 (goto-char (point-max))
4679 (insert ")")) ;insert end-string delimiter
4681 (defsubst ps-init-output-queue ()
4682 (setq ps-output-head (list "")
4683 ps-output-tail ps-output-head))
4686 (defun ps-selected-pages ()
4687 (while (progn
4688 (setq ps-first-page (car (car ps-selected-pages))
4689 ps-last-page (cdr (car ps-selected-pages))
4690 ps-selected-pages (cdr ps-selected-pages))
4691 (and ps-selected-pages
4692 (< ps-last-page ps-page-postscript)))))
4695 (defsubst ps-print-page-p ()
4696 (setq ps-print-page-p
4697 (and (cond ((null ps-first-page))
4698 ((<= ps-page-postscript ps-last-page)
4699 (<= ps-first-page ps-page-postscript))
4700 (ps-selected-pages
4701 (ps-selected-pages)
4702 (and (<= ps-first-page ps-page-postscript)
4703 (<= ps-page-postscript ps-last-page)))
4705 nil))
4706 (cond ((eq ps-even-or-odd-pages 'even-page)
4707 (= (logand ps-page-postscript 1) 0))
4708 ((eq ps-even-or-odd-pages 'odd-page)
4709 (= (logand ps-page-postscript 1) 1))
4711 ))))
4714 (defsubst ps-print-sheet-p ()
4715 (setq ps-print-page-p
4716 (cond ((eq ps-even-or-odd-pages 'even-sheet)
4717 (= (logand ps-page-sheet 1) 0))
4718 ((eq ps-even-or-odd-pages 'odd-sheet)
4719 (= (logand ps-page-sheet 1) 1))
4724 (defun ps-output (&rest args)
4725 (when ps-print-page-p
4726 (setcdr ps-output-tail args)
4727 (while (cdr ps-output-tail)
4728 (setq ps-output-tail (cdr ps-output-tail)))))
4730 (defun ps-output-string (string)
4731 (ps-output t string))
4733 ;; Output strings in the list ARGS in the PostScript prologue part.
4734 (defun ps-output-prologue (args)
4735 (ps-output 'prologue (if (stringp args) (list args) args)))
4737 (defun ps-flush-output ()
4738 (with-current-buffer ps-spool-buffer
4739 (goto-char (point-max))
4740 (while ps-output-head
4741 (let ((it (car ps-output-head)))
4742 (cond
4743 ((eq t it)
4744 (setq ps-output-head (cdr ps-output-head))
4745 (ps-output-string-prim (car ps-output-head)))
4746 ((eq 'prologue it)
4747 (setq ps-output-head (cdr ps-output-head))
4748 (save-excursion
4749 (search-backward "\nBeginDoc")
4750 (forward-char 1)
4751 (apply 'insert (car ps-output-head))))
4753 (insert it))))
4754 (setq ps-output-head (cdr ps-output-head))))
4755 (ps-init-output-queue))
4757 (defun ps-insert-file (fname)
4758 (ps-flush-output)
4759 (with-current-buffer ps-spool-buffer
4760 (goto-char (point-max))
4761 (insert-file-contents fname)))
4763 ;; These functions insert the arrays that define the contents of the headers.
4765 (defvar ps-encode-header-string-function nil)
4767 (defun ps-generate-header-line (fonttag &optional content)
4768 (ps-output " [" fonttag " ")
4769 (cond
4770 ;; Literal strings should be output as is -- the string must contain its own
4771 ;; PS string delimiters, '(' and ')', if necessary.
4772 ((stringp content)
4773 (ps-output content))
4775 ;; Functions are called -- they should return strings; they will be inserted
4776 ;; as strings and the PS string delimiters added.
4777 ((functionp content)
4778 (if (functionp ps-encode-header-string-function)
4779 (dolist (l (funcall ps-encode-header-string-function
4780 (funcall content) fonttag))
4781 (ps-output-string l))
4782 (ps-output-string (funcall content))))
4784 ;; Variables will have their contents inserted. They should contain
4785 ;; strings, and will be inserted as strings.
4786 ((and (symbolp content) (boundp content))
4787 (if (fboundp ps-encode-header-string-function)
4788 (dolist (l (funcall ps-encode-header-string-function
4789 (symbol-value content) fonttag))
4790 (ps-output-string l))
4791 (ps-output-string (symbol-value content))))
4793 ;; Anything else will get turned into an empty string.
4795 (ps-output-string "")))
4796 (ps-output "]\n"))
4798 (defun ps-generate-header (name fonttag0 fonttag1 contents)
4799 (ps-output "/" name "[\n")
4800 (and contents (> ps-header-lines 0)
4801 (let ((count 1))
4802 (ps-generate-header-line fonttag0 (car contents))
4803 (while (and (< count ps-header-lines)
4804 (setq contents (cdr contents)))
4805 (ps-generate-header-line fonttag1 (car contents))
4806 (setq count (1+ count)))))
4807 (ps-output "]def\n"))
4810 (defun ps-output-boolean (name bool)
4811 (ps-output (format "/%s %s def\n" name (if bool "true" "false"))))
4814 (defun ps-output-frame-properties (name alist)
4815 (ps-output "/" name " ["
4816 (ps-format-color (cdr (assq 'fore-color alist)) 0.0)
4817 (ps-format-color (cdr (assq 'back-color alist)) 0.9)
4818 (ps-float-format (or (cdr (assq 'border-width alist)) 0.4))
4819 (ps-format-color (cdr (assq 'border-color alist)) 0.0)
4820 (ps-format-color (cdr (assq 'shadow-color alist)) 0.0)
4821 "]def\n"))
4824 (defun ps-background-pages (page-list func)
4825 (if page-list
4826 (mapcar
4827 #'(lambda (pages)
4828 (let ((start (if (consp pages) (car pages) pages))
4829 (end (if (consp pages) (cdr pages) pages)))
4830 (and (integerp start) (integerp end) (<= start end)
4831 (add-to-list 'ps-background-pages (vector start end func)))))
4832 page-list)
4833 (setq ps-background-all-pages (cons func ps-background-all-pages))))
4836 (defconst ps-boundingbox-re
4837 "^%%BoundingBox:\
4838 \\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)")
4841 (defun ps-get-boundingbox ()
4842 (with-current-buffer ps-spool-buffer
4843 (save-excursion
4844 (if (re-search-forward ps-boundingbox-re nil t)
4845 (vector (string-to-number ; lower x
4846 (buffer-substring (match-beginning 1) (match-end 1)))
4847 (string-to-number ; lower y
4848 (buffer-substring (match-beginning 2) (match-end 2)))
4849 (string-to-number ; upper x
4850 (buffer-substring (match-beginning 3) (match-end 3)))
4851 (string-to-number ; upper y
4852 (buffer-substring (match-beginning 4) (match-end 4))))
4853 (vector 0 0 0 0)))))
4856 (defun ps-float-format (value &optional default)
4857 (let ((literal (or value default)))
4858 (cond ((null literal)
4859 " ")
4860 ((numberp literal)
4861 (format ps-float-format (* literal 1.0))) ; force float number
4863 (format "%s " literal))
4867 (defun ps-background-text ()
4868 (mapcar
4869 #'(lambda (text)
4870 (setq ps-background-text-count (1+ ps-background-text-count))
4871 (ps-output (format "/ShowBackText-%d{\n" ps-background-text-count))
4872 (ps-output-string (nth 0 text)) ; text
4873 (ps-output
4874 "\n"
4875 (ps-float-format (nth 4 text) 200.0) ; font size
4876 (format "/%s " (or (nth 3 text) "Times-Roman")) ; font name
4877 (ps-float-format (nth 6 text)
4878 "PrintHeight PrintPageWidth atan") ; rotation
4879 (ps-float-format (nth 5 text) 0.85) ; gray
4880 (ps-float-format (nth 1 text) "0") ; x position
4881 (ps-float-format (nth 2 text) "0") ; y position
4882 "\nShowBackText}def\n")
4883 (ps-background-pages (nthcdr 7 text) ; page list
4884 (format "ShowBackText-%d\n"
4885 ps-background-text-count)))
4886 ps-print-background-text))
4889 (defun ps-background-image ()
4890 (mapcar
4891 #'(lambda (image)
4892 (let ((image-file (expand-file-name (nth 0 image))))
4893 (when (file-readable-p image-file)
4894 (setq ps-background-image-count (1+ ps-background-image-count))
4895 (ps-output
4896 (format "/ShowBackImage-%d{\n--back-- "
4897 ps-background-image-count)
4898 (ps-float-format (nth 5 image) 0.0) ; rotation
4899 (ps-float-format (nth 3 image) 1.0) ; x scale
4900 (ps-float-format (nth 4 image) 1.0) ; y scale
4901 (ps-float-format (nth 1 image) ; x position
4902 "PrintPageWidth 2 div")
4903 (ps-float-format (nth 2 image) ; y position
4904 "PrintHeight 2 div BottomMargin add")
4905 "\nBeginBackImage\n")
4906 (ps-insert-file image-file)
4907 ;; coordinate adjustment to center image
4908 ;; around x and y position
4909 (let ((box (ps-get-boundingbox)))
4910 (with-current-buffer ps-spool-buffer
4911 (save-excursion
4912 (if (re-search-backward "^--back--" nil t)
4913 (replace-match
4914 (format "%s %s"
4915 (ps-float-format
4916 (- (+ (/ (- (aref box 2) (aref box 0)) 2.0)
4917 (aref box 0))))
4918 (ps-float-format
4919 (- (+ (/ (- (aref box 3) (aref box 1)) 2.0)
4920 (aref box 1)))))
4921 t)))))
4922 (ps-output "\nEndBackImage}def\n")
4923 (ps-background-pages (nthcdr 6 image) ; page list
4924 (format "ShowBackImage-%d\n"
4925 ps-background-image-count)))))
4926 ps-print-background-image))
4929 (defun ps-background (page-number)
4930 (let (has-local-background)
4931 (mapc #'(lambda (range)
4932 (and (<= (aref range 0) page-number)
4933 (<= page-number (aref range 1))
4934 (if has-local-background
4935 (ps-output (aref range 2))
4936 (setq has-local-background t)
4937 (ps-output "/printLocalBackground{\n"
4938 (aref range 2)))))
4939 ps-background-pages)
4940 (and has-local-background (ps-output "}def\n"))))
4943 ;; Return a list of the distinct elements of LIST.
4944 ;; Elements are compared with `equal'.
4945 (defun ps-remove-duplicates (list)
4946 (let (new (tail list))
4947 (while tail
4948 (or (member (car tail) new)
4949 (setq new (cons (car tail) new)))
4950 (setq tail (cdr tail)))
4951 (nreverse new)))
4954 ;; Find the first occurrence of ITEM in LIST.
4955 ;; Return the index of the matching item, or nil if not found.
4956 ;; Elements are compared with `eq'.
4957 (defun ps-alist-position (item list)
4958 (let ((tail list) (index 0) found)
4959 (while tail
4960 (if (setq found (eq (car (car tail)) item))
4961 (setq tail nil)
4962 (setq index (1+ index)
4963 tail (cdr tail))))
4964 (and found index)))
4967 (defconst ps-n-up-database
4968 '((a4
4969 (1 nil 1 1 0)
4970 (2 t 1 2 0)
4971 (4 nil 2 2 0)
4972 (6 t 2 3 1)
4973 (8 t 2 4 0)
4974 (9 nil 3 3 0)
4975 (12 t 3 4 2)
4976 (16 nil 4 4 0)
4977 (18 t 3 6 0)
4978 (20 nil 5 4 1)
4979 (25 nil 5 5 0)
4980 (30 nil 6 5 1)
4981 (32 t 4 8 0)
4982 (36 nil 6 6 0)
4983 (42 nil 7 6 1)
4984 (49 nil 7 7 0)
4985 (50 t 5 10 0)
4986 (56 nil 8 7 1)
4987 (64 nil 8 8 0)
4988 (72 nil 9 8 1)
4989 (81 nil 9 9 0)
4990 (90 nil 10 9 1)
4991 (100 nil 10 10 0))
4993 (1 nil 1 1 0)
4994 (2 t 1 2 0)
4995 (4 nil 2 2 0)
4996 (6 t 2 3 1)
4997 (8 t 2 4 0)
4998 (9 nil 3 3 0)
4999 (12 nil 4 3 1)
5000 (16 nil 4 4 0)
5001 (18 t 3 6 0)
5002 (20 nil 5 4 1)
5003 (25 nil 5 5 0)
5004 (30 nil 6 5 1)
5005 (32 t 4 8 0)
5006 (36 nil 6 6 0)
5007 (42 nil 7 6 1)
5008 (49 nil 7 7 0)
5009 (50 t 5 10 0)
5010 (56 nil 8 7 1)
5011 (64 nil 8 8 0)
5012 (72 nil 9 8 1)
5013 (81 nil 9 9 0)
5014 (90 nil 10 9 1)
5015 (100 nil 10 10 0))
5016 (letter
5017 (1 nil 1 1 0)
5018 (2 t 1 2 0) ; adjusted by PostScript code
5019 (4 nil 2 2 0)
5020 (6 t 2 3 0)
5021 (9 nil 3 3 0)
5022 (12 nil 4 3 1)
5023 (16 nil 4 4 0)
5024 (20 nil 5 4 1)
5025 (25 nil 5 5 0)
5026 (30 nil 6 5 1)
5027 (36 nil 6 6 0)
5028 (40 t 5 8 0)
5029 (42 nil 7 6 1)
5030 (49 nil 7 7 0)
5031 (56 nil 8 7 1)
5032 (64 nil 8 8 0)
5033 (72 nil 9 8 1)
5034 (81 nil 9 9 0)
5035 (90 nil 10 9 1)
5036 (100 nil 10 10 0))
5037 (legal
5038 (1 nil 1 1 0)
5039 (2 t 1 2 0)
5040 (4 nil 2 2 0)
5041 (6 nil 3 2 1)
5042 (9 nil 3 3 0)
5043 (10 t 2 5 0)
5044 (12 nil 4 3 1)
5045 (16 nil 4 4 0)
5046 (20 nil 5 4 1)
5047 (25 nil 5 5 0)
5048 (30 nil 6 5 1)
5049 (36 nil 6 6 0)
5050 (42 nil 7 6 1)
5051 (49 nil 7 7 0)
5052 (56 nil 8 7 1)
5053 (64 nil 8 8 0)
5054 (70 t 5 14 0)
5055 (72 nil 9 8 1)
5056 (81 nil 9 9 0)
5057 (90 nil 10 9 1)
5058 (100 nil 10 10 0))
5059 (letter-small
5060 (1 nil 1 1 0)
5061 (2 t 1 2 0) ; adjusted by PostScript code
5062 (4 nil 2 2 0)
5063 (6 t 2 3 0)
5064 (9 nil 3 3 0)
5065 (12 t 3 4 1)
5066 (15 t 3 5 0)
5067 (16 nil 4 4 0)
5068 (20 nil 5 4 1)
5069 (25 nil 5 5 0)
5070 (28 t 4 7 0)
5071 (30 nil 6 5 1)
5072 (36 nil 6 6 0)
5073 (40 t 5 8 0)
5074 (42 nil 7 6 1)
5075 (49 nil 7 7 0)
5076 (56 nil 8 7 1)
5077 (60 t 6 10 0)
5078 (64 nil 8 8 0)
5079 (72 ni 9 8 1)
5080 (81 nil 9 9 0)
5081 (84 t 7 12 0)
5082 (90 nil 10 9 1)
5083 (100 nil 10 10 0))
5084 (tabloid
5085 (1 nil 1 1 0)
5086 (2 t 1 2 0)
5087 (4 nil 2 2 0)
5088 (6 t 2 3 1)
5089 (8 t 2 4 0)
5090 (9 nil 3 3 0)
5091 (12 nil 4 3 1)
5092 (16 nil 4 4 0)
5093 (20 nil 5 4 1)
5094 (25 nil 5 5 0)
5095 (30 nil 6 5 1)
5096 (36 nil 6 6 0)
5097 (42 nil 7 6 1)
5098 (49 nil 7 7 0)
5099 (56 nil 8 7 1)
5100 (64 nil 8 8 0)
5101 (72 nil 9 8 1)
5102 (81 nil 9 9 0)
5103 (84 t 6 14 0)
5104 (90 nil 10 9 1)
5105 (100 nil 10 10 0))
5106 ;; Ledger paper size is a special case, it is the only paper size where the
5107 ;; normal size is landscaped, that is, the height is smaller than width.
5108 ;; So, we use the special value `pag' in the `landscape' field.
5109 (ledger
5110 (1 nil 1 1 0)
5111 (2 pag 1 2 0)
5112 (4 nil 2 2 0)
5113 (6 pag 2 3 1)
5114 (8 pag 2 4 0)
5115 (9 nil 3 3 0)
5116 (12 nil 4 3 1)
5117 (16 nil 4 4 0)
5118 (20 nil 5 4 1)
5119 (25 nil 5 5 0)
5120 (30 nil 6 5 1)
5121 (36 nil 6 6 0)
5122 (42 nil 7 6 1)
5123 (49 nil 7 7 0)
5124 (56 nil 8 7 1)
5125 (64 nil 8 8 0)
5126 (72 nil 9 8 1)
5127 (81 nil 9 9 0)
5128 (84 pag 6 14 0)
5129 (90 nil 10 9 1)
5130 (100 nil 10 10 0))
5131 (statement
5132 (1 nil 1 1 0)
5133 (2 t 1 2 0)
5134 (4 nil 2 2 0)
5135 (6 nil 3 2 1)
5136 (9 nil 3 3 0)
5137 (10 t 2 5 0)
5138 (12 nil 4 3 1)
5139 (16 nil 4 4 0)
5140 (20 nil 5 4 1)
5141 (21 t 3 7 0)
5142 (25 nil 5 5 0)
5143 (30 nil 6 5 1)
5144 (36 nil 6 6 0)
5145 (40 t 4 10 0)
5146 (42 nil 7 6 1)
5147 (49 nil 7 7 0)
5148 (56 nil 8 7 1)
5149 (60 t 5 12 0)
5150 (64 nil 8 8 0)
5151 (72 nil 9 8 1)
5152 (81 nil 9 9 0)
5153 (90 nil 10 9 1)
5154 (100 nil 10 10 0))
5155 (executive
5156 (1 nil 1 1 0)
5157 (2 t 1 2 0) ; adjusted by PostScript code
5158 (4 nil 2 2 0)
5159 (6 t 2 3 0)
5160 (9 nil 3 3 0)
5161 (12 nil 4 3 1)
5162 (16 nil 4 4 0)
5163 (20 nil 5 4 1)
5164 (25 nil 5 5 0)
5165 (28 t 4 7 0)
5166 (30 nil 6 5 1)
5167 (36 nil 6 6 0)
5168 (42 nil 7 6 1)
5169 (45 t 5 9 0)
5170 (49 nil 7 7 0)
5171 (56 nil 8 7 1)
5172 (60 t 6 10 0)
5173 (64 nil 8 8 0)
5174 (72 nil 9 8 1)
5175 (81 nil 9 9 0)
5176 (84 t 7 12 0)
5177 (90 nil 10 9 1)
5178 (100 nil 10 10 0))
5179 (a4small
5180 (1 nil 1 1 0)
5181 (2 t 1 2 0)
5182 (4 nil 2 2 0)
5183 (6 t 2 3 1)
5184 (8 t 2 4 0)
5185 (9 nil 3 3 0)
5186 (12 nil 4 3 1)
5187 (16 nil 4 4 0)
5188 (18 t 3 6 0)
5189 (20 nil 5 4 1)
5190 (25 nil 5 5 0)
5191 (30 nil 6 5 1)
5192 (32 t 4 8 0)
5193 (36 nil 6 6 0)
5194 (42 nil 7 6 1)
5195 (49 nil 7 7 0)
5196 (50 t 5 10 0)
5197 (56 nil 8 7 1)
5198 (64 nil 8 8 0)
5199 (72 nil 9 8 1)
5200 (78 t 6 13 0)
5201 (81 nil 9 9 0)
5202 (90 nil 10 9 1)
5203 (100 nil 10 10 0))
5205 (1 nil 1 1 0)
5206 (2 t 1 2 0)
5207 (4 nil 2 2 0)
5208 (6 t 2 3 1)
5209 (8 t 2 4 0)
5210 (9 nil 3 3 0)
5211 (12 nil 4 3 1)
5212 (16 nil 4 4 0)
5213 (18 t 3 6 0)
5214 (20 nil 5 4 1)
5215 (25 nil 5 5 0)
5216 (30 nil 6 5 1)
5217 (32 t 4 8 0)
5218 (36 nil 6 6 0)
5219 (42 nil 7 6 1)
5220 (49 nil 7 7 0)
5221 (50 t 5 10 0)
5222 (56 nil 8 7 1)
5223 (64 nil 8 8 0)
5224 (72 nil 9 8 1)
5225 (81 nil 9 9 0)
5226 (90 nil 10 9 1)
5227 (100 nil 10 10 0))
5229 (1 nil 1 1 0)
5230 (2 t 1 2 0)
5231 (4 nil 2 2 0)
5232 (6 t 2 3 1)
5233 (8 t 2 4 0)
5234 (9 nil 3 3 0)
5235 (12 nil 4 3 1)
5236 (16 nil 4 4 0)
5237 (18 t 3 6 0)
5238 (20 nil 5 4 1)
5239 (25 nil 5 5 0)
5240 (30 nil 6 5 1)
5241 (32 t 4 8 0)
5242 (36 nil 6 6 0)
5243 (42 nil 7 6 1)
5244 (49 nil 7 7 0)
5245 (50 t 5 10 0)
5246 (56 nil 8 7 1)
5247 (64 nil 8 8 0)
5248 (72 nil 9 8 0)
5249 (81 nil 9 9 0)
5250 (90 nil 10 9 1)
5251 (98 t 7 14 0)
5252 (100 nil 10 10 0)))
5253 "Alist which is the page matrix database used for N-up printing.
5255 Each element has the following form:
5257 (PAGE
5258 (MAX LANDSCAPE LINES COLUMNS COL-MISSING)
5259 ...)
5261 Where:
5262 PAGE is the page size used (see `ps-paper-type').
5263 MAX is the maximum elements of this page matrix.
5264 LANDSCAPE specifies if page matrix is landscaped, has the following valid
5265 values:
5266 nil the sheet is in portrait mode.
5267 t the sheet is in landscape mode.
5268 pag the sheet is in portrait mode and page is in landscape mode.
5269 LINES is the number of lines of page matrix.
5270 COLUMNS is the number of columns of page matrix.
5271 COL-MISSING is the number of columns missing to fill the sheet.")
5274 (defmacro ps-n-up-landscape (mat) `(nth 1 ,mat))
5275 (defmacro ps-n-up-lines (mat) `(nth 2 ,mat))
5276 (defmacro ps-n-up-columns (mat) `(nth 3 ,mat))
5277 (defmacro ps-n-up-missing (mat) `(nth 4 ,mat))
5280 (defun ps-n-up-printing ()
5281 ;; force `ps-n-up-printing' be in range 1 to 100.
5282 (setq ps-n-up-printing (max (min ps-n-up-printing 100) 1))
5283 ;; find suitable page matrix for a given `ps-paper-type'.
5284 (let ((the-list (cdr (assq ps-paper-type ps-n-up-database))))
5285 (and the-list
5286 (while (> ps-n-up-printing (caar the-list))
5287 (setq the-list (cdr the-list))))
5288 (or (car the-list)
5289 '(1 nil 1 1 0))))
5292 (defconst ps-n-up-filling-database
5293 '((left-top
5294 "PageWidth" ; N-Up-XColumn
5295 "0" ; N-Up-YColumn
5296 "N-Up-End 1 sub PageWidth mul neg" ; N-Up-XLine
5297 "LandscapePageHeight neg" ; N-Up-YLine
5298 "N-Up-Lines" ; N-Up-Repeat
5299 "N-Up-Columns" ; N-Up-End
5300 "0" ; N-Up-XStart
5301 "0") ; N-Up-YStart
5302 (left-bottom
5303 "PageWidth" ; N-Up-XColumn
5304 "0" ; N-Up-YColumn
5305 "N-Up-End 1 sub PageWidth mul neg" ; N-Up-XLine
5306 "LandscapePageHeight" ; N-Up-YLine
5307 "N-Up-Lines" ; N-Up-Repeat
5308 "N-Up-Columns" ; N-Up-End
5309 "0" ; N-Up-XStart
5310 "N-Up-Repeat 1 sub LandscapePageHeight mul neg") ; N-Up-YStart
5311 (right-top
5312 "PageWidth neg" ; N-Up-XColumn
5313 "0" ; N-Up-YColumn
5314 "N-Up-End 1 sub PageWidth mul" ; N-Up-XLine
5315 "LandscapePageHeight neg" ; N-Up-YLine
5316 "N-Up-Lines" ; N-Up-Repeat
5317 "N-Up-Columns" ; N-Up-End
5318 "N-Up-End 1 sub PageWidth mul" ; N-Up-XStart
5319 "0") ; N-Up-YStart
5320 (right-bottom
5321 "PageWidth neg" ; N-Up-XColumn
5322 "0" ; N-Up-YColumn
5323 "N-Up-End 1 sub PageWidth mul" ; N-Up-XLine
5324 "LandscapePageHeight" ; N-Up-YLine
5325 "N-Up-Lines" ; N-Up-Repeat
5326 "N-Up-Columns" ; N-Up-End
5327 "N-Up-End 1 sub PageWidth mul" ; N-Up-XStart
5328 "N-Up-Repeat 1 sub LandscapePageHeight mul neg") ; N-Up-YStart
5329 (top-left
5330 "0" ; N-Up-XColumn
5331 "LandscapePageHeight neg" ; N-Up-YColumn
5332 "PageWidth" ; N-Up-XLine
5333 "N-Up-End 1 sub LandscapePageHeight mul" ; N-Up-YLine
5334 "N-Up-Columns" ; N-Up-Repeat
5335 "N-Up-Lines" ; N-Up-End
5336 "0" ; N-Up-XStart
5337 "0") ; N-Up-YStart
5338 (bottom-left
5339 "0" ; N-Up-XColumn
5340 "LandscapePageHeight" ; N-Up-YColumn
5341 "PageWidth" ; N-Up-XLine
5342 "N-Up-End 1 sub LandscapePageHeight mul neg" ; N-Up-YLine
5343 "N-Up-Columns" ; N-Up-Repeat
5344 "N-Up-Lines" ; N-Up-End
5345 "0" ; N-Up-XStart
5346 "N-Up-End 1 sub LandscapePageHeight mul neg") ; N-Up-YStart
5347 (top-right
5348 "0" ; N-Up-XColumn
5349 "LandscapePageHeight neg" ; N-Up-YColumn
5350 "PageWidth neg" ; N-Up-XLine
5351 "N-Up-End 1 sub LandscapePageHeight mul" ; N-Up-YLine
5352 "N-Up-Columns" ; N-Up-Repeat
5353 "N-Up-Lines" ; N-Up-End
5354 "N-Up-Repeat 1 sub PageWidth mul" ; N-Up-XStart
5355 "0") ; N-Up-YStart
5356 (bottom-right
5357 "0" ; N-Up-XColumn
5358 "LandscapePageHeight" ; N-Up-YColumn
5359 "PageWidth neg" ; N-Up-XLine
5360 "N-Up-End 1 sub LandscapePageHeight mul neg" ; N-Up-YLine
5361 "N-Up-Columns" ; N-Up-Repeat
5362 "N-Up-Lines" ; N-Up-End
5363 "N-Up-Repeat 1 sub PageWidth mul" ; N-Up-XStart
5364 "N-Up-End 1 sub LandscapePageHeight mul neg")) ; N-Up-YStart
5365 "Alist for n-up printing initializations.
5367 Each element has the following form:
5369 (KIND XCOL YCOL XLIN YLIN REPEAT END XSTART YSTART)
5371 Where:
5372 KIND is a valid value of `ps-n-up-filling'.
5373 XCOL YCOL are the relative position for the next column.
5374 XLIN YLIN are the relative position for the beginning of next line.
5375 REPEAT is the number of repetions for external loop.
5376 END is the number of repetions for internal loop and also the number of pages in
5377 a row.
5378 XSTART YSTART are the relative position for the first page in a sheet.")
5381 (defun ps-n-up-filling ()
5382 (cdr (or (assq ps-n-up-filling ps-n-up-filling-database)
5383 (assq 'left-top ps-n-up-filling-database))))
5386 (defmacro ps-n-up-xcolumn (init) `(nth 0 ,init))
5387 (defmacro ps-n-up-ycolumn (init) `(nth 1 ,init))
5388 (defmacro ps-n-up-xline (init) `(nth 2 ,init))
5389 (defmacro ps-n-up-yline (init) `(nth 3 ,init))
5390 (defmacro ps-n-up-repeat (init) `(nth 4 ,init))
5391 (defmacro ps-n-up-end (init) `(nth 5 ,init))
5392 (defmacro ps-n-up-xstart (init) `(nth 6 ,init))
5393 (defmacro ps-n-up-ystart (init) `(nth 7 ,init))
5396 (defconst ps-error-handler-alist
5397 '((none . 0)
5398 (paper . 1)
5399 (system . 2)
5400 (paper-and-system . 3))
5401 "Alist for error handler message.")
5404 (defconst ps-zebra-stripe-alist
5405 '((follow . 1)
5406 (full . 2)
5407 (full-follow . 3))
5408 "Alist for zebra stripe continuation.")
5411 (defun ps-begin-file ()
5412 (setq ps-page-order 0
5413 ps-page-printed 0
5414 ps-background-text-count 0
5415 ps-background-image-count 0
5416 ps-background-pages nil
5417 ps-background-all-pages nil)
5419 (let ((dimensions (cdr (assq ps-paper-type ps-page-dimensions-database)))
5420 (tumble (if ps-landscape-mode (not ps-spool-tumble) ps-spool-tumble))
5421 (n-up (ps-n-up-printing))
5422 (n-up-filling (ps-n-up-filling)))
5423 (and ps-n-up-on (setq tumble (not tumble)))
5424 (ps-output
5425 ps-adobe-tag
5426 "%%Title: " (buffer-name) ; Take job name from name of
5427 ; first buffer printed
5428 "\n%%Creator: ps-print v" ps-print-version
5429 "\n%%For: " (user-full-name)
5430 "\n%%CreationDate: " (format-time-string "%T %b %d %Y")
5431 "\n%%Orientation: "
5432 (if ps-landscape-mode "Landscape" "Portrait")
5433 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font "
5434 (mapconcat 'identity
5435 (ps-remove-duplicates
5436 (append (ps-fonts 'ps-font-for-text)
5437 (list (ps-font 'ps-font-for-header 'normal)
5438 (ps-font 'ps-font-for-header 'bold)
5439 (ps-font 'ps-font-for-footer 'normal)
5440 (ps-font 'ps-font-for-footer 'bold))))
5441 "\n%%+ font ")
5442 "\n%%DocumentSuppliedResources: procset PSPrintUserDefinedPrologue-" (user-login-name) " 0 0"
5443 "\n%%DocumentMedia: " (ps-page-dimensions-get-media dimensions)
5444 (format " %d" (round (ps-page-dimensions-get-width dimensions)))
5445 (format " %d" (round (ps-page-dimensions-get-height dimensions)))
5446 " 0 () ()\n%%PageOrder: Ascend\n%%Pages: (atend)\n%%Requirements:"
5447 (if ps-spool-duplex
5448 (if tumble " duplex(tumble)\n" " duplex\n")
5449 "\n"))
5451 (ps-insert-string ps-print-prologue-header)
5453 (ps-output "%%EndComments\n%%BeginDefaults\n%%PageMedia: "
5454 (ps-page-dimensions-get-media dimensions)
5455 "\n%%EndDefaults\n\n%%BeginProlog\n\n"
5456 "/languagelevel where{pop}{/languagelevel 1 def}ifelse\n"
5457 (format "/ErrorMessage %s def\n\n"
5458 (or (cdr (assoc ps-error-handler-message
5459 ps-error-handler-alist))
5460 1)) ; send to paper
5461 ps-print-prologue-0
5462 "\n%%BeginResource: procset PSPrintUserDefinedPrologue-" (user-login-name) " 0 0\n\n")
5464 (ps-insert-string ps-user-defined-prologue)
5466 (ps-output "\n%%EndResource\n\n")
5468 (ps-output-boolean "LandscapeMode "
5469 (or ps-landscape-mode
5470 (eq (ps-n-up-landscape n-up) 'pag)))
5471 (ps-output-boolean "UpsideDown " ps-print-upside-down)
5472 (ps-output (format "/NumberOfColumns %d def\n" ps-number-of-columns)
5474 (format "/LandscapePageHeight %s def\n" ps-landscape-page-height)
5475 (format "/PrintPageWidth %s def\n"
5476 (- (* (+ ps-print-width ps-inter-column)
5477 ps-number-of-columns)
5478 ps-inter-column))
5479 (format "/PrintWidth %s def\n" ps-print-width)
5480 (format "/PrintHeight %s def\n" ps-print-height)
5482 (format "/LeftMargin %s def\n" ps-left-margin)
5483 (format "/RightMargin %s def\n" ps-right-margin)
5484 (format "/InterColumn %s def\n" ps-inter-column)
5486 (format "/BottomMargin %s def\n" ps-bottom-margin)
5487 (format "/TopMargin %s def\n" ps-top-margin) ; not used
5488 (format "/HeaderOffset %s def\n" ps-header-offset)
5489 (format "/HeaderPad %s def\n" ps-header-pad)
5490 (format "/FooterOffset %s def\n" ps-footer-offset)
5491 (format "/FooterPad %s def\n" ps-footer-pad)
5492 (format "/FooterLines %s def\n" ps-footer-lines))
5494 (ps-output-boolean "ShowNofN " ps-show-n-of-n)
5495 (ps-output-boolean "SwitchHeader " (if (eq ps-switch-header 'duplex)
5496 ps-spool-duplex
5497 ps-switch-header))
5498 (ps-output-boolean "PrintOnlyOneHeader" ps-print-only-one-header)
5499 (ps-output-boolean "PrintHeader " ps-print-header)
5500 (ps-output-boolean "PrintHeaderFrame " ps-print-header-frame)
5501 (ps-output-frame-properties "HeaderFrameProperties" ps-header-frame-alist)
5502 (ps-output-boolean "PrintFooter " ps-print-footer)
5503 (ps-output-boolean "PrintFooterFrame " ps-print-footer-frame)
5504 (ps-output-frame-properties "FooterFrameProperties" ps-footer-frame-alist)
5506 (let ((line-height (ps-line-height 'ps-font-for-text)))
5507 (ps-output (format "/LineSpacing %s def\n" ps-line-spacing-internal)
5508 (format "/ParagraphSpacing %s def\n"
5509 ps-paragraph-spacing-internal)
5510 (format "/LineHeight %s def\n" line-height)
5511 (format "/LinesPerColumn %d def\n"
5512 (let ((height (+ line-height
5513 ps-line-spacing-internal)))
5514 (round (/ (+ ps-print-height
5515 (* height 0.45))
5516 height))))))
5518 (ps-output-boolean "WarnPaperSize " ps-warn-paper-type)
5519 (ps-output-boolean "Zebra " ps-zebra-stripes)
5520 (ps-output-boolean "PrintLineNumber " ps-line-number)
5521 (ps-output-boolean "SyncLineZebra " (not (integerp ps-line-number-step)))
5522 (ps-output (format "/ZebraFollow %d def\n"
5523 (or (cdr (assq ps-zebra-stripe-follow
5524 ps-zebra-stripe-alist))
5526 (format "/PrintLineStep %d def\n"
5527 (if (integerp ps-line-number-step)
5528 ps-line-number-step
5529 ps-zebra-stripe-height))
5530 (format "/PrintLineStart %d def\n" ps-line-number-start)
5531 "/LineNumberColor "
5532 (ps-format-color ps-line-number-color 0.0)
5533 (format "def\n/ZebraHeight %d def\n"
5534 ps-zebra-stripe-height)
5535 "/ZebraColor "
5536 (ps-format-color ps-zebra-color 0.95)
5537 "def\n")
5538 (ps-output "/BackgroundColor "
5539 (ps-format-color ps-default-background 1.0)
5540 "def\n")
5541 (ps-output "/UseSetpagedevice "
5542 (if (eq ps-spool-config 'setpagedevice)
5543 "/setpagedevice where{pop languagelevel 2 eq}{false}ifelse"
5544 "false")
5545 " def\n\n/PageWidth "
5546 "PrintPageWidth LeftMargin add RightMargin add def\n\n"
5547 (format "/N-Up %d def\n" ps-n-up-printing))
5548 (ps-output-boolean "N-Up-Landscape" (eq (ps-n-up-landscape n-up) t))
5549 (ps-output-boolean "N-Up-Border " ps-n-up-border-p)
5550 (ps-output (format "/N-Up-Lines %d def\n" (ps-n-up-lines n-up))
5551 (format "/N-Up-Columns %d def\n" (ps-n-up-columns n-up))
5552 (format "/N-Up-Missing %d def\n" (ps-n-up-missing n-up))
5553 (format "/N-Up-Margin %s def\n" ps-n-up-margin)
5554 "/N-Up-Repeat "
5555 (if ps-landscape-mode
5556 (ps-n-up-end n-up-filling)
5557 (ps-n-up-repeat n-up-filling))
5558 " def\n/N-Up-End "
5559 (if ps-landscape-mode
5560 (ps-n-up-repeat n-up-filling)
5561 (ps-n-up-end n-up-filling))
5562 " def\n/N-Up-XColumn " (ps-n-up-xcolumn n-up-filling)
5563 " def\n/N-Up-YColumn " (ps-n-up-ycolumn n-up-filling)
5564 " def\n/N-Up-XLine " (ps-n-up-xline n-up-filling)
5565 " def\n/N-Up-YLine " (ps-n-up-yline n-up-filling)
5566 " def\n/N-Up-XStart " (ps-n-up-xstart n-up-filling)
5567 " def\n/N-Up-YStart " (ps-n-up-ystart n-up-filling) " def\n")
5569 (ps-background-text)
5570 (ps-background-image)
5571 (setq ps-background-all-pages (nreverse ps-background-all-pages)
5572 ps-background-pages (nreverse ps-background-pages))
5574 (ps-output "\n" ps-print-prologue-1
5575 "\n/printGlobalBackground{\n")
5576 (mapc 'ps-output ps-background-all-pages)
5577 (ps-output
5578 "}def\n/printLocalBackground{\n}def\n"
5579 "\n%%EndProlog\n\n%%BeginSetup\n"
5580 "\n%%IncludeResource: font Times-Roman"
5581 "\n%%IncludeResource: font Times-Italic"
5582 "\n%%IncludeResource: font "
5583 (mapconcat 'identity
5584 (ps-remove-duplicates
5585 (append (ps-fonts 'ps-font-for-text)
5586 (list (ps-font 'ps-font-for-header 'normal)
5587 (ps-font 'ps-font-for-header 'bold)
5588 (ps-font 'ps-font-for-footer 'normal)
5589 (ps-font 'ps-font-for-footer 'bold))))
5590 "\n%%IncludeResource: font ")
5591 ;; Header/line number fonts
5592 (format "\n/h0 %s(%s)cvn DefFont\n" ; /h0 14/Helvetica-Bold DefFont
5593 ps-header-title-font-size-internal
5594 (ps-font 'ps-font-for-header 'bold))
5595 (format "/h1 %s(%s)cvn DefFont\n" ; /h1 12/Helvetica DefFont
5596 ps-header-font-size-internal
5597 (ps-font 'ps-font-for-header 'normal))
5598 (format "/L0 %s(%s)cvn DefFont\n" ; /L0 6/Times-Italic DefFont
5599 (ps-get-font-size 'ps-line-number-font-size)
5600 ps-line-number-font)
5601 (format "/H0 %s(%s)cvn DefFont\n" ; /H0 12/Helvetica DefFont
5602 ps-footer-font-size-internal
5603 (ps-font 'ps-font-for-footer 'normal))
5604 "\n\n% ---- These lines must be kept together because...
5606 /h0 F
5607 /HeaderTitleLineHeight FontHeight def
5609 /h1 F
5610 /HeaderLineHeight FontHeight def
5611 /HeaderDescent Descent def
5613 /H0 F
5614 /FooterLineHeight FontHeight def
5615 /FooterDescent Descent def
5617 % ---- ...because `F' has a side-effect on `FontHeight' and `Descent'\n\n")
5619 ;; Text fonts
5620 (let ((font (ps-font-alist 'ps-font-for-text))
5621 (i 0))
5622 (while font
5623 (ps-output (format "/f%d %s(%s)cvn DefFont\n"
5625 ps-font-size-internal
5626 (ps-font 'ps-font-for-text (car (car font)))))
5627 (setq font (cdr font)
5628 i (1+ i))))
5630 (let ((font-entry (cdr (assq ps-font-family ps-font-info-database))))
5631 (ps-output (format "/SpaceWidthRatio %f def\n"
5632 (/ (ps-lookup 'space-width) (ps-lookup 'size)))))
5634 (unless (eq ps-spool-config 'lpr-switches)
5635 (ps-output "\n%%BeginFeature: *Duplex "
5636 (ps-boolean-capitalized ps-spool-duplex)
5637 " *Tumble "
5638 (ps-boolean-capitalized tumble)
5639 "\nUseSetpagedevice\n{BMark/Duplex "
5640 (ps-boolean-constant ps-spool-duplex)
5641 "/Tumble "
5642 (ps-boolean-constant tumble)
5643 " EMark setpagedevice}\n{statusdict begin "
5644 (ps-boolean-constant ps-spool-duplex)
5645 " setduplexmode "
5646 (ps-boolean-constant tumble)
5647 " settumble end}ifelse\n%%EndFeature\n")))
5648 (ps-output "\n%%BeginFeature: *ManualFeed "
5649 (ps-boolean-capitalized ps-manual-feed)
5650 "\nBMark /ManualFeed "
5651 (ps-boolean-constant ps-manual-feed)
5652 " EMark setpagedevice\n%%EndFeature\n\nBeginDoc\n%%EndSetup\n")
5653 (and ps-banner-page-when-duplexing
5654 (ps-output "\n%%Page: banner 0\nsave showpage restore\n")))
5657 (defun ps-format-color (color &optional default)
5658 (let ((the-color (if (stringp color)
5659 (ps-color-scale color)
5660 color)))
5661 (if (and the-color (listp the-color))
5662 (concat "["
5663 (format ps-color-format
5664 (* (nth 0 the-color) 1.0) ; force float number
5665 (* (nth 1 the-color) 1.0) ; force float number
5666 (* (nth 2 the-color) 1.0)) ; force float number
5667 "] ")
5668 (ps-float-format (if (numberp the-color) the-color default)))))
5671 (defun ps-insert-string (prologue)
5672 (let ((str (if (functionp prologue)
5673 (funcall prologue)
5674 prologue)))
5675 (and (stringp str)
5676 (ps-output str))))
5679 (defun ps-boolean-capitalized (bool)
5680 (if bool "True" "False"))
5683 (defun ps-boolean-constant (bool)
5684 (if bool "true" "false"))
5687 (defun ps-header-dirpart ()
5688 (let ((fname (buffer-file-name)))
5689 (if fname
5690 (if (string-equal (buffer-name) (file-name-nondirectory fname))
5691 (abbreviate-file-name (file-name-directory fname))
5692 fname)
5693 "")))
5696 (defun ps-get-buffer-name ()
5697 (cond
5698 ;; Indulge Jim this little easter egg:
5699 ((string= (buffer-name) "ps-print.el")
5700 "Hey, Cool! It's ps-print.el!!!")
5701 ;; Indulge Jack this other little easter egg:
5702 ((string= (buffer-name) "sokoban.el")
5703 "Super! C'est sokoban.el!")
5704 (t (concat
5705 (and ps-printing-region-p "Subset of: ")
5706 (buffer-name)
5707 (and (buffer-modified-p) " (unsaved)")))))
5710 (defun ps-get-size (size mess &optional arg)
5711 (let ((siz (cond ((numberp size)
5712 size)
5713 ((and (consp size)
5714 (numberp (car size))
5715 (numberp (cdr size)))
5716 (if ps-landscape-mode
5717 (car size)
5718 (cdr size)))
5720 -1))))
5721 (and (< siz 0)
5722 (error "Invalid %s `%S'%s"
5723 mess size
5724 (if arg
5725 (format " for `%S'" arg)
5726 "")))
5727 siz))
5730 (defun ps-get-font-size (font-sym)
5731 (ps-get-size (symbol-value font-sym) "font size" font-sym))
5734 (defun ps-rgb-color (color unspecified default)
5735 (cond
5736 ;; (float float float) ==> (R G B)
5737 ((and color (listp color) (= (length color) 3)
5738 (let ((cl color)
5739 (ok t) e)
5740 (while (and ok cl)
5741 (setq e (car cl)
5742 cl (cdr cl)
5743 ok (and (floatp e) (<= 0.0 e) (<= e 1.0))))
5744 ok))
5745 color)
5746 ;; float ==> 0.0 = black .. 1.0 = white
5747 ((and (floatp color) (<= 0.0 color) (<= color 1.0))
5748 (list color color color))
5749 ;; "colorName" but different from "unspecified-[bf]g"
5750 ((and (stringp color) (not (string= color unspecified)))
5751 (ps-color-scale color))
5752 ;; ok, use the default
5754 (list default default default))))
5756 (defvar ps-basic-plot-string-function 'ps-basic-plot-string)
5758 (defun ps-begin-job (genfunc)
5759 ;; prologue files
5760 (or (equal ps-mark-code-directory ps-postscript-code-directory)
5761 (setq ps-print-prologue-0 (ps-prologue-file 0)
5762 ps-print-prologue-1 (ps-prologue-file 1)
5763 ps-mark-code-directory ps-postscript-code-directory))
5764 ;; selected pages
5765 (let (new page)
5766 (while ps-selected-pages
5767 (setq page (car ps-selected-pages)
5768 ps-selected-pages (cdr ps-selected-pages))
5769 (cond ((integerp page)
5770 (and (> page 0)
5771 (setq new (cons (cons page page) new))))
5772 ((consp page)
5773 (and (integerp (car page)) (integerp (cdr page))
5774 (> (car page) 0)
5775 (<= (car page) (cdr page))
5776 (setq new (cons page new))))))
5777 (setq ps-selected-pages (sort new #'(lambda (one other)
5778 (< (car one) (car other))))
5779 ps-last-selected-pages ps-selected-pages
5780 ps-first-page nil
5781 ps-last-page nil))
5782 ;; face background
5783 (or (listp ps-use-face-background)
5784 (setq ps-use-face-background t))
5785 ;; line number
5786 (and (integerp ps-line-number-step)
5787 (<= ps-line-number-step 0)
5788 (setq ps-line-number-step 1))
5789 (setq ps-n-up-on (> ps-n-up-printing 1)
5790 ps-line-number-start (max 1 (min ps-line-number-start
5791 (if (integerp ps-line-number-step)
5792 ps-line-number-step
5793 ps-zebra-stripe-height))))
5794 ;; spooling buffer
5795 (with-current-buffer ps-spool-buffer
5796 (goto-char (point-max))
5797 (and (re-search-backward "^%%Trailer$" nil t)
5798 (delete-region (match-beginning 0) (point-max))))
5799 ;; miscellaneous
5800 (setq ps-zebra-stripe-full-p (memq ps-zebra-stripe-follow
5801 '(full full-follow))
5802 ps-page-postscript 0
5803 ps-page-sheet 0
5804 ps-page-n-up 0
5805 ps-page-column 0
5806 ps-lines-printed 0
5807 ps-print-page-p t
5808 ps-showline-count (car ps-printing-region)
5809 ps-line-spacing-internal (ps-get-size ps-line-spacing
5810 "line spacing")
5811 ps-paragraph-spacing-internal (ps-get-size ps-paragraph-spacing
5812 "paragraph spacing")
5813 ps-font-size-internal (ps-get-font-size 'ps-font-size)
5814 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size)
5815 ps-header-title-font-size-internal
5816 (ps-get-font-size 'ps-header-title-font-size)
5817 ps-footer-font-size-internal (ps-get-font-size 'ps-footer-font-size)
5818 ps-control-or-escape-regexp
5819 (cond ((eq ps-print-control-characters '8-bit)
5820 (string-as-unibyte "[\000-\037\177-\377]"))
5821 ((eq ps-print-control-characters 'control-8-bit)
5822 (string-as-unibyte "[\000-\037\177-\237]"))
5823 ((eq ps-print-control-characters 'control)
5824 "[\000-\037\177]")
5825 (t "[\t\n\f]"))
5826 ;; Set the color scale. We do it here instead of in the defvar so
5827 ;; that ps-print can be dumped into emacs. This expression can't be
5828 ;; evaluated at dump-time because X isn't initialized.
5829 ps-color-p (and ps-print-color-p (ps-color-device))
5830 ps-print-color-scale (if ps-color-p
5831 (float (car (ps-color-values "white")))
5832 1.0)
5833 ps-default-background (ps-rgb-color
5834 (cond
5835 ((or (member ps-print-color-p
5836 '(nil back-white))
5837 (eq genfunc 'ps-generate-postscript))
5838 nil)
5839 ((eq ps-default-bg 'frame-parameter)
5840 (ps-frame-parameter nil 'background-color))
5841 ((eq ps-default-bg t)
5842 (ps-face-background-name 'default))
5844 ps-default-bg))
5845 "unspecified-bg"
5846 1.0)
5847 ps-default-foreground (ps-rgb-color
5848 (cond
5849 ((or (member ps-print-color-p
5850 '(nil back-white))
5851 (eq genfunc 'ps-generate-postscript))
5852 nil)
5853 ((eq ps-default-fg 'frame-parameter)
5854 (ps-frame-parameter nil 'foreground-color))
5855 ((eq ps-default-fg t)
5856 (ps-face-foreground-name 'default))
5858 ps-default-fg))
5859 "unspecified-fg"
5860 0.0)
5861 ps-foreground-list (mapcar
5862 #'(lambda (arg)
5863 (ps-rgb-color arg "unspecified-fg" 0.0))
5864 (append (and (not (member ps-print-color-p
5865 '(nil back-white)))
5866 ps-fg-list)
5867 (list ps-default-foreground
5868 "black")))
5869 ps-default-color (and (not (member ps-print-color-p
5870 '(nil back-white)))
5871 ps-default-foreground)
5872 ps-current-color ps-default-color
5873 ;; Set up default functions.
5874 ;; They may be overridden by ps-mule-begin-job.
5875 ps-basic-plot-string-function 'ps-basic-plot-string
5876 ps-encode-header-string-function nil)
5877 ;; initialize page dimensions
5878 (ps-get-page-dimensions)
5879 ;; final check
5880 (unless (listp ps-lpr-switches)
5881 (error "`ps-lpr-switches' value should be a list"))
5882 (and ps-color-p
5883 (equal ps-default-background ps-default-foreground)
5884 (error
5885 (concat
5886 "`ps-default-fg' and `ps-default-bg' have the same color.\n"
5887 "Text won't appear on page. Please, check these variables."))))
5890 (defun ps-page-number ()
5891 (if ps-print-only-one-header
5892 (1+ (/ (1- ps-page-column) ps-number-of-columns))
5893 ps-page-column))
5896 (defsubst ps-end-page ()
5897 (ps-output "EndPage\nEndDSCPage\n"))
5900 (defsubst ps-next-page ()
5901 (ps-end-page)
5902 (ps-flush-output)
5903 (ps-begin-page))
5906 (defun ps-end-sheet ()
5907 (and ps-print-page-p (> ps-page-sheet 0)
5908 (ps-output "EndSheet\n")))
5911 (defun ps-header-sheet ()
5912 ;; Print only when a new sheet begins.
5913 (ps-end-sheet)
5914 (setq ps-page-sheet (1+ ps-page-sheet))
5915 (when (ps-print-sheet-p)
5916 (setq ps-page-order (1+ ps-page-order))
5917 (ps-output (if ps-n-up-on
5918 (format "\n%%%%Page: (%d \\(%d\\)) %d\n"
5919 ps-page-order ps-page-postscript ps-page-order)
5920 (format "\n%%%%Page: %d %d\n"
5921 ps-page-postscript ps-page-order))
5922 ;; spooling needs to redefine Lines and PageCount on each page
5923 "/Lines 0 def\n/PageCount 0 def\n"
5924 (format "%d BeginSheet\nBeginDSCPage\n"
5925 ps-n-up-printing))))
5928 (defun ps-header-page ()
5929 ;; set total line and page number when printing has finished
5930 ;; (see `ps-generate')
5931 (if (zerop (mod ps-page-column ps-number-of-columns))
5932 (progn
5933 (setq ps-page-postscript (1+ ps-page-postscript))
5934 (when (ps-print-page-p)
5935 (ps-print-sheet-p)
5936 (if (zerop (mod ps-page-n-up ps-n-up-printing))
5937 ;; Print only when a new sheet begins.
5938 (progn
5939 (ps-header-sheet)
5940 (run-hooks 'ps-print-begin-sheet-hook))
5941 ;; Print only when a new page begins.
5942 (ps-output "BeginDSCPage\n")
5943 (run-hooks 'ps-print-begin-page-hook))
5944 (ps-background ps-page-postscript)
5945 (setq ps-page-n-up (1+ ps-page-n-up))
5946 (and ps-print-page-p
5947 (setq ps-page-printed (1+ ps-page-printed)))))
5948 ;; Print only when a new column begins.
5949 (ps-output "BeginDSCPage\n")
5950 (run-hooks 'ps-print-begin-column-hook))
5951 (setq ps-page-column (1+ ps-page-column)))
5953 (defun ps-begin-page ()
5954 (setq ps-width-remaining ps-print-width
5955 ps-height-remaining ps-print-height)
5957 (ps-header-page)
5959 (ps-output (format "/LineNumber %d def\n" ps-showline-count)
5960 (format "/PageNumber %d def\n" (ps-page-number)))
5962 (when ps-print-header
5963 (ps-generate-header "HeaderLinesLeft" "/h0" "/h1" ps-left-header)
5964 (ps-generate-header "HeaderLinesRight" "/h0" "/h1" ps-right-header)
5965 (ps-output (format "%d SetHeaderLines\n" ps-header-lines)))
5967 (when ps-print-footer
5968 (ps-generate-header "FooterLinesLeft" "/H0" "/H0" ps-left-footer)
5969 (ps-generate-header "FooterLinesRight" "/H0" "/H0" ps-right-footer)
5970 (ps-output (format "%d SetFooterLines\n" ps-footer-lines)))
5972 (ps-output (number-to-string ps-lines-printed) " BeginPage\n")
5973 (ps-set-font ps-current-font)
5974 (ps-set-bg ps-current-bg)
5975 (ps-set-color ps-current-color))
5977 (defsubst ps-skip-newline (limit)
5978 (setq ps-showline-count (1+ ps-showline-count)
5979 ps-lines-printed (1+ ps-lines-printed))
5980 (and (< (point) limit)
5981 (forward-char 1)))
5983 (defsubst ps-next-line ()
5984 (setq ps-showline-count (1+ ps-showline-count)
5985 ps-lines-printed (1+ ps-lines-printed))
5986 (let* ((paragraph-p (and ps-paragraph-regexp
5987 (looking-at ps-paragraph-regexp)))
5988 (lh (+ (ps-line-height 'ps-font-for-text)
5989 (if paragraph-p
5990 ps-paragraph-spacing-internal
5991 ps-line-spacing-internal))))
5992 (if (< ps-height-remaining lh)
5993 (ps-next-page)
5994 (setq ps-width-remaining ps-print-width
5995 ps-height-remaining (- ps-height-remaining lh))
5996 (ps-output (if paragraph-p "PHL\n" "LHL\n")))))
5998 (defun ps-continue-line ()
5999 (setq ps-lines-printed (1+ ps-lines-printed))
6000 (let ((lh (+ (ps-line-height 'ps-font-for-text) ps-line-spacing-internal)))
6001 (if (< ps-height-remaining lh)
6002 (ps-next-page)
6003 (setq ps-width-remaining ps-print-width
6004 ps-height-remaining (- ps-height-remaining lh))
6005 (ps-output "SL\n"))))
6007 (defun ps-find-wrappoint (from to char-width)
6008 (let ((avail (truncate (/ ps-width-remaining char-width)))
6009 (todo (- to from)))
6010 (if (< todo avail)
6011 (cons to (* todo char-width))
6012 (cons (+ from avail) ps-width-remaining))))
6014 (defun ps-basic-plot-str (from to string)
6015 (let* ((wrappoint (ps-find-wrappoint from to
6016 (ps-avg-char-width 'ps-font-for-text)))
6017 (to (car wrappoint))
6018 (str (substring string from to)))
6019 (ps-output-string str)
6020 (ps-output " S\n")
6021 wrappoint))
6023 (defun ps-basic-plot-string (from to &optional bg-color)
6024 (let* ((wrappoint (ps-find-wrappoint from to
6025 (ps-avg-char-width 'ps-font-for-text)))
6026 (to (car wrappoint))
6027 (string (buffer-substring-no-properties from to)))
6028 (ps-output-string string)
6029 (ps-output " S\n")
6030 wrappoint))
6032 (defun ps-basic-plot-whitespace (from to &optional bg-color)
6033 (let* ((wrappoint (ps-find-wrappoint from to
6034 (ps-space-width 'ps-font-for-text)))
6035 (to (car wrappoint)))
6036 (ps-output (format "%d W\n" (- to from)))
6037 wrappoint))
6039 (defun ps-plot (plotfunc from to &optional bg-color)
6040 (while (< from to)
6041 (let* ((wrappoint (funcall plotfunc from to bg-color))
6042 (plotted-to (car wrappoint))
6043 (plotted-width (cdr wrappoint)))
6044 (setq from plotted-to
6045 ps-width-remaining (- ps-width-remaining plotted-width))
6046 (if (< from to)
6047 (ps-continue-line))))
6048 (if ps-razzle-dazzle
6049 (let* ((q-todo (- (point-max) (point-min)))
6050 (q-done (- (point) (point-min)))
6051 (chunkfrac (/ q-todo 8))
6052 (chunksize (min chunkfrac 1000)))
6053 (if (> (- q-done ps-razchunk) chunksize)
6054 (progn
6055 (setq ps-razchunk q-done)
6056 (message "Formatting...%3d%%"
6057 (if (< q-todo 100)
6058 (/ (* 100 q-done) q-todo)
6059 (/ q-done (/ q-todo 100)))
6060 ))))))
6062 (defvar ps-last-font nil)
6064 (defun ps-set-font (font)
6065 (setq ps-last-font (format "f%d" (setq ps-current-font font)))
6066 (ps-output (format "/%s F\n" ps-last-font)))
6068 (defun ps-set-bg (color)
6069 (if (setq ps-current-bg color)
6070 (ps-output (format ps-color-format
6071 (nth 0 color) (nth 1 color) (nth 2 color))
6072 " true BG\n")
6073 (ps-output "false BG\n")))
6075 (defun ps-set-color (color)
6076 (setq ps-current-color (or color ps-default-foreground))
6077 (ps-output (format ps-color-format
6078 (nth 0 ps-current-color)
6079 (nth 1 ps-current-color) (nth 2 ps-current-color))
6080 " FG\n"))
6083 (defsubst ps-plot-string (string)
6084 (ps-plot 'ps-basic-plot-str 0 (length string) string))
6087 (defvar ps-current-effect 0)
6089 (defvar ps-print-translation-table
6090 (let ((tbl (make-char-table 'translation-table nil)))
6091 (if (and (boundp 'ucs-mule-8859-to-mule-unicode)
6092 (char-table-p ucs-mule-8859-to-mule-unicode))
6093 (map-char-table
6094 #'(lambda (k v)
6095 (if (and v (eq (char-charset v) 'latin-iso8859-1) (/= k v))
6096 (aset tbl k v)))
6097 ucs-mule-8859-to-mule-unicode))
6098 tbl)
6099 "Translation table for PostScript printing.
6100 The default value is a table that translates non-Latin-1 Latin characters
6101 to the equivalent Latin-1 characters.")
6103 (defun ps-plot-region (from to font &optional fg-color bg-color effects)
6104 (or (equal font ps-current-font)
6105 (ps-set-font font))
6107 ;; Specify a foreground color only if:
6108 ;; one's specified,
6109 ;; it's different than the background (if `ps-fg-validate-p' is non-nil)
6110 ;; and it's different than the current.
6111 (let ((fg (or fg-color ps-default-foreground)))
6112 (if ps-fg-validate-p
6113 (let ((bg (or bg-color ps-default-background))
6114 (el ps-foreground-list))
6115 (while (and el (equal fg bg))
6116 (setq fg (car el)
6117 el (cdr el)))))
6118 (or (equal fg ps-current-color)
6119 (ps-set-color fg)))
6121 (or (equal bg-color ps-current-bg)
6122 (ps-set-bg bg-color))
6124 ;; Specify effects (underline, overline, box, etc.)
6125 (cond
6126 ((not (integerp effects))
6127 (ps-output "0 EF\n")
6128 (setq ps-current-effect 0))
6129 ((/= effects ps-current-effect)
6130 (ps-output (number-to-string effects) " EF\n")
6131 (setq ps-current-effect effects)))
6133 ;; Starting at the beginning of the specified region...
6134 (save-excursion
6135 (goto-char from)
6137 ;; ...break the region up into chunks separated by tabs, linefeeds,
6138 ;; pagefeeds, control characters, and plot each chunk.
6139 (while (< from to)
6140 ;; skip lines between cut markers
6141 (and ps-begin-cut-regexp ps-end-cut-regexp
6142 (looking-at ps-begin-cut-regexp)
6143 (progn
6144 (goto-char (match-end 0))
6145 (and (re-search-forward ps-end-cut-regexp to 'noerror)
6146 (= (following-char) ?\n)
6147 (forward-char 1))
6148 (setq from (point))))
6149 (if (re-search-forward ps-control-or-escape-regexp to t)
6150 ;; region with some control characters or some multi-byte characters
6151 (let* ((match-point (match-beginning 0))
6152 (match (char-after match-point)))
6153 (when (< from match-point)
6154 (ps-plot ps-basic-plot-string-function
6155 from match-point bg-color))
6156 (cond
6157 ((= match ?\t) ; tab
6158 (let ((linestart (line-beginning-position)))
6159 (forward-char -1)
6160 (setq from (+ linestart (current-column)))
6161 (when (re-search-forward "[ \t]+" to t)
6162 (ps-plot 'ps-basic-plot-whitespace
6163 from (+ linestart (current-column))
6164 bg-color))))
6166 ((= match ?\n) ; newline
6167 (if (looking-at "\f[^\n]")
6168 ;; \n\ftext\n ==>> next page, but keep line counting!!
6169 (progn
6170 (ps-skip-newline to)
6171 (ps-next-page))
6172 ;; \n\f\n ==>> it'll be handled by form feed
6173 ;; \ntext\n ==>> next line
6174 (ps-next-line)))
6176 ((= match ?\f) ; form feed
6177 ;; do not skip page if previous character is NEWLINE and
6178 ;; it is a beginning of page.
6179 (unless (and (equal (char-after (1- match-point)) ?\n)
6180 (= ps-height-remaining ps-print-height))
6181 ;; \f\n ==>> skip \n, but keep line counting!!
6182 (and (equal (following-char) ?\n)
6183 (ps-skip-newline to))
6184 (ps-next-page)))
6186 (t ; characters from 127 to 255
6187 (ps-control-character match)))
6188 (setq from (point)))
6189 ;; region without control characters
6190 (ps-plot ps-basic-plot-string-function from to bg-color)
6191 (setq from to)))))
6193 (defvar ps-string-control-codes
6194 (let ((table (make-vector 256 nil))
6195 (char ?\000))
6196 ;; control character
6197 (while (<= char ?\037)
6198 (aset table char (format "^%c" (+ char ?@)))
6199 (setq char (1+ char)))
6200 ;; printable character
6201 (while (< char ?\177)
6202 (aset table char (format "%c" char))
6203 (setq char (1+ char)))
6204 ;; DEL
6205 (aset table char "^?")
6206 ;; 8-bit character
6207 (while (<= (setq char (1+ char)) ?\377)
6208 (aset table char (format "\\%o" char)))
6209 table)
6210 "Vector used to map characters to a printable string.")
6212 (defun ps-control-character (char)
6213 (let* ((str (aref ps-string-control-codes char))
6214 (from (1- (point)))
6215 (len (length str))
6216 (to (+ from len))
6217 (char-width (ps-avg-char-width 'ps-font-for-text))
6218 (wrappoint (ps-find-wrappoint from to char-width)))
6219 (if (< (car wrappoint) to)
6220 (ps-continue-line))
6221 (setq ps-width-remaining (- ps-width-remaining (* len char-width)))
6222 (ps-output-string str)
6223 (ps-output " S\n")))
6226 (defsubst ps-face-foreground-color-p (attr)
6227 (memq attr '(foreground-color :foreground)))
6230 (defsubst ps-face-background-color-p (attr)
6231 (memq attr '(background-color :background)))
6234 (defsubst ps-face-color-p (attr)
6235 (memq attr '(foreground-color :foreground background-color :background)))
6238 (defun ps-face-extract-color (face-attrs)
6239 (let ((color (cdr face-attrs)))
6240 (if (listp color)
6241 (car color)
6242 color)))
6245 (defun ps-face-attributes (face)
6246 "Return face attribute vector.
6248 If FACE is not in `ps-print-face-extension-alist' or in
6249 `ps-print-face-alist', insert it on `ps-print-face-alist' and
6250 return the attribute vector.
6252 If FACE is not a valid face name, use default face."
6253 (and (stringp face) (facep face) (setq face (intern face)))
6254 (cond
6255 (ps-black-white-faces-alist
6256 (or (and (symbolp face)
6257 (cdr (assq face ps-black-white-faces-alist)))
6258 (vector 0 nil nil)))
6259 ((symbolp face)
6260 (cdr (or (assq face ps-print-face-extension-alist)
6261 (assq face ps-print-face-alist)
6262 (let* ((the-face (if (facep face) face 'default))
6263 (new-face (ps-screen-to-bit-face the-face)))
6264 (or (and (eq the-face 'default)
6265 (assq the-face ps-print-face-alist))
6266 (setq ps-print-face-alist
6267 (cons new-face ps-print-face-alist)))
6268 new-face))))
6269 ((ps-face-foreground-color-p (car face))
6270 (vector 0 (ps-face-extract-color face) nil))
6271 ((ps-face-background-color-p (car face))
6272 (vector 0 nil (ps-face-extract-color face)))
6274 (vector 0 nil nil))))
6277 (defun ps-face-background (face background)
6278 (and (cond ((eq ps-use-face-background t)) ; always
6279 ((null ps-use-face-background) nil) ; never
6280 ;; ps-user-face-background is a symbol face list
6281 ((symbolp face)
6282 (memq face ps-use-face-background))
6283 ((listp face)
6284 (or (ps-face-color-p (car face))
6285 (let (ok)
6286 (while face
6287 (if (or (memq (car face) ps-use-face-background)
6288 (ps-face-color-p (car face)))
6289 (setq face nil
6290 ok t)
6291 (setq face (cdr face))))
6292 ok)))
6294 nil)
6296 background))
6299 (defun ps-face-attribute-list (face-or-list)
6300 (cond
6301 ;; simple face
6302 ((not (listp face-or-list))
6303 (ps-face-attributes face-or-list))
6304 ;; only foreground color, not a `real' face
6305 ((ps-face-foreground-color-p (car face-or-list))
6306 (vector 0 (ps-face-extract-color face-or-list) nil))
6307 ;; only background color, not a `real' face
6308 ((ps-face-background-color-p (car face-or-list))
6309 (vector 0 nil (ps-face-extract-color face-or-list)))
6310 ;; list of faces
6312 (let ((effects 0)
6313 foreground background face-attr face)
6314 (while face-or-list
6315 (setq face (car face-or-list)
6316 face-or-list (cdr face-or-list)
6317 face-attr (ps-face-attributes face)
6318 effects (logior effects (aref face-attr 0)))
6319 (or foreground (setq foreground (aref face-attr 1)))
6320 (or background
6321 (setq background (ps-face-background face (aref face-attr 2)))))
6322 (vector effects foreground background)))))
6325 (defconst ps-font-type (vector nil 'bold 'italic 'bold-italic))
6328 (defun ps-plot-with-face (from to face)
6329 (cond
6330 ((null face) ; print text with null face
6331 (ps-plot-region from to 0))
6332 ((eq face 'emacs--invisible--face)) ; skip invisible text!!!
6333 (t ; otherwise, text has a valid face
6334 (let* ((face-bit (ps-face-attribute-list face))
6335 (effect (aref face-bit 0))
6336 (foreground (aref face-bit 1))
6337 (background (ps-face-background face (aref face-bit 2)))
6338 (fg-color (if (and ps-color-p foreground)
6339 (ps-color-scale foreground)
6340 ps-default-color))
6341 (bg-color (and ps-color-p background
6342 (ps-color-scale background))))
6343 (ps-plot-region
6344 from to
6345 (ps-font-number 'ps-font-for-text
6346 (or (aref ps-font-type (logand effect 3))
6347 face))
6348 fg-color bg-color (lsh effect -2)))))
6349 (goto-char to))
6352 ;; Ensure that face-list is fbound.
6353 (or (fboundp 'face-list) (defalias 'face-list 'list-faces))
6356 (defun ps-build-reference-face-lists ()
6357 ;; Ensure that face database is updated with faces on
6358 ;; `font-lock-face-attributes' (obsolete stuff)
6359 (ps-font-lock-face-attributes)
6360 ;; Now, rebuild reference face lists
6361 (setq ps-print-face-alist nil)
6362 (if ps-auto-font-detect
6363 (mapc 'ps-map-face (face-list))
6364 (mapc 'ps-set-face-bold ps-bold-faces)
6365 (mapc 'ps-set-face-italic ps-italic-faces)
6366 (mapc 'ps-set-face-underline ps-underlined-faces))
6367 (setq ps-build-face-reference nil))
6370 (defun ps-set-face-bold (face)
6371 (ps-set-face-attribute face 1))
6373 (defun ps-set-face-italic (face)
6374 (ps-set-face-attribute face 2))
6376 (defun ps-set-face-underline (face)
6377 (ps-set-face-attribute face 4))
6380 (defun ps-set-face-attribute (face effect)
6381 (let ((face-bit (cdr (ps-map-face face))))
6382 (aset face-bit 0 (logior (aref face-bit 0) effect))))
6385 (defun ps-map-face (face)
6386 (let* ((face-map (ps-screen-to-bit-face face))
6387 (ps-face-bit (cdr (assq (car face-map) ps-print-face-alist))))
6388 (if ps-face-bit
6389 ;; if face exists, merge both
6390 (let ((face-bit (cdr face-map)))
6391 (aset ps-face-bit 0 (logior (aref ps-face-bit 0) (aref face-bit 0)))
6392 (or (aref ps-face-bit 1) (aset ps-face-bit 1 (aref face-bit 1)))
6393 (or (aref ps-face-bit 2) (aset ps-face-bit 2 (aref face-bit 2))))
6394 ;; if face does not exist, insert it
6395 (setq ps-print-face-alist (cons face-map ps-print-face-alist)))
6396 face-map))
6399 (defun ps-screen-to-bit-face (face)
6400 (cons face
6401 (vector (logior (if (ps-face-bold-p face) 1 0) ; bold
6402 (if (ps-face-italic-p face) 2 0) ; italic
6403 (if (ps-face-underlined-p face) 4 0) ; underline
6404 (if (ps-face-strikeout-p face) 8 0) ; strikeout
6405 (if (ps-face-overline-p face) 16 0) ; overline
6406 (if (ps-face-box-p face) 64 0)) ; box
6407 (ps-face-foreground-name face)
6408 (ps-face-background-name face))))
6411 (declare-function jit-lock-fontify-now "jit-lock" (&optional start end))
6412 (declare-function lazy-lock-fontify-region "lazy-lock" (beg end))
6414 ;; to avoid compilation gripes
6415 (defun ps-print-ensure-fontified (start end)
6416 (cond ((and (boundp 'jit-lock-mode) (symbol-value 'jit-lock-mode))
6417 (jit-lock-fontify-now start end))
6418 ((and (boundp 'lazy-lock-mode) (symbol-value 'lazy-lock-mode))
6419 (lazy-lock-fontify-region start end))))
6422 (defun ps-generate-postscript-with-faces (from to)
6423 ;; Some initialization...
6424 (setq ps-current-effect 0)
6426 ;; Build the reference lists of faces if necessary.
6427 (when (or ps-always-build-face-reference
6428 ps-build-face-reference)
6429 (message "Collecting face information...")
6430 (ps-build-reference-face-lists))
6432 ;; Black/white printer.
6433 (setq ps-black-white-faces-alist nil)
6434 (and (eq ps-print-color-p 'black-white)
6435 (ps-extend-face-list ps-black-white-faces nil
6436 'ps-black-white-faces-alist))
6438 ;; Generate some PostScript.
6439 (save-restriction
6440 (narrow-to-region from to)
6441 (ps-print-ensure-fontified from to)
6442 (ps-generate-postscript-with-faces1 from to)))
6444 (defun ps-generate-postscript (from to)
6445 (ps-plot-region from to 0))
6447 ;; These are autoloaded, but ps-mule generates autoloads at the end of
6448 ;; this file, so they are unknown at this point when compiling.
6449 (declare-function ps-mule-initialize "ps-mule" ())
6450 (declare-function ps-mule-begin-job "ps-mule" (from to))
6451 (declare-function ps-mule-end-job "ps-mule" ())
6453 (defun ps-generate (buffer from to genfunc)
6454 (save-excursion
6455 (let ((from (min to from))
6456 (to (max to from))
6457 ;; This avoids trouble if chars with read-only properties
6458 ;; are copied into ps-spool-buffer.
6459 (inhibit-read-only t))
6460 (save-restriction
6461 (narrow-to-region from to)
6462 (and ps-razzle-dazzle
6463 (message "Formatting...%3d%%" (setq ps-razchunk 0)))
6464 (setq ps-source-buffer buffer
6465 ps-spool-buffer (get-buffer-create ps-spool-buffer-name))
6466 (ps-init-output-queue)
6467 (let (safe-marker completed-safely needs-begin-file)
6468 (unwind-protect
6469 (progn
6470 (set-buffer ps-spool-buffer)
6471 (set-buffer-multibyte nil)
6473 ;; Get a marker and make it point to the current end of the
6474 ;; buffer, If an error occurs, we'll delete everything from
6475 ;; the end of this marker onwards.
6476 (setq safe-marker (make-marker))
6477 (set-marker safe-marker (point-max))
6479 (goto-char (point-min))
6480 (or (looking-at (regexp-quote ps-adobe-tag))
6481 (setq needs-begin-file t))
6483 (set-buffer ps-source-buffer)
6484 (save-excursion
6485 (let ((ps-print-page-p t)
6486 ps-even-or-odd-pages)
6487 (ps-begin-job genfunc)
6488 (when needs-begin-file
6489 (ps-begin-file)
6490 (ps-mule-initialize))
6491 (ps-mule-begin-job from to)
6492 (ps-selected-pages)))
6493 (ps-begin-page)
6494 (funcall genfunc from to)
6495 (ps-end-page)
6496 (ps-mule-end-job)
6497 (ps-end-job needs-begin-file)
6499 ;; Setting this variable tells the unwind form that the
6500 ;; the PostScript was generated without error.
6501 (setq completed-safely t))
6503 ;; Unwind form: If some bad mojo occurred while generating
6504 ;; PostScript, delete all the PostScript that was generated.
6505 ;; This protects the previously spooled files from getting
6506 ;; corrupted.
6507 (and (markerp safe-marker) (not completed-safely)
6508 (progn
6509 (set-buffer ps-spool-buffer)
6510 (delete-region (marker-position safe-marker) (point-max))))))
6512 (and ps-razzle-dazzle (message "Formatting...done"))))))
6515 (defun ps-end-job (needs-begin-file)
6516 (let ((ps-print-page-p t))
6517 (ps-flush-output)
6518 (save-excursion
6519 (let ((pages-per-sheet (mod ps-page-printed ps-n-up-printing))
6520 (total-lines (cdr ps-printing-region))
6521 (total-pages (ps-page-number)))
6522 (set-buffer ps-spool-buffer)
6523 (let (case-fold-search)
6524 ;; Back to the PS output buffer to set the last page n-up printing
6525 (goto-char (point-max))
6526 (and (> pages-per-sheet 0)
6527 (re-search-backward "^[0-9]+ BeginSheet$" nil t)
6528 (replace-match (format "%d BeginSheet" pages-per-sheet) t))
6529 ;; Back to the PS output buffer to set the page count
6530 (goto-char (point-min))
6531 (while (re-search-forward "^/Lines 0 def\n/PageCount 0 def$" nil t)
6532 (replace-match (format "/Lines %d def\n/PageCount %d def"
6533 total-lines total-pages) t)))))
6534 ;; Set dummy page
6535 (and ps-spool-duplex (= (mod ps-page-order 2) 1)
6536 (let ((ps-n-up-printing 0))
6537 (ps-header-sheet)
6538 (ps-output "/PrintHeader false def\n/ColumnIndex 0 def\n"
6539 "/PrintLineNumber false def\n"
6540 (number-to-string ps-lines-printed) " BeginPage\n")
6541 (ps-end-page)))
6542 ;; Set end of PostScript file
6543 (ps-end-sheet)
6544 (ps-output "\n%%Trailer\n%%Pages: "
6545 (number-to-string
6546 (if (and needs-begin-file
6547 ps-banner-page-when-duplexing)
6548 (1+ ps-page-order)
6549 ps-page-order))
6550 "\n\nEndDoc\n\n%%EOF\n")
6551 (and ps-end-with-control-d
6552 (ps-output "\C-d"))
6553 (ps-flush-output))
6554 ;; disable selected pages
6555 (setq ps-selected-pages nil))
6558 ;; Permit dynamic evaluation at print time of `ps-lpr-switches'.
6559 (defun ps-do-despool (filename)
6560 (if (or (not (boundp 'ps-spool-buffer))
6561 (not (symbol-value 'ps-spool-buffer)))
6562 (message "No spooled PostScript to print")
6563 (if filename
6564 (save-excursion
6565 (and ps-razzle-dazzle (message "Saving..."))
6566 (set-buffer ps-spool-buffer)
6567 (setq filename (expand-file-name filename))
6568 (let ((coding-system-for-write 'raw-text-unix))
6569 (write-region (point-min) (point-max) filename))
6570 (and ps-razzle-dazzle (message "Wrote %s" filename)))
6571 ;; Else, spool to the printer
6572 (and ps-razzle-dazzle (message "Printing..."))
6573 (with-current-buffer ps-spool-buffer
6574 (let* ((coding-system-for-write 'raw-text-unix)
6575 (ps-printer-name (or ps-printer-name
6576 (and (boundp 'printer-name)
6577 (symbol-value 'printer-name))))
6578 (ps-lpr-switches
6579 (append ps-lpr-switches
6580 (and (stringp ps-printer-name)
6581 (string< "" ps-printer-name)
6582 (list (concat
6583 (and (stringp ps-printer-name-option)
6584 ps-printer-name-option)
6585 ps-printer-name))))))
6586 (or (stringp ps-printer-name)
6587 (setq ps-printer-name nil))
6588 (apply (or ps-print-region-function 'call-process-region)
6589 (point-min) (point-max) ps-lpr-command nil
6590 (and (fboundp 'start-process) 0)
6592 (ps-flatten-list ; dynamic evaluation
6593 (ps-string-list
6594 (mapcar 'ps-eval-switch ps-lpr-switches))))))
6595 (and ps-razzle-dazzle (message "Printing...done")))
6596 (kill-buffer ps-spool-buffer)))
6598 (defun ps-string-list (arg)
6599 (let (lstr)
6600 (dolist (elm arg)
6601 (cond ((stringp elm)
6602 (setq lstr (cons elm lstr)))
6603 ((listp elm)
6604 (let ((s (ps-string-list elm)))
6605 (when s
6606 (setq lstr (cons s lstr)))))
6607 (t ))) ; ignore any other value
6608 (nreverse lstr)))
6610 ;; Dynamic evaluation
6611 (defun ps-eval-switch (arg)
6612 (cond ((stringp arg) arg)
6613 ((functionp arg) (apply arg nil))
6614 ((symbolp arg) (symbol-value arg))
6615 ((consp arg) (apply (car arg) (cdr arg)))
6616 (t nil)))
6618 ;; `ps-flatten-list' is defined here (copied from "message.el" and
6619 ;; enhanced to handle dotted pairs as well) until we can get some
6620 ;; sensible autoloads, or `flatten-list' gets put somewhere decent.
6622 ;; (ps-flatten-list '((a . b) c (d . e) (f g h) i . j))
6623 ;; => (a b c d e f g h i j)
6625 (defun ps-flatten-list (&rest list)
6626 (ps-flatten-list-1 list))
6628 (defun ps-flatten-list-1 (list)
6629 (cond ((null list) nil)
6630 ((consp list) (append (ps-flatten-list-1 (car list))
6631 (ps-flatten-list-1 (cdr list))))
6632 (t (list list))))
6634 (defun ps-kill-emacs-check ()
6635 (let (ps-buffer)
6636 (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
6637 (buffer-name ps-buffer) ; check if it's not killed
6638 (buffer-modified-p ps-buffer)
6639 (y-or-n-p "Unprinted PostScript waiting; print now? ")
6640 (ps-despool))
6641 (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
6642 (buffer-name ps-buffer) ; check if it's not killed
6643 (buffer-modified-p ps-buffer)
6644 (not (yes-or-no-p "Unprinted PostScript waiting; exit anyway? "))
6645 (error "Unprinted PostScript"))))
6647 (cond ((fboundp 'add-hook)
6648 (funcall 'add-hook 'kill-emacs-hook 'ps-kill-emacs-check))
6649 (kill-emacs-hook
6650 (message "Won't override existing `kill-emacs-hook'"))
6652 (setq kill-emacs-hook 'ps-kill-emacs-check)))
6655 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6656 ;; To make this file smaller, some commands go in a separate file.
6657 ;; But autoload them here to make the separation invisible.
6659 ;;;### (autoloads (ps-mule-end-job ps-mule-begin-job ps-mule-initialize
6660 ;;;;;; ps-multibyte-buffer) "ps-mule" "ps-mule.el" "d2fcad95db7404989362657faf744796")
6661 ;;; Generated autoloads from ps-mule.el
6663 (defvar ps-multibyte-buffer nil "\
6664 Specifies the multi-byte buffer handling.
6666 Valid values are:
6668 nil This is the value to use the default settings;
6669 by default, this only works to print buffers with
6670 only ASCII and Latin characters. But this default
6671 setting can be changed by setting the variable
6672 `ps-mule-font-info-database-default' differently.
6673 The initial value of this variable is
6674 `ps-mule-font-info-database-latin' (see
6675 documentation).
6677 `non-latin-printer' This is the value to use when you have a Japanese
6678 or Korean PostScript printer and want to print
6679 buffer with ASCII, Latin-1, Japanese (JISX0208 and
6680 JISX0201-Kana) and Korean characters. At present,
6681 it was not tested with the Korean characters
6682 printing. If you have a korean PostScript printer,
6683 please, test it.
6685 `bdf-font' This is the value to use when you want to print
6686 buffer with BDF fonts. BDF fonts include both latin
6687 and non-latin fonts. BDF (Bitmap Distribution
6688 Format) is a format used for distributing X's font
6689 source file. BDF fonts are included in
6690 `intlfonts-1.2' which is a collection of X11 fonts
6691 for all characters supported by Emacs. In order to
6692 use this value, be sure to have installed
6693 `intlfonts-1.2' and set the variable
6694 `bdf-directory-list' appropriately (see ps-bdf.el for
6695 documentation of this variable).
6697 `bdf-font-except-latin' This is like `bdf-font' except that it uses
6698 PostScript default fonts to print ASCII and Latin-1
6699 characters. This is convenient when you want or
6700 need to use both latin and non-latin characters on
6701 the same buffer. See `ps-font-family',
6702 `ps-header-font-family' and `ps-font-info-database'.
6704 Any other value is treated as nil.")
6706 (custom-autoload 'ps-multibyte-buffer "ps-mule" t)
6708 (autoload 'ps-mule-initialize "ps-mule" "\
6709 Initialize global data for printing multi-byte characters.
6711 \(fn)" nil nil)
6713 (autoload 'ps-mule-begin-job "ps-mule" "\
6714 Start printing job for multi-byte chars between FROM and TO.
6715 It checks if all multi-byte characters in the region are printable or not.
6717 \(fn FROM TO)" nil nil)
6719 (autoload 'ps-mule-end-job "ps-mule" "\
6720 Finish printing job for multi-byte chars.
6722 \(fn)" nil nil)
6724 ;;;***
6726 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6728 (provide 'ps-print)
6730 ;; arch-tag: fb06a585-1112-4206-885d-a57d95d50579
6731 ;;; ps-print.el ends here