ps-print.el 136 KB
Newer Older
1
;;; ps-print.el --- Print text from the buffer as PostScript
2

3
;; Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
4

5
;; Author:     Jim Thompson (was <thompson@wg2.waii.com>)
6
;; Author:     Jacques Duthen <duthen@cegelec-red.fr>
7
;; Author:     Vinicius Jose Latorre <vinicius@cpqd.com.br>
Karl Heuer's avatar
Karl Heuer committed
8
;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
9
;; Keywords:   print, PostScript
10 11
;; Time-stamp: <98/03/06 11:14:08 vinicius>
;; Version:    3.06
12

13 14
(defconst ps-print-version "3.06"
  "ps-print.el, v 3.06 <98/03/06 vinicius>
15

16
Vinicius's last change version -- this file may have been edited as part of
17 18 19 20 21
Emacs without changes to the version number.  When reporting bugs,
please also report the version of Emacs, if any, that ps-print was
distributed with.

Please send all bug fixes and enhancements to
Karl Heuer's avatar
Karl Heuer committed
22
	Vinicius Jose Latorre <vinicius@cpqd.com.br>.
23
")
Richard M. Stallman's avatar
Richard M. Stallman committed
24

Richard M. Stallman's avatar
Richard M. Stallman committed
25
;; This file is part of GNU Emacs.
Richard M. Stallman's avatar
Richard M. Stallman committed
26 27 28 29 30 31 32 33 34 35 36 37

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
Erik Naggum's avatar
Erik Naggum committed
38 39 40
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
Richard M. Stallman's avatar
Richard M. Stallman committed
41

42
;;; Commentary:
Richard M. Stallman's avatar
Richard M. Stallman committed
43 44 45

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
46
;; About ps-print
Richard M. Stallman's avatar
Richard M. Stallman committed
47
;; --------------
48
;;
Richard M. Stallman's avatar
Richard M. Stallman committed
49 50 51
;; This package provides printing of Emacs buffers on PostScript
;; printers; the buffer's bold and italic text attributes are
;; preserved in the printer output.  Ps-print is intended for use with
Richard M. Stallman's avatar
Richard M. Stallman committed
52 53
;; Emacs 19 or Lucid Emacs, together with a fontifying package such as
;; font-lock or hilit.
54
;;
55 56 57 58 59 60 61 62 63
;; ps-print uses the same face attributes defined through font-lock or hilit
;; to print a PostScript file, but some faces are better seeing on the screen
;; than on paper, specially when you have a black/white PostScript printer.
;;
;; ps-print allows a remap of face to another one that it is better to print,
;; for example, the face font-lock-comment-face (if you are using font-lock)
;; could have bold or italic attribute when printing, besides foreground color.
;; This remap improves printing look (see How Ps-Print Maps Faces).
;;
64
;;
65
;; Using ps-print
Richard M. Stallman's avatar
Richard M. Stallman committed
66 67
;; --------------
;;
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
;; The Commands
;;
;; Ps-print provides eight commands for generating PostScript images
;; of Emacs buffers:
;;
;;        ps-print-buffer
;;        ps-print-buffer-with-faces
;;        ps-print-region
;;        ps-print-region-with-faces
;;        ps-spool-buffer
;;        ps-spool-buffer-with-faces
;;        ps-spool-region
;;        ps-spool-region-with-faces
;;
;; These commands all perform essentially the same function: they
;; generate PostScript images suitable for printing on a PostScript
;; printer or displaying with GhostScript.  These commands are
;; collectively referred to as "ps-print- commands".
;;
;; The word "print" or "spool" in the command name determines when the
;; PostScript image is sent to the printer:
Richard M. Stallman's avatar
Richard M. Stallman committed
89
;;
90 91
;;        print      - The PostScript image is immediately sent to the
;;                     printer;
Richard M. Stallman's avatar
Richard M. Stallman committed
92
;;
93 94 95
;;        spool      - The PostScript image is saved temporarily in an
;;                     Emacs buffer.  Many images may be spooled locally
;;                     before printing them.  To send the spooled images
96
;;                     to the printer, use the command `ps-despool'.
Richard M. Stallman's avatar
Richard M. Stallman committed
97
;;
98 99 100 101 102
;; The spooling mechanism was designed for printing lots of small
;; files (mail messages or netnews articles) to save paper that would
;; otherwise be wasted on banner pages, and to make it easier to find
;; your output at the printer (it's easier to pick up one 50-page
;; printout than to find 50 single-page printouts).
103
;;
Karl Heuer's avatar
Karl Heuer committed
104
;; Ps-print has a hook in the `kill-emacs-hook' so that you won't
Karl Heuer's avatar
Karl Heuer committed
105
;; accidentally quit from Emacs while you have unprinted PostScript
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
;; waiting in the spool buffer.  If you do attempt to exit with
;; spooled PostScript, you'll be asked if you want to print it, and if
;; you decline, you'll be asked to confirm the exit; this is modeled
;; on the confirmation that Emacs uses for modified buffers.
;;
;; The word "buffer" or "region" in the command name determines how
;; much of the buffer is printed:
;;
;;        buffer     - Print the entire buffer.
;;
;;        region     - Print just the current region.
;;
;; The -with-faces suffix on the command name means that the command
;; will include font, color, and underline information in the
;; PostScript image, so the printed image can look as pretty as the
;; buffer.  The ps-print- commands without the -with-faces suffix
;; don't include font, color, or underline information; images printed
;; with these commands aren't as pretty, but are faster to generate.
;;
;; Two ps-print- command examples:
;;
;;        ps-print-buffer             - print the entire buffer,
;;                                      without font, color, or
;;                                      underline information, and
;;                                      send it immediately to the
;;                                      printer.
;;
;;        ps-spool-region-with-faces  - print just the current region;
;;                                      include font, color, and
;;                                      underline information, and
;;                                      spool the image in Emacs to
;;                                      send to the printer later.
;;
;;
;; Invoking Ps-Print
141
;; -----------------
Richard M. Stallman's avatar
Richard M. Stallman committed
142
;;
143
;; To print your buffer, type
Richard M. Stallman's avatar
Richard M. Stallman committed
144
;;
145
;;        M-x ps-print-buffer
Richard M. Stallman's avatar
Richard M. Stallman committed
146
;;
147 148 149 150 151 152 153 154 155 156
;; or substitute one of the other seven ps-print- commands.  The
;; command will generate the PostScript image and print or spool it as
;; specified.  By giving the command a prefix argument
;;
;;        C-u M-x ps-print-buffer
;;
;; it will save the PostScript image to a file instead of sending it
;; to the printer; you will be prompted for the name of the file to
;; save the image to.  The prefix argument is ignored by the commands
;; that spool their images, but you may save the spooled images to a
157
;; file by giving a prefix argument to `ps-despool':
158 159 160
;;
;;        C-u M-x ps-despool
;;
161
;; When invoked this way, `ps-despool' will prompt you for the name of
162 163
;; the file to save to.
;;
164 165 166
;; Any of the `ps-print-' commands can be bound to keys; I recommend
;; binding `ps-spool-buffer-with-faces', `ps-spool-region-with-faces',
;; and `ps-despool'.  Here are the bindings I use on my Sun 4 keyboard:
167 168
;;
;;   (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc
Richard M. Stallman's avatar
Richard M. Stallman committed
169 170 171
;;   (global-set-key '(shift f22) 'ps-spool-region-with-faces)
;;   (global-set-key '(control f22) 'ps-despool)
;;
172 173
;;
;; The Printer Interface
174
;; ---------------------
175
;;
176
;; The variables `ps-lpr-command' and `ps-lpr-switches' determine what
177
;; command is used to send the PostScript images to the printer, and
178 179
;; what arguments to give the command.  These are analogous to
;; `lpr-command' and `lpr-switches'.
180
;;
181 182 183 184 185 186 187
;; Make sure that they contain appropriate values for your system;
;; see the usage notes below and the documentation of these variables.
;;
;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values
;;       from the variables `lpr-command' and `lpr-switches'.  If you have
;;       `lpr-command' set to invoke a pretty-printer such as `enscript',
;;       then ps-print won't work properly.  `ps-lpr-command' must name
188 189 190
;;       a program that does not format the files it prints.
;;
;;
191 192
;; The Page Layout
;; ---------------
193
;;
194 195 196
;; All dimensions are floats in PostScript points.
;; 1 inch  ==       2.54  cm    ==     72       points
;; 1 cm    ==  (/ 1 2.54) inch  ==  (/ 72 2.54) points
197
;;
198 199 200 201
;; The variable `ps-paper-type' determines the size of paper ps-print
;; formats for; it should contain one of the symbols:
;; `a4' `a3' `letter' `legal' `letter-small' `tabloid'
;; `ledger' `statement' `executive' `a4small' `b4' `b5'
202
;;
203 204 205 206
;; The variable `ps-landscape-mode' determines the orientation
;; of the printing on the page:
;; nil means `portrait' mode, non-nil means `landscape' mode.
;; There is no oblique mode yet, though this is easy to do in ps.
207
;;
208 209 210 211 212
;; In landscape mode, the text is NOT scaled: you may print 70 lines
;; in portrait mode and only 50 lignes in landscape mode.
;; The margins represent margins in the printed paper:
;; the top margin is the margin between the top of the page
;; and the printed header, whatever the orientation is.
213
;;
214 215 216 217 218 219 220 221
;; The variable `ps-number-of-columns' determines the number of columns
;; both in landscape and portrait mode.
;; You can use:
;; - (the standard) one column portrait mode
;; - (my favorite) two columns landscape mode (which spares trees)
;; but also
;; - one column landscape mode for files with very long lines.
;; - multi-column portrait or landscape mode
222 223
;;
;;
224 225
;; Horizontal layout
;; -----------------
226
;;
227 228 229
;; The horizontal layout is determined by the variables
;; `ps-left-margin' `ps-inter-column' `ps-right-margin'
;; as follows:
230
;;
231 232 233 234 235
;;  ------------------------------------------
;;  |    |      |    |      |    |      |    |
;;  | lm | text | ic | text | ic | text | rm |
;;  |    |      |    |      |    |      |    |
;;  ------------------------------------------
236
;;
237 238 239
;; If `ps-number-of-columns' is 1, `ps-inter-column' is not relevant.
;; Usually, lm = rm > 0 and ic = lm
;; If (ic < 0), the text of adjacent columns can overlap.
240 241
;;
;;
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
;; Vertical layout
;; ---------------
;;
;; The vertical layout is determined by the variables
;; `ps-bottom-margin' `ps-top-margin' `ps-header-offset'
;; as follows:
;;
;; |--------|        |--------|
;; | tm     |        | tm     |
;; |--------|        |--------|
;; | header |        |        |
;; |--------|        |        |
;; | ho     |        |        |
;; |--------|   or   | text   |
;; |        |        |        |
;; | text   |        |        |
;; |        |        |        |
;; |--------|        |--------|
;; | bm     |        | bm     |
;; |--------|        |--------|
;;
;; If `ps-print-header' is nil, `ps-header-offset' is not relevant.
;; The margins represent margins in the printed paper:
;; the top margin is the margin between the top of the page
;; and the printed header, whatever the orientation is.
267 268 269
;;
;;
;; Headers
270
;; -------
271
;;
272 273 274 275 276
;; Ps-print can print headers at the top of each column or at the top
;; of each page; the default headers contain the following four items:
;; on the left, the name of the buffer and, if the buffer is visiting
;; a file, the file's directory; on the right, the page number and
;; date of printing.  The default headers look something like this:
277 278 279
;;
;;     ps-print.el                                         1/21
;;     /home/jct/emacs-lisp/ps/new                     94/12/31
280
;;
281
;; When printing on duplex printers, left and right are reversed so
282
;; that the page numbers are toward the outside (cf. `ps-spool-duplex').
283
;;
284 285 286 287 288
;; Headers are configurable:
;; To turn them off completely, set `ps-print-header' to nil.
;; To turn off the header's gaudy framing box,
;; set `ps-print-header-frame' to nil.
;;
289 290 291
;; To print only one header at the top of each page,
;; set `ps-print-only-one-header' to t.
;;
292
;; The font family and size of text in the header are determined
293
;; by the variables `ps-header-font-family', `ps-header-font-size' and
294 295 296 297 298 299 300 301 302 303
;; `ps-header-title-font-size' (see below).
;;
;; The variable `ps-header-line-pad' determines the portion of a header
;; title line height to insert between the header frame and the text
;; it contains, both in the vertical and horizontal directions:
;; .5 means half a line.

;; Page numbers are printed in `n/m' format, indicating page n of m pages;
;; to omit the total page count and just print the page number,
;; set `ps-show-n-of-n' to nil.
304 305
;;
;; The amount of information in the header can be changed by changing
306
;; the number of lines.  To show less, set `ps-header-lines' to 1, and
307
;; the header will show only the buffer name and page number.  To show
308
;; more, set `ps-header-lines' to 3, and the header will show the time of
309 310 311
;; printing below the date.
;;
;; To change the content of the headers, change the variables
312 313 314 315 316 317
;; `ps-left-header' and `ps-right-header'.
;; These variables are lists, specifying top-to-bottom the text
;; to display on the left or right side of the header.
;; Each element of the list should be a string or a symbol.
;; Strings are inserted directly into the PostScript arrays,
;; and should contain the PostScript string delimiters '(' and ')'.
318 319 320 321 322
;;
;; Symbols in the header format lists can either represent functions
;; or variables.  Functions are called, and should return a string to
;; show in the header.  Variables should contain strings to display in
;; the header.  In either case, function or variable, the PostScript
Karl Heuer's avatar
Karl Heuer committed
323
;; string delimiters are added by ps-print, and should not be part of
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
;; the returned value.
;;
;; Here's an example: say we want the left header to display the text
;;
;;     Moe
;;     Larry
;;     Curly
;;
;; where we have a function to return "Moe"
;;
;;     (defun moe-func ()
;;       "Moe")
;;
;; a variable specifying "Larry"
;;
;;     (setq larry-var "Larry")
;;
341
;; and a literal for "Curly".  Here's how `ps-left-header' should be
342 343 344 345 346
;; set:
;;
;;     (setq ps-left-header (list 'moe-func 'larry-var "(Curly)"))
;;
;; Note that Curly has the PostScript string delimiters inside his
347
;; quotes -- those aren't misplaced lisp delimiters!
348
;;
349 350
;; Without them, PostScript would attempt to call the undefined
;; function Curly, which would result in a PostScript error.
351
;;
352 353
;; Since most printers don't report PostScript errors except by
;; aborting the print job, this kind of error can be hard to track down.
354
;;
355
;; Consider yourself warned!
356 357 358
;;
;;
;; Duplex Printers
359
;; ---------------
360 361
;;
;; If you have a duplex-capable printer (one that prints both sides of
362 363 364 365 366 367
;; the paper), set `ps-spool-duplex' to t.
;; Ps-print will insert blank pages to make sure each buffer starts
;; on the correct side of the paper.
;; Don't forget to set `ps-lpr-switches' to select duplex printing
;; for your printer.
;;
368
;;
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
;; Control And 8-bit Characters
;; ----------------------------
;;
;; The variable `ps-print-control-characters' specifies whether you want to see
;; a printable form for control and 8-bit characters, that is, instead of
;; sending, for example, a ^D (\005) to printer, it is sent the string "^D".
;;
;; Valid values for `ps-print-control-characters' are:
;;
;;  '8-bit          printable form for control and 8-bit characters
;;                  (characters from \000 to \037 and \177 to \377).
;;  'control-8-bit  printable form for control and *control* 8-bit characters
;;		    (characters from \000 to \037 and \177 to \237).
;;  'control        printable form for control character
;;		    (characters from \000 to \037 and \177).
;;  nil             raw character (no printable form).
;;
;; Any other value is treated as nil.
;;
;; The default is 'control-8-bit.
;;
;; Characters TAB, NEWLINE and FORMFEED are always treated by ps-print engine.
;;
;;
393 394 395
;; Line Number
;; -----------
;;
396 397
;; The variable `ps-line-number' specifies whether to number each line;
;; non-nil means do so.  The default is nil (don't number each line).
398 399 400 401 402
;;
;;
;; Zebra Stripes
;; -------------
;;
403 404
;; Zebra stripes are a kind of background that appear "underneath" the text
;; and can make the text easier to read.  They look like this:
405 406 407
;;
;; XXXXXXXXXXXXXXXXXXXXXXXX
;; XXXXXXXXXXXXXXXXXXXXXXXX
408 409
;; XXXXXXXXXXXXXXXXXXXXXXXX
;;
410 411 412 413
;;
;;
;; XXXXXXXXXXXXXXXXXXXXXXXX
;; XXXXXXXXXXXXXXXXXXXXXXXX
414
;; XXXXXXXXXXXXXXXXXXXXXXXX
415
;;
416
;; The blocks of X's represent rectangles filled with a light gray color.
417 418 419
;; Each rectangle extends all the way across the page.
;;
;; The height, in lines, of each rectangle is controlled by
420 421
;; the variable `ps-zebra-stripe-height', which is 3 by default.
;; The distance between stripes equals the height of a stripe.
Karl Heuer's avatar
Karl Heuer committed
422
;;
423
;; The variable `ps-zebra-stripes' controls whether to print zebra stripes.
424 425 426
;; Non-nil means yes, nil means no.  The default is nil.
;;
;; See also section How Ps-Print Has A Text And/Or Image On Background.
427 428
;;
;;
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
;; Hooks
;; -----
;;
;; Ps-print has the following hook variables:
;;
;; `ps-print-hook'
;;    It is evaluated once before any printing process.  This is the right
;;    place to initialize ps-print global data.
;;    For an example, see section Adding a New Font Family.
;;
;; `ps-print-begin-page-hook'
;;    It is evaluated on each real beginning of page, that is, ps-print
;;    considers each beginning of column as a beginning of page, and a real
;;    beginning of page is when the beginning of column coincides with a
;;    paper change on your printer.
;;
;; `ps-print-begin-column-hook'
;;    It is evaluated on each beginning of column, except in the beginning
;;    of column that `ps-print-begin-page-hook' is evaluated.
;;
;;
;; Font Managing
451 452 453 454 455 456 457 458 459
;; -------------
;;
;; Ps-print now knows rather precisely some fonts:
;; the variable `ps-font-info-database' contains information
;; for a list of font families (currently mainly `Courier' `Helvetica'
;; `Times' `Palatino' `Helvetica-Narrow' `NewCenturySchlbk').
;; Each font family contains the font names for standard, bold, italic
;; and bold-italic characters, a reference size (usually 10) and the
;; corresponding line height, width of a space and average character width.
460
;;
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
;; The variable `ps-font-family' determines which font family
;; is to be used for ordinary text.
;; If its value does not correspond to a known font family,
;; an error message is printed into the `*Messages*' buffer,
;; which lists the currently available font families.
;;
;; The variable `ps-font-size' determines the size (in points)
;; of the font for ordinary text, when generating Postscript.
;; Its value is a float.
;;
;; Similarly, the variable `ps-header-font-family' determines
;; which font family is to be used for text in the header.
;; The variable `ps-header-font-size' determines the font size,
;; in points, for text in the header.
;; The variable `ps-header-title-font-size' determines the font size,
;; in points, for the top line of text in the header.
;;
;;
479
;; Adding a New Font Family
480 481 482
;; ------------------------
;;
;; To use a new font family, you MUST first teach ps-print
483
;; this font, i.e., add its information to `ps-font-info-database',
484 485
;; otherwise ps-print cannot correctly place line and page breaks.
;;
486
;; For example, assuming `Helvetica' is unknown,
487 488 489 490 491 492
;; you first need to do the following ONLY ONCE:
;;
;; - create a new buffer
;; - generate the PostScript image to a file (C-u M-x ps-print-buffer)
;; - open this file and find the line:
;;	`% 3 cm 20 cm moveto  10 /Courier ReportFontInfo  showpage'
493
;; - delete the leading `%' (which is the PostScript comment character)
494 495 496 497 498 499 500 501 502 503 504
;; - replace in this line `Courier' by the new font (say `Helvetica')
;;   to get the line:
;;	`3 cm 20 cm moveto  10 /Helvetica ReportFontInfo  showpage'
;; - send this file to the printer (or to ghostscript).
;;   You should read the following on the output page:
;;
;;     For Helvetica 10 point, the line height is 11.56, the space width is 2.78
;;     and a crude estimate of average character width is 5.09243
;;
;; - Add these values to the `ps-font-info-database':
;;   (setq ps-font-info-database
505 506 507 508 509 510 511 512 513 514 515
;;	   (append
;;	    '((Helvetica			; the family key
;;	       (fonts (normal      . "Helvetica")
;;		      (bold        . "Helvetica-Bold")
;;		      (italic      . "Helvetica-Oblique")
;;		      (bold-italic . "Helvetica-BoldOblique"))
;;	       (size . 10.0)
;;	       (line-height . 11.56)
;;	       (space-width . 2.78)
;;	       (avg-char-width . 5.09243)))
;;	    ps-font-info-database))
516 517 518 519 520 521 522 523
;; - Now you can use this font family with any size:
;;	(setq ps-font-family 'Helvetica)
;; - if you want to use this family in another emacs session, you must
;;   put into your `~/.emacs':
;;	(require 'ps-print)
;;	(setq ps-font-info-database (append ...)))
;;   if you don't want to load ps-print, you have to copy the whole value:
;;	(setq ps-font-info-database '(<your stuff> <the standard stuff>))
524 525 526
;;   or, use `ps-print-hook' (see section Hooks):
;;	(add-hook 'ps-print-hook
;;		  '(lambda () (setq ps-font-info-database (append ...))))
527 528
;;
;; You can create new `mixed' font families like:
529 530 531 532 533 534 535 536 537 538
;;      (my-mixed-family
;;       (fonts (normal               . "Courier-Bold")
;;              (bold                 . "Helvetica")
;;              (italic               . "Zapf-Chancery-MediumItalic")
;;              (bold-italic          . "NewCenturySchlbk-BoldItalic")
;;              (w3-table-hack-x-face . "LineDrawNormal"))
;;       (size . 10.0)
;;       (line-height . 10.55)
;;       (space-width . 6.0)
;;       (avg-char-width . 6.0))
539 540 541
;; Now you can use your new font family with any size:
;;	(setq ps-font-family 'my-mixed-family)
;;
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
;; Note that on above example the `w3-table-hack-x-face' entry refers to
;; a face symbol, so when printing this face it'll be used the font
;; `LineDrawNormal'.  If the face  `w3-table-hack-x-face'  is remapped to
;; use bold and/or italic attribute, the corresponding entry (bold, italic
;; or bold-italic) will be used instead of `w3-table-hack-x-face' entry.
;;
;; Note also that the font family entry order is irrelevant, so the above
;; example could also be written:
;;      (my-mixed-family
;;       (size . 10.0)
;;       (fonts (w3-table-hack-x-face . "LineDrawNormal")
;;              (bold                 . "Helvetica")
;;              (bold-italic          . "NewCenturySchlbk-BoldItalic")
;;              (italic               . "Zapf-Chancery-MediumItalic")
;;              (normal               . "Courier-Bold"))
;;       (avg-char-width . 6.0)
;;       (space-width . 6.0)
;;       (line-height . 10.55))
;;
;; Despite the note above, it is recommended that some convention about
;; entry order be used.
;;
564 565 566 567
;; You can get information on all the fonts resident in YOUR printer
;; by uncommenting the line:
;;	% 3 cm 20 cm moveto  ReportAllFontInfo           showpage
;;
568 569
;; The PostScript file should be sent to YOUR PostScript printer.
;; If you send it to ghostscript or to another PostScript printer,
570 571 572 573 574 575 576
;; you may get slightly different results.
;; Anyway, as ghostscript fonts are autoload, you won't get
;; much font info.
;;
;;
;; How Ps-Print Deals With Faces
;; -----------------------------
577
;;
578 579 580 581
;; The ps-print-*-with-faces commands attempt to determine which faces
;; should be printed in bold or italic, but their guesses aren't
;; always right.  For example, you might want to map colors into faces
;; so that blue faces print in bold, and red faces in italic.
582
;;
583 584 585 586 587 588
;; It is possible to force ps-print to consider specific faces bold,
;; italic or underline, no matter what font they are displayed in, by setting
;; the variables `ps-bold-faces', `ps-italic-faces' and `ps-underlined-faces'.
;; These variables contain lists of faces that ps-print should consider bold,
;; italic or underline; to set them, put code like the following into your
;; .emacs file:
589
;;
590
;;      (setq ps-bold-faces '(my-blue-face))
591
;;      (setq ps-italic-faces '(my-red-face))
592
;;      (setq ps-underlined-faces '(my-green-face))
593 594 595 596 597 598 599 600 601 602 603 604 605
;;
;; Faces like bold-italic that are both bold and italic should go in
;; *both* lists.
;;
;; Ps-print keeps internal lists of which fonts are bold and which are
;; italic; these lists are built the first time you invoke ps-print.
;; For the sake of efficiency, the lists are built only once; the same
;; lists are referred in later invocations of ps-print.
;;
;; Because these lists are built only once, it's possible for them to
;; get out of sync, if a face changes, or if new faces are added.  To
;; get the lists back in sync, you can set the variable
;; `ps-build-face-reference' to t, and the lists will be rebuilt the
606 607 608
;; next time ps-print is invoked.  If you need that the lists always be
;; rebuilt when ps-print is invoked, set the variable
;; `ps-always-build-face-reference' to t.
609 610 611 612 613 614 615 616 617 618 619 620 621
;;
;;
;; How Ps-Print Deals With Color
;; -----------------------------
;;
;; Ps-print detects faces with foreground and background colors
;; defined and embeds color information in the PostScript image.
;; The default foreground and background colors are defined by the
;; variables `ps-default-fg' and `ps-default-bg'.
;; On black-and-white printers, colors are displayed in grayscale.
;; To turn off color output, set `ps-print-color-p' to nil.
;;
;;
622 623 624 625 626 627 628 629 630 631 632
;; How Ps-Print Maps Faces
;; -----------------------
;;
;; As ps-print uses PostScript to print buffers, it is possible to have
;; other attributes associated with faces. So the new attributes used
;; by ps-print are:
;;
;;   strikeout - like underline, but the line is in middle of text.
;;   overline  - like underline, but the line is over the text.
;;   shadow    - text will have a shadow.
;;   box       - text will be surrounded by a box.
633
;;   outline   - print characters as hollow outlines.
634
;;
635
;; See the documentation for `ps-extend-face'.
636 637 638 639
;;
;; Let's, for example, remap font-lock-keyword-face to another foreground color
;; and bold attribute:
;;
640
;;    (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE)
641
;;
642 643 644
;; If you want to use a new face, define it first with `defface',
;; and then call `ps-extend-face' to specify how to print it.
;;
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
;;
;; How Ps-Print Has A Text And/Or Image On Background
;; --------------------------------------------------
;;
;; Ps-print can print texts and/or EPS PostScript images on background; it is
;; possible to define the following text attributes: font name, font size,
;; initial position, angle, gray scale and pages to print.
;;
;; It has the following EPS PostScript images attributes: file name containing
;; the image, initial position, X and Y scales, angle and pages to print.
;;
;; See documentation for `ps-print-background-text' and
;; `ps-print-background-image'.
;;
;; For example, if we wish to print text "preliminary" on all pages and text
;; "special" on page 5 and from page 11 to page 17, we could specify:
;;
;; (setq ps-print-background-text
;;       '(("preliminary")
;;         ("special"
;;          "LeftMargin" "BottomMargin PrintHeight add" ; X and Y position
;;                                      ; (upper left corner)
;;          nil nil nil
668
;;          "PrintHeight neg PrintPageWidth atan" ; angle
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
;;          5 (11 . 17))                ; page list
;;         ))
;;
;; Similarly, we could print image "~/images/EPS-image1.ps" on all pages and
;; image "~/images/EPS-image2.ps" on page 5 and from page 11 to page 17, we
;; specify:
;;
;; (setq ps-print-background-image
;;       '(("~/images/EPS-image1.ps"
;;          "LeftMargin" "BottomMargin") ; X and Y position (lower left corner)
;;         ("~/images/EPS-image2.ps"
;;          "LeftMargin" "BottomMargin PrintHeight 2 div add" ; X and Y position
;;                                      ; (upper left corner)
;;          nil nil nil
;;          5 (11 . 17))                ; page list
;;         ))
;;
;; If it is not possible to read (or does not exist) an image file, that file
;; is ignored.
;;
;; The printing order is:
;;
;;    1. Print zebra stripes
;;    2. Print background texts that it should be on all pages
;;    3. Print background images that it should be on all pages
;;    4. Print background texts only for current page (if any)
;;    5. Print background images only for current page (if any)
;;    6. Print header
697
;;    7. Print buffer text (with faces, if specified) and line number
698 699
;;
;;
700 701 702 703 704 705 706 707 708 709 710
;; Utilities
;; ---------
;;
;; Some tools are provided to help you customize your font setup.
;;
;; `ps-setup' returns (some part of) the current setup.
;;
;; To avoid wrapping too many lines, you may want to adjust the
;; left and right margins and the font size.  On UN*X systems, do:
;; pr -t file | awk '{printf "%3d %s\n", length($0), $0}' | sort -r | head
;; to determine the longest lines of your file.
711
;; Then, the command `ps-line-lengths' will give you the correspondence
712 713 714 715
;; between a line length (number of characters) and the maximum font
;; size which doesn't wrap such a line with the current ps-print setup.
;;
;; The commands `ps-nb-pages-buffer' and `ps-nb-pages-region' display
716
;; the correspondence between a number of pages and the maximum font
717 718
;; size which allow the number of lines of the current buffer or of
;; its current region to fit in this number of pages.
719 720 721
;;
;; NOTE: line folding is not taken into account in this process and could
;;       change the results.
722 723 724 725 726
;;
;;
;; New since version 1.5
;; ---------------------
;;
727
;; Color output capability.
728 729 730 731 732 733
;; Automatic detection of font attributes (bold, italic).
;; Configurable headers with page numbers.
;; Slightly faster.
;; Support for different paper sizes.
;; Better conformance to PostScript Document Structure Conventions.
;;
Richard M. Stallman's avatar
Richard M. Stallman committed
734
;;
735 736 737
;; New since version 2.8
;; ---------------------
;;
738 739 740 741 742 743 744 745 746 747 748 749
;; [vinicius] 980306 Vinicius Jose Latorre <vinicius@cpqd.com.br>
;;
;; Skip invisible text
;;
;; [vinicius] 971130 Vinicius Jose Latorre <vinicius@cpqd.com.br>
;;
;; Hooks: `ps-print-hook', `ps-print-begin-page-hook' and
;; `ps-print-begin-column-hook'.
;; Put one header per page over the columns.
;; Better database font management.
;; Better control characters handling.
;;
750
;; [vinicius] 971121 Vinicius Jose Latorre <vinicius@cpqd.com.br>
751
;;
752
;; Dynamic evaluation at print time of `ps-lpr-switches'.
753 754 755 756 757 758 759
;; Handle control characters.
;; Face remapping.
;; New face attributes.
;; Line number.
;; Zebra stripes.
;; Text and/or image on background.
;;
760 761
;; [jack] 960517 Jacques Duthen <duthen@cegelec-red.fr>
;;
762
;; Font family and float size for text and header.
763 764 765 766 767
;; Landscape mode.
;; Multiple columns.
;; Tools for page setup.
;;
;;
Richard M. Stallman's avatar
Richard M. Stallman committed
768 769
;; Known bugs and limitations of ps-print:
;; --------------------------------------
770
;;
771 772 773 774 775 776
;; Although color printing will work in XEmacs 19.12, it doesn't work
;; well; in particular, bold or italic fonts don't print in the right
;; background color.
;;
;; Invisible properties aren't correctly ignored in XEmacs 19.12.
;;
777
;; Automatic font-attribute detection doesn't work well, especially
Richard M. Stallman's avatar
Richard M. Stallman committed
778
;; with hilit19 and older versions of get-create-face.  Users having
779
;; problems with auto-font detection should use the lists
780 781
;; `ps-italic-faces', `ps-bold-faces' and `ps-underlined-faces' and/or
;; turn off automatic detection by setting `ps-auto-font-detect' to nil.
Richard M. Stallman's avatar
Richard M. Stallman committed
782
;;
783
;; Automatic font-attribute detection doesn't work with XEmacs 19.12
784 785
;; in tty mode; use the lists `ps-italic-faces', `ps-bold-faces' and
;; `ps-underlined-faces' instead.
786
;;
Richard M. Stallman's avatar
Richard M. Stallman committed
787
;; Still too slow; could use some hand-optimization.
Richard M. Stallman's avatar
Richard M. Stallman committed
788
;;
789
;; Default background color isn't working.
Richard M. Stallman's avatar
Richard M. Stallman committed
790 791 792
;;
;; Faces are always treated as opaque.
;;
793
;; Epoch and Emacs 18 not supported.  At all.
Richard M. Stallman's avatar
Richard M. Stallman committed
794
;;
795
;; Fixed-pitch fonts work better for line folding, but are not required.
796 797 798
;;
;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care
;; of folding lines.
Richard M. Stallman's avatar
Richard M. Stallman committed
799
;;
800
;;
801 802
;; Things to change:
;; ----------------
Richard M. Stallman's avatar
Richard M. Stallman committed
803
;;
804
;; Avoid page break inside a paragraph.
805 806 807 808
;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy).
;; Improve the memory management for big files (hard?).
;; `ps-nb-pages-buffer' and `ps-nb-pages-region' should take care
;; of folding lines.
Richard M. Stallman's avatar
Richard M. Stallman committed
809 810
;;
;;
811 812
;; Acknowledgements
;; ----------------
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
;;
;; Thanks to Marcus G Daniels <marcus@cathcart.sysc.pdx.edu> for a better
;; database font management.
;;
;; Thanks to Martin Boyer <gamin@videotron.ca> for some ideas on putting one
;; header per page over the columns.
;;
;; Thanks to Steven L Baur <steve@miranova.com> for dynamic evaluation at
;; print time of `ps-lpr-switches'.
;;
;; Thanks to some suggestions on:
;;  * Face color map: Marco Melgazzi <marco@techie.com>
;;  * XEmacs compatibility: William J. Henney <will@astrosmo.unam.mx>
;;  * Check ps-paper-type: Sudhakar Frederick <sfrederi@asc.corp.mot.com>
;;
828 829 830
;; Thanks to Jacques Duthen <duthen@cegelec-red.fr> (Jack) for the 3.4 version
;; I started from. [vinicius]
;;
831 832 833
;; Thanks to Jim Thompson <?@?> for the 2.8 version I started from.
;; [jack]
;;
834 835
;; Thanks to Kevin Rodgers <kevinr@ihs.com> for adding support for
;; color and the invisible property.
Richard M. Stallman's avatar
Richard M. Stallman committed
836
;;
837 838 839
;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing
;; the initial port to Emacs 19.  His code is no longer part of
;; ps-print, but his work is still appreciated.
Richard M. Stallman's avatar
Richard M. Stallman committed
840
;;
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
;; Thanks to Remi Houdaille and Michel Train, michel@metasoft.fdn.org,
;; for adding underline support.  Their code also is no longer part of
;; ps-print, but their efforts are not forgotten.
;;
;; Thanks also to all of you who mailed code to add features to
;; ps-print; although I didn't use your code, I still appreciate your
;; sharing it with me.
;;
;; Thanks to all who mailed comments, encouragement, and criticism.
;; Thanks also to all who responded to my survey; I had too many
;; responses to reply to them all, but I greatly appreciate your
;; interest.
;;
;; Jim
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Richard M. Stallman's avatar
Richard M. Stallman committed
856 857 858

;;; Code:

859 860
(eval-when-compile
  (require 'cl))
861

862 863
(unless (featurep 'lisp-float-type)
  (error "`ps-print' requires floating point support"))
Richard M. Stallman's avatar
Richard M. Stallman committed
864 865

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
866 867
;; User Variables:

868 869
;;; Interface to the command system

870
(defgroup ps-print nil
Karl Heuer's avatar
Karl Heuer committed
871
  "PostScript generator for Emacs 19"
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
  :prefix "ps-"
  :group 'wp)

(defgroup ps-print-horizontal nil
  "Horizontal page layout"
  :prefix "ps-"
  :tag "Horizontal"
  :group 'ps-print)

(defgroup ps-print-vertical nil
  "Vertical page layout"
  :prefix "ps-"
  :tag "Vertical"
  :group 'ps-print)

(defgroup ps-print-header nil
  "Headers layout"
  :prefix "ps-"
  :tag "Header"
  :group 'ps-print)

(defgroup ps-print-font nil
  "Fonts customization"
  :prefix "ps-"
  :tag "Font"
  :group 'ps-print)

(defgroup ps-print-color nil
  "Color customization"
  :prefix "ps-"
  :tag "Color"
  :group 'ps-print)

(defgroup ps-print-face nil
  "Faces customization"
  :prefix "ps-"
  :tag "PS Faces"
  :group 'ps-print
  :group 'faces)


(defcustom ps-lpr-command lpr-command
  "*The shell command for printing a PostScript file."
  :type 'string
  :group 'ps-print)

(defcustom ps-lpr-switches lpr-switches
  "*A list of extra switches to pass to `ps-lpr-command'."
  :type '(repeat string)
  :group 'ps-print)
922

923
;;; Page layout
924

925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
;; All page dimensions are in PostScript points.
;; 1 inch  ==       2.54  cm    ==     72       points
;; 1 cm    ==  (/ 1 2.54) inch  ==  (/ 72 2.54) points

;; Letter      8.5   inch x 11.0   inch
;; Legal       8.5   inch x 14.0   inch
;; A4          8.26  inch x 11.69  inch = 21.0 cm x 29.7 cm

;; LetterSmall 7.68  inch x 10.16  inch
;; Tabloid    11.0   inch x 17.0   inch
;; Ledger     17.0   inch x 11.0   inch
;; Statement   5.5   inch x  8.5   inch
;; Executive   7.5   inch x 10.0   inch
;; A3         11.69  inch x 16.5   inch = 29.7 cm x 42.0 cm
;; A4Small     7.47  inch x 10.85  inch
;; B4         10.125 inch x 14.33  inch
;; B5          7.16  inch x 10.125 inch

943
(defcustom ps-page-dimensions-database
944 945 946 947 948 949 950 951 952 953 954 955 956
  (list (list 'a4    (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54))
	(list 'a3    (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54))
	(list 'letter       (* 72  8.5)   (* 72 11.0))
	(list 'legal        (* 72  8.5)   (* 72 14.0))
	(list 'letter-small (* 72  7.68)  (* 72 10.16))
	(list 'tabloid      (* 72 11.0)   (* 72 17.0))
	(list 'ledger       (* 72 17.0)   (* 72 11.0))
	(list 'statement    (* 72  5.5)   (* 72  8.5))
	(list 'executive    (* 72  7.5)   (* 72 10.0))
	(list 'a4small      (* 72  7.47)  (* 72 10.85))
	(list 'b4           (* 72 10.125) (* 72 14.33))
	(list 'b5           (* 72  7.16)  (* 72 10.125)))
  "*List associating a symbolic paper type to its width and height.
957 958 959 960 961 962 963
see `ps-paper-type'."
  :type '(repeat (list :tag "Paper Type"
		       (symbol :tag "Name")
		       (number :tag "Width")
		       (number :tag "Height")))
  :group 'ps-print)

964
;;;###autoload
965
(defcustom ps-paper-type 'letter
966
  "*Specifies the size of paper to format for.
967
Should be one of the paper types defined in `ps-page-dimensions-database', for
968 969
example `letter', `legal' or `a4'."
  :type '(symbol :validate (lambda (wid)
970 971
			     (if (assq (widget-value wid)
				       ps-page-dimensions-database)
972 973 974 975 976
				 nil
			       (widget-put wid :error "Unknown paper size")
			       wid)))
  :group 'ps-print)

977
(defcustom ps-landscape-mode nil
978 979 980 981
  "*Non-nil means print in landscape mode."
  :type 'boolean
  :group 'ps-print)

982 983 984 985 986 987 988 989 990 991 992
(defcustom ps-print-control-characters 'control-8-bit
  "*Specifies the printable form for control and 8-bit characters.
Valid values are:
  '8-bit          printable form for control and 8-bit characters
                  (characters from \000 to \037 and \177 to \377).
  'control-8-bit  printable form for control and *control* 8-bit characters
                  (characters from \000 to \037 and \177 to \237).
  'control        printable form for control character
                  (characters from \000 to \037 and \177).
  nil             raw character (no printable form).
Any other value is treated as nil."
993 994
  :type '(choice (const 8-bit) (const control-8-bit)
		 (const control) (const nil))
995 996
  :group 'ps-print)

997 998
(defcustom ps-number-of-columns (if ps-landscape-mode 2 1)
  "*Specifies the number of columns"
999 1000 1001
  :type 'number
  :group 'ps-print)

1002
(defcustom ps-zebra-stripes nil
1003
  "*Non-nil means print zebra stripes.
1004
See also documentation for `ps-zebra-stripe-height'."
1005 1006 1007
  :type 'boolean
  :group 'ps-print)

1008
(defcustom ps-zebra-stripe-height 3
1009
  "*Number of zebra stripe lines.
1010
See also documentation for `ps-zebra-stripes'."
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
  :type 'number
  :group 'ps-print)

(defcustom ps-line-number nil
  "*Non-nil means print line number."
  :type 'boolean
  :group 'ps-print)

(defcustom ps-print-background-image nil
  "*EPS image list to be printed on background.

The elements are:

   (FILENAME X Y XSCALE YSCALE ROTATION PAGES...)

FILENAME is a file name which contains an EPS image or some PostScript
programming like EPS.
FILENAME is ignored, if it doesn't exist or is read protected.

X and Y are relative positions on paper to put the image.
If X and Y are nil, the image is centralized on paper.

XSCALE and YSCALE are scale factor to be applied to image before printing.
If XSCALE and YSCALE are nil, the original size is used.

ROTATION is the image rotation angle; if nil, the default is 0.

PAGES designates the page to print background image.
PAGES may be a number or a cons cell (FROM . TO) designating FROM page
to TO page.
If PAGES is nil, print background image on all pages.

X, Y, XSCALE, YSCALE and ROTATION may be a floating point number,
an integer number or a string. If it is a string, the string should contain
PostScript programming that returns a float or integer value.

For example, if you wish to print an EPS image on all pages do:

   '((\"~/images/EPS-image.ps\"))"
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
  :type '(repeat (list file
		       (choice :tag "X" number string (const nil))
		       (choice :tag "Y" number string (const nil))
		       (choice :tag "X Scale" number string (const nil))
		       (choice :tag "Y Scale" number string (const nil))
		       (choice :tag "Rotation" number string (const nil))
		       (repeat :tag "Pages" :inline t
			       (radio integer
				      (cons :tag "Range"
					    (integer :tag "From")
					    (integer :tag "To"))))))
1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
  :group 'ps-print)

(defcustom ps-print-background-text nil
  "*Text list to be printed on background.

The elements are:

   (STRING X Y FONT FONTSIZE GRAY ROTATION PAGES...)

STRING is the text to be printed on background.

X and Y are positions on paper to put the text.
If X and Y are nil, the text is positioned at lower left corner.

FONT is a font name to be used on printing the text.
If nil, \"Times-Roman\" is used.

FONTSIZE is font size to be used, if nil, 200 is used.

GRAY is the text gray factor (should be very light like 0.8).
If nil, the default is 0.85.

ROTATION is the text rotation angle; if nil, the angle is given by
the diagonal from lower left corner to upper right corner.

PAGES designates the page to print background text.
PAGES may be a number or a cons cell (FROM . TO) designating FROM page
to TO page.
If PAGES is nil, print background text on all pages.

X, Y, FONTSIZE, GRAY and ROTATION may be a floating point number,
an integer number or a string. If it is a string, the string should contain
PostScript programming that returns a float or integer value.

For example, if you wish to print text \"Preliminary\" on all pages do:

   '((\"Preliminary\"))"
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
  :type '(repeat (list string
		       (choice :tag "X" number string (const nil))
		       (choice :tag "Y" number string (const nil))
		       (choice :tag "Font" string (const nil))
		       (choice :tag "Fontsize" number string (const nil))
		       (choice :tag "Gray" number string (const nil))
		       (choice :tag "Rotation" number string (const nil))
		       (repeat :tag "Pages" :inline t
			       (radio integer
				      (cons :tag "Range"
					    (integer :tag "From")
					    (integer :tag "To"))))))
1110
  :group 'ps-print)
1111 1112 1113 1114 1115 1116 1117 1118 1119

;;; Horizontal layout

;;  ------------------------------------------
;;  |    |      |    |      |    |      |    |
;;  | lm | text | ic | text | ic | text | rm |
;;  |    |      |    |      |    |      |    |
;;  ------------------------------------------

1120 1121 1122 1123
(defcustom ps-left-margin   (/ (* 72  2.0) 2.54) ;   2 cm
  "*Left margin in points (1/72 inch)."
  :type 'number
  :group 'ps-print-horizontal)
1124

1125 1126 1127 1128
(defcustom ps-right-margin  (/ (* 72  2.0) 2.54) ;   2 cm
  "*Right margin in points (1/72 inch)."
  :type 'number
  :group 'ps-print-horizontal)
1129

1130 1131 1132 1133
(defcustom ps-inter-column  (/ (* 72  2.0) 2.54) ;   2 cm
  "*Horizontal space between columns in points (1/72 inch)."
  :type 'number
  :group 'ps-print-horizontal)
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148

;;; Vertical layout

;; |--------|
;; | tm     |
;; |--------|
;; | header |
;; |--------|
;; | ho     |
;; |--------|
;; | text   |
;; |--------|
;; | bm     |
;; |--------|

1149 1150 1151 1152
(defcustom ps-bottom-margin (/ (* 72  1.5) 2.54) ; 1.5 cm
  "*Bottom margin in points (1/72 inch)."
  :type 'number
  :group 'ps-print-vertical)
1153

1154 1155 1156 1157
(defcustom ps-top-margin    (/ (* 72  1.5) 2.54) ; 1.5 cm
  "*Top margin in points (1/72 inch)."
  :type 'number
  :group 'ps-print-vertical)
1158

1159 1160 1161 1162
(defcustom ps-header-offset (/ (* 72  1.0) 2.54) ; 1.0 cm
  "*Vertical space in points (1/72 inch) between the main text and the header."
  :type 'number
  :group 'ps-print-vertical)
1163

1164
(defcustom ps-header-line-pad 0.15
1165
  "*Portion of a header title line height to insert between the header frame
1166 1167 1168
and the text it contains, both in the vertical and horizontal directions."
  :type 'number
  :group 'ps-print-vertical)
1169 1170

;;; Header setup
1171

1172
(defcustom ps-print-header t
Richard M. Stallman's avatar
Richard M. Stallman committed
1173 1174 1175
  "*Non-nil means print a header at the top of each page.
By default, the header displays the buffer name, page number, and, if
the buffer is visiting a file, the file's directory.  Headers are
1176
customizable by changing variables `ps-left-header' and
1177 1178 1179 1180
`ps-right-header'."
  :type 'boolean
  :group 'ps-print-header)

1181 1182 1183 1184 1185 1186 1187 1188
(defcustom ps-print-only-one-header nil
  "*Non-nil means print only one header at the top of each page.
This is useful when printing more than one column, so it is possible
to have only one header over all columns or one header per column.
See also `ps-print-header'."
  :type 'boolean
  :group 'ps-print-header)

1189 1190 1191 1192 1193 1194
(defcustom ps-print-header-frame t
  "*Non-nil means draw a gaudy frame around the header."
  :type 'boolean
  :group 'ps-print-header)

(defcustom ps-header-lines 2
Karl Heuer's avatar
Karl Heuer committed
1195
  "*Number of lines to display in page header, when generating PostScript."
1196 1197
  :type 'integer
  :group 'ps-print-header)
1198 1199
(make-variable-buffer-local 'ps-header-lines)

1200
(defcustom ps-show-n-of-n t
Richard M. Stallman's avatar
Richard M. Stallman committed
1201
  "*Non-nil means show page numbers as N/M, meaning page N of M.
Karl Heuer's avatar
Karl Heuer committed
1202 1203
NOTE: page numbers are displayed as part of headers,
      see variable `ps-print-headers'."
1204 1205
  :type 'boolean
  :group 'ps-print-header)
1206

1207
(defcustom ps-spool-duplex nil		; Not many people have duplex
1208 1209 1210 1211 1212 1213
					; printers, so default to nil.
  "*Non-nil indicates spooling is for a two-sided printer.
For a duplex printer, the `ps-spool-*' commands will insert blank pages
as needed between print jobs so that the next buffer printed will
start on the right page.  Also, if headers are turned on, the headers
will be reversed on duplex printers so that the page numbers fall to
1214 1215 1216
the left on even-numbered pages."
  :type 'boolean
  :group 'ps-print-header)
1217 1218 1219

;;; Fonts

1220
(defcustom ps-font-info-database