comparison lisp/ps-print.el @ 47328:ac7145660745

Many doc fixes.
author Richard M. Stallman <rms@gnu.org>
date Mon, 09 Sep 2002 19:26:40 +0000
parents a41a116523ad
children 12f18e82e5e2
comparison
equal deleted inserted replaced
47327:94b3c6a53104 47328:ac7145660745
20 Vinicius's last change version -- this file may have been edited as part of 20 Vinicius's last change version -- this file may have been edited as part of
21 Emacs without changes to the version number. When reporting bugs, please also 21 Emacs without changes to the version number. When reporting bugs, please also
22 report the version of Emacs, if any, that ps-print was distributed with. 22 report the version of Emacs, if any, that ps-print was distributed with.
23 23
24 Please send all bug fixes and enhancements to 24 Please send all bug fixes and enhancements to
25 Vinicius Jose Latorre <vinicius@cpqd.com.br>. 25 Vinicius Jose Latorre <vinicius@cpqd.com.br>.")
26 ")
27 26
28 ;; This file is part of GNU Emacs. 27 ;; This file is part of GNU Emacs.
29 28
30 ;; GNU Emacs is free software; you can redistribute it and/or modify it under 29 ;; GNU Emacs is free software; you can redistribute it and/or modify it under
31 ;; the terms of the GNU General Public License as published by the Free 30 ;; the terms of the GNU General Public License as published by the Free
1651 As an example for `ps-user-defined-prologue' setting: 1650 As an example for `ps-user-defined-prologue' setting:
1652 1651
1653 ;; Setting for HP PostScript printer 1652 ;; Setting for HP PostScript printer
1654 (setq ps-user-defined-prologue 1653 (setq ps-user-defined-prologue
1655 (concat \"<</DeferredMediaSelection true /PageSize [612 792] \" 1654 (concat \"<</DeferredMediaSelection true /PageSize [612 792] \"
1656 \"/MediaPosition 2 /MediaType (Plain)>> setpagedevice\")) 1655 \"/MediaPosition 2 /MediaType (Plain)>> setpagedevice\"))"
1657 "
1658 :type '(choice :menu-tag "User Defined Prologue" 1656 :type '(choice :menu-tag "User Defined Prologue"
1659 :tag "User Defined Prologue" 1657 :tag "User Defined Prologue"
1660 (const :tag "none" nil) string symbol) 1658 (const :tag "none" nil) string symbol)
1661 :group 'ps-print-miscellany) 1659 :group 'ps-print-miscellany)
1662 1660
1671 ps-print always inserts the %%Requirements: comment, so if you need to insert 1669 ps-print always inserts the %%Requirements: comment, so if you need to insert
1672 more requirements put them first in `ps-print-prologue-header' using the 1670 more requirements put them first in `ps-print-prologue-header' using the
1673 \"%%+\" comment. For example, if you need to set numcopies to 3 and jog on 1671 \"%%+\" comment. For example, if you need to set numcopies to 3 and jog on
1674 requirements and set %%LanguageLevel: to 2, do: 1672 requirements and set %%LanguageLevel: to 2, do:
1675 1673
1676 (setq ps-print-prologue-header 1674 (setq ps-print-prologue-header
1677 \"%%+ numcopies(3) jog\\n%%LanguageLevel: 2\\n\") 1675 \"%%+ numcopies(3) jog\\n%%LanguageLevel: 2\\n\")
1678 1676
1679 The duplex requirement is inserted by ps-print (see `ps-spool-duplex'). 1677 The duplex requirement is inserted by ps-print (see `ps-spool-duplex').
1680 1678
1681 Do not forget to terminate the string with \"\\n\". 1679 Do not forget to terminate the string with \"\\n\".
1727 "-d") 1725 "-d")
1728 (t 1726 (t
1729 "-P" )) 1727 "-P" ))
1730 "*Option for `ps-printer-name' variable (see it). 1728 "*Option for `ps-printer-name' variable (see it).
1731 1729
1732 On Unix-like systems, if it's been used lpr utility, it should be the string 1730 On Unix-like systems, if `lpr' is in use, this should be the string
1733 \"-P\"; if it's been used lp utility, it should be the string \"-d\". 1731 \"-P\"; if `lp' is in use, this should be the string \"-d\".
1734 1732
1735 On MS-DOS and MS-Windows systems, if it's been used print utility, it should be 1733 On MS-DOS and MS-Windows systems, if `print' is in use, this should be
1736 the string \"/D:\". 1734 the string \"/D:\".
1737 1735
1738 For any other printing utility, see the proper manual or documentation. 1736 For any other printing utility, see its documentation.
1739 1737
1740 Set to \"\" or nil, if the utility given by `ps-lpr-command' needs an empty 1738 Set this to \"\" or nil, if the utility given by `ps-lpr-command' needs an empty
1741 option printer name option. 1739 printer name option.
1742 1740
1743 Any other value is treated as nil, that is, an empty printer name option. 1741 Any other value is treated as nil, that is, an empty printer name option.
1744 1742
1745 This variable is used only when `ps-printer-name' is a non-empty string." 1743 This variable is used only when `ps-printer-name' is a non-empty string."
1746 :type '(choice :menu-tag "Printer Name Option" 1744 :type '(choice :menu-tag "Printer Name Option"
1856 "*Non-nil means print in landscape mode." 1854 "*Non-nil means print in landscape mode."
1857 :type 'boolean 1855 :type 'boolean
1858 :group 'ps-print-page) 1856 :group 'ps-print-page)
1859 1857
1860 (defcustom ps-print-upside-down nil 1858 (defcustom ps-print-upside-down nil
1861 "*Non-nil means print upside-down (that is, it's rotated by 180 grades)." 1859 "*Non-nil means print upside-down (that is, rotated by 180 degrees)."
1862 :type 'boolean 1860 :type 'boolean
1863 :version "21.1" 1861 :version "21.1"
1864 :group 'ps-print-page) 1862 :group 'ps-print-page)
1865 1863
1866 (defcustom ps-selected-pages nil 1864 (defcustom ps-selected-pages nil
1867 "*Specify which pages to print. 1865 "*Specify which pages to print.
1868 1866
1869 If it's nil, all pages are printed. 1867 If nil, print all pages.
1870 1868
1871 If it's a list, the list element may be an integer or a cons cell (FROM . TO) 1869 If a list, the lists element may be an integer or a cons cell (FROM . TO)
1872 designating FROM page to TO page; any invalid element is ignored, that is, an 1870 designating FROM page to TO page; any invalid element is ignored, that is, an
1873 integer lesser than one or if FROM is greater than TO. 1871 integer less than one or if FROM is greater than TO.
1874 1872
1875 Otherwise, it's treated as nil. 1873 Otherwise, it's treated as nil.
1876 1874
1877 After ps-print processing `ps-selected-pages' is set to nil. But the latest 1875 After ps-print processing `ps-selected-pages' is set to nil. But the
1878 `ps-selected-pages' is saved in `ps-last-selected-pages' (see it for 1876 latest `ps-selected-pages' is saved in `ps-last-selected-pages' (which
1879 documentation). So you can restore the latest selected pages by using 1877 see). So you can restore the latest selected pages by using
1880 `ps-last-selected-pages' or by calling `ps-restore-selected-pages' command (see 1878 `ps-last-selected-pages' or with the `ps-restore-selected-pages'
1881 it for documentation). 1879 command (which see).
1882 1880
1883 See also `ps-even-or-odd-pages'." 1881 See also `ps-even-or-odd-pages'."
1884 :type '(repeat :tag "Selected Pages" 1882 :type '(repeat :tag "Selected Pages"
1885 (radio :tag "Page" 1883 (radio :tag "Page"
1886 (integer :tag "Number") 1884 (integer :tag "Number")
2033 (const top-left) (const bottom-left) 2031 (const top-left) (const bottom-left)
2034 (const top-right) (const bottom-right)) 2032 (const top-right) (const bottom-right))
2035 :group 'ps-print-n-up) 2033 :group 'ps-print-n-up)
2036 2034
2037 (defcustom ps-number-of-columns (if ps-landscape-mode 2 1) 2035 (defcustom ps-number-of-columns (if ps-landscape-mode 2 1)
2038 "*Specify the number of columns" 2036 "*Specify the number of columns."
2039 :type 'number 2037 :type 'number
2040 :group 'ps-print-miscellany) 2038 :group 'ps-print-miscellany)
2041 2039
2042 (defcustom ps-zebra-stripes nil 2040 (defcustom ps-zebra-stripes nil
2043 "*Non-nil means print zebra stripes. 2041 "*Non-nil means print zebra stripes.
2193 PAGES may be a number or a cons cell (FROM . TO) designating FROM page to TO 2191 PAGES may be a number or a cons cell (FROM . TO) designating FROM page to TO
2194 page. 2192 page.
2195 If PAGES is nil, print background image on all pages. 2193 If PAGES is nil, print background image on all pages.
2196 2194
2197 X, Y, XSCALE, YSCALE and ROTATION may be a floating point number, an integer 2195 X, Y, XSCALE, YSCALE and ROTATION may be a floating point number, an integer
2198 number or a string. If it is a string, the string should contain PostScript 2196 number or a string. If it is a string, the string should contain PostScript
2199 programming that returns a float or integer value. 2197 programming that returns a float or integer value.
2200 2198
2201 For example, if you wish to print an EPS image on all pages do: 2199 For example, if you wish to print an EPS image on all pages do:
2202 2200
2203 '((\"~/images/EPS-image.ps\"))" 2201 '((\"~/images/EPS-image.ps\"))"
2243 PAGES may be a number or a cons cell (FROM . TO) designating FROM page to TO 2241 PAGES may be a number or a cons cell (FROM . TO) designating FROM page to TO
2244 page. 2242 page.
2245 If PAGES is nil, print background text on all pages. 2243 If PAGES is nil, print background text on all pages.
2246 2244
2247 X, Y, FONTSIZE, GRAY and ROTATION may be a floating point number, an integer 2245 X, Y, FONTSIZE, GRAY and ROTATION may be a floating point number, an integer
2248 number or a string. If it is a string, the string should contain PostScript 2246 number or a string. If it is a string, the string should contain PostScript
2249 programming that returns a float or integer value. 2247 programming that returns a float or integer value.
2250 2248
2251 For example, if you wish to print text \"Preliminary\" on all pages do: 2249 For example, if you wish to print text \"Preliminary\" on all pages do:
2252 2250
2253 '((\"Preliminary\"))" 2251 '((\"Preliminary\"))"
2318 "*Vertical space in points (1/72 inch) between the main text and the header." 2316 "*Vertical space in points (1/72 inch) between the main text and the header."
2319 :type 'number 2317 :type 'number
2320 :group 'ps-print-vertical) 2318 :group 'ps-print-vertical)
2321 2319
2322 (defcustom ps-header-line-pad 0.15 2320 (defcustom ps-header-line-pad 0.15
2323 "*Portion of a header title line height to insert between the header frame 2321 "*Portion of a header title line height to insert.
2324 and the text it contains, both in the vertical and horizontal directions." 2322 The insertion is done between the header frame and the text it contains,
2323 both in the vertical and horizontal directions."
2325 :type 'number 2324 :type 'number
2326 :group 'ps-print-vertical) 2325 :group 'ps-print-vertical)
2327 2326
2328 (defcustom ps-footer-offset (/ (* 72 1.0) 2.54) ; 1.0 cm 2327 (defcustom ps-footer-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
2329 "*Vertical space in points (1/72 inch) between the main text and the footer." 2328 "*Vertical space in points (1/72 inch) between the main text and the footer."
2330 :type 'number 2329 :type 'number
2331 :group 'ps-print-vertical) 2330 :group 'ps-print-vertical)
2332 2331
2333 (defcustom ps-footer-line-pad 0.15 2332 (defcustom ps-footer-line-pad 0.15
2334 "*Portion of a footer title line height to insert between the footer frame 2333 "*Portion of a footer title line height to insert.
2335 and the text it contains, both in the vertical and horizontal directions." 2334 The insertion is done between the footer frame and the text it contains,
2335 both in the vertical and horizontal directions."
2336 :type 'number 2336 :type 'number
2337 :group 'ps-print-vertical) 2337 :group 'ps-print-vertical)
2338 2338
2339 ;;; Header/Footer setup 2339 ;;; Header/Footer setup
2340 2340
2580 affects the left margin. 2580 affects the left margin.
2581 Besides all that, if your printer does not have the paper size 2581 Besides all that, if your printer does not have the paper size
2582 specified by setpagedevice, your printing will be aborted. 2582 specified by setpagedevice, your printing will be aborted.
2583 So, if you need to use setpagedevice, set `ps-spool-config' to 2583 So, if you need to use setpagedevice, set `ps-spool-config' to
2584 `setpagedevice', generate a test file and send it to your printer; if 2584 `setpagedevice', generate a test file and send it to your printer; if
2585 the printed file isn't ok, set `ps-spool-config' to nil." 2585 the printed file isn't OK, set `ps-spool-config' to nil."
2586 :type '(choice :menu-tag "Spool Config" 2586 :type '(choice :menu-tag "Spool Config"
2587 :tag "Spool Config" 2587 :tag "Spool Config"
2588 (const lpr-switches) (const setpagedevice) 2588 (const lpr-switches) (const setpagedevice)
2589 (const :tag "nil" nil)) 2589 (const :tag "nil" nil))
2590 :group 'ps-print-headers) 2590 :group 'ps-print-headers)
2716 (size . 10.0) 2716 (size . 10.0)
2717 (line-height . 11.45) 2717 (line-height . 11.45)
2718 (space-width . 2.2) 2718 (space-width . 2.2)
2719 (avg-char-width . 4.10811)) 2719 (avg-char-width . 4.10811))
2720 ) 2720 )
2721 "*Font info database: font family (the key), name, bold, italic, bold-italic, 2721 "*Font info database.
2722 Each element comprises: font family (the key), name, bold, italic, bold-italic,
2722 reference size, line height, space width, average character width. 2723 reference size, line height, space width, average character width.
2723 To get the info for another specific font (say Helvetica), do the following: 2724 To get the info for another specific font (say Helvetica), do the following:
2724 - create a new buffer 2725 - create a new buffer
2725 - generate the PostScript image to a file (C-u M-x ps-print-buffer) 2726 - generate the PostScript image to a file (C-u M-x ps-print-buffer)
2726 - open this file and delete the leading `%' (which is the PostScript comment 2727 - open this file and delete the leading `%' (which is the PostScript comment
3038 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\". 3039 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\".
3039 3040
3040 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\". 3041 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\".
3041 3042
3042 You can also create your own time stamp function by using `format-time-string' 3043 You can also create your own time stamp function by using `format-time-string'
3043 (which see)." 3044 \(which see)."
3044 :type '(repeat (choice :menu-tag "Right Header" 3045 :type '(repeat (choice :menu-tag "Right Header"
3045 :tag "Right Header" 3046 :tag "Right Header"
3046 string symbol)) 3047 string symbol))
3047 :group 'ps-print-headers) 3048 :group 'ps-print-headers)
3048 3049
3085 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\". 3086 `ps-time-stamp-hh:mm:ss' Return time as \"17:28:31\".
3086 3087
3087 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\". 3088 `ps-time-stamp-mon-dd-yyyy' Return date as \"Jun 18 2001\".
3088 3089
3089 You can also create your own time stamp function by using `format-time-string' 3090 You can also create your own time stamp function by using `format-time-string'
3090 (which see)." 3091 \(which see)."
3091 :version "21.1" 3092 :version "21.1"
3092 :type '(repeat (choice :menu-tag "Right Footer" 3093 :type '(repeat (choice :menu-tag "Right Footer"
3093 :tag "Right Footer" 3094 :tag "Right Footer"
3094 string symbol)) 3095 string symbol))
3095 :group 'ps-print-headers) 3096 :group 'ps-print-headers)
3247 3248
3248 ;;;###autoload 3249 ;;;###autoload
3249 (defun ps-print-buffer (&optional filename) 3250 (defun ps-print-buffer (&optional filename)
3250 "Generate and print a PostScript image of the buffer. 3251 "Generate and print a PostScript image of the buffer.
3251 3252
3252 Interactively, when you use a prefix argument (C-u), the command prompts the 3253 Interactively, when you use a prefix argument (\\[universal-argument]), the command prompts the
3253 user for a file name, and saves the PostScript image in that file instead of 3254 user for a file name, and saves the PostScript image in that file instead of
3254 sending it to the printer. 3255 sending it to the printer.
3255 3256
3256 Noninteractively, the argument FILENAME is treated as follows: if it is nil, 3257 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3257 send the image to the printer. If FILENAME is a string, save the PostScript 3258 send the image to the printer. If FILENAME is a string, save the PostScript
3334 3335
3335 ;;;###autoload 3336 ;;;###autoload
3336 (defun ps-despool (&optional filename) 3337 (defun ps-despool (&optional filename)
3337 "Send the spooled PostScript to the printer. 3338 "Send the spooled PostScript to the printer.
3338 3339
3339 Interactively, when you use a prefix argument (C-u), the command prompts the 3340 Interactively, when you use a prefix argument (\\[universal-argument]), the command prompts the
3340 user for a file name, and saves the spooled PostScript image in that file 3341 user for a file name, and saves the spooled PostScript image in that file
3341 instead of sending it to the printer. 3342 instead of sending it to the printer.
3342 3343
3343 Noninteractively, the argument FILENAME is treated as follows: if it is nil, 3344 Noninteractively, the argument FILENAME is treated as follows: if it is nil,
3344 send the image to the printer. If FILENAME is a string, save the PostScript 3345 send the image to the printer. If FILENAME is a string, save the PostScript
3346 (interactive (list (ps-print-preprint current-prefix-arg))) 3347 (interactive (list (ps-print-preprint current-prefix-arg)))
3347 (ps-do-despool filename)) 3348 (ps-do-despool filename))
3348 3349
3349 ;;;###autoload 3350 ;;;###autoload
3350 (defun ps-line-lengths () 3351 (defun ps-line-lengths ()
3351 "Display the correspondence between a line length and a font size, using the 3352 "Display the correspondence between a line length and a font size.
3352 current ps-print setup. 3353 Done using the current ps-print setup.
3353 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head" 3354 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
3354 (interactive) 3355 (interactive)
3355 (ps-line-lengths-internal)) 3356 (ps-line-lengths-internal))
3356 3357
3357 ;;;###autoload 3358 ;;;###autoload
3727 (or (face-underline-p face) 3728 (or (face-underline-p face)
3728 (memq face ps-underlined-faces))) 3729 (memq face ps-underlined-faces)))
3729 3730
3730 3731
3731 (defun ps-prologue-file (filenumber) 3732 (defun ps-prologue-file (filenumber)
3732 "If prologue FILENUMBER exists and is readable, returns contents as string. 3733 "If prologue FILENUMBER exists and is readable, return contents as string.
3733 3734
3734 Note: No major/minor-mode is activated and no local variables are evaluated for 3735 Note: No major/minor-mode is activated and no local variables are evaluated for
3735 FILENUMBER, but proper EOL-conversion and character interpretation is 3736 FILENUMBER, but proper EOL-conversion and character interpretation is
3736 done!" 3737 done!"
3737 (let ((filename (convert-standard-filename 3738 (let ((filename (convert-standard-filename
3843 3844
3844 3845
3845 (defvar ps-black-white-faces-alist nil 3846 (defvar ps-black-white-faces-alist nil
3846 "Alist of symbolic faces used for black/white PostScript printers. 3847 "Alist of symbolic faces used for black/white PostScript printers.
3847 An element of this list has the same form as `ps-print-face-extension-alist' 3848 An element of this list has the same form as `ps-print-face-extension-alist'
3848 (which see). 3849 \(which see).
3849 3850
3850 Don't change this list directly; instead, 3851 Don't change this list directly; instead,
3851 use `ps-extend-face' and `ps-extend-face-list'. 3852 use `ps-extend-face' and `ps-extend-face-list'.
3852 See documentation for `ps-extend-face' for valid extension symbol. 3853 See documentation for `ps-extend-face' for valid extension symbol.
3853 See also documentation for `ps-print-color-p'.") 3854 See also documentation for `ps-print-color-p'.")
4138 x-dimension, of the text it has printed, and thus affects the point at 4139 x-dimension, of the text it has printed, and thus affects the point at
4139 which long lines wrap around." 4140 which long lines wrap around."
4140 (get font-sym 'avg-char-width)) 4141 (get font-sym 'avg-char-width))
4141 4142
4142 (defun ps-line-lengths-internal () 4143 (defun ps-line-lengths-internal ()
4143 "Display the correspondence between a line length and a font size, 4144 "Display the correspondence between a line length and a font size.
4144 using the current ps-print setup. 4145 Done using the current ps-print setup.
4145 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head" 4146 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
4146 (let* ((ps-font-size-internal 4147 (let* ((ps-font-size-internal
4147 (or ps-font-size-internal 4148 (or ps-font-size-internal
4148 (ps-get-font-size 'ps-font-size))) 4149 (ps-get-font-size 'ps-font-size)))
4149 (ps-header-font-size-internal 4150 (ps-header-font-size-internal