comparison lisp/packages/ps-print.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children b82b59fe008d
comparison
equal deleted inserted replaced
1:c0c6a60d29db 2:ac2d302a0011
1 ;;; ps-print.el --- Jim's Pretty-Good PostScript Generator for Emacs 19. 1 ;;; ps-print.el --- Jim's Pretty-Good PostScript Generator for Emacs 19.
2 2
3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. 3 ;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4 4
5 ;; Author: Jim Thompson <thompson@wg2.waii.com> 5 ;; Author: Jim Thompson <thompson@wg2.waii.com>
6 ;; Maintainer: duthen@cegelec-red.fr (Jacques Duthen Prestataire)
6 ;; Keywords: print, PostScript 7 ;; Keywords: print, PostScript
7 8
8 ;; This file is part of XEmacs. 9 ;; This file is part of XEmacs.
9 10
10 ;; XEmacs is free software; you can redistribute it and/or modify it 11 ;; XEmacs is free software; you can redistribute it and/or modify it
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details. 19 ;; General Public License for more details.
19 20
20 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; 02111-1307, USA.
23 25
24 ;; LCD Archive Entry: 26 ;; LCD Archive Entry:
25 ;; ps-print|James C. Thompson|thompson@wg2.waii.com| 27 ;; ps-print|James C. Thompson|thompson@wg2.waii.com|
26 ;; Jim's Pretty-Good PostScript Generator for Emacs 19 (ps-print)| 28 ;; Jim's Pretty-Good PostScript Generator for Emacs 19 (ps-print)|
27 ;; 26-Feb-1994|2.8|~/packages/ps-print.el| 29 ;; 26-Feb-1994|2.8|~/packages/ps-print.el|
29 ;; Baseline-version: 2.8. (Jim's last change version -- this 31 ;; Baseline-version: 2.8. (Jim's last change version -- this
30 ;; file may have been edited as part of Emacs without changes to the 32 ;; file may have been edited as part of Emacs without changes to the
31 ;; version number. When reporting bugs, please also report the 33 ;; version number. When reporting bugs, please also report the
32 ;; version of Emacs, if any, that ps-print was distributed with.) 34 ;; version of Emacs, if any, that ps-print was distributed with.)
33 35
34 ;;; Synched up with: FSF 19.30. 36 ;;; Synched up with: FSF 19.34.
35 37
36 ;;; Commentary: 38 ;;; Commentary:
37 39
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 ;; 41 ;;
83 ;; otherwise be wasted on banner pages, and to make it easier to find 85 ;; otherwise be wasted on banner pages, and to make it easier to find
84 ;; your output at the printer (it's easier to pick up one 50-page 86 ;; your output at the printer (it's easier to pick up one 50-page
85 ;; printout than to find 50 single-page printouts). 87 ;; printout than to find 50 single-page printouts).
86 ;; 88 ;;
87 ;; Ps-print has a hook in the kill-emacs-hooks so that you won't 89 ;; Ps-print has a hook in the kill-emacs-hooks so that you won't
88 ;; accidently quit from Emacs while you have unprinted PostScript 90 ;; accidentally quit from Emacs while you have unprinted PostScript
89 ;; waiting in the spool buffer. If you do attempt to exit with 91 ;; waiting in the spool buffer. If you do attempt to exit with
90 ;; spooled PostScript, you'll be asked if you want to print it, and if 92 ;; spooled PostScript, you'll be asked if you want to print it, and if
91 ;; you decline, you'll be asked to confirm the exit; this is modeled 93 ;; you decline, you'll be asked to confirm the exit; this is modeled
92 ;; on the confirmation that Emacs uses for modified buffers. 94 ;; on the confirmation that Emacs uses for modified buffers.
93 ;; 95 ;;
198 ;; ps-print cannot correctly place line and page breaks. 200 ;; ps-print cannot correctly place line and page breaks.
199 ;; 201 ;;
200 ;; Ps-print keeps internal lists of which fonts are bold and which are 202 ;; Ps-print keeps internal lists of which fonts are bold and which are
201 ;; italic; these lists are built the first time you invoke ps-print. 203 ;; italic; these lists are built the first time you invoke ps-print.
202 ;; For the sake of efficiency, the lists are built only once; the same 204 ;; For the sake of efficiency, the lists are built only once; the same
203 ;; lists are referred in later invokations of ps-print. 205 ;; lists are referred in later invocations of ps-print.
204 ;; 206 ;;
205 ;; Because these lists are built only once, it's possible for them to 207 ;; Because these lists are built only once, it's possible for them to
206 ;; get out of sync, if a face changes, or if new faces are added. To 208 ;; get out of sync, if a face changes, or if new faces are added. To
207 ;; get the lists back in sync, you can set the variable 209 ;; get the lists back in sync, you can set the variable
208 ;; ps-build-face-reference to t, and the lists will be rebuilt the 210 ;; ps-build-face-reference to t, and the lists will be rebuilt the
255 ;; 257 ;;
256 ;; Symbols in the header format lists can either represent functions 258 ;; Symbols in the header format lists can either represent functions
257 ;; or variables. Functions are called, and should return a string to 259 ;; or variables. Functions are called, and should return a string to
258 ;; show in the header. Variables should contain strings to display in 260 ;; show in the header. Variables should contain strings to display in
259 ;; the header. In either case, function or variable, the PostScript 261 ;; the header. In either case, function or variable, the PostScript
260 ;; strings delimeters are added by ps-print, and should not be part of 262 ;; string delimeters are added by ps-print, and should not be part of
261 ;; the returned value. 263 ;; the returned value.
262 ;; 264 ;;
263 ;; Here's an example: say we want the left header to display the text 265 ;; Here's an example: say we want the left header to display the text
264 ;; 266 ;;
265 ;; Moe 267 ;; Moe
302 ;; 304 ;;
303 ;; The variable ps-paper-type determines the size of paper ps-print 305 ;; The variable ps-paper-type determines the size of paper ps-print
304 ;; formats for; it should contain one of the symbols ps-letter, 306 ;; formats for; it should contain one of the symbols ps-letter,
305 ;; ps-legal, or ps-a4. The default is ps-letter. 307 ;; ps-legal, or ps-a4. The default is ps-letter.
306 ;; 308 ;;
307 ;; 309 ;; Make sure that the variables ps-lpr-command and ps-lpr-switches
308 ;; Installing ps-print 310 ;; contain appropriate values for your system; see the usage notes
309 ;; ------------------- 311 ;; below and the documentation of these variables.
310 ;;
311 ;; 1. Place ps-print.el somewhere in your load-path and byte-compile
312 ;; it. You can ignore all byte-compiler warnings; they are the
313 ;; result of multi-Emacs support. This step is necessary only if
314 ;; you're installing your own ps-print; if ps-print came with your
315 ;; copy of Emacs, this been done already.
316 ;;
317 ;; 2. Place in your .emacs file the line
318 ;;
319 ;; (require 'ps-print)
320 ;;
321 ;; to load ps-print. Or you may cause any of the ps-print commands
322 ;; to be autoloaded with an autoload command such as:
323 ;;
324 ;; (autoload 'ps-print-buffer "ps-print"
325 ;; "Generate and print a PostScript image of the buffer..." t)
326 ;;
327 ;; 3. Make sure that the variables ps-lpr-command and ps-lpr-switches
328 ;; contain appropriate values for your system; see the usage notes
329 ;; below and the documentation of these variables.
330 ;; 312 ;;
331 ;; New since version 1.5 313 ;; New since version 1.5
332 ;; --------------------- 314 ;; ---------------------
333 ;; Color output capability. 315 ;; Color output capability.
334 ;; 316 ;;
457 "*Non-nil means show page numbers as N/M, meaning page N of M. 439 "*Non-nil means show page numbers as N/M, meaning page N of M.
458 Note: page numbers are displayed as part of headers, see variable 440 Note: page numbers are displayed as part of headers, see variable
459 `ps-print-headers'.") 441 `ps-print-headers'.")
460 442
461 ;;;###autoload 443 ;;;###autoload
444 ;;; The 19.33 fsf version includes a test on pixel components instead
445 ;;; of color-instance-rgb-components
462 (defvar ps-print-color-p (and (or (fboundp 'x-color-values) ; fsf 446 (defvar ps-print-color-p (and (or (fboundp 'x-color-values) ; fsf
463 (fboundp 'color-instance-rgb-components)) 447 (fboundp 'color-instance-rgb-components))
464 ; xemacs 448 ; xemacs
465 (fboundp 'float)) 449 (fboundp 'float))
466 ; Printing color requires both floating point and x-color-values. 450 ; Printing color requires both floating point and x-color-values.
606 590
607 591
608 ;;;###autoload 592 ;;;###autoload
609 (defun ps-print-buffer-with-faces (&optional filename) 593 (defun ps-print-buffer-with-faces (&optional filename)
610 "Generate and print a PostScript image of the buffer. 594 "Generate and print a PostScript image of the buffer.
611
612 Like `ps-print-buffer', but includes font, color, and underline 595 Like `ps-print-buffer', but includes font, color, and underline
613 information in the generated image." 596 information in the generated image. This command works only if you
597 are using a window system, so it has a way to determine color values."
614 (interactive (list (ps-print-preprint current-prefix-arg))) 598 (interactive (list (ps-print-preprint current-prefix-arg)))
615 (ps-generate (current-buffer) (point-min) (point-max) 599 (ps-generate (current-buffer) (point-min) (point-max)
616 'ps-generate-postscript-with-faces) 600 'ps-generate-postscript-with-faces)
617 (ps-do-despool filename)) 601 (ps-do-despool filename))
618 602
619 603
620 ;;;###autoload 604 ;;;###autoload
621 (defun ps-print-region (from to &optional filename) 605 (defun ps-print-region (from to &optional filename)
622 "Generate and print a PostScript image of the region. 606 "Generate and print a PostScript image of the region.
623
624 Like `ps-print-buffer', but prints just the current region." 607 Like `ps-print-buffer', but prints just the current region."
625 608
626 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg))) 609 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
627 (ps-generate (current-buffer) from to 610 (ps-generate (current-buffer) from to
628 'ps-generate-postscript) 611 'ps-generate-postscript)
630 613
631 614
632 ;;;###autoload 615 ;;;###autoload
633 (defun ps-print-region-with-faces (from to &optional filename) 616 (defun ps-print-region-with-faces (from to &optional filename)
634 "Generate and print a PostScript image of the region. 617 "Generate and print a PostScript image of the region.
635
636 Like `ps-print-region', but includes font, color, and underline 618 Like `ps-print-region', but includes font, color, and underline
637 information in the generated image." 619 information in the generated image. This command works only if you
620 are using a window system, so it has a way to determine color values."
638 621
639 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg))) 622 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
640 (ps-generate (current-buffer) from to 623 (ps-generate (current-buffer) from to
641 'ps-generate-postscript-with-faces) 624 'ps-generate-postscript-with-faces)
642 (ps-do-despool filename)) 625 (ps-do-despool filename))
643 626
644 627
645 ;;;###autoload 628 ;;;###autoload
646 (defun ps-spool-buffer () 629 (defun ps-spool-buffer ()
647 "Generate and spool a PostScript image of the buffer. 630 "Generate and spool a PostScript image of the buffer.
648
649 Like `ps-print-buffer' except that the PostScript image is saved in a 631 Like `ps-print-buffer' except that the PostScript image is saved in a
650 local buffer to be sent to the printer later. 632 local buffer to be sent to the printer later.
651 633
652 Use the command `ps-despool' to send the spooled images to the printer." 634 Use the command `ps-despool' to send the spooled images to the printer."
653 (interactive) 635 (interactive)
656 638
657 639
658 ;;;###autoload 640 ;;;###autoload
659 (defun ps-spool-buffer-with-faces () 641 (defun ps-spool-buffer-with-faces ()
660 "Generate and spool a PostScript image of the buffer. 642 "Generate and spool a PostScript image of the buffer.
661
662 Like `ps-spool-buffer', but includes font, color, and underline 643 Like `ps-spool-buffer', but includes font, color, and underline
663 information in the generated image. 644 information in the generated image. This command works only if you
645 are using a window system, so it has a way to determine color values.
664 646
665 Use the command `ps-despool' to send the spooled images to the printer." 647 Use the command `ps-despool' to send the spooled images to the printer."
666 648
667 (interactive) 649 (interactive)
668 (ps-generate (current-buffer) (point-min) (point-max) 650 (ps-generate (current-buffer) (point-min) (point-max)
670 652
671 653
672 ;;;###autoload 654 ;;;###autoload
673 (defun ps-spool-region (from to) 655 (defun ps-spool-region (from to)
674 "Generate a PostScript image of the region and spool locally. 656 "Generate a PostScript image of the region and spool locally.
675
676 Like `ps-spool-buffer', but spools just the current region. 657 Like `ps-spool-buffer', but spools just the current region.
677 658
678 Use the command `ps-despool' to send the spooled images to the printer." 659 Use the command `ps-despool' to send the spooled images to the printer."
679 (interactive "r") 660 (interactive "r")
680 (ps-generate (current-buffer) from to 661 (ps-generate (current-buffer) from to
682 663
683 664
684 ;;;###autoload 665 ;;;###autoload
685 (defun ps-spool-region-with-faces (from to) 666 (defun ps-spool-region-with-faces (from to)
686 "Generate a PostScript image of the region and spool locally. 667 "Generate a PostScript image of the region and spool locally.
687
688 Like `ps-spool-region', but includes font, color, and underline 668 Like `ps-spool-region', but includes font, color, and underline
689 information in the generated image. 669 information in the generated image. This command works only if you
670 are using a window system, so it has a way to determine color values.
690 671
691 Use the command `ps-despool' to send the spooled images to the printer." 672 Use the command `ps-despool' to send the spooled images to the printer."
692 (interactive "r") 673 (interactive "r")
693 (ps-generate (current-buffer) from to 674 (ps-generate (current-buffer) from to
694 'ps-generate-postscript-with-faces)) 675 'ps-generate-postscript-with-faces))
743 /minus 724 /minus
744 StandardEncoding 46 82 getinterval aload pop 725 StandardEncoding 46 82 getinterval aload pop
745 %*** NOTE: the following are missing in the Adobe documentation, 726 %*** NOTE: the following are missing in the Adobe documentation,
746 %*** but appear in the displayed table: 727 %*** but appear in the displayed table:
747 %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240. 728 %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
748 % \20x 729 % ^Px
749 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 730 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
750 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 731 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
751 /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent 732 /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
752 /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron 733 /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
753 % \24x 734 % ^Tx
754 /space /exclamdown /cent /sterling 735 /space /exclamdown /cent /sterling
755 /currency /yen /brokenbar /section 736 /currency /yen /brokenbar /section
756 /dieresis /copyright /ordfeminine /guillemotleft 737 /dieresis /copyright /ordfeminine /guillemotleft
757 /logicalnot /hyphen /registered /macron 738 /logicalnot /hyphen /registered /macron
758 /degree /plusminus /twosuperior /threesuperior 739 /degree /plusminus /twosuperior /threesuperior
759 /acute /mu /paragraph /periodcentered 740 /acute /mu /paragraph /periodcentered
760 /cedilla /onesuperior /ordmasculine /guillemotright 741 /cedilla /onesuperior /ordmasculine /guillemotright
761 /onequarter /onehalf /threequarters /questiondown 742 /onequarter /onehalf /threequarters /questiondown
762 % \30x 743 % ^Xx
763 /Agrave /Aacute /Acircumflex /Atilde 744 /Agrave /Aacute /Acircumflex /Atilde
764 /Adieresis /Aring /AE /Ccedilla 745 /Adieresis /Aring /AE /Ccedilla
765 /Egrave /Eacute /Ecircumflex /Edieresis 746 /Egrave /Eacute /Ecircumflex /Edieresis
766 /Igrave /Iacute /Icircumflex /Idieresis 747 /Igrave /Iacute /Icircumflex /Idieresis
767 /Eth /Ntilde /Ograve /Oacute 748 /Eth /Ntilde /Ograve /Oacute
768 /Ocircumflex /Otilde /Odieresis /multiply 749 /Ocircumflex /Otilde /Odieresis /multiply
769 /Oslash /Ugrave /Uacute /Ucircumflex 750 /Oslash /Ugrave /Uacute /Ucircumflex
770 /Udieresis /Yacute /Thorn /germandbls 751 /Udieresis /Yacute /Thorn /germandbls
771 % \34x 752 % ^\\x
772 /agrave /aacute /acircumflex /atilde 753 /agrave /aacute /acircumflex /atilde
773 /adieresis /aring /ae /ccedilla 754 /adieresis /aring /ae /ccedilla
774 /egrave /eacute /ecircumflex /edieresis 755 /egrave /eacute /ecircumflex /edieresis
775 /igrave /iacute /icircumflex /idieresis 756 /igrave /iacute /icircumflex /idieresis
776 /eth /ntilde /ograve /oacute 757 /eth /ntilde /ograve /oacute
1196 (if (and filename 1177 (if (and filename
1197 (or (numberp filename) 1178 (or (numberp filename)
1198 (listp filename))) 1179 (listp filename)))
1199 (let* ((name (concat (buffer-name) ".ps")) 1180 (let* ((name (concat (buffer-name) ".ps"))
1200 (prompt (format "Save PostScript to file: (default %s) " 1181 (prompt (format "Save PostScript to file: (default %s) "
1201 name))) 1182 name))
1202 (read-file-name prompt default-directory 1183 (res (read-file-name prompt default-directory name nil)))
1203 name nil)))) 1184 (if (file-directory-p res)
1185 (expand-file-name name (file-name-as-directory res))
1186 res))))
1204 1187
1205 ;; The following functions implement a simple list-buffering scheme so 1188 ;; The following functions implement a simple list-buffering scheme so
1206 ;; that ps-print doesn't have to repeatedly switch between buffers 1189 ;; that ps-print doesn't have to repeatedly switch between buffers
1207 ;; while spooling. The functions ps-output and ps-output-string build 1190 ;; while spooling. The functions ps-output and ps-output-string build
1208 ;; up the lists; the function ps-flush-output takes the lists and 1191 ;; up the lists; the function ps-flush-output takes the lists and
1563 (/ x-color-value ps-print-color-scale)) 1546 (/ x-color-value ps-print-color-scale))
1564 1547
1565 (defun ps-color-values (x-color) 1548 (defun ps-color-values (x-color)
1566 (cond ((fboundp 'x-color-values) 1549 (cond ((fboundp 'x-color-values)
1567 (x-color-values x-color)) 1550 (x-color-values x-color))
1551 ;; From fsf 19.33
1552 ;; ((fboundp 'pixel-components)
1553 ;; (pixel-components x-color))
1568 ((and (fboundp 'color-instance-rgb-components) 1554 ((and (fboundp 'color-instance-rgb-components)
1569 (xemacs-color-device)) 1555 (xemacs-color-device))
1570 (color-instance-rgb-components 1556 (color-instance-rgb-components
1571 (if (color-instance-p x-color) x-color 1557 (if (color-instance-p x-color) x-color
1572 (if (color-specifier-p x-color) 1558 (if (color-specifier-p x-color)
1642 1628
1643 ;; Check the user's preferences 1629 ;; Check the user's preferences
1644 (memq face kind-list)))) 1630 (memq face kind-list))))
1645 1631
1646 (defun ps-xemacs-face-kind-p (face kind kind-regex kind-list) 1632 (defun ps-xemacs-face-kind-p (face kind kind-regex kind-list)
1633 ;; fsf 19.33:
1634 ;; (let* ((frame-font (or (face-font face) (face-font 'default)))
1635 ;; (kind-cons (assq kind (x-font-properties frame-font)))
1647 (let* ((frame-font 1636 (let* ((frame-font
1648 (or (face-font-instance face) (face-font-instance 'default))) 1637 (or (face-font-instance face) (face-font-instance 'default)))
1649 (kind-cons (and frame-font 1638 (kind-cons (and frame-font
1650 (assq kind (font-instance-properties frame-font)))) 1639 (assq kind (font-instance-properties frame-font))))
1651 (kind-spec (cdr-safe kind-cons)) 1640 (kind-spec (cdr-safe kind-cons))
1800 ; unless previous search succeeded. 1789 ; unless previous search succeeded.
1801 (setq overlay-change 1790 (setq overlay-change
1802 (min (next-overlay-change from) to))) 1791 (min (next-overlay-change from) to)))
1803 (setq position 1792 (setq position
1804 (min property-change overlay-change)) 1793 (min property-change overlay-change))
1794 ;; The code below is not quite correct,
1795 ;; because a non-nil overlay invisible property
1796 ;; which is inactive according to the current value
1797 ;; of buffer-invisibility-spec nonetheless overrides
1798 ;; a face text property.
1805 (setq face 1799 (setq face
1806 (cond ((get-text-property from 'invisible) nil) 1800 (cond ((let ((prop (get-text-property from 'invisible)))
1801 ;; Decide whether this invisible property
1802 ;; really makes the text invisible.
1803 (if (eq buffer-invisibility-spec t)
1804 (not (null prop))
1805 (or (memq prop buffer-invisibility-spec)
1806 (assq prop buffer-invisibility-spec))))
1807 nil)
1807 ((get-text-property from 'face)) 1808 ((get-text-property from 'face))
1808 (t 'default))) 1809 (t 'default)))
1809 (let ((overlays (overlays-at from)) 1810 (let ((overlays (overlays-at from))
1810 (face-priority -1)) ; text-property 1811 (face-priority -1)) ; text-property
1811 (while overlays 1812 (while overlays
1815 (overlay-priority (or (overlay-get overlay 1816 (overlay-priority (or (overlay-get overlay
1816 'priority) 1817 'priority)
1817 0))) 1818 0)))
1818 (if (and (or overlay-invisible overlay-face) 1819 (if (and (or overlay-invisible overlay-face)
1819 (> overlay-priority face-priority)) 1820 (> overlay-priority face-priority))
1820 (setq face (cond (overlay-invisible nil) 1821 (setq face (cond ((if (eq buffer-invisibility-spec t)
1822 (not (null overlay-invisible))
1823 (or (memq overlay-invisible buffer-invisibility-spec)
1824 (assq overlay-invisible buffer-invisibility-spec)))
1825 nil)
1821 ((and face overlay-face))) 1826 ((and face overlay-face)))
1822 face-priority overlay-priority))) 1827 face-priority overlay-priority)))
1823 (setq overlays (cdr overlays)))) 1828 (setq overlays (cdr overlays))))
1824 ;; Plot up to this record. 1829 ;; Plot up to this record.
1825 (ps-plot-with-face from position face) 1830 (ps-plot-with-face from position face)
1829 (defun ps-generate-postscript (from to) 1834 (defun ps-generate-postscript (from to)
1830 (ps-plot-region from to 0 nil)) 1835 (ps-plot-region from to 0 nil))
1831 1836
1832 (defun ps-generate (buffer from to genfunc) 1837 (defun ps-generate (buffer from to genfunc)
1833 (let ((from (min to from)) 1838 (let ((from (min to from))
1834 (to (max to from))) 1839 (to (max to from))
1840 ;; This avoids trouble if chars with read-only properties
1841 ;; are copied into ps-spool-buffer.
1842 (inhibit-read-only t))
1835 (save-restriction 1843 (save-restriction
1836 (narrow-to-region from to) 1844 (narrow-to-region from to)
1837 (if ps-razzle-dazzle 1845 (if ps-razzle-dazzle
1838 (message "Formatting...%d%%" (setq ps-razchunk 0))) 1846 (message "Formatting...%d%%" (setq ps-razchunk 0)))
1839 (set-buffer buffer) 1847 (set-buffer buffer)
1873 (set-buffer ps-spool-buffer) 1881 (set-buffer ps-spool-buffer)
1874 (goto-char (point-max)) 1882 (goto-char (point-max))
1875 (while (re-search-backward "^/PageCount 0 def$" nil t) 1883 (while (re-search-backward "^/PageCount 0 def$" nil t)
1876 (replace-match (format "/PageCount %d def" ps-page-count) t)) 1884 (replace-match (format "/PageCount %d def" ps-page-count) t))
1877 1885
1878 ;; Setting this variable tells the unwind form that the 1886 ;; Setting this variable tells the unwind form that
1879 ;; the postscript was generated without error. 1887 ;; the postscript was generated without error.
1880 (setq completed-safely t)) 1888 (setq completed-safely t))
1881 1889
1882 ;; Unwind form: If some bad mojo ocurred while generating 1890 ;; Unwind form: If some bad mojo occurred while generating
1883 ;; postscript, delete all the postscript that was generated. 1891 ;; postscript, delete all the postscript that was generated.
1884 ;; This protects the previously spooled files from getting 1892 ;; This protects the previously spooled files from getting
1885 ;; corrupted. 1893 ;; corrupted.
1886 (if (and (markerp safe-marker) (not completed-safely)) 1894 (if (and (markerp safe-marker) (not completed-safely))
1887 (progn 1895 (progn
1909 ;; Else, spool to the printer 1917 ;; Else, spool to the printer
1910 (if ps-razzle-dazzle 1918 (if ps-razzle-dazzle
1911 (message "Printing...")) 1919 (message "Printing..."))
1912 (save-excursion 1920 (save-excursion
1913 (set-buffer ps-spool-buffer) 1921 (set-buffer ps-spool-buffer)
1914 (apply 'call-process-region 1922 (if (and (eq system-type 'ms-dos) (stringp dos-ps-printer))
1915 (point-min) (point-max) ps-lpr-command nil 0 nil 1923 (write-region (point-min) (point-max) dos-ps-printer t 0)
1916 ps-lpr-switches)) 1924 (let ((binary-process-input t)) ; for MS-DOS
1925 (apply 'call-process-region
1926 (point-min) (point-max) ps-lpr-command nil
1927 (if (fboundp 'start-process) 0 nil)
1928 nil
1929 ps-lpr-switches))))
1917 (if ps-razzle-dazzle 1930 (if ps-razzle-dazzle
1918 (message "Printing...done"))) 1931 (message "Printing...done")))
1919 (kill-buffer ps-spool-buffer))) 1932 (kill-buffer ps-spool-buffer)))
1920 1933
1921 (defun ps-kill-emacs-check () 1934 (defun ps-kill-emacs-check ()
1957 ;; Look in an article or mail message for the Subject: line. To be 1970 ;; Look in an article or mail message for the Subject: line. To be
1958 ;; placed in ps-left-headers. 1971 ;; placed in ps-left-headers.
1959 (defun ps-article-subject () 1972 (defun ps-article-subject ()
1960 (save-excursion 1973 (save-excursion
1961 (goto-char (point-min)) 1974 (goto-char (point-min))
1962 (if (re-search-forward "^Subject:[ \t]+\\(.*\\)$") 1975 (if (re-search-forward "^Subject:[ \t]+\\(.*\\)$" nil t)
1963 (buffer-substring (match-beginning 1) (match-end 1)) 1976 (buffer-substring (match-beginning 1) (match-end 1))
1964 "Subject ???"))) 1977 "Subject ???")))
1965 1978
1966 ;; Look in an article or mail message for the From: line. Sorta-kinda 1979 ;; Look in an article or mail message for the From: line. Sorta-kinda
1967 ;; understands RFC-822 addresses and can pull the real name out where 1980 ;; understands RFC-822 addresses and can pull the real name out where
1968 ;; it's provided. To be placed in ps-left-headers. 1981 ;; it's provided. To be placed in ps-left-headers.
1969 (defun ps-article-author () 1982 (defun ps-article-author ()
1970 (save-excursion 1983 (save-excursion
1971 (goto-char (point-min)) 1984 (goto-char (point-min))
1972 (if (re-search-forward "^From:[ \t]+\\(.*\\)$") 1985 (if (re-search-forward "^From:[ \t]+\\(.*\\)$" nil t)
1973 (let ((fromstring (buffer-substring (match-beginning 1) (match-end 1)))) 1986 (let ((fromstring (buffer-substring (match-beginning 1) (match-end 1))))
1974 (cond 1987 (cond
1975 1988
1976 ;; Try first to match addresses that look like 1989 ;; Try first to match addresses that look like
1977 ;; thompson@wg2.waii.com (Jim Thompson) 1990 ;; thompson@wg2.waii.com (Jim Thompson)
2040 ;; Look in an article or mail message for the Subject: line. To be 2053 ;; Look in an article or mail message for the Subject: line. To be
2041 ;; placed in ps-left-headers. 2054 ;; placed in ps-left-headers.
2042 (defun ps-info-file () 2055 (defun ps-info-file ()
2043 (save-excursion 2056 (save-excursion
2044 (goto-char (point-min)) 2057 (goto-char (point-min))
2045 (if (re-search-forward "File:[ \t]+\\([^, \t\n]*\\)") 2058 (if (re-search-forward "File:[ \t]+\\([^, \t\n]*\\)" nil t)
2046 (buffer-substring (match-beginning 1) (match-end 1)) 2059 (buffer-substring (match-beginning 1) (match-end 1))
2047 "File ???"))) 2060 "File ???")))
2048 2061
2049 ;; Look in an article or mail message for the Subject: line. To be 2062 ;; Look in an article or mail message for the Subject: line. To be
2050 ;; placed in ps-left-headers. 2063 ;; placed in ps-left-headers.
2051 (defun ps-info-node () 2064 (defun ps-info-node ()
2052 (save-excursion 2065 (save-excursion
2053 (goto-char (point-min)) 2066 (goto-char (point-min))
2054 (if (re-search-forward "Node:[ \t]+\\([^,\t\n]*\\)") 2067 (if (re-search-forward "Node:[ \t]+\\([^,\t\n]*\\)" nil t)
2055 (buffer-substring (match-beginning 1) (match-end 1)) 2068 (buffer-substring (match-beginning 1) (match-end 1))
2056 "Node ???"))) 2069 "Node ???")))
2057 2070
2058 (defun ps-info-mode-hook () 2071 (defun ps-info-mode-hook ()
2059 (setq ps-left-header 2072 (setq ps-left-header