• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/

Lines Matching +defs:ps +defs:font +defs:info +defs:database

0 ;;; ps-print.el --- print text from the buffer as PostScript
16 (defconst ps-print-version "6.7.4"
17 "ps-print.el, v 6.7.4 <2007/05/13 vinicius>
21 report the version of Emacs, if any, that ps-print was distributed with.
46 ;; About ps-print
51 ;; output. ps-print is intended for use with Emacs or XEmacs, together with a
52 ;; fontifying package such as font-lock or hilit.
54 ;; ps-print uses the same face attributes defined through font-lock or hilit to
58 ;; ps-print allows a remap of face to another one that it is better to print,
59 ;; for example, the face font-lock-comment-face (if you are using font-lock)
64 ;; Using ps-print
67 ;; ps-print provides eight commands for generating PostScript images of Emacs
70 ;; ps-print-buffer
71 ;; ps-print-buffer-with-faces
72 ;; ps-print-region
73 ;; ps-print-region-with-faces
74 ;; ps-spool-buffer
75 ;; ps-spool-buffer-with-faces
76 ;; ps-spool-region
77 ;; ps-spool-region-with-faces
82 ;; "ps-print- commands".
92 ;; printer, use the command `ps-despool'.
100 ;; ps-print has a hook in the `kill-emacs-hook' so that you won't accidentally
115 ;; include font, color, and underline information in the PostScript image, so
116 ;; the printed image can look as pretty as the buffer. The ps-print- commands
117 ;; without the -with-faces suffix don't include font, color, or underline
121 ;; Two ps-print- command examples:
123 ;; ps-print-buffer - print the entire buffer, without font,
127 ;; ps-spool-region-with-faces - print just the current region; include
128 ;; font, color, and underline information,
138 ;; M-x ps-print-buffer
140 ;; or substitute one of the other seven ps-print- commands. The command will
144 ;; C-u M-x ps-print-buffer
150 ;; `ps-despool':
152 ;; C-u M-x ps-despool
154 ;; When invoked this way, `ps-despool' will prompt you for the name of the file
157 ;; Any of the `ps-print-' commands can be bound to keys; I recommend binding
158 ;; `ps-spool-buffer-with-faces', `ps-spool-region-with-faces', and
159 ;; `ps-despool'. Here are the bindings I use on my Sun 4 keyboard:
161 ;; (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc
162 ;; (global-set-key '(shift f22) 'ps-spool-region-with-faces)
163 ;; (global-set-key '(control f22) 'ps-despool)
169 ;; The variables `ps-lpr-command' and `ps-lpr-switches' determine what command
176 ;; The variable `ps-printer-name' determines the name of a local printer for
179 ;; The variable `ps-printer-name-option' determines the option used by some
181 ;; `ps-printer-name' is a non-empty string. If you're using lpr utility to
182 ;; print, for example, `ps-printer-name-option' should be set to "-P".
184 ;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values from
187 ;; ps-print won't work properly. `ps-lpr-command' must name a program
189 ;; `ps-printer-name' takes its initial value from the variable
190 ;; `printer-name'. `ps-printer-name-option' tries to guess which system
194 ;; The variable `ps-print-region-function' specifies a function to print the
199 ;; The variable `ps-manual-feed' indicates if the printer will manually feed
203 ;; The variable `ps-end-with-control-d' specifies whether C-d (\x04) should be
208 ;; customize the following variables: `ps-printer-name',
209 ;; `ps-printer-name-option', `ps-lpr-command', `ps-lpr-switches' and
210 ;; `ps-spool-config'. See these variables documentation in the code or by
211 ;; typing, for example, C-h v ps-printer-name RET.
221 ;; The variable `ps-paper-type' determines the size of paper ps-print formats
226 ;; If variable `ps-warn-paper-type' is nil, it's *not* given an error if
228 ;; `ps-paper-type', instead it uses the default paper size. If variable
229 ;; `ps-warn-paper-type' is non-nil, it's given an error if PostScript printer
230 ;; doesn't have a paper with the size indicated by `ps-paper-type'. It's used
231 ;; when `ps-spool-config' is set to `setpagedevice' (see section Duplex
234 ;; The variable `ps-landscape-mode' determines the orientation of the printing
236 ;; There is no oblique mode yet, though this is easy to do in ps.
243 ;; The variable `ps-number-of-columns' determines the number of columns both in
252 ;; The variable `ps-print-upside-down' determines other orientation for
259 ;; The variable `ps-selected-pages' specifies which pages to print. If it's
264 ;; nil (print all pages). After ps-print processing `ps-selected-pages' is set
265 ;; to nil. But the latest `ps-selected-pages' is saved in
266 ;; `ps-last-selected-pages' (see it for documentation). So you can restore the
267 ;; latest selected pages by using `ps-last-selected-pages' or by calling
268 ;; `ps-restore-selected-pages' command (see it for documentation).
270 ;; The variable `ps-even-or-odd-pages' specifies if it prints even/odd pages.
286 ;; See `ps-even-or-odd-pages' for more detailed documentation.
293 ;; `ps-left-margin' `ps-inter-column' `ps-right-margin'
302 ;; If `ps-number-of-columns' is 1, `ps-inter-column' is not relevant.
311 ;; `ps-bottom-margin' `ps-top-margin' `ps-header-offset' `ps-footer-offset'
332 ;; If `ps-print-header' is nil, `ps-header-offset' is not relevant.
333 ;; If `ps-print-footer' is nil, `ps-footer-offset' is not relevant.
344 ;; ps-print can print headers at the top of each column or at the top of each
350 ;; ps-print.el 1/21
351 ;; /home/jct/emacs-lisp/ps/new 94/12/31
354 ;; page numbers are toward the outside (cf. `ps-spool-duplex').
357 ;; To turn them off completely, set `ps-print-header' to nil.
359 ;; set `ps-print-header-frame' to nil.
361 ;; The variable `ps-header-frame-alist' specifies header frame properties
386 ;; Don't change this alist directly, instead use customization, or `ps-value',
387 ;; `ps-get', `ps-put' and `ps-del' functions (see them for documentation).
390 ;; `ps-print-only-one-header' to t.
392 ;; To switch headers, set `ps-switch-header' to:
399 ;; `ps-spool-duplex' is non-nil (see Duplex Printers).
403 ;; The font family and size of text in the header are determined by the
404 ;; variables `ps-header-font-family', `ps-header-font-size' and
405 ;; `ps-header-title-font-size' (see below).
407 ;; The variable `ps-header-line-pad' determines the portion of a header title
413 ;; `ps-show-n-of-n' to nil.
416 ;; number of lines. To show less, set `ps-header-lines' to 1, and the header
418 ;; `ps-header-lines' to 3, and the header will show the time of printing below
421 ;; To change the content of the headers, change the variables `ps-left-header'
422 ;; and `ps-right-header'.
432 ;; added by ps-print, and should not be part of the returned value.
449 ;; and a literal for "Curly". Here's how `ps-left-header' should be set:
451 ;; (setq ps-left-header (list 'moe-func 'larry-var "(Curly)"))
464 ;; ps-print also print footers. The footer variables are: `ps-print-footer',
465 ;; `ps-footer-offset', `ps-print-footer-frame', `ps-footer-font-family',
466 ;; `ps-footer-font-size', `ps-footer-line-pad', `ps-footer-lines',
467 ;; `ps-left-footer', `ps-right-footer' and `ps-footer-frame-alist'. These
470 ;; The variables `ps-print-only-one-header' and `ps-switch-header' also control
476 ;; (setq ps-print-header nil
477 ;; ps-print-footer t
478 ;; ps-print-footer-frame nil
479 ;; ps-footer-lines 1
480 ;; ps-right-footer nil
481 ;; ps-left-footer
490 ;; ps-print generates by setting the variable `ps-print-prologue-header'.
492 ;; `ps-print-prologue-header' may be a string or a symbol function which
497 ;; By default `ps-print-prologue-header' is nil.
499 ;; ps-print always inserts the %%Requirements: comment, so if you need to
500 ;; insert more requirements put them first in `ps-print-prologue-header' using
504 ;; (setq ps-print-prologue-header
507 ;; The duplex requirement is inserted by ps-print (see section Duplex
519 ;; `ps-user-defined-prologue'.
521 ;; `ps-user-defined-prologue' may be a string or a symbol function which
522 ;; returns a string. Note that this string is inserted after `ps-adobe-tag'
523 ;; and PostScript prologue comments, and before ps-print PostScript prologue
525 ;; initialization and before ps-print settings.
527 ;; By default `ps-user-defined-prologue' is nil.
534 ;; ps-print handles this in a suitable way.
540 ;; As an example for `ps-user-defined-prologue' setting:
543 ;; (setq ps-user-defined-prologue
551 ;; ps-print instruments generated PostScript code with an error handler.
553 ;; The variable `ps-error-handler-message' specifies where the error handler
579 ;; paper), set `ps-spool-duplex' to t.
580 ;; ps-print will insert blank pages to make sure each buffer starts on the
583 ;; The variable `ps-spool-config' specifies who is the responsible for setting
586 ;; lpr-switches duplex and page size are configured by `ps-lpr-switches'.
587 ;; Don't forget to set `ps-lpr-switches' to select duplex
590 ;; setpagedevice duplex and page size are configured by ps-print using the
593 ;; nil duplex and page size are configured by ps-print *not* using
606 ;; So, if you need to use setpagedevice, set `ps-spool-config' to
608 ;; if the printed file isn't ok, set `ps-spool-config' to nil.
610 ;; The variable `ps-spool-tumble' specifies how the page images on opposite
612 ;; `ps-spool-tumble' is nil, produces output suitable for binding on the left
613 ;; or right. If `ps-spool-tumble' is non-nil, produces output suitable for
614 ;; binding at the top or bottom. It has effect only when `ps-spool-duplex' is
619 ;; this behavior, set variable `ps-banner-page-when-duplexing' to t.
621 ;; When `ps-banner-page-when-duplexing' is non-nil, it prints a blank page as
625 ;; The default for `ps-banner-page-when-duplexing' is nil (*don't* skip the
632 ;; The variable `ps-n-up-printing' specifies the number of pages per sheet of
635 ;; NOTE: some PostScript printer may crash printing if `ps-n-up-printing' is
638 ;; The variable `ps-n-up-margin' specifies the margin in points between the
642 ;; If variable `ps-n-up-border-p' is non-nil a border is drawn around each
645 ;; The variable `ps-n-up-filling' specifies how page matrix is filled on each
646 ;; sheet of paper. Following are the valid values for `ps-n-up-filling' with a
673 ;; The variable `ps-print-control-characters' specifies whether you want to see
677 ;; Valid values for `ps-print-control-characters' are:
687 ;; the current font.
691 ;; the current font.
694 ;; current font.
700 ;; Characters TAB, NEWLINE and FORMFEED are always treated by ps-print engine.
706 ;; See ps-mule.el for documentation.
712 ;; The variable `ps-line-number' specifies whether to number each line;
715 ;; The variable `ps-line-number-color' specifies the color for line number.
716 ;; See `ps-zebra-color' for documentation. The default is "black" (or 0.0, or
719 ;; The variable `ps-line-number-font' specifies the font for line number.
722 ;; The variable `ps-line-number-font-size' specifies the font size in points
723 ;; for line number. See `ps-font-size' for documentation. The default is 6.
725 ;; The variable `ps-line-number-step' specifies the interval that line number
726 ;; is printed. For example, if `ps-line-number-step' is set to 2, the printing
749 ;; The variable `ps-line-number-start' specifies the starting point in the
750 ;; interval given by `ps-line-number-step'. For example, if
751 ;; `ps-line-number-step' is set to 3 and `ps-line-number-start' is set to 3,
766 ;; The values for `ps-line-number-start':
768 ;; * If `ps-line-number-step' is an integer, must be between 1 and the value
769 ;; of `ps-line-number-step' inclusive.
771 ;; * If `ps-line-number-step' is set to `zebra', must be between 1 and the
772 ;; value of `ps-zebra-stripe-height' inclusive.
798 ;; `ps-zebra-stripe-height', which is 3 by default. The distance between
801 ;; The variable `ps-zebra-stripes' controls whether to print zebra stripes.
804 ;; The variable `ps-zebra-color' controls the zebra stripes gray scale or RGB
810 ;; The variable `ps-zebra-stripe-follow' specifies how zebra stripes continue
850 ;; ps-print has the following hook variables:
852 ;; `ps-print-hook'
854 ;; place to initialize ps-print global data.
857 ;; `ps-print-begin-sheet-hook'
859 ;; If `ps-n-up-printing' is equal to 1, `ps-print-begin-page-hook' is never
862 ;; `ps-print-begin-page-hook'
864 ;; page that `ps-print-begin-sheet-hook' is evaluated.
866 ;; `ps-print-begin-column-hook'
868 ;; column that `ps-print-begin-page-hook' is evaluated or that
869 ;; `ps-print-begin-sheet-hook' is evaluated.
875 ;; ps-print now knows rather precisely some fonts: the variable
876 ;; `ps-font-info-database' contains information for a list of font families
878 ;; `Helvetica-Narrow' `NewCenturySchlbk'). Each font family contains the font
883 ;; The variable `ps-font-family' determines which font family is to be used for
884 ;; ordinary text. If its value does not correspond to a known font family, an
886 ;; currently available font families.
888 ;; The variable `ps-font-size' determines the size (in points) of the font for
894 ;; Similarly, the variable `ps-header-font-family' determines which font family
897 ;; The variable `ps-header-font-size' determines the font size, in points, for
898 ;; text in the header (similar to `ps-font-size').
900 ;; The variable `ps-header-title-font-size' determines the font size, in
901 ;; points, for the top line of text in the header (similar to `ps-font-size').
903 ;; The variable `ps-line-spacing' determines the line spacing, in points, for
904 ;; ordinary text, when generating PostScript (similar to `ps-font-size'). The
907 ;; The variable `ps-paragraph-spacing' determines the paragraph spacing, in
909 ;; `ps-font-size'). The default value is 0 (zero = no paragraph spacing).
911 ;; To get all lines with some spacing set both `ps-line-spacing' and
912 ;; `ps-paragraph-spacing' variables.
914 ;; The variable `ps-paragraph-regexp' specifies the paragraph delimiter. It
918 ;; The variable `ps-begin-cut-regexp' and `ps-end-cut-regexp' specify the start
921 ;; As an example, variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' may
928 ;; Variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' control together
936 ;; To use a new font family, you MUST first teach ps-print this font, i.e., add
937 ;; its information to `ps-font-info-database', otherwise ps-print cannot
944 ;; - generate the PostScript image to a file (C-u M-x ps-print-buffer)
948 ;; - replace in this line `Courier' by the new font (say `Helvetica') to get
957 ;; - Add these values to the `ps-font-info-database':
958 ;; (setq ps-font-info-database
969 ;; ps-font-info-database))
970 ;; - Now you can use this font family with any size:
971 ;; (setq ps-font-family 'Helvetica)
974 ;; (require 'ps-print)
975 ;; (setq ps-font-info-database (append ...)))
976 ;; if you don't want to load ps-print, you have to copy the whole value:
977 ;; (setq ps-font-info-database '(<your stuff> <the standard stuff>))
978 ;; or, use `ps-print-hook' (see section Hooks):
979 ;; (add-hook 'ps-print-hook
981 ;; (or (assq 'Helvetica ps-font-info-database)
982 ;; (setq ps-font-info-database (append ...)))))
984 ;; You can create new `mixed' font families like:
996 ;; Now you can use your new font family with any size:
997 ;; (setq ps-font-family 'my-mixed-family)
1000 ;; symbol, so when printing this face it'll be used the font `LineDrawNormal'.
1005 ;; Note also that the font family entry order is irrelevant, so the above
1028 ;; Anyway, as ghostscript fonts are autoload, you won't get much font info.
1030 ;; Note also that ps-print DOESN'T download any font to your printer, instead
1037 ;; The ps-print-*-with-faces commands attempt to determine which faces should
1042 ;; It is possible to force ps-print to consider specific faces bold, italic or
1043 ;; underline, no matter what font they are displayed in, by setting the
1044 ;; variables `ps-bold-faces', `ps-italic-faces' and `ps-underlined-faces'.
1045 ;; These variables contain lists of faces that ps-print should consider bold,
1049 ;; (setq ps-bold-faces '(my-blue-face))
1050 ;; (setq ps-italic-faces '(my-red-face))
1051 ;; (setq ps-underlined-faces '(my-green-face))
1056 ;; ps-print keeps internal lists of which fonts are bold and which are italic;
1057 ;; these lists are built the first time you invoke ps-print.
1059 ;; are referred in later invocations of ps-print.
1063 ;; back in sync, you can set the variable `ps-build-face-reference' to t, and
1064 ;; the lists will be rebuilt the next time ps-print is invoked. If you need
1065 ;; that the lists always be rebuilt when ps-print is invoked, set the variable
1066 ;; `ps-always-build-face-reference' to t.
1069 ;; variable `ps-use-face-background' which specifies if face background should
1083 ;; ps-print detects faces with foreground and background colors defined and
1086 ;; `ps-default-fg' and `ps-default-bg'.
1088 ;; To turn off color output, set `ps-print-color-p' to nil.
1089 ;; You can also set `ps-print-color-p' to 'black-white to have a better looking
1090 ;; on black/white printers. See also `ps-black-white-faces' for documentation.
1096 ;; As ps-print uses PostScript to print buffers, it is possible to have other
1097 ;; attributes associated with faces. So the new attributes used by ps-print
1106 ;; See the documentation for `ps-extend-face'.
1108 ;; Let's, for example, remap `font-lock-keyword-face' to another foreground
1111 ;; (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE)
1114 ;; `ps-extend-face' to specify how to print it.
1120 ;; ps-print can print texts and/or EPS PostScript images on background; it is
1121 ;; possible to define the following text attributes: font name, font size,
1127 ;; See documentation for `ps-print-background-text' and
1128 ;; `ps-print-background-image'.
1133 ;; (setq ps-print-background-text
1143 ;; Similarly, we could print image "~/images/EPS-image1.ps" on all pages and
1144 ;; image "~/images/EPS-image2.ps" on page 5 and from page 11 to page 17, we
1147 ;; (setq ps-print-background-image
1148 ;; '(("~/images/EPS-image1.ps"
1150 ;; ("~/images/EPS-image2.ps"
1175 ;; Some tools are provided to help you customize your font setup.
1177 ;; `ps-setup' returns (some part of) the current setup.
1180 ;; margins and the font size. On UN*X systems, do:
1183 ;; Then, the command `ps-line-lengths' will give you the correspondence between
1184 ;; a line length (number of characters) and the maximum font size which doesn't
1185 ;; wrap such a line with the current ps-print setup.
1187 ;; The commands `ps-nb-pages-buffer' and `ps-nb-pages-region' display the
1188 ;; correspondence between a number of pages and the maximum font size which
1195 ;; The command `ps-print-customize' activates a customization buffer for
1196 ;; ps-print options.
1203 ;; Automatic detection of font attributes (bold, italic).
1216 ;; `ps-time-stamp-yyyy-mm-dd', `ps-time-stamp-iso8601'
1219 ;; `ps-time-stamp-locale-default'
1225 ;; `ps-line-number-color', `ps-print-footer', `ps-footer-offset',
1226 ;; `ps-print-footer-frame', `ps-footer-font-family',
1227 ;; `ps-footer-font-size', `ps-footer-line-pad', `ps-footer-lines',
1228 ;; `ps-left-footer', `ps-right-footer', `ps-footer-frame-alist' and
1229 ;; `ps-header-frame-alist'.
1232 ;; `ps-line-spacing', `ps-paragraph-spacing', `ps-paragraph-regexp',
1233 ;; `ps-begin-cut-regexp' and `ps-end-cut-regexp'.
1236 ;; `ps-line-number-font', `ps-line-number-font-size' and
1237 ;; `ps-end-with-control-d'.
1240 ;; `ps-even-or-odd-pages'
1243 ;; `ps-manual-feed', `ps-warn-paper-type', `ps-print-upside-down',
1244 ;; `ps-selected-pages', `ps-last-selected-pages',
1245 ;; `ps-restore-selected-pages', `ps-switch-header',
1246 ;; `ps-line-number-step', `ps-line-number-start',
1247 ;; `ps-zebra-stripe-follow' and `ps-use-face-background'.
1251 ;; `ps-user-defined-prologue' and `ps-error-handler-message'.
1254 ;; `ps-print-customize'.
1258 ;; `ps-banner-page-when-duplexing' and `ps-zebra-color'.
1262 ;; Hook: `ps-print-begin-sheet-hook'.
1266 ;; `ps-print-region-function'
1287 ;; Hooks: `ps-print-hook', `ps-print-begin-page-hook' and
1288 ;; `ps-print-begin-column-hook'.
1290 ;; Better database font management.
1294 ;; Dynamic evaluation at print time of `ps-lpr-switches'.
1310 ;; Known bugs and limitations of ps-print
1318 ;; Automatic font-attribute detection doesn't work well, especially with
1320 ;; auto-font detection should use the lists `ps-italic-faces', `ps-bold-faces'
1321 ;; and `ps-underlined-faces' and/or turn off automatic detection by setting
1322 ;; `ps-auto-font-detect' to nil.
1324 ;; Automatic font-attribute detection doesn't work with XEmacs 19.12 in tty
1325 ;; mode; use the lists `ps-italic-faces', `ps-bold-faces' and
1326 ;; `ps-underlined-faces' instead.
1338 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care of folding
1346 ;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy).
1348 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' should take care of folding
1366 ;; Thanks to Corinne Ilvedson <cilvedson@draper.com> for line number font size
1370 ;; `ps-user-defined-prologue' example setting for HP PostScript printer.
1373 ;; suggestion for `ps-postscript-code-directory' variable.
1381 ;; - `ps-time-stamp-yyyy-mm-dd' and `ps-time-stamp-iso8601' suggestion.
1386 ;; `ps-prologue-file' enhancement.
1397 ;; `ps-print-control-characters' variable documentation.
1400 ;; database font management.
1407 ;; print time of `ps-lpr-switches'.
1415 ;; * Check `ps-paper-type': Sudhakar Frederick <sfrederi@asc.corp.mot.com>
1426 ;; initial port to Emacs 19. His code is no longer part of ps-print, but his
1430 ;; adding underline support. Their code also is no longer part of ps-print,
1433 ;; Thanks also to all of you who mailed code to add features to ps-print;
1449 (error "`ps-print' requires floating point support"))
1454 (error "`ps-print' doesn't support Lucid"))
1456 (error "`ps-print' doesn't support Epoch"))
1460 (error "`ps-print' only supports Emacs 22 and higher")))))
1475 (defalias 'ps-x-color-instance-p 'color-instance-p)
1476 (defalias 'ps-x-color-instance-rgb-components 'color-instance-rgb-components)
1477 (defalias 'ps-x-color-name 'color-name)
1478 (defalias 'ps-x-color-specifier-p 'color-specifier-p)
1479 (defalias 'ps-x-copy-coding-system 'copy-coding-system)
1480 (defalias 'ps-x-device-class 'device-class)
1481 (defalias 'ps-x-extent-end-position 'extent-end-position)
1482 (defalias 'ps-x-extent-face 'extent-face)
1483 (defalias 'ps-x-extent-priority 'extent-priority)
1484 (defalias 'ps-x-extent-start-position 'extent-start-position)
1485 (defalias 'ps-x-face-font-instance 'face-font-instance)
1486 (defalias 'ps-x-find-coding-system 'find-coding-system)
1487 (defalias 'ps-x-font-instance-properties 'font-instance-properties)
1488 (defalias 'ps-x-make-color-instance 'make-color-instance)
1489 (defalias 'ps-x-map-extents 'map-extents)
1492 (defalias 'ps-e-face-bold-p 'face-bold-p)
1493 (defalias 'ps-e-face-italic-p 'face-italic-p)
1494 (defalias 'ps-e-next-overlay-change 'next-overlay-change)
1495 (defalias 'ps-e-overlays-at 'overlays-at)
1496 (defalias 'ps-e-overlay-get 'overlay-get)
1497 (defalias 'ps-e-overlay-end 'overlay-end)
1498 (defalias 'ps-e-x-color-values 'x-color-values)
1499 (defalias 'ps-e-color-values 'color-values)
1500 (defalias 'ps-e-find-composition (if (fboundp 'find-composition)
1505 (defconst ps-windows-system
1507 (defconst ps-lp-system
1511 (defun ps-xemacs-color-name (color)
1512 (if (ps-x-color-specifier-p color)
1513 (ps-x-color-name color)
1516 (defalias 'ps-frame-parameter
1519 (defalias 'ps-mark-active-p
1526 (defun ps-face-foreground-name (face)
1527 (ps-xemacs-color-name (face-foreground face)))
1528 (defun ps-face-background-name (face)
1529 (ps-xemacs-color-name (face-background face)))
1532 (defun ps-face-foreground-name (face)
1534 (defun ps-face-background-name (face)
1551 (defgroup ps-print nil
1553 :link '(emacs-library-link :tag "Source Lisp File" "ps-print.el")
1554 :prefix "ps-"
1559 (defgroup ps-print-horizontal nil
1561 :prefix "ps-"
1564 :group 'ps-print)
1566 (defgroup ps-print-vertical nil
1568 :prefix "ps-"
1571 :group 'ps-print)
1573 (defgroup ps-print-headers nil
1575 :prefix "ps-"
1578 :group 'ps-print)
1580 (defgroup ps-print-font nil
1582 :prefix "ps-"
1585 :group 'ps-print)
1587 (defgroup ps-print-color nil
1589 :prefix "ps-"
1592 :group 'ps-print)
1594 (defgroup ps-print-face nil
1596 :prefix "ps-"
1599 :group 'ps-print
1602 (defgroup ps-print-n-up nil
1604 :prefix "ps-"
1607 :group 'ps-print)
1609 (defgroup ps-print-zebra nil
1611 :prefix "ps-"
1614 :group 'ps-print)
1616 (defgroup ps-print-background nil
1618 :prefix "ps-"
1621 :group 'ps-print)
1623 (defgroup ps-print-printer '((lpr custom-group))
1625 :prefix "ps-"
1628 :group 'ps-print)
1630 (defgroup ps-print-page nil
1632 :prefix "ps-"
1635 :group 'ps-print)
1637 (defgroup ps-print-miscellany nil
1639 :prefix "ps-"
1642 :group 'ps-print)
1645 (defcustom ps-error-handler-message 'paper
1669 :group 'ps-print-miscellany)
1671 (defcustom ps-user-defined-prologue nil
1674 `ps-user-defined-prologue' may be a string or a symbol function which returns a
1675 string. Note that this string is inserted after `ps-adobe-tag' and PostScript
1676 prologue comments, and before ps-print PostScript prologue code section. That
1678 ps-print settings.
1685 ps-print handles this in a suitable way.
1691 As an example for `ps-user-defined-prologue' setting:
1694 (setq ps-user-defined-prologue
1701 :group 'ps-print-miscellany)
1703 (defcustom ps-print-prologue-header nil
1704 "*PostScript prologue header comments besides that ps-print generates.
1706 `ps-print-prologue-header' may be a string or a symbol function which returns a
1711 ps-print always inserts the %%Requirements: comment, so if you need to insert
1712 more requirements put them first in `ps-print-prologue-header' using the
1716 (setq ps-print-prologue-header
1719 The duplex requirement is inserted by ps-print (see `ps-spool-duplex').
1731 :group 'ps-print-miscellany)
1733 (defcustom ps-printer-name (and (boundp 'printer-name)
1742 `ps-lpr-command' is \"\". By default it is the same as `printer-name'; typical
1746 which case the output gets appended to that file. \(Note that `ps-print'
1751 Set to t, if the utility given by `ps-lpr-command' needs an empty printer name.
1755 See also `ps-printer-name-option' for documentation."
1761 (string :tag "Pipe to ps-lpr-command"))
1763 :group 'ps-print-printer)
1765 (defcustom ps-printer-name-option
1766 (cond (ps-windows-system
1768 (ps-lp-system
1772 "*Option for `ps-printer-name' variable (see it).
1782 Set this to \"\" or nil, if the utility given by `ps-lpr-command'
1788 This variable is used only when `ps-printer-name' is a non-empty string."
1794 :group 'ps-print-printer)
1796 (defcustom ps-lpr-command lpr-command
1800 will write directly to the printer port named by `ps-printer-name'. The
1802 Novell Netware respectively) are handled specially, using `ps-printer-name' as
1807 :group 'ps-print-printer)
1809 (defcustom ps-lpr-switches lpr-switches
1810 "*A list of extra switches to pass to `ps-lpr-command'."
1816 :group 'ps-print-printer)
1818 (defcustom ps-print-region-function nil
1824 :group 'ps-print-printer)
1826 (defcustom ps-manual-feed nil
1832 :group 'ps-print-printer)
1834 (defcustom ps-end-with-control-d (and ps-windows-system t)
1839 :group 'ps-print-printer)
1862 (defcustom ps-page-dimensions-database
1876 See `ps-paper-type'."
1883 :group 'ps-print-page)
1886 (defcustom ps-paper-type 'letter
1888 Should be one of the paper types defined in `ps-page-dimensions-database', for
1892 ps-page-dimensions-database)
1897 :group 'ps-print-page)
1899 (defcustom ps-warn-paper-type t
1900 "*Non-nil means give an error if paper size is not equal to `ps-paper-type'.
1902 It's used when `ps-spool-config' is set to `setpagedevice'."
1905 :group 'ps-print-page)
1907 (defcustom ps-landscape-mode nil
1911 :group 'ps-print-page)
1913 (defcustom ps-print-upside-down nil
1917 :group 'ps-print-page)
1919 (defcustom ps-selected-pages nil
1930 After ps-print processing `ps-selected-pages' is set to nil. But the
1931 latest `ps-selected-pages' is saved in `ps-last-selected-pages' (which
1933 `ps-last-selected-pages' or with the `ps-restore-selected-pages'
1936 See also `ps-even-or-odd-pages'."
1944 :group 'ps-print-page)
1946 (defcustom ps-even-or-odd-pages nil
1958 That is, if `ps-n-up-printing' is 1, it behaves as `even-page';
1963 That is, if `ps-n-up-printing' is 1, it behaves as `odd-page';
1969 If you set `ps-selected-pages' (see it for documentation), first the pages are
1970 filtered by `ps-selected-pages' and then by `ps-even-or-odd-pages'. For
1973 (setq ps-selected-pages '(1 4 (6 . 10) (12 . 16) 20))
1975 Combining with `ps-even-or-odd-pages' and `ps-n-up-printing', we have:
1977 `ps-n-up-printing' = 1:
1978 `ps-even-or-odd-pages' PAGES PRINTED
1985 `ps-n-up-printing' = 2:
1986 `ps-even-or-odd-pages' PAGES PRINTED
2003 :group 'ps-print-page)
2005 (defcustom ps-print-control-characters 'control-8-bit
2020 the current font.
2024 the current font.
2027 current font.
2035 :group 'ps-print-miscellany)
2037 (defcustom ps-n-up-printing 1
2051 :group 'ps-print-n-up)
2053 (defcustom ps-n-up-margin (/ (* 72 1.0) 2.54) ; 1 cm
2057 :group 'ps-print-n-up)
2059 (defcustom ps-n-up-border-p t
2063 :group 'ps-print-n-up)
2065 (defcustom ps-n-up-filling 'left-top
2068 Following are the valid values for `ps-n-up-filling' with a filling example
2095 :group 'ps-print-n-up)
2097 (defcustom ps-number-of-columns (if ps-landscape-mode 2 1)
2101 :group 'ps-print-miscellany)
2103 (defcustom ps-zebra-stripes nil
2105 See also documentation for `ps-zebra-stripe-height' and `ps-zebra-color'."
2108 :group 'ps-print-zebra)
2110 (defcustom ps-zebra-stripe-height 3
2112 See also documentation for `ps-zebra-stripes' and `ps-zebra-color'."
2115 :group 'ps-print-zebra)
2117 (defcustom ps-zebra-color 0.95
2119 See also documentation for `ps-zebra-stripes' and `ps-zebra-stripe-height'."
2129 :group 'ps-print-zebra)
2131 (defcustom ps-zebra-stripe-follow nil
2173 :group 'ps-print-zebra)
2175 (defcustom ps-line-number nil
2179 :group 'ps-print-miscellany)
2181 (defcustom ps-line-number-step 1
2184 For example, `ps-line-number-step' is set to 2, the printing will look like:
2209 :group 'ps-print-miscellany)
2211 (defcustom ps-line-number-start 1
2212 "*Specify the starting point in the interval given by `ps-line-number-step'.
2214 For example, if `ps-line-number-step' is set to 3 and `ps-line-number-start' is
2229 The values for `ps-line-number-start':
2231 * If `ps-line-number-step' is an integer, must be between 1 and the value of
2232 `ps-line-number-step' inclusive.
2234 * If `ps-line-number-step' is set to `zebra', must be between 1 and the
2235 value of `ps-zebra-strip-height' inclusive. Use this combination if you
2239 :group 'ps-print-miscellany)
2241 (defcustom ps-print-background-image nil
2271 '((\"~/images/EPS-image.ps\"))"
2286 :group 'ps-print-background)
2288 (defcustom ps-print-background-text nil
2300 FONT is a font name to be used on printing the text.
2303 FONTSIZE is font size to be used, if nil, 200 is used.
2338 :group 'ps-print-background)
2348 (defcustom ps-left-margin (/ (* 72 2.0) 2.54) ; 2 cm
2352 :group 'ps-print-horizontal)
2354 (defcustom ps-right-margin (/ (* 72 2.0) 2.54) ; 2 cm
2358 :group 'ps-print-horizontal)
2360 (defcustom ps-inter-column (/ (* 72 2.0) 2.54) ; 2 cm
2364 :group 'ps-print-horizontal)
2380 (defcustom ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
2384 :group 'ps-print-vertical)
2386 (defcustom ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
2390 :group 'ps-print-vertical)
2392 (defcustom ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
2396 :group 'ps-print-vertical)
2398 (defcustom ps-header-line-pad 0.15
2404 :group 'ps-print-vertical)
2406 (defcustom ps-footer-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
2410 :group 'ps-print-vertical)
2412 (defcustom ps-footer-line-pad 0.15
2418 :group 'ps-print-vertical)
2422 (defcustom ps-print-header t
2426 changing variables `ps-left-header' and `ps-right-header'."
2429 :group 'ps-print-headers)
2431 (defcustom ps-print-header-frame t
2435 :group 'ps-print-headers)
2437 (defcustom ps-header-frame-alist
2465 Don't change this alist directly, instead use customization, or `ps-value',
2466 `ps-get', `ps-put' and `ps-del' functions (see them for documentation)."
2515 :group 'ps-print-headers)
2517 (defcustom ps-header-lines 2
2521 :group 'ps-print-headers)
2523 (defcustom ps-print-footer nil
2526 Footers are customizable by changing variables `ps-left-footer' and
2527 `ps-right-footer'."
2530 :group 'ps-print-headers)
2532 (defcustom ps-print-footer-frame t
2536 :group 'ps-print-headers)
2538 (defcustom ps-footer-frame-alist
2546 Don't change this alist directly, instead use customization, or `ps-value',
2547 `ps-get', `ps-put' and `ps-del' functions (see them for documentation).
2549 See also `ps-header-frame-alist' for documentation."
2597 :group 'ps-print-headers)
2599 (defcustom ps-footer-lines 2
2603 :group 'ps-print-headers)
2605 (defcustom ps-print-only-one-header nil
2609 See also `ps-print-header' and `ps-print-footer'."
2612 :group 'ps-print-headers)
2614 (defcustom ps-switch-header 'duplex
2624 `ps-spool-duplex' is non-nil.
2628 See also `ps-print-header' and `ps-print-footer'."
2635 :group 'ps-print-headers)
2637 (defcustom ps-show-n-of-n t
2640 see variable `ps-print-header'."
2643 :group 'ps-print-headers)
2645 (defcustom ps-spool-config
2646 (if ps-windows-system
2653 `lpr-switches' duplex and page size are configured by `ps-lpr-switches'.
2654 Don't forget to set `ps-lpr-switches' to select duplex
2657 `setpagedevice' duplex and page size are configured by ps-print using the
2660 nil duplex and page size are configured by ps-print *not* using
2671 So, if you need to use setpagedevice, set `ps-spool-config' to
2673 the printed file isn't OK, set `ps-spool-config' to nil."
2679 :group 'ps-print-headers)
2681 (defcustom ps-spool-duplex nil ; Not many people have duplex printers,
2684 For a duplex printer, the `ps-spool-*' and `ps-print-*' commands will insert
2690 See also `ps-spool-tumble'."
2693 :group 'ps-print-headers)
2695 (defcustom ps-spool-tumble nil
2697 If `ps-spool-tumble' is nil, produces output suitable for binding on the left
2698 or right. If `ps-spool-tumble' is non-nil, produces output suitable for
2701 It has effect only when `ps-spool-duplex' is non-nil."
2704 :group 'ps-print-headers)
2708 (defcustom ps-font-info-database
2811 ;; We keep this wrong entry name (but with correct font name) for
2820 "*Font info database.
2821 Each element comprises: font family (the key), name, bold, italic, bold-italic,
2823 To get the info for another specific font (say Helvetica), do the following:
2825 - generate the PostScript image to a file (C-u M-x ps-print-buffer)
2831 - add the values to `ps-font-info-database'.
2834 Note also that ps-print DOESN'T download any font to your printer, instead it
2863 :group 'ps-print-font)
2865 (defcustom ps-font-family 'Courier
2869 :group 'ps-print-font)
2871 (defcustom ps-font-size '(7 . 8.5)
2880 :group 'ps-print-font)
2882 (defcustom ps-header-font-family 'Helvetica
2886 :group 'ps-print-font)
2888 (defcustom ps-header-font-size '(10 . 12)
2897 :group 'ps-print-font)
2899 (defcustom ps-header-title-font-size '(12 . 14)
2908 :group 'ps-print-font)
2910 (defcustom ps-footer-font-family 'Helvetica
2914 :group 'ps-print-font)
2916 (defcustom ps-footer-font-size '(10 . 12)
2925 :group 'ps-print-font)
2927 (defcustom ps-line-number-color "black"
2938 :group 'ps-print-font
2939 :group 'ps-print-miscellany)
2941 (defcustom ps-line-number-font "Times-Italic"
2945 :group 'ps-print-font
2946 :group 'ps-print-miscellany)
2948 (defcustom ps-line-number-font-size 6
2957 :group 'ps-print-font
2958 :group 'ps-print-miscellany)
2966 (defcustom ps-print-color-p
2979 See also `ps-black-white-faces'.
2988 :group 'ps-print-color)
2990 (defcustom ps-default-fg 'frame-parameter
2993 The `ps-default-fg' variable contains the default foreground color used by
2994 ps-print, that is, if there is a face in a text that doesn't have a foreground
2995 color, the `ps-default-fg' color should be used.
3019 It's used only when `ps-print-color-p' is non-nil."
3031 :group 'ps-print-color)
3033 (defcustom ps-default-bg 'frame-parameter
3036 The `ps-default-bg' variable contains the default background color used by
3037 ps-print, that is, if there is a face in a text that doesn't have a background
3038 color, the `ps-default-bg' color should be used.
3062 It's used only when `ps-print-color-p' is non-nil.
3064 See also `ps-use-face-background'."
3076 :group 'ps-print-color)
3078 (defcustom ps-auto-font-detect t
3080 If nil, we rely solely on the lists `ps-bold-faces', `ps-italic-faces', and
3081 `ps-underlined-faces'."
3084 :group 'ps-print-font)
3086 (defcustom ps-black-white-faces
3087 '((font-lock-builtin-face "black" nil bold )
3088 (font-lock-comment-face "gray20" nil italic)
3089 (font-lock-constant-face "black" nil bold )
3090 (font-lock-function-name-face "black" nil bold )
3091 (font-lock-keyword-face "black" nil bold )
3092 (font-lock-string-face "black" nil italic)
3093 (font-lock-type-face "black" nil italic)
3094 (font-lock-variable-name-face "black" nil bold italic)
3095 (font-lock-warning-face "black" nil bold italic))
3098 The list elements are the same as defined on `ps-extend-face' (which see).
3100 This variable is used only when `ps-print-color-p' is set to `black-white'."
3124 :group 'ps-print-face)
3126 (defcustom ps-bold-faces
3127 (unless ps-print-color-p
3128 '(font-lock-function-name-face
3129 font-lock-builtin-face
3130 font-lock-variable-name-face
3131 font-lock-keyword-face
3132 font-lock-warning-face))
3133 "*A list of the \(non-bold\) faces that should be printed in bold font.
3137 :group 'ps-print-face)
3139 (defcustom ps-italic-faces
3140 (unless ps-print-color-p
3141 '(font-lock-variable-name-face
3142 font-lock-type-face
3143 font-lock-string-face
3144 font-lock-comment-face
3145 font-lock-warning-face))
3146 "*A list of the \(non-italic\) faces that should be printed in italic font.
3150 :group 'ps-print-face)
3152 (defcustom ps-underlined-faces
3153 (unless ps-print-color-p
3154 '(font-lock-function-name-face
3155 font-lock-constant-face
3156 font-lock-warning-face))
3161 :group 'ps-print-face)
3163 (defcustom ps-use-face-background nil
3181 :group 'ps-print-face)
3183 (defcustom ps-left-header
3184 (list 'ps-get-buffer-name 'ps-header-dirpart)
3205 :group 'ps-print-headers)
3207 (defcustom ps-right-header
3209 'ps-time-stamp-locale-default 'ps-time-stamp-hh:mm:ss)
3213 See the variable `ps-left-header' for a description of the format of this
3218 `ps-time-stamp-locale-default' Return the locale's \"preferred\" date
3221 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\".
3223 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\".
3225 `ps-time-stamp-yyyy-mm-dd' Return date as \"2001-06-18\" (ISO
3228 `ps-time-stamp-iso8601' Alias for `ps-time-stamp-yyyy-mm-dd'.
3236 :group 'ps-print-headers)
3238 (defcustom ps-left-footer
3239 (list 'ps-get-buffer-name 'ps-header-dirpart)
3260 :group 'ps-print-headers)
3262 (defcustom ps-right-footer
3264 'ps-time-stamp-locale-default 'ps-time-stamp-hh:mm:ss)
3268 See the variable `ps-left-footer' for a description of the format of this
3273 `ps-time-stamp-locale-default' Return the locale's \"preferred\" date
3276 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\".
3278 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\".
3280 `ps-time-stamp-yyyy-mm-dd' Return date as \"2001-06-18\" (ISO
3283 `ps-time-stamp-iso8601' Alias for `ps-time-stamp-yyyy-mm-dd'.
3291 :group 'ps-print-headers)
3293 (defcustom ps-razzle-dazzle t
3297 :group 'ps-print-miscellany)
3299 (defcustom ps-adobe-tag "%!PS-Adobe-3.0\n"
3301 By default, `ps-adobe-tag' contains the standard identifier. Some printers
3305 :group 'ps-print-miscellany)
3307 (defcustom ps-build-face-reference t
3310 ps-print sets this value to nil after it builds its internal reference lists of
3311 bold and italic faces. By setting its value back to t, you can force ps-print
3320 :group 'ps-print-face)
3322 (defcustom ps-always-build-face-reference nil
3325 If this variable is non-nil, ps-print will rebuild its internal reference lists
3330 :group 'ps-print-face)
3332 (defcustom ps-banner-page-when-duplexing nil
3337 :group 'ps-print-headers)
3339 (defcustom ps-postscript-code-directory
3342 (locate-data-directory "ps-print"))
3348 (error "`ps-postscript-code-directory' isn't set properly"))
3349 "*Directory where it's located the PostScript prologue file used by ps-print.
3353 :group 'ps-print-miscellany)
3355 (defcustom ps-line-spacing 0
3358 See also `ps-paragraph-spacing' and `ps-paragraph-regexp'.
3360 To get all lines with some spacing set both `ps-line-spacing' and
3361 `ps-paragraph-spacing' variables."
3369 :group 'ps-print-miscellany)
3371 (defcustom ps-paragraph-spacing 0
3374 See also `ps-line-spacing' and `ps-paragraph-regexp'.
3376 To get all lines with some spacing set both `ps-line-spacing' and
3377 `ps-paragraph-spacing' variables."
3385 :group 'ps-print-miscellany)
3387 (defcustom ps-paragraph-regexp "[ \t]*$"
3392 See also `ps-paragraph-spacing'."
3397 :group 'ps-print-miscellany)
3399 (defcustom ps-begin-cut-regexp nil
3402 As an example, variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' may be
3409 Variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' control together what
3415 :group 'ps-print-miscellany)
3417 (defcustom ps-end-cut-regexp nil
3420 See `ps-begin-cut-regexp' for more information."
3424 :group 'ps-print-miscellany)
3431 (defvar ps-last-selected-pages nil
3432 "Latest `ps-selected-pages' value.")
3435 (defun ps-restore-selected-pages ()
3436 "Restore latest `ps-selected-pages' value."
3438 (setq ps-selected-pages ps-last-selected-pages))
3446 (defun ps-print-customize ()
3447 "Customization of ps-print group."
3449 (customize-group 'ps-print))
3457 (defun ps-print-buffer (&optional filename)
3467 (interactive (list (ps-print-preprint current-prefix-arg)))
3468 (ps-print-without-faces (point-min) (point-max) filename))
3472 (defun ps-print-buffer-with-faces (&optional filename)
3474 Like `ps-print-buffer', but includes font, color, and underline information in
3477 (interactive (list (ps-print-preprint current-prefix-arg)))
3478 (ps-print-with-faces (point-min) (point-max) filename))
3482 (defun ps-print-region (from to &optional filename)
3484 Like `ps-print-buffer', but prints just the current region."
3485 (interactive (ps-print-preprint-region current-prefix-arg))
3486 (ps-print-without-faces from to filename t))
3490 (defun ps-print-region-with-faces (from to &optional filename)
3492 Like `ps-print-region', but includes font, color, and underline information in
3495 (interactive (ps-print-preprint-region current-prefix-arg))
3496 (ps-print-with-faces from to filename t))
3500 (defun ps-spool-buffer ()
3502 Like `ps-print-buffer' except that the PostScript image is saved in a local
3505 Use the command `ps-despool' to send the spooled images to the printer."
3507 (ps-spool-without-faces (point-min) (point-max)))
3511 (defun ps-spool-buffer-with-faces ()
3513 Like `ps-spool-buffer', but includes font, color, and underline information in
3517 Use the command `ps-despool' to send the spooled images to the printer."
3519 (ps-spool-with-faces (point-min) (point-max)))
3523 (defun ps-spool-region (from to)
3525 Like `ps-spool-buffer', but spools just the current region.
3527 Use the command `ps-despool' to send the spooled images to the printer."
3529 (ps-spool-without-faces from to t))
3533 (defun ps-spool-region-with-faces (from to)
3535 Like `ps-spool-region', but includes font, color, and underline information in
3539 Use the command `ps-despool' to send the spooled images to the printer."
3541 (ps-spool-with-faces from to t))
3544 (defun ps-despool (&optional filename)
3554 (interactive (list (ps-print-preprint current-prefix-arg)))
3555 (ps-do-despool filename))
3558 (defun ps-line-lengths ()
3559 "Display the correspondence between a line length and a font size.
3560 Done using the current ps-print setup.
3563 (ps-line-lengths-internal))
3566 (defun ps-nb-pages-buffer (nb-lines)
3567 "Display number of pages to print this buffer, for various font heights.
3568 The table depends on the current ps-print setup."
3569 (interactive (ps-count-lines-preprint (point-min) (point-max)))
3570 (ps-nb-pages nb-lines))
3573 (defun ps-nb-pages-region (nb-lines)
3574 "Display number of pages to print the region, for various font heights.
3575 The table depends on the current ps-print setup."
3576 (interactive (ps-count-lines-preprint (mark) (point)))
3577 (ps-nb-pages nb-lines))
3579 (defvar ps-prefix-quote nil
3580 "Used for `ps-print-quote' (which see).")
3583 (defun ps-setup ()
3585 (let (ps-prefix-quote)
3587 #'ps-print-quote
3590 ") ps-print version " ps-print-version "\n")
3592 (ps-comment-string "emacs-version " emacs-version)
3593 (ps-comment-string "ps-windows-system " ps-windows-system)
3594 (ps-comment-string "ps-lp-system " ps-lp-system)
3596 '(25 . ps-print-color-p)
3597 '(25 . ps-lpr-command)
3598 '(25 . ps-lpr-switches)
3599 '(25 . ps-printer-name)
3600 '(25 . ps-printer-name-option)
3601 '(25 . ps-print-region-function)
3602 '(25 . ps-manual-feed)
3603 '(25 . ps-end-with-control-d)
3605 '(23 . ps-paper-type)
3606 '(23 . ps-warn-paper-type)
3607 '(23 . ps-landscape-mode)
3608 '(23 . ps-print-upside-down)
3609 '(23 . ps-number-of-columns)
3611 '(23 . ps-zebra-stripes)
3612 '(23 . ps-zebra-stripe-height)
3613 '(23 . ps-zebra-stripe-follow)
3614 '(23 . ps-zebra-color)
3615 '(23 . ps-line-number)
3616 '(23 . ps-line-number-step)
3617 '(23 . ps-line-number-start)
3619 '(17 . ps-default-fg)
3620 '(17 . ps-default-bg)
3621 '(17 . ps-razzle-dazzle)
3623 '(23 . ps-use-face-background)
3625 '(28 . ps-print-control-characters)
3627 '(26 . ps-print-background-image)
3629 '(25 . ps-print-background-text)
3631 '(29 . ps-error-handler-message)
3632 '(29 . ps-user-defined-prologue)
3633 '(29 . ps-print-prologue-header)
3634 '(29 . ps-postscript-code-directory)
3635 '(29 . ps-adobe-tag)
3637 '(30 . ps-left-margin)
3638 '(30 . ps-right-margin)
3639 '(30 . ps-inter-column)
3640 '(30 . ps-bottom-margin)
3641 '(30 . ps-top-margin)
3642 '(30 . ps-print-only-one-header)
3643 '(30 . ps-switch-header)
3644 '(30 . ps-print-header)
3645 '(30 . ps-header-lines)
3646 '(30 . ps-header-offset)
3647 '(30 . ps-header-line-pad)
3648 '(30 . ps-print-header-frame)
3649 '(30 . ps-header-frame-alist)
3650 '(30 . ps-print-footer)
3651 '(30 . ps-footer-lines)
3652 '(30 . ps-footer-offset)
3653 '(30 . ps-footer-line-pad)
3654 '(30 . ps-print-footer-frame)
3655 '(30 . ps-footer-frame-alist)
3656 '(30 . ps-show-n-of-n)
3657 '(30 . ps-spool-config)
3658 '(30 . ps-spool-duplex)
3659 '(30 . ps-spool-tumble)
3660 '(30 . ps-banner-page-when-duplexing)
3661 '(30 . ps-left-header)
3662 '(30 . ps-right-header)
3663 '(30 . ps-left-footer)
3664 '(30 . ps-right-footer)
3666 '(23 . ps-n-up-printing)
3667 '(23 . ps-n-up-margin)
3668 '(23 . ps-n-up-border-p)
3669 '(23 . ps-n-up-filling)
3671 '(26 . ps-multibyte-buffer)
3672 '(26 . ps-font-family)
3673 '(26 . ps-font-size)
3674 '(26 . ps-header-font-family)
3675 '(26 . ps-header-font-size)
3676 '(26 . ps-header-title-font-size)
3677 '(26 . ps-footer-font-family)
3678 '(26 . ps-footer-font-size)
3679 '(26 . ps-line-number-color)
3680 '(26 . ps-line-number-font)
3681 '(26 . ps-line-number-font-size)
3682 '(26 . ps-line-spacing)
3683 '(26 . ps-paragraph-spacing)
3684 '(26 . ps-paragraph-regexp)
3685 '(26 . ps-begin-cut-regexp)
3686 '(26 . ps-end-cut-regexp)
3688 '(23 . ps-even-or-odd-pages)
3689 '(23 . ps-selected-pages)
3690 '(23 . ps-last-selected-pages)
3692 '(31 . ps-build-face-reference)
3693 '(31 . ps-always-build-face-reference)
3695 '(20 . ps-auto-font-detect)
3696 '(20 . ps-bold-faces)
3697 '(20 . ps-italic-faces)
3698 '(20 . ps-underlined-faces)
3699 '(20 . ps-black-white-faces)
3702 ;; ps-page-dimensions-database
3703 ;; ps-font-info-database
3705 ;;; ps-print - end of settings\n")
3713 (defun ps-print-quote (elt)
3720 `ps-prefix-quote' is used to form the string, if `ps-prefix-quote' is nil, it's
3724 * If `ps-prefix-quote' is nil:
3729 * If `ps-prefix-quote' is non-nil:
3734 If `ps-prefix-quote' is nil, it's set to t after generating string."
3744 (concat (if ps-prefix-quote
3746 (setq ps-prefix-quote t)
3752 (ps-value-string val))))
3757 (defun ps-value-string (val)
3758 "Return a string representation of VAL. Used by `ps-print-quote'."
3769 (defun ps-comment-string (str value)
3771 (format ";; %s = %s" str (ps-value-string value)))
3774 (defun ps-value (alist-sym key)
3779 (defun ps-get (alist-sym key)
3784 (defun ps-put (alist-sym key value)
3787 It can be retrieved with `(ps-get ALIST-SYM KEY)'."
3796 (defun ps-del (alist-sym key)
3812 (defun ps-time-stamp-locale-default ()
3817 (defun ps-time-stamp-mon-dd-yyyy ()
3822 (defun ps-time-stamp-yyyy-mm-dd ()
3827 ;; Alias for `ps-time-stamp-yyyy-mm-dd' (which see).
3828 (defalias 'ps-time-stamp-iso8601 'ps-time-stamp-yyyy-mm-dd)
3831 (defun ps-time-stamp-hh:mm:ss ()
3840 (setq ps-print-color-p nil))
3846 (defalias 'ps-color-device
3853 (eq (ps-x-device-class) 'color)))
3858 (ps-e-color-values "Green")
3862 (defun ps-mapper (extent list)
3864 (list (list (ps-x-extent-start-position extent) 'push extent)
3865 (list (ps-x-extent-end-position extent) 'pull extent)))
3868 (defun ps-extent-sorter (a b)
3869 (< (ps-x-extent-priority a) (ps-x-extent-priority b)))
3871 (defun ps-xemacs-face-kind-p (face kind kind-regex)
3872 (let* ((frame-font (or (ps-x-face-font-instance face)
3873 (ps-x-face-font-instance 'default)))
3875 (and frame-font
3877 (ps-x-font-instance-properties frame-font))))
3890 (or (ps-x-find-coding-system 'raw-text-unix)
3891 (ps-x-copy-coding-system 'no-conversion-unix 'raw-text-unix)))
3893 (defun ps-color-values (x-color)
3894 (let ((color (ps-xemacs-color-name x-color)))
3897 (ps-e-x-color-values color))
3899 (ps-color-device))
3900 (ps-x-color-instance-rgb-components
3901 (if (ps-x-color-instance-p x-color)
3903 (ps-x-make-color-instance color))))
3907 (defun ps-face-bold-p (face)
3908 (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
3909 (memq face ps-bold-faces))) ; Kludge-compatible
3911 (defun ps-face-italic-p (face)
3912 (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o")
3913 (ps-xemacs-face-kind-p face 'SLANT "i\\|o")
3914 (memq face ps-italic-faces))) ; Kludge-compatible
3919 (defun ps-color-values (x-color)
3922 (ps-e-color-values x-color))
3924 (ps-e-x-color-values x-color))
3928 (defun ps-face-bold-p (face)
3929 (or (ps-e-face-bold-p face)
3930 (memq face ps-bold-faces)))
3932 (defun ps-face-italic-p (face)
3933 (or (ps-e-face-italic-p face)
3934 (memq face ps-italic-faces)))
3938 (defvar ps-print-color-scale 1.0)
3940 (defun ps-color-scale (color)
3942 (mapcar #'(lambda (value) (/ value ps-print-color-scale))
3943 (ps-color-values color)))
3946 (defun ps-face-underlined-p (face)
3948 (memq face ps-underlined-faces)))
3951 (defun ps-prologue-file (filenumber)
3958 (expand-file-name (format "ps-prin%d.ps" filenumber)
3959 ps-postscript-code-directory))))
3965 (error "ps-print PostScript prologue `%s' file was not found"
3969 (defvar ps-mark-code-directory nil)
3971 (defvar ps-print-prologue-0 ""
3972 "ps-print PostScript error handler.")
3974 (defvar ps-print-prologue-1 ""
3975 "ps-print PostScript prologue.")
3979 (defvar ps-source-buffer nil)
3980 (defvar ps-spool-buffer-name "*PostScript*")
3981 (defvar ps-spool-buffer nil)
3983 (defvar ps-output-head nil)
3984 (defvar ps-output-tail nil)
3986 (defvar ps-page-postscript 0) ; page number
3987 (defvar ps-page-order 0) ; PostScript page counter
3988 (defvar ps-page-sheet 0) ; sheet counter
3989 (defvar ps-page-column 0) ; column counter
3990 (defvar ps-page-printed 0) ; total pages printed
3991 (defvar ps-page-n-up 0) ; n-up counter
3992 (defvar ps-lines-printed 0) ; total lines printed
3993 (defvar ps-showline-count 1) ; line number counter
3994 (defvar ps-first-page nil)
3995 (defvar ps-last-page nil)
3996 (defvar ps-print-page-p t)
3998 (defvar ps-control-or-escape-regexp nil)
3999 (defvar ps-n-up-on nil)
4001 (defvar ps-background-pages nil)
4002 (defvar ps-background-all-pages nil)
4003 (defvar ps-background-text-count 0)
4004 (defvar ps-background-image-count 0)
4006 (defvar ps-current-font 0)
4007 (defvar ps-default-foreground nil)
4008 (defvar ps-default-background nil)
4009 (defvar ps-default-color nil)
4010 (defvar ps-current-color nil)
4011 (defvar ps-current-bg nil)
4013 (defvar ps-zebra-stripe-full-p nil)
4014 (defvar ps-razchunk 0)
4016 (defvar ps-color-p nil)
4017 (defvar ps-color-format
4031 (defvar ps-header-pad 0
4035 (defvar ps-footer-pad 0
4041 (defmacro ps-page-dimensions-get-width (dims) `(nth 0 ,dims))
4042 (defmacro ps-page-dimensions-get-height (dims) `(nth 1 ,dims))
4043 (defmacro ps-page-dimensions-get-media (dims) `(nth 2 ,dims))
4045 (defvar ps-landscape-page-height nil)
4047 (defvar ps-print-width nil)
4048 (defvar ps-print-height nil)
4050 (defvar ps-height-remaining nil)
4051 (defvar ps-width-remaining nil)
4053 (defvar ps-font-size-internal nil)
4054 (defvar ps-header-font-size-internal nil)
4055 (defvar ps-header-title-font-size-internal nil)
4056 (defvar ps-footer-font-size-internal nil)
4057 (defvar ps-line-spacing-internal nil)
4058 (defvar ps-paragraph-spacing-internal nil)
4066 (defvar ps-black-white-faces-alist nil
4068 An element of this list has the same form as `ps-print-face-extension-alist'
4072 use `ps-extend-face' and `ps-extend-face-list'.
4073 See documentation for `ps-extend-face' for valid extension symbol.
4074 See also documentation for `ps-print-color-p'.")
4077 (defvar ps-print-face-extension-alist nil
4086 (see documentation for `ps-print-face-map-alist')
4091 use `ps-extend-face' and `ps-extend-face-list'.
4092 See documentation for `ps-extend-face' for valid extension symbol.")
4095 (defvar ps-print-face-alist nil
4099 `ps-print-face-extension-alist'.
4101 Don't change this list directly; this list is used by `ps-face-attributes',
4102 `ps-map-face' and `ps-build-reference-face-lists'.")
4105 (defconst ps-print-face-map-alist
4124 (defun ps-extend-face-list (face-extension-list &optional merge-p alist-sym)
4130 If optional ALIST-SYM is nil, `ps-print-face-extension-alist' is used;
4133 The elements in FACE-EXTENSION-LIST are like those for `ps-extend-face'.
4135 See `ps-extend-face' for documentation."
4137 (ps-extend-face (car face-extension-list) merge-p alist-sym)
4142 (defun ps-extend-face (face-extension &optional merge-p alist-sym)
4148 If optional ALIST-SYM is nil, `ps-print-face-extension-alist' is used;
4161 bold - use bold font.
4162 italic - use italic font.
4172 (setq alist-sym 'ps-print-face-extension-alist))
4176 (ps-face (cdr (assq face-name (symbol-value alist-sym))))
4177 (face-vector (or ps-face (vector 0 nil nil)))
4178 (face-bit (ps-extension-bit face-extension)))
4188 (or ps-face
4193 (defun ps-extension-bit (face-extension)
4200 ps-print-face-map-alist))
4207 ;; Adapted from font-lock: (obsolete stuff)
4208 ;; Originally face attributes were specified via `font-lock-face-attributes'.
4214 (defun ps-font-lock-face-attributes ()
4215 (and (boundp 'font-lock-mode) (symbol-value 'font-lock-mode)
4216 (boundp 'font-lock-face-attributes)
4217 (let ((face-attributes (symbol-value 'font-lock-face-attributes)))
4224 ;; `font-lock-face-attributes' entry.
4253 (defun ps-message-log-max ()
4259 (defvar ps-print-hook nil)
4260 (defvar ps-print-begin-sheet-hook nil)
4261 (defvar ps-print-begin-page-hook nil)
4262 (defvar ps-print-begin-column-hook nil)
4265 (defun ps-print-without-faces (from to &optional filename region-p)
4266 (ps-spool-without-faces from to region-p)
4267 (ps-do-despool filename))
4270 (defun ps-spool-without-faces (from to &optional region-p)
4271 (let ((message-log-max (ps-message-log-max))) ; to print *Messages* buffer
4272 (run-hooks 'ps-print-hook)
4273 (ps-printing-region region-p from to)
4274 (ps-generate (current-buffer) from to 'ps-generate-postscript)))
4277 (defun ps-print-with-faces (from to &optional filename region-p)
4278 (ps-spool-with-faces from to region-p)
4279 (ps-do-despool filename))
4282 (defun ps-spool-with-faces (from to &optional region-p)
4283 (let ((message-log-max (ps-message-log-max))) ; to print *Messages* buffer
4284 (run-hooks 'ps-print-hook)
4285 (ps-printing-region region-p from to)
4286 (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces)))
4289 (defun ps-count-lines-preprint (from to)
4292 (let ((message-log-max (ps-message-log-max))) ; to count lines of *Messages*
4296 (defun ps-count-lines (from to)
4303 (defvar ps-printing-region nil
4304 "Variable used to indicate the region that ps-print is printing.
4312 (defvar ps-printing-region-p nil
4313 "Non-nil means ps-print is printing a region.")
4316 (defun ps-printing-region (region-p from to)
4317 (setq ps-printing-region-p region-p
4318 ps-printing-region
4320 (ps-count-lines (point-min) (min from to))
4322 (ps-count-lines (point-min) (point-max)))))
4330 (defsubst ps-font-alist (font-sym)
4331 (get font-sym 'fonts))
4333 (defun ps-font (font-sym font-type)
4334 "Font family name for text of `font-type', when generating PostScript."
4335 (let* ((font-list (ps-font-alist font-sym))
4336 (normal-font (cdr (assq 'normal font-list))))
4337 (while (and font-list (not (eq font-type (car (car font-list)))))
4338 (setq font-list (cdr font-list)))
4339 (or (cdr (car font-list)) normal-font)))
4341 (defsubst ps-fonts (font-sym)
4342 (mapcar 'cdr (ps-font-alist font-sym)))
4344 (defsubst ps-font-number (font-sym font-type)
4345 (or (ps-alist-position font-type (ps-font-alist font-sym))
4348 (defsubst ps-line-height (font-sym)
4350 This is the value that ps-print uses to determine the height,
4353 The line-height is *not* the same as the point size of the font."
4354 (get font-sym 'line-height))
4356 (defsubst ps-title-line-height (font-sym)
4358 This is the value that ps-print uses to determine the height,
4361 The title-line-height is *not* the same as the point size of the font."
4362 (get font-sym 'title-line-height))
4364 (defsubst ps-space-width (font-sym)
4367 (get font-sym 'space-width))
4369 (defsubst ps-avg-char-width (font-sym)
4371 This is the value that ps-print uses to determine the length,
4374 (get font-sym 'avg-char-width))
4376 (defun ps-line-lengths-internal ()
4377 "Display the correspondence between a line length and a font size.
4378 Done using the current ps-print setup.
4380 (let* ((ps-font-size-internal
4381 (or ps-font-size-internal
4382 (ps-get-font-size 'ps-font-size)))
4383 (ps-header-font-size-internal
4384 (or ps-header-font-size-internal
4385 (ps-get-font-size 'ps-header-font-size)))
4386 (ps-header-title-font-size-internal
4387 (or ps-header-title-font-size-internal
4388 (ps-get-font-size 'ps-header-title-font-size)))
4390 (ifs ps-font-size-internal) ; initial font size
4391 (icw (ps-avg-char-width 'ps-font-for-text)) ; initial character width
4392 (print-width (progn (ps-get-page-dimensions)
4393 ps-print-width))
4394 (ps-setup (ps-setup)) ; setup for the current buffer
4395 (fs-min 5) ; minimum font size
4398 (fs-max 14) ; maximum font size
4401 fs ; current font size
4413 (insert ps-setup
4414 "\nnb char per line / font size\n")
4423 (defun ps-nb-pages (nb-lines)
4424 "Display correspondence between font size and the number of pages.
4426 and on the current ps-print setup."
4427 (let* ((ps-font-size-internal
4428 (or ps-font-size-internal
4429 (ps-get-font-size 'ps-font-size)))
4430 (ps-header-font-size-internal
4431 (or ps-header-font-size-internal
4432 (ps-get-font-size 'ps-header-font-size)))
4433 (ps-header-title-font-size-internal
4434 (or ps-header-title-font-size-internal
4435 (ps-get-font-size 'ps-header-title-font-size)))
4436 (ps-line-spacing-internal
4437 (or ps-line-spacing-internal
4438 (ps-get-size ps-line-spacing "line spacing")))
4440 (ils ps-line-spacing-internal) ; initial line spacing
4441 (ifs ps-font-size-internal) ; initial font size
4442 (ilh (ps-line-height 'ps-font-for-text)) ; initial line height
4443 (page-height (progn (ps-get-page-dimensions)
4444 ps-print-height))
4445 (ps-setup (ps-setup)) ; setup for the current buffer
4446 (fs-min 4) ; minimum font size
4450 (fs-max 14) ; maximum font size
4454 fs ; current font size
4469 (insert ps-setup
4471 "nb page / font size\n")
4481 ;; macros used in `ps-select-font'
4482 (defmacro ps-lookup (key) `(cdr (assq ,key font-entry)))
4483 (defmacro ps-size-scale (key) `(/ (* (ps-lookup ,key) font-size) size))
4485 (defun ps-select-font (font-family sym font-size title-font-size)
4486 (let ((font-entry (cdr (assq font-family ps-font-info-database))))
4487 (or font-entry
4488 (error "Don't have data to scale font %s. Known fonts families are %s"
4489 font-family
4490 (mapcar 'car ps-font-info-database)))
4491 (let ((size (ps-lookup 'size)))
4492 (put sym 'fonts (ps-lookup 'fonts))
4493 (put sym 'space-width (ps-size-scale 'space-width))
4494 (put sym 'avg-char-width (ps-size-scale 'avg-char-width))
4495 (put sym 'line-height (ps-size-scale 'line-height))
4497 (/ (* (ps-lookup 'line-height) title-font-size) size)))))
4499 (defun ps-get-page-dimensions ()
4500 (let ((page-dimensions (cdr (assq ps-paper-type ps-page-dimensions-database)))
4504 (error "`ps-paper-type' must be one of:\n%s"
4505 (mapcar 'car ps-page-dimensions-database)))
4506 ((< ps-number-of-columns 1)
4508 ps-number-of-columns)))
4510 (ps-select-font ps-font-family 'ps-font-for-text
4511 ps-font-size-internal ps-font-size-internal)
4512 (ps-select-font ps-header-font-family 'ps-font-for-header
4513 ps-header-font-size-internal
4514 ps-header-title-font-size-internal)
4515 (ps-select-font ps-footer-font-family 'ps-font-for-footer
4516 ps-footer-font-size-internal ps-footer-font-size-internal)
4518 (setq page-width (ps-page-dimensions-get-width page-dimensions)
4519 page-height (ps-page-dimensions-get-height page-dimensions))
4522 (if ps-landscape-mode
4527 (setq ps-landscape-page-height page-height)
4532 (setq ps-print-width (/ (- page-width
4533 ps-left-margin ps-right-margin
4534 (* (1- ps-number-of-columns) ps-inter-column))
4535 ps-number-of-columns))
4536 (if (<= ps-print-width 0)
4539 ps-left-margin == %s
4540 ps-right-margin == %s
4541 ps-inter-column == %s
4542 ps-number-of-columns == %s
4547 ps-left-margin
4548 ps-right-margin
4549 ps-inter-column
4550 ps-number-of-columns
4551 ps-print-width))
4553 (setq ps-print-height
4554 (- page-height ps-bottom-margin ps-top-margin))
4555 (if (<= ps-print-height 0)
4557 ps-top-margin == %s
4558 ps-bottom-margin == %s
4561 ps-top-margin
4562 ps-bottom-margin
4563 ps-print-height))
4566 (if ps-print-header
4567 (setq ps-header-pad (* ps-header-line-pad
4568 (ps-title-line-height 'ps-font-for-header))
4569 ps-print-height (- ps-print-height
4570 ps-header-offset
4571 ps-header-pad
4572 (ps-title-line-height 'ps-font-for-header)
4573 (* (ps-line-height 'ps-font-for-header)
4574 (1- ps-header-lines))
4575 ps-header-pad)))
4576 (if (<= ps-print-height 0)
4578 ps-top-margin == %s
4579 ps-bottom-margin == %s
4580 ps-header-offset == %s
4581 ps-header-pad == %s
4585 ps-top-margin
4586 ps-bottom-margin
4587 ps-header-offset
4588 ps-header-pad
4589 (+ ps-header-pad
4590 (ps-title-line-height 'ps-font-for-header)
4591 (* (ps-line-height 'ps-font-for-header)
4592 (1- ps-header-lines))
4593 ps-header-pad)
4594 ps-print-height))
4597 (if ps-print-footer
4598 (setq ps-footer-pad (* ps-footer-line-pad
4599 (ps-title-line-height 'ps-font-for-footer))
4600 ps-print-height (- ps-print-height
4601 ps-footer-offset
4602 ps-footer-pad
4603 (* (ps-line-height 'ps-font-for-footer)
4604 (1- ps-footer-lines))
4605 ps-footer-pad)))
4606 (if (<= ps-print-height 0)
4608 ps-top-margin == %s
4609 ps-bottom-margin == %s
4610 ps-footer-offset == %s
4611 ps-footer-pad == %s
4615 ps-top-margin
4616 ps-bottom-margin
4617 ps-footer-offset
4618 ps-footer-pad
4619 (+ ps-footer-pad
4620 (* (ps-line-height 'ps-font-for-footer)
4621 (1- ps-footer-lines))
4622 ps-footer-pad)
4623 ps-print-height))
4624 ;; ps-zebra-stripe-follow is `full' or `full-follow'
4625 (if ps-zebra-stripe-full-p
4626 (let* ((line-height (ps-line-height 'ps-font-for-text))
4627 (zebra (* (+ line-height ps-line-spacing-internal)
4628 ps-zebra-stripe-height)))
4629 (setq ps-print-height (- (* (floor ps-print-height zebra) zebra)
4631 (if (<= ps-print-height 0)
4633 ps-zebra-stripe-follow == %s
4634 ps-zebra-stripe-height == %s
4635 font-text-height == %s
4639 ps-zebra-stripe-follow
4640 ps-zebra-stripe-height
4641 (ps-line-height 'ps-font-for-text)
4642 ps-line-spacing-internal
4643 ps-print-height))))))
4646 (defun ps-print-preprint-region (prefix-arg)
4647 (or (ps-mark-active-p)
4649 (list (point) (mark) (ps-print-preprint prefix-arg)))
4652 (defun ps-print-preprint (prefix-arg)
4658 ".ps"))
4681 ;; that ps-print doesn't have to repeatedly switch between buffers
4682 ;; while spooling. The functions `ps-output' and `ps-output-string' build
4683 ;; up the lists; the function `ps-flush-output' takes the lists and
4686 (defvar ps-string-escape-codes
4714 (defsubst ps-output-string-prim (string)
4725 (aref ps-string-escape-codes special)
4732 (defsubst ps-init-output-queue ()
4733 (setq ps-output-head (list "")
4734 ps-output-tail ps-output-head))
4737 (defun ps-selected-pages ()
4739 (setq ps-first-page (car (car ps-selected-pages))
4740 ps-last-page (cdr (car ps-selected-pages))
4741 ps-selected-pages (cdr ps-selected-pages))
4742 (and ps-selected-pages
4743 (< ps-last-page ps-page-postscript)))))
4746 (defsubst ps-print-page-p ()
4747 (setq ps-print-page-p
4748 (and (cond ((null ps-first-page))
4749 ((<= ps-page-postscript ps-last-page)
4750 (<= ps-first-page ps-page-postscript))
4751 (ps-selected-pages
4752 (ps-selected-pages)
4753 (and (<= ps-first-page ps-page-postscript)
4754 (<= ps-page-postscript ps-last-page)))
4757 (cond ((eq ps-even-or-odd-pages 'even-page)
4758 (= (logand ps-page-postscript 1) 0))
4759 ((eq ps-even-or-odd-pages 'odd-page)
4760 (= (logand ps-page-postscript 1) 1))
4765 (defsubst ps-print-sheet-p ()
4766 (setq ps-print-page-p
4767 (cond ((eq ps-even-or-odd-pages 'even-sheet)
4768 (= (logand ps-page-sheet 1) 0))
4769 ((eq ps-even-or-odd-pages 'odd-sheet)
4770 (= (logand ps-page-sheet 1) 1))
4775 (defun ps-output (&rest args)
4776 (when ps-print-page-p
4777 (setcdr ps-output-tail args)
4778 (while (cdr ps-output-tail)
4779 (setq ps-output-tail (cdr ps-output-tail)))))
4781 (defun ps-output-string (string)
4782 (ps-output t string))
4785 (defun ps-output-prologue (args)
4786 (ps-output 'prologue (if (stringp args) (list args) args)))
4788 (defun ps-flush-output ()
4790 (set-buffer ps-spool-buffer)
4792 (while ps-output-head
4793 (let ((it (car ps-output-head)))
4796 (setq ps-output-head (cdr ps-output-head))
4797 (ps-output-string-prim (car ps-output-head)))
4799 (setq ps-output-head (cdr ps-output-head))
4803 (apply 'insert (car ps-output-head))))
4806 (setq ps-output-head (cdr ps-output-head))))
4807 (ps-init-output-queue))
4809 (defun ps-insert-file (fname)
4810 (ps-flush-output)
4812 (set-buffer ps-spool-buffer)
4816 ;; These functions are used in `ps-mule' to get charset of header and footer.
4817 ;; To avoid unnecessary calls to functions in `ps-left-header',
4818 ;; `ps-right-header', `ps-left-footer' and `ps-right-footer'.
4820 (defun ps-generate-string-list (content)
4840 (defvar ps-lh-cache nil)
4841 (defvar ps-rh-cache nil)
4842 (defvar ps-lf-cache nil)
4843 (defvar ps-rf-cache nil)
4845 (defun ps-header-footer-string ()
4846 (and ps-print-header
4847 (setq ps-lh-cache (ps-generate-string-list ps-left-header)
4848 ps-rh-cache (ps-generate-string-list ps-right-header)))
4849 (and ps-print-footer
4850 (setq ps-lf-cache (ps-generate-string-list ps-left-footer)
4851 ps-rf-cache (ps-generate-string-list ps-right-footer)))
4852 (append ps-lh-cache ps-rh-cache ps-lf-cache ps-rf-cache))
4856 (defun ps-generate-header-line (fonttag &optional content)
4857 (ps-output " [" fonttag " ")
4862 (ps-output (ps-mule-encode-header-string content fonttag)))
4867 (ps-output-string (ps-mule-encode-header-string (funcall content)
4873 (ps-output-string (ps-mule-encode-header-string (symbol-value content)
4878 (ps-output-string "")))
4879 (ps-output "]\n"))
4881 (defun ps-generate-header (name fonttag0 fonttag1 contents)
4882 (ps-output "/" name "[\n")
4883 (and contents (> ps-header-lines 0)
4885 (ps-generate-header-line fonttag0 (car contents))
4886 (while (and (< count ps-header-lines)
4888 (ps-generate-header-line fonttag1 (car contents))
4890 (ps-output "]def\n"))
4893 (defun ps-output-boolean (name bool)
4894 (ps-output (format "/%s %s def\n" name (if bool "true" "false"))))
4897 (defun ps-output-frame-properties (name alist)
4898 (ps-output "/" name " ["
4899 (ps-format-color (cdr (assq 'fore-color alist)) 0.0)
4900 (ps-format-color (cdr (assq 'back-color alist)) 0.9)
4901 (ps-float-format (or (cdr (assq 'border-width alist)) 0.4))
4902 (ps-format-color (cdr (assq 'border-color alist)) 0.0)
4903 (ps-format-color (cdr (assq 'shadow-color alist)) 0.0)
4907 (defun ps-background-pages (page-list func)
4914 (add-to-list 'ps-background-pages (vector start end func)))))
4916 (setq ps-background-all-pages (cons func ps-background-all-pages))))
4919 (defconst ps-boundingbox-re
4924 (defun ps-get-boundingbox ()
4926 (set-buffer ps-spool-buffer)
4928 (if (re-search-forward ps-boundingbox-re nil t)
4944 (defvar ps-float-format (if (featurep 'xemacs)
4949 (defun ps-float-format (value &optional default)
4954 (format ps-float-format (* literal 1.0))) ; force float number
4960 (defun ps-background-text ()
4963 (setq ps-background-text-count (1+ ps-background-text-count))
4964 (ps-output (format "/ShowBackText-%d{\n" ps-background-text-count))
4965 (ps-output-string (nth 0 text)) ; text
4966 (ps-output
4968 (ps-float-format (nth 4 text) 200.0) ; font size
4969 (format "/%s " (or (nth 3 text) "Times-Roman")) ; font name
4970 (ps-float-format (nth 6 text)
4972 (ps-float-format (nth 5 text) 0.85) ; gray
4973 (ps-float-format (nth 1 text) "0") ; x position
4974 (ps-float-format (nth 2 text) "0") ; y position
4976 (ps-background-pages (nthcdr 7 text) ; page list
4978 ps-background-text-count)))
4979 ps-print-background-text))
4982 (defun ps-background-image ()
4987 (setq ps-background-image-count (1+ ps-background-image-count))
4988 (ps-output
4990 ps-background-image-count)
4991 (ps-float-format (nth 5 image) 0.0) ; rotation
4992 (ps-float-format (nth 3 image) 1.0) ; x scale
4993 (ps-float-format (nth 4 image) 1.0) ; y scale
4994 (ps-float-format (nth 1 image) ; x position
4996 (ps-float-format (nth 2 image) ; y position
4999 (ps-insert-file image-file)
5002 (let ((box (ps-get-boundingbox)))
5004 (set-buffer ps-spool-buffer)
5009 (ps-float-format
5012 (ps-float-format
5016 (ps-output "\nEndBackImage}def\n")
5017 (ps-background-pages (nthcdr 6 image) ; page list
5019 ps-background-image-count)))))
5020 ps-print-background-image))
5023 (defun ps-background (page-number)
5029 (ps-output (aref range 2))
5031 (ps-output "/printLocalBackground{\n"
5033 ps-background-pages)
5034 (and has-local-background (ps-output "}def\n"))))
5039 (defun ps-remove-duplicates (list)
5051 (defun ps-alist-position (item list)
5061 (defconst ps-n-up-database
5347 "Alist which is the page matrix database used for N-up printing.
5356 PAGE is the page size used (see `ps-paper-type').
5368 (defmacro ps-n-up-landscape (mat) `(nth 1 ,mat))
5369 (defmacro ps-n-up-lines (mat) `(nth 2 ,mat))
5370 (defmacro ps-n-up-columns (mat) `(nth 3 ,mat))
5371 (defmacro ps-n-up-missing (mat) `(nth 4 ,mat))
5374 (defun ps-n-up-printing ()
5375 ;; force `ps-n-up-printing' be in range 1 to 100.
5376 (setq ps-n-up-printing (max (min ps-n-up-printing 100) 1))
5377 ;; find suitable page matrix for a given `ps-paper-type'.
5378 (let ((the-list (cdr (assq ps-paper-type ps-n-up-database))))
5380 (while (> ps-n-up-printing (caar the-list))
5385 (defconst ps-n-up-filling-database
5465 KIND is a valid value of `ps-n-up-filling'.
5474 (defun ps-n-up-filling ()
5475 (cdr (or (assq ps-n-up-filling ps-n-up-filling-database)
5476 (assq 'left-top ps-n-up-filling-database))))
5479 (defmacro ps-n-up-xcolumn (init) `(nth 0 ,init))
5480 (defmacro ps-n-up-ycolumn (init) `(nth 1 ,init))
5481 (defmacro ps-n-up-xline (init) `(nth 2 ,init))
5482 (defmacro ps-n-up-yline (init) `(nth 3 ,init))
5483 (defmacro ps-n-up-repeat (init) `(nth 4 ,init))
5484 (defmacro ps-n-up-end (init) `(nth 5 ,init))
5485 (defmacro ps-n-up-xstart (init) `(nth 6 ,init))
5486 (defmacro ps-n-up-ystart (init) `(nth 7 ,init))
5489 (defconst ps-error-handler-alist
5497 (defconst ps-zebra-stripe-alist
5504 (defun ps-begin-file ()
5505 (setq ps-page-order 0
5506 ps-page-printed 0
5507 ps-background-text-count 0
5508 ps-background-image-count 0
5509 ps-background-pages nil
5510 ps-background-all-pages nil)
5512 (let ((dimensions (cdr (assq ps-paper-type ps-page-dimensions-database)))
5513 (tumble (if ps-landscape-mode (not ps-spool-tumble) ps-spool-tumble))
5514 (n-up (ps-n-up-printing))
5515 (n-up-filling (ps-n-up-filling)))
5516 (and ps-n-up-on (setq tumble (not tumble)))
5517 (ps-output
5518 ps-adobe-tag
5521 "\n%%Creator: ps-print v" ps-print-version
5525 (if ps-landscape-mode "Landscape" "Portrait")
5526 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font "
5528 (ps-remove-duplicates
5529 (append (ps-fonts 'ps-font-for-text)
5530 (list (ps-font 'ps-font-for-header 'normal)
5531 (ps-font 'ps-font-for-header 'bold)
5532 (ps-font 'ps-font-for-footer 'normal)
5533 (ps-font 'ps-font-for-footer 'bold))))
5534 "\n%%+ font ")
5536 "\n%%DocumentMedia: " (ps-page-dimensions-get-media dimensions)
5537 (format " %d" (round (ps-page-dimensions-get-width dimensions)))
5538 (format " %d" (round (ps-page-dimensions-get-height dimensions)))
5540 (if ps-spool-duplex
5544 (ps-insert-string ps-print-prologue-header)
5546 (ps-output "%%EndComments\n%%BeginDefaults\n%%PageMedia: "
5547 (ps-page-dimensions-get-media dimensions)
5551 (or (cdr (assoc ps-error-handler-message
5552 ps-error-handler-alist))
5554 ps-print-prologue-0
5557 (ps-insert-string ps-user-defined-prologue)
5559 (ps-output "\n%%EndResource\n\n")
5561 (ps-output-boolean "LandscapeMode "
5562 (or ps-landscape-mode
5563 (eq (ps-n-up-landscape n-up) 'pag)))
5564 (ps-output-boolean "UpsideDown " ps-print-upside-down)
5565 (ps-output (format "/NumberOfColumns %d def\n" ps-number-of-columns)
5567 (format "/LandscapePageHeight %s def\n" ps-landscape-page-height)
5569 (- (* (+ ps-print-width ps-inter-column)
5570 ps-number-of-columns)
5571 ps-inter-column))
5572 (format "/PrintWidth %s def\n" ps-print-width)
5573 (format "/PrintHeight %s def\n" ps-print-height)
5575 (format "/LeftMargin %s def\n" ps-left-margin)
5576 (format "/RightMargin %s def\n" ps-right-margin)
5577 (format "/InterColumn %s def\n" ps-inter-column)
5579 (format "/BottomMargin %s def\n" ps-bottom-margin)
5580 (format "/TopMargin %s def\n" ps-top-margin) ; not used
5581 (format "/HeaderOffset %s def\n" ps-header-offset)
5582 (format "/HeaderPad %s def\n" ps-header-pad)
5583 (format "/FooterOffset %s def\n" ps-footer-offset)
5584 (format "/FooterPad %s def\n" ps-footer-pad)
5585 (format "/FooterLines %s def\n" ps-footer-lines))
5587 (ps-output-boolean "ShowNofN " ps-show-n-of-n)
5588 (ps-output-boolean "SwitchHeader " (if (eq ps-switch-header 'duplex)
5589 ps-spool-duplex
5590 ps-switch-header))
5591 (ps-output-boolean "PrintOnlyOneHeader" ps-print-only-one-header)
5592 (ps-output-boolean "PrintHeader " ps-print-header)
5593 (ps-output-boolean "PrintHeaderFrame " ps-print-header-frame)
5594 (ps-output-frame-properties "HeaderFrameProperties" ps-header-frame-alist)
5595 (ps-output-boolean "PrintFooter " ps-print-footer)
5596 (ps-output-boolean "PrintFooterFrame " ps-print-footer-frame)
5597 (ps-output-frame-properties "FooterFrameProperties" ps-footer-frame-alist)
5599 (let ((line-height (ps-line-height 'ps-font-for-text)))
5600 (ps-output (format "/LineSpacing %s def\n" ps-line-spacing-internal)
5602 ps-paragraph-spacing-internal)
5606 ps-line-spacing-internal)))
5607 (round (/ (+ ps-print-height
5611 (ps-output-boolean "WarnPaperSize " ps-warn-paper-type)
5612 (ps-output-boolean "Zebra " ps-zebra-stripes)
5613 (ps-output-boolean "PrintLineNumber " ps-line-number)
5614 (ps-output-boolean "SyncLineZebra " (not (integerp ps-line-number-step)))
5615 (ps-output (format "/ZebraFollow %d def\n"
5616 (or (cdr (assq ps-zebra-stripe-follow
5617 ps-zebra-stripe-alist))
5620 (if (integerp ps-line-number-step)
5621 ps-line-number-step
5622 ps-zebra-stripe-height))
5623 (format "/PrintLineStart %d def\n" ps-line-number-start)
5625 (ps-format-color ps-line-number-color 0.0)
5627 ps-zebra-stripe-height)
5629 (ps-format-color ps-zebra-color 0.95)
5631 (ps-format-color ps-default-background 1.0)
5633 (if (eq ps-spool-config 'setpagedevice)
5638 (format "/N-Up %d def\n" ps-n-up-printing))
5639 (ps-output-boolean "N-Up-Landscape" (eq (ps-n-up-landscape n-up) t))
5640 (ps-output-boolean "N-Up-Border " ps-n-up-border-p)
5641 (ps-output (format "/N-Up-Lines %d def\n" (ps-n-up-lines n-up))
5642 (format "/N-Up-Columns %d def\n" (ps-n-up-columns n-up))
5643 (format "/N-Up-Missing %d def\n" (ps-n-up-missing n-up))
5644 (format "/N-Up-Margin %s def\n" ps-n-up-margin)
5646 (if ps-landscape-mode
5647 (ps-n-up-end n-up-filling)
5648 (ps-n-up-repeat n-up-filling))
5650 (if ps-landscape-mode
5651 (ps-n-up-repeat n-up-filling)
5652 (ps-n-up-end n-up-filling))
5653 " def\n/N-Up-XColumn " (ps-n-up-xcolumn n-up-filling)
5654 " def\n/N-Up-YColumn " (ps-n-up-ycolumn n-up-filling)
5655 " def\n/N-Up-XLine " (ps-n-up-xline n-up-filling)
5656 " def\n/N-Up-YLine " (ps-n-up-yline n-up-filling)
5657 " def\n/N-Up-XStart " (ps-n-up-xstart n-up-filling)
5658 " def\n/N-Up-YStart " (ps-n-up-ystart n-up-filling) " def\n")
5660 (ps-background-text)
5661 (ps-background-image)
5662 (setq ps-background-all-pages (nreverse ps-background-all-pages)
5663 ps-background-pages (nreverse ps-background-pages))
5665 (ps-output "\n" ps-print-prologue-1
5667 (mapcar 'ps-output ps-background-all-pages)
5668 (ps-output
5671 "\n%%IncludeResource: font Times-Roman"
5672 "\n%%IncludeResource: font Times-Italic"
5673 "\n%%IncludeResource: font "
5675 (ps-remove-duplicates
5676 (append (ps-fonts 'ps-font-for-text)
5677 (list (ps-font 'ps-font-for-header 'normal)
5678 (ps-font 'ps-font-for-header 'bold)
5679 (ps-font 'ps-font-for-footer 'normal)
5680 (ps-font 'ps-font-for-footer 'bold))))
5681 "\n%%IncludeResource: font ")
5684 ps-header-title-font-size-internal
5685 (ps-font 'ps-font-for-header 'bold))
5687 ps-header-font-size-internal
5688 (ps-font 'ps-font-for-header 'normal))
5690 (ps-get-font-size 'ps-line-number-font-size)
5691 ps-line-number-font)
5693 ps-footer-font-size-internal
5694 (ps-font 'ps-font-for-footer 'normal))
5711 (let ((font (ps-font-alist 'ps-font-for-text))
5713 (while font
5714 (ps-output (format "/f%d %s(%s)cvn DefFont\n"
5716 ps-font-size-internal
5717 (ps-font 'ps-font-for-text (car (car font)))))
5718 (setq font (cdr font)
5721 (let ((font-entry (cdr (assq ps-font-family ps-font-info-database))))
5722 (ps-output (format "/SpaceWidthRatio %f def\n"
5723 (/ (ps-lookup 'space-width) (ps-lookup 'size)))))
5725 (unless (eq ps-spool-config 'lpr-switches)
5726 (ps-output "\n%%BeginFeature: *Duplex "
5727 (ps-boolean-capitalized ps-spool-duplex)
5729 (ps-boolean-capitalized tumble)
5731 (ps-boolean-constant ps-spool-duplex)
5733 (ps-boolean-constant tumble)
5735 (ps-boolean-constant ps-spool-duplex)
5737 (ps-boolean-constant tumble)
5739 (ps-output "\n%%BeginFeature: *ManualFeed "
5740 (ps-boolean-capitalized ps-manual-feed)
5742 (ps-boolean-constant ps-manual-feed)
5744 (and ps-banner-page-when-duplexing
5745 (ps-output "\n%%Page: banner 0\nsave showpage restore\n")))
5748 (defun ps-format-color (color &optional default)
5750 (ps-color-scale color)
5754 (format ps-color-format
5759 (ps-float-format (if (numberp the-color) the-color default)))))
5762 (defun ps-insert-string (prologue)
5767 (ps-output str))))
5770 (defun ps-boolean-capitalized (bool)
5774 (defun ps-boolean-constant (bool)
5778 (defun ps-header-dirpart ()
5787 (defun ps-get-buffer-name ()
5790 ((string= (buffer-name) "ps-print.el")
5791 "Hey, Cool! It's ps-print.el!!!")
5796 (and ps-printing-region-p "Subset of: ")
5801 (defun ps-get-size (size mess &optional arg)
5807 (if ps-landscape-mode
5821 (defun ps-get-font-size (font-sym)
5822 (ps-get-size (symbol-value font-sym) "font size" font-sym))
5825 (defun ps-rgb-color (color unspecified default)
5842 (ps-color-scale color))
5848 (defun ps-begin-job (genfunc)
5850 (or (equal ps-mark-code-directory ps-postscript-code-directory)
5851 (setq ps-print-prologue-0 (ps-prologue-file 0)
5852 ps-print-prologue-1 (ps-prologue-file 1)
5853 ps-mark-code-directory ps-postscript-code-directory))
5856 (while ps-selected-pages
5857 (setq page (car ps-selected-pages)
5858 ps-selected-pages (cdr ps-selected-pages))
5867 (setq ps-selected-pages (sort new #'(lambda (one other)
5869 ps-last-selected-pages ps-selected-pages
5870 ps-first-page nil
5871 ps-last-page nil))
5873 (or (listp ps-use-face-background)
5874 (setq ps-use-face-background t))
5876 (and (integerp ps-line-number-step)
5877 (<= ps-line-number-step 0)
5878 (setq ps-line-number-step 1))
5879 (setq ps-n-up-on (> ps-n-up-printing 1)
5880 ps-line-number-start (max 1 (min ps-line-number-start
5881 (if (integerp ps-line-number-step)
5882 ps-line-number-step
5883 ps-zebra-stripe-height))))
5886 (set-buffer ps-spool-buffer)
5891 (setq ps-zebra-stripe-full-p (memq ps-zebra-stripe-follow
5893 ps-page-postscript 0
5894 ps-page-sheet 0
5895 ps-page-n-up 0
5896 ps-page-column 0
5897 ps-lines-printed 0
5898 ps-print-page-p t
5899 ps-showline-count (car ps-printing-region)
5900 ps-line-spacing-internal (ps-get-size ps-line-spacing
5902 ps-paragraph-spacing-internal (ps-get-size ps-paragraph-spacing
5904 ps-font-size-internal (ps-get-font-size 'ps-font-size)
5905 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size)
5906 ps-header-title-font-size-internal
5907 (ps-get-font-size 'ps-header-title-font-size)
5908 ps-footer-font-size-internal (ps-get-font-size 'ps-footer-font-size)
5909 ps-control-or-escape-regexp
5910 (cond ((eq ps-print-control-characters '8-bit)
5912 ((eq ps-print-control-characters 'control-8-bit)
5914 ((eq ps-print-control-characters 'control)
5917 ps-default-background (ps-rgb-color
5919 ((eq genfunc 'ps-generate-postscript)
5921 ((eq ps-default-bg 'frame-parameter)
5922 (ps-frame-parameter nil 'background-color))
5923 ((eq ps-default-bg t)
5924 (ps-face-background-name 'default))
5926 ps-default-bg))
5929 ps-default-foreground (ps-rgb-color
5931 ((eq genfunc 'ps-generate-postscript)
5933 ((eq ps-default-fg 'frame-parameter)
5934 (ps-frame-parameter nil 'foreground-color))
5935 ((eq ps-default-fg t)
5936 (ps-face-foreground-name 'default))
5938 ps-default-fg))
5941 ps-default-color (and (eq ps-print-color-p t) ps-default-foreground)
5942 ps-current-color ps-default-color
5944 ;; that ps-print can be dumped into emacs. This expression can't be
5946 ps-color-p (and ps-print-color-p (ps-color-device))
5947 ps-print-color-scale (if ps-color-p
5948 (float (car (ps-color-values "white")))
5951 (ps-get-page-dimensions)
5953 (and ps-color-p
5954 (equal ps-default-background ps-default-foreground)
5957 "`ps-default-fg' and `ps-default-bg' have the same color.\n"
5961 (defun ps-page-number ()
5962 (if ps-print-only-one-header
5963 (1+ (/ (1- ps-page-column) ps-number-of-columns))
5964 ps-page-column))
5967 (defsubst ps-end-page ()
5968 (ps-output "EndPage\nEndDSCPage\n"))
5971 (defsubst ps-next-page ()
5972 (ps-end-page)
5973 (ps-flush-output)
5974 (ps-begin-page))
5977 (defun ps-end-sheet ()
5978 (and ps-print-page-p (> ps-page-sheet 0)
5979 (ps-output "EndSheet\n")))
5982 (defun ps-header-sheet ()
5984 (ps-end-sheet)
5985 (setq ps-page-sheet (1+ ps-page-sheet))
5986 (when (ps-print-sheet-p)
5987 (setq ps-page-order (1+ ps-page-order))
5988 (ps-output (if ps-n-up-on
5990 ps-page-order ps-page-postscript ps-page-order)
5992 ps-page-postscript ps-page-order))
5996 ps-n-up-printing))))
5999 (defun ps-header-page ()
6001 ;; (see `ps-generate')
6002 (if (zerop (mod ps-page-column ps-number-of-columns))
6004 (setq ps-page-postscript (1+ ps-page-postscript))
6005 (when (ps-print-page-p)
6006 (ps-print-sheet-p)
6007 (if (zerop (mod ps-page-n-up ps-n-up-printing))
6010 (ps-header-sheet)
6011 (run-hooks 'ps-print-begin-sheet-hook))
6013 (ps-output "BeginDSCPage\n")
6014 (run-hooks 'ps-print-begin-page-hook))
6015 (ps-background ps-page-postscript)
6016 (setq ps-page-n-up (1+ ps-page-n-up))
6017 (and ps-print-page-p
6018 (setq ps-page-printed (1+ ps-page-printed)))))
6020 (ps-output "BeginDSCPage\n")
6021 (run-hooks 'ps-print-begin-column-hook))
6022 (setq ps-page-column (1+ ps-page-column)))
6024 (defun ps-begin-page ()
6025 (setq ps-width-remaining ps-print-width
6026 ps-height-remaining ps-print-height)
6028 (ps-header-page)
6030 (ps-output (format "/LineNumber %d def\n" ps-showline-count)
6031 (format "/PageNumber %d def\n" (ps-page-number)))
6033 (when ps-print-header
6034 (ps-generate-header "HeaderLinesLeft" "/h0" "/h1"
6035 (or ps-lh-cache ps-left-header))
6036 (ps-generate-header "HeaderLinesRight" "/h0" "/h1"
6037 (or ps-rh-cache ps-right-header))
6038 (ps-output (format "%d SetHeaderLines\n" ps-header-lines))
6039 (setq ps-lh-cache nil
6040 ps-rh-cache nil))
6042 (when ps-print-footer
6043 (ps-generate-header "FooterLinesLeft" "/H0" "/H0"
6044 (or ps-lf-cache ps-left-footer))
6045 (ps-generate-header "FooterLinesRight" "/H0" "/H0"
6046 (or ps-rf-cache ps-right-footer))
6047 (ps-output (format "%d SetFooterLines\n" ps-footer-lines))
6048 (setq ps-lf-cache nil
6049 ps-rf-cache nil))
6051 (ps-output (number-to-string ps-lines-printed) " BeginPage\n")
6052 (ps-set-font ps-current-font)
6053 (ps-set-bg ps-current-bg)
6054 (ps-set-color ps-current-color)
6055 (ps-mule-begin-page))
6057 (defsubst ps-skip-newline (limit)
6058 (setq ps-showline-count (1+ ps-showline-count)
6059 ps-lines-printed (1+ ps-lines-printed))
6063 (defsubst ps-next-line ()
6064 (setq ps-showline-count (1+ ps-showline-count)
6065 ps-lines-printed (1+ ps-lines-printed))
6066 (let* ((paragraph-p (and ps-paragraph-regexp
6067 (looking-at ps-paragraph-regexp)))
6068 (lh (+ (ps-line-height 'ps-font-for-text)
6070 ps-paragraph-spacing-internal
6071 ps-line-spacing-internal))))
6072 (if (< ps-height-remaining lh)
6073 (ps-next-page)
6074 (setq ps-width-remaining ps-print-width
6075 ps-height-remaining (- ps-height-remaining lh))
6076 (ps-output (if paragraph-p "PHL\n" "LHL\n")))))
6078 (defun ps-continue-line ()
6079 (setq ps-lines-printed (1+ ps-lines-printed))
6080 (let ((lh (+ (ps-line-height 'ps-font-for-text) ps-line-spacing-internal)))
6081 (if (< ps-height-remaining lh)
6082 (ps-next-page)
6083 (setq ps-width-remaining ps-print-width
6084 ps-height-remaining (- ps-height-remaining lh))
6085 (ps-output "SL\n"))))
6087 (defun ps-find-wrappoint (from to char-width)
6088 (let ((avail (truncate (/ ps-width-remaining char-width)))
6092 (cons (+ from avail) ps-width-remaining))))
6094 (defun ps-basic-plot-str (from to string)
6095 (let* ((wrappoint (ps-find-wrappoint from to
6096 (ps-avg-char-width 'ps-font-for-text)))
6099 (ps-mule-prepare-ascii-font str)
6100 (ps-output-string str)
6101 (ps-output " S\n")
6104 (defun ps-basic-plot-string (from to &optional bg-color)
6105 (let* ((wrappoint (ps-find-wrappoint from to
6106 (ps-avg-char-width 'ps-font-for-text)))
6109 (ps-mule-prepare-ascii-font string)
6110 (ps-output-string string)
6111 (ps-output " S\n")
6114 (defun ps-basic-plot-whitespace (from to &optional bg-color)
6115 (let* ((wrappoint (ps-find-wrappoint from to
6116 (ps-space-width 'ps-font-for-text)))
6118 (ps-output (format "%d W\n" (- to from)))
6121 (defun ps-plot (plotfunc from to &optional bg-color)
6127 ps-width-remaining (- ps-width-remaining plotted-width))
6129 (ps-continue-line))))
6130 (if ps-razzle-dazzle
6135 (if (> (- q-done ps-razchunk) chunksize)
6137 (setq ps-razchunk q-done)
6144 (defvar ps-last-font nil)
6146 (defun ps-set-font (font)
6147 (setq ps-last-font (format "f%d" (setq ps-current-font font)))
6148 (ps-output (format "/%s F\n" ps-last-font)))
6150 (defun ps-set-bg (color)
6151 (if (setq ps-current-bg color)
6152 (ps-output (format ps-color-format
6155 (ps-output "false BG\n")))
6157 (defun ps-set-color (color)
6158 (setq ps-current-color (or color ps-default-foreground))
6159 (ps-output (format ps-color-format
6160 (nth 0 ps-current-color)
6161 (nth 1 ps-current-color) (nth 2 ps-current-color))
6165 (defsubst ps-plot-string (string)
6166 (ps-plot 'ps-basic-plot-str 0 (length string) string))
6169 (defvar ps-current-effect 0)
6171 (defvar ps-print-translation-table
6185 (defun ps-plot-region (from to font &optional fg-color bg-color effects)
6186 (or (equal font ps-current-font)
6187 (ps-set-font font))
6191 (let ((fg (or fg-color ps-default-foreground)))
6192 (or (equal fg ps-current-color)
6193 (ps-set-color fg)))
6195 (or (equal bg-color ps-current-bg)
6196 (ps-set-bg bg-color))
6201 (ps-output "0 EF\n")
6202 (setq ps-current-effect 0))
6203 ((/= effects ps-current-effect)
6204 (ps-output (number-to-string effects) " EF\n")
6205 (setq ps-current-effect effects)))
6215 (and ps-begin-cut-regexp ps-end-cut-regexp
6216 (looking-at ps-begin-cut-regexp)
6219 (and (re-search-forward ps-end-cut-regexp to 'noerror)
6223 (if (re-search-forward ps-control-or-escape-regexp to t)
6227 (composition (ps-e-find-composition from (1+ match-point))))
6237 (ps-mule-set-ascii-font)
6238 (ps-plot 'ps-basic-plot-string from match-point bg-color))
6245 (ps-mule-set-ascii-font)
6246 (ps-plot 'ps-basic-plot-whitespace
6254 (ps-skip-newline to)
6255 (ps-next-page))
6258 (ps-next-line)))
6264 (= ps-height-remaining ps-print-height))
6267 (ps-skip-newline to))
6268 (ps-next-page)))
6271 (ps-plot 'ps-mule-plot-composition match-point (point) bg-color))
6274 (setq match (or (aref ps-print-translation-table match) match))
6276 (composition (ps-e-find-composition match-point to))
6282 (or (aref ps-print-translation-table ch)
6286 (ps-plot 'ps-mule-plot-string match-point (point) bg-color)))
6289 (ps-control-character match)))
6292 (ps-mule-set-ascii-font)
6293 (ps-plot 'ps-basic-plot-string from to bg-color)
6296 (defvar ps-string-control-codes
6315 (defun ps-control-character (char)
6316 (let* ((str (aref ps-string-control-codes char))
6320 (char-width (ps-avg-char-width 'ps-font-for-text))
6321 (wrappoint (ps-find-wrappoint from to char-width)))
6323 (ps-continue-line))
6324 (setq ps-width-remaining (- ps-width-remaining (* len char-width)))
6325 (ps-mule-prepare-ascii-font str)
6326 (ps-output-string str)
6327 (ps-output " S\n")))
6330 (defun ps-face-attributes (face)
6333 If FACE is not in `ps-print-face-extension-alist' or in
6334 `ps-print-face-alist', insert it on `ps-print-face-alist' and
6339 (ps-black-white-faces-alist
6341 (cdr (assq face ps-black-white-faces-alist)))
6344 (cdr (or (assq face ps-print-face-extension-alist)
6345 (assq face ps-print-face-alist)
6347 (new-face (ps-screen-to-bit-face the-face)))
6349 (assq the-face ps-print-face-alist))
6350 (setq ps-print-face-alist
6351 (cons new-face ps-print-face-alist)))
6361 (defun ps-face-background (face background)
6362 (and (cond ((eq ps-use-face-background t)) ; always
6363 ((null ps-use-face-background) nil) ; never
6364 ;; ps-user-face-background is a symbol face list
6366 (memq face ps-use-face-background))
6371 (if (or (memq (car face) ps-use-face-background)
6384 (defun ps-face-attribute-list (face-or-list)
6388 (ps-face-attributes face-or-list))
6402 face-attr (ps-face-attributes face)
6406 (setq background (ps-face-background face (aref face-attr 2)))))
6410 (defconst ps-font-type (vector nil 'bold 'italic 'bold-italic))
6413 (defun ps-plot-with-face (from to face)
6416 (ps-plot-region from to 0))
6419 (let* ((face-bit (ps-face-attribute-list face))
6422 (background (ps-face-background face (aref face-bit 2)))
6423 (fg-color (if (and ps-color-p foreground)
6424 (ps-color-scale foreground)
6425 ps-default-color))
6426 (bg-color (and ps-color-p background
6427 (ps-color-scale background))))
6428 (ps-plot-region
6430 (ps-font-number 'ps-font-for-text
6431 (or (aref ps-font-type (logand effect 3))
6441 (defun ps-build-reference-face-lists ()
6442 ;; Ensure that face database is updated with faces on
6443 ;; `font-lock-face-attributes' (obsolete stuff)
6444 (ps-font-lock-face-attributes)
6446 (setq ps-print-face-alist nil)
6447 (if ps-auto-font-detect
6448 (mapcar 'ps-map-face (face-list))
6449 (mapcar 'ps-set-face-bold ps-bold-faces)
6450 (mapcar 'ps-set-face-italic ps-italic-faces)
6451 (mapcar 'ps-set-face-underline ps-underlined-faces))
6452 (setq ps-build-face-reference nil))
6455 (defun ps-set-face-bold (face)
6456 (ps-set-face-attribute face 1))
6458 (defun ps-set-face-italic (face)
6459 (ps-set-face-attribute face 2))
6461 (defun ps-set-face-underline (face)
6462 (ps-set-face-attribute face 4))
6465 (defun ps-set-face-attribute (face effect)
6466 (let ((face-bit (cdr (ps-map-face face))))
6470 (defun ps-map-face (face)
6471 (let* ((face-map (ps-screen-to-bit-face face))
6472 (ps-face-bit (cdr (assq (car face-map) ps-print-face-alist))))
6473 (if ps-face-bit
6476 (aset ps-face-bit 0 (logior (aref ps-face-bit 0) (aref face-bit 0)))
6477 (or (aref ps-face-bit 1) (aset ps-face-bit 1 (aref face-bit 1)))
6478 (or (aref ps-face-bit 2) (aset ps-face-bit 2 (aref face-bit 2))))
6480 (setq ps-print-face-alist (cons face-map ps-print-face-alist)))
6484 (defun ps-screen-to-bit-face (face)
6486 (vector (logior (if (ps-face-bold-p face) 1 0) ; bold
6487 (if (ps-face-italic-p face) 2 0) ; italic
6488 (if (ps-face-underlined-p face) 4 0)) ; underline
6489 (ps-face-foreground-name face)
6490 (ps-face-background-name face))))
6494 (defalias 'ps-jitify 'jit-lock-fontify-now)
6495 (defalias 'ps-lazify 'lazy-lock-fontify-region)
6499 (defun ps-print-ensure-fontified (start end)
6501 (ps-jitify start end))
6503 (ps-lazify start end))))
6506 (defun ps-generate-postscript-with-faces (from to)
6508 (setq ps-current-effect 0)
6511 (when (or ps-always-build-face-reference
6512 ps-build-face-reference)
6514 (ps-build-reference-face-lists))
6517 (setq ps-black-white-faces-alist nil)
6518 (and (eq ps-print-color-p 'black-white)
6519 (ps-extend-face-list ps-black-white-faces nil
6520 'ps-black-white-faces-alist))
6525 (ps-print-ensure-fontified from to)
6533 (ps-x-map-extents 'ps-mapper nil from to a)
6553 ;; but don't call ps-plot-with-face unless from > point-min.
6555 (ps-plot-with-face from (min position (point-max)) face))
6559 (and (ps-x-extent-face extent)
6561 'ps-extent-sorter))))
6565 'ps-extent-sorter))))
6568 (ps-x-extent-face (car extent-list))
6585 (setq overlay-change (min (ps-e-next-overlay-change from)
6606 (let ((overlays (ps-e-overlays-at from))
6612 (ps-e-overlay-get overlay 'invisible))
6614 (or (ps-e-overlay-get overlay 'priority) 0)))
6617 (or (ps-e-overlay-get overlay 'before-string)
6620 (or (and (<= (ps-e-overlay-end overlay) position)
6621 (ps-e-overlay-get overlay 'after-string))
6633 ((ps-e-overlay-get overlay 'face))
6639 (ps-plot-string before-string))
6640 (ps-plot-with-face from position face)
6642 (ps-plot-string after-string))
6644 (ps-plot-with-face from to face))))
6646 (defun ps-generate-postscript (from to)
6647 (ps-plot-region from to 0))
6649 (defun ps-generate (buffer from to genfunc)
6654 ;; are copied into ps-spool-buffer.
6658 (and ps-razzle-dazzle
6659 (message "Formatting...%3d%%" (setq ps-razchunk 0)))
6660 (setq ps-source-buffer buffer
6661 ps-spool-buffer (get-buffer-create ps-spool-buffer-name))
6662 (ps-init-output-queue)
6666 (set-buffer ps-spool-buffer)
6676 (or (looking-at (regexp-quote ps-adobe-tag))
6679 (set-buffer ps-source-buffer)
6681 (let ((ps-print-page-p t)
6682 ps-even-or-odd-pages)
6683 (ps-begin-job genfunc)
6685 (ps-begin-file)
6686 (ps-mule-initialize))
6687 (ps-mule-begin-job from to)
6688 (ps-selected-pages)))
6689 (ps-begin-page)
6691 (ps-end-page)
6692 (ps-end-job needs-begin-file)
6704 (set-buffer ps-spool-buffer)
6707 (and ps-razzle-dazzle (message "Formatting...done"))))))
6710 (defun ps-end-job (needs-begin-file)
6711 (let ((ps-print-page-p t))
6712 (ps-flush-output)
6714 (let ((pages-per-sheet (mod ps-page-printed ps-n-up-printing))
6715 (total-lines (cdr ps-printing-region))
6716 (total-pages (ps-page-number)))
6717 (set-buffer ps-spool-buffer)
6730 (and ps-spool-duplex (= (mod ps-page-order 2) 1)
6731 (let ((ps-n-up-printing 0))
6732 (ps-header-sheet)
6733 (ps-output "/PrintHeader false def\n/ColumnIndex 0 def\n"
6735 (number-to-string ps-lines-printed) " BeginPage\n")
6736 (ps-end-page)))
6738 (ps-end-sheet)
6739 (ps-output "\n%%Trailer\n%%Pages: "
6742 ps-banner-page-when-duplexing)
6743 (1+ ps-page-order)
6744 ps-page-order))
6746 (and ps-end-with-control-d
6747 (ps-output "\C-d"))
6748 (ps-flush-output))
6750 (setq ps-selected-pages nil))
6753 ;; Permit dynamic evaluation at print time of `ps-lpr-switches'.
6754 (defun ps-do-despool (filename)
6755 (if (or (not (boundp 'ps-spool-buffer))
6756 (not (symbol-value 'ps-spool-buffer)))
6760 (and ps-razzle-dazzle (message "Saving..."))
6761 (set-buffer ps-spool-buffer)
6765 (and ps-razzle-dazzle (message "Wrote %s" filename)))
6767 (and ps-razzle-dazzle (message "Printing..."))
6769 (set-buffer ps-spool-buffer)
6771 (ps-printer-name (or ps-printer-name
6774 (ps-lpr-switches
6775 (append ps-lpr-switches
6776 (and (stringp ps-printer-name)
6777 (string< "" ps-printer-name)
6779 (and (stringp ps-printer-name-option)
6780 ps-printer-name-option)
6781 ps-printer-name))))))
6782 (or (stringp ps-printer-name)
6783 (setq ps-printer-name nil))
6784 (apply (or ps-print-region-function 'call-process-region)
6785 (point-min) (point-max) ps-lpr-command nil
6788 (ps-flatten-list ; dynamic evaluation
6789 (mapcar 'ps-eval-switch ps-lpr-switches)))))
6790 (and ps-razzle-dazzle (message "Printing...done")))
6791 (kill-buffer ps-spool-buffer)))
6794 (defun ps-eval-switch (arg)
6801 ;; `ps-flatten-list' is defined here (copied from "message.el" and
6805 ;; (ps-flatten-list '((a . b) c (d . e) (f g h) i . j))
6808 (defun ps-flatten-list (&rest list)
6809 (ps-flatten-list-1 list))
6811 (defun ps-flatten-list-1 (list)
6813 ((consp list) (append (ps-flatten-list-1 (car list))
6814 (ps-flatten-list-1 (cdr list))))
6817 (defun ps-kill-emacs-check ()
6818 (let (ps-buffer)
6819 (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
6820 (buffer-name ps-buffer) ; check if it's not killed
6821 (buffer-modified-p ps-buffer)
6823 (ps-despool))
6824 (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
6825 (buffer-name ps-buffer) ; check if it's not killed
6826 (buffer-modified-p ps-buffer)
6831 (funcall 'add-hook 'kill-emacs-hook 'ps-kill-emacs-check))
6835 (setq kill-emacs-hook 'ps-kill-emacs-check)))
6845 ;; ps-print, but I'll leave it here in hopes it might be useful:
6853 ;; `ps-left-headers' specially for mail messages.
6854 (defun ps-rmail-mode-hook ()
6855 (local-set-key [(f22)] 'ps-rmail-print-message-from-summary)
6856 (setq ps-header-lines 3
6857 ps-left-header
6860 '(ps-article-subject ps-article-author buffer-name)))
6862 ;; See `ps-gnus-print-article-from-summary'. This function does the
6864 (defun ps-rmail-print-message-from-summary ()
6866 (ps-print-message-from-summary 'rmail-summary-buffer "RMAIL"))
6868 ;; Used in `ps-rmail-print-article-from-summary',
6869 ;; `ps-gnus-print-article-from-summary' and `ps-vm-print-message-from-summary'.
6870 (defun ps-print-message-from-summary (summary-buffer summary-default)
6871 (let ((ps-buf (or (and (boundp summary-buffer)
6874 (and (get-buffer ps-buf)
6876 (set-buffer ps-buf)
6877 (ps-spool-buffer-with-faces)))))
6880 ;; placed in `ps-left-headers'.
6881 (defun ps-article-subject ()
6890 ;; it's provided. To be placed in `ps-left-headers'.
6891 (defun ps-article-author ()
6914 ;; `ps-left-headers' specially for gnus articles. Unfortunately,
6919 (defun ps-gnus-article-prepare-hook ()
6920 (setq ps-header-lines 3
6921 ps-left-header
6924 '(ps-article-subject ps-article-author gnus-newsgroup-name)))
6927 ;; `ps-left-headers' specially for mail messages.
6928 (defun ps-vm-mode-hook ()
6929 (local-set-key [(f22)] 'ps-vm-print-message-from-summary)
6930 (setq ps-header-lines 3
6931 ps-left-header
6934 '(ps-article-subject ps-article-author buffer-name)))
6942 (defun ps-gnus-print-article-from-summary ()
6944 (ps-print-message-from-summary 'gnus-article-buffer "*Article*"))
6946 ;; See `ps-gnus-print-article-from-summary'. This function does the
6948 (defun ps-vm-print-message-from-summary ()
6950 (ps-print-message-from-summary 'vm-mail-buffer ""))
6954 (defun ps-gnus-summary-setup ()
6955 (local-set-key [(f22)] 'ps-gnus-print-article-from-summary))
6958 ;; placed in `ps-left-headers'.
6959 (defun ps-info-file ()
6967 ;; placed in `ps-left-headers'.
6968 (defun ps-info-node ()
6975 (defun ps-info-mode-hook ()
6976 (setq ps-left-header
6978 '(ps-info-node ps-info-file)))
6982 ;; will be! (In fact, this is a copy of Jim's setup for ps-print --
6986 (defun ps-jts-ps-setup ()
6987 (global-set-key [(f22)] 'ps-spool-buffer-with-faces) ;f22 is prsc
6988 (global-set-key [(shift f22)] 'ps-spool-region-with-faces)
6989 (global-set-key [(control f22)] 'ps-despool)
6990 (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook)
6991 (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup)
6992 (add-hook 'vm-mode-hook 'ps-vm-mode-hook)
6993 (add-hook 'vm-mode-hooks 'ps-vm-mode-hook)
6994 (add-hook 'Info-mode-hook 'ps-info-mode-hook)
6995 (setq ps-spool-duplex t
6996 ps-print-color-p nil
6997 ps-lpr-command "lpr"
6998 ps-lpr-switches '("-Jjct,duplex_long"))
6999 'ps-jts-ps-setup)
7003 ;; (In fact, this is a copy of Jack's setup for ps-print --
7007 (defun ps-jack-setup ()
7008 (setq ps-print-color-p nil
7009 ps-lpr-command "lpr"
7010 ps-lpr-switches nil
7012 ps-paper-type 'a4
7013 ps-landscape-mode t
7014 ps-number-of-columns 2
7016 ps-left-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
7017 ps-right-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
7018 ps-inter-column (/ (* 72 1.0) 2.54) ; 1.0 cm
7019 ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
7020 ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
7021 ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
7022 ps-header-line-pad .15
7023 ps-print-header t
7024 ps-print-header-frame t
7025 ps-header-lines 2
7026 ps-show-n-of-n t
7027 ps-spool-duplex nil
7029 ps-font-family 'Courier
7030 ps-font-size 5.5
7031 ps-header-font-family 'Helvetica
7032 ps-header-font-size 6
7033 ps-header-title-font-size 8)
7034 'ps-jack-setup)
7042 (autoload 'ps-mule-prepare-ascii-font "ps-mule"
7043 "Setup special ASCII font for STRING.
7046 (autoload 'ps-mule-set-ascii-font "ps-mule"
7047 "Adjust current font if current charset is not ASCII.")
7049 (autoload 'ps-mule-plot-string "ps-mule"
7063 (autoload 'ps-mule-initialize "ps-mule"
7066 (autoload 'ps-mule-begin-job "ps-mule"
7070 (autoload 'ps-mule-begin-page "ps-mule"
7073 (autoload 'ps-mule-encode-header-string "ps-mule"
7082 (provide 'ps-print)
7085 ;;; ps-print.el ends here