aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-02-07 22:51:35 +0000
committerRichard M. Stallman1995-02-07 22:51:35 +0000
commit00aa16af7c3cef9973a5ad46f4bf8f275f465bbd (patch)
tree058121e6338252abcdbd903c3ff5de4b6b910369
parent719b242f866ff9ecd9e358c5f68c5650608d2991 (diff)
downloademacs-00aa16af7c3cef9973a5ad46f4bf8f275f465bbd.tar.gz
emacs-00aa16af7c3cef9973a5ad46f4bf8f275f465bbd.zip
Various changes.
-rw-r--r--lisp/ps-print.el256
1 files changed, 128 insertions, 128 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index b854b377bbd..e4d04f8b26a 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -3,7 +3,7 @@
3;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4 4
5;; Author: Jim Thompson <thompson@wg2.waii.com> 5;; Author: Jim Thompson <thompson@wg2.waii.com>
6;; Version: Jim's last version is 1.10 6;; Thompson's last version: 1.14
7;; Keywords: print, PostScript 7;; Keywords: print, PostScript
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
@@ -22,6 +22,11 @@
22;; along with GNU Emacs; see the file COPYING. If not, write to 22;; along with GNU Emacs; see the file COPYING. If not, write to
23;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 24
25;; LCD Archive Entry:
26;; ps-print|James C. Thompson|thompson@wg2.waii.com|
27;; Jim's Pretty-Good PostScript Generator for Emacs 19 (ps-print)|
28;; 26-Feb-1994|1.6|~/packages/ps-print.el|
29
25;;; Commentary: 30;;; Commentary:
26 31
27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -31,31 +36,15 @@
31;; This package provides printing of Emacs buffers on PostScript 36;; This package provides printing of Emacs buffers on PostScript
32;; printers; the buffer's bold and italic text attributes are 37;; printers; the buffer's bold and italic text attributes are
33;; preserved in the printer output. Ps-print is intended for use with 38;; preserved in the printer output. Ps-print is intended for use with
34;; Emacs 19 (Lucid or FSF) and a fontifying package such as font-lock 39;; Emacs 19 or Lucid Emacs, together with a fontifying package such as
35;; or hilit. 40;; font-lock or hilit.
36;; 41;;
37;; Installing ps-print 42;; Installing ps-print
38;; ------------------- 43;; -------------------
39;; 44;;
40;; 1. Place ps-print.el somewhere in your load-path and byte-compile 45;; Make sure that the variables ps-lpr-command and ps-lpr-switches
41;; it. You can ignore all byte-compiler warnings; they are the 46;; contain appropriate values for your system; see the usage notes
42;; result of multi-Emacs support. This step is necessary only if 47;; below and the documentation of these variables.
43;; you're installing your own ps-print; if ps-print came with your
44;; copy of Emacs, this been done already.
45;;
46;; 2. Place in your .emacs file the line
47;;
48;; (require 'ps-print)
49;;
50;; to load ps-print. Or you may cause any of the ps-print commands
51;; to be autoloaded with an autoload command such as:
52;;
53;; (autoload 'ps-print-buffer "ps-print"
54;; "Generate and print a PostScript image of the buffer..." t)
55;;
56;; 3. Make sure that the variables ps-lpr-command and ps-lpr-switches
57;; contain appropriate values for your system; see the usage notes
58;; below and the documentation of these variables.
59;; 48;;
60;; Using ps-print 49;; Using ps-print
61;; -------------- 50;; --------------
@@ -174,7 +163,7 @@
174;; NOTE: ps-lpr-command and ps-lpr-switches take their initial values 163;; NOTE: ps-lpr-command and ps-lpr-switches take their initial values
175;; from the variables lpr-command and lpr-switches. If you have 164;; from the variables lpr-command and lpr-switches. If you have
176;; lpr-command set to invoke a pretty-printer such as enscript, 165;; lpr-command set to invoke a pretty-printer such as enscript,
177;; then ps-print won't work properly. Ps-lpr-command must name 166;; then ps-print won't work properly. ps-lpr-command must name
178;; a program that does not format the files it prints. 167;; a program that does not format the files it prints.
179;; 168;;
180;; 169;;
@@ -313,30 +302,18 @@
313;; formats for; it should contain one of the symbols ps-letter, 302;; formats for; it should contain one of the symbols ps-letter,
314;; ps-legal, or ps-a4. The default is ps-letter. 303;; ps-legal, or ps-a4. The default is ps-letter.
315;; 304;;
316;;
317;; New in version 1.6
318;; ------------------
319;; Color output capability.
320;;
321;; Automatic detection of font attributes (bold, italic).
322;;
323;; Configurable headers with page numbers.
324;;
325;; Slightly faster.
326;;
327;; Support for different paper sizes.
328;;
329;; Better conformance to PostScript Document Structure Conventions.
330;;
331;; 305;;
332;; Known bugs and limitations of ps-print: 306;; Known bugs and limitations of ps-print:
333;; -------------------------------------- 307;; --------------------------------------
308;; Automatic font-attribute detection doesn't work will, especially
309;; with hilit19 and older versions of get-create-face. Users having
310;; problems with auto-font detection should use the lists ps-italic-
311;; faces and ps-bold-faces and/or turn off automatic detection by
312;; setting ps-auto-font-detect to nil.
313;;
334;; Color output doesn't yet work in XEmacs. 314;; Color output doesn't yet work in XEmacs.
335;; 315;;
336;; Slow. Because XEmacs implements certain functions, such as 316;; Still too slow; could use some hand-optimization.
337;; next-property-change, in lisp, printing with faces is several times
338;; slower in XEmacs. In Emacs, these functions are implemented in C,
339;; so Emacs is somewhat faster.
340;; 317;;
341;; ASCII Control characters other than tab, linefeed and pagefeed are 318;; ASCII Control characters other than tab, linefeed and pagefeed are
342;; not handled. 319;; not handled.
@@ -384,11 +361,8 @@
384 361
385;;; Code: 362;;; Code:
386 363
387(defconst ps-print-version "1.10" 364(defconst ps-print-thompson-version "1.14"
388 "ps-print.el,v 1.10 1995/01/09 14:45:03 jct Exp 365 "Report bugs to thompson@wg2.waii.com and bug-gnu-emacs@prep.ai.mit.edu.")
389
390Please send all bug fixes and enhancements to
391 Jim Thompson <thompson@wg2.waii.com>.")
392 366
393;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 367;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
394;; User Variables: 368;; User Variables:
@@ -410,7 +384,7 @@ the left on even-numbered pages.")
410 384
411(defvar ps-paper-type 'ps-letter 385(defvar ps-paper-type 'ps-letter
412 "*Specifies the size of paper to format for. Should be one of 386 "*Specifies the size of paper to format for. Should be one of
413'ps-letter, 'ps-legal, or 'ps-a4.") 387`ps-letter', `ps-legal', or `ps-a4'.")
414 388
415(defvar ps-print-header t 389(defvar ps-print-header t
416 "*Non-nil means print a header at the top of each page. 390 "*Non-nil means print a header at the top of each page.
@@ -423,9 +397,9 @@ customizable by changing variables `ps-header-left' and
423 "*Non-nil means draw a gaudy frame around the header.") 397 "*Non-nil means draw a gaudy frame around the header.")
424 398
425(defvar ps-show-n-of-n t 399(defvar ps-show-n-of-n t
426 "*Non-nil means show page numbers as `N/M', meaning page N of M. 400 "*Non-nil means show page numbers as N/M, meaning page N of M.
427Note: page numbers are displayed as part of headers, see variable `ps- 401Note: page numbers are displayed as part of headers, see variable
428print-headers'.") 402`ps-print-headers'.")
429 403
430(defvar ps-print-color-p (and (fboundp 'x-color-values) 404(defvar ps-print-color-p (and (fboundp 'x-color-values)
431 (fboundp 'float)) 405 (fboundp 'float))
@@ -552,6 +526,7 @@ variable.")
552;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 526;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
553;; User commands 527;; User commands
554 528
529;;;###autoload
555(defun ps-print-buffer (&optional filename) 530(defun ps-print-buffer (&optional filename)
556 "Generate and print a PostScript image of the buffer. 531 "Generate and print a PostScript image of the buffer.
557 532
@@ -564,50 +539,50 @@ is nil, send the image to the printer. If FILENAME is a string, save
564the PostScript image in a file with that name. If FILENAME is a 539the PostScript image in a file with that name. If FILENAME is a
565number, prompt the user for the name of the file to save in." 540number, prompt the user for the name of the file to save in."
566 541
567 (interactive "P") 542 (interactive (list (ps-print-preprint current-prefix-arg)))
568 (setq filename (ps-print-preprint filename))
569 (ps-generate (current-buffer) (point-min) (point-max) 543 (ps-generate (current-buffer) (point-min) (point-max)
570 'ps-generate-postscript) 544 'ps-generate-postscript)
571 (ps-do-despool filename)) 545 (ps-do-despool filename))
572 546
573 547
548;;;###autoload
574(defun ps-print-buffer-with-faces (&optional filename) 549(defun ps-print-buffer-with-faces (&optional filename)
575 "Generate and print a PostScript image of the buffer. 550 "Generate and print a PostScript image of the buffer.
576 551
577Like `ps-print-buffer', but includes font, color, and underline 552Like `ps-print-buffer', but includes font, color, and underline
578information in the generated image." 553information in the generated image."
579 (interactive "P") 554 (interactive (list (ps-print-preprint current-prefix-arg)))
580 (setq filename (ps-print-preprint filename))
581 (ps-generate (current-buffer) (point-min) (point-max) 555 (ps-generate (current-buffer) (point-min) (point-max)
582 'ps-generate-postscript-with-faces) 556 'ps-generate-postscript-with-faces)
583 (ps-do-despool filename)) 557 (ps-do-despool filename))
584 558
585 559
560;;;###autoload
586(defun ps-print-region (from to &optional filename) 561(defun ps-print-region (from to &optional filename)
587 "Generate and print a PostScript image of the region. 562 "Generate and print a PostScript image of the region.
588 563
589Like `ps-print-buffer', but prints just the current region." 564Like `ps-print-buffer', but prints just the current region."
590 565
591 (interactive "r\nP") 566 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
592 (setq filename (ps-print-preprint filename))
593 (ps-generate (current-buffer) from to 567 (ps-generate (current-buffer) from to
594 'ps-generate-postscript) 568 'ps-generate-postscript)
595 (ps-do-despool filename)) 569 (ps-do-despool filename))
596 570
597 571
572;;;###autoload
598(defun ps-print-region-with-faces (from to &optional filename) 573(defun ps-print-region-with-faces (from to &optional filename)
599 "Generate and print a PostScript image of the region. 574 "Generate and print a PostScript image of the region.
600 575
601Like `ps-print-region', but includes font, color, and underline 576Like `ps-print-region', but includes font, color, and underline
602information in the generated image." 577information in the generated image."
603 578
604 (interactive "r\nP") 579 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
605 (setq filename (ps-print-preprint filename))
606 (ps-generate (current-buffer) from to 580 (ps-generate (current-buffer) from to
607 'ps-generate-postscript-with-faces) 581 'ps-generate-postscript-with-faces)
608 (ps-do-despool filename)) 582 (ps-do-despool filename))
609 583
610 584
585;;;###autoload
611(defun ps-spool-buffer () 586(defun ps-spool-buffer ()
612 "Generate and spool a PostScript image of the buffer. 587 "Generate and spool a PostScript image of the buffer.
613 588
@@ -620,6 +595,7 @@ Use the command `ps-despool' to send the spooled images to the printer."
620 'ps-generate-postscript)) 595 'ps-generate-postscript))
621 596
622 597
598;;;###autoload
623(defun ps-spool-buffer-with-faces () 599(defun ps-spool-buffer-with-faces ()
624 "Generate and spool a PostScript image of the buffer. 600 "Generate and spool a PostScript image of the buffer.
625 601
@@ -633,6 +609,7 @@ Use the command `ps-despool' to send the spooled images to the printer."
633 'ps-generate-postscript-with-faces)) 609 'ps-generate-postscript-with-faces))
634 610
635 611
612;;;###autoload
636(defun ps-spool-region (from to) 613(defun ps-spool-region (from to)
637 "Generate a PostScript image of the region and spool locally. 614 "Generate a PostScript image of the region and spool locally.
638 615
@@ -644,6 +621,7 @@ Use the command `ps-despool' to send the spooled images to the printer."
644 'ps-generate-postscript)) 621 'ps-generate-postscript))
645 622
646 623
624;;;###autoload
647(defun ps-spool-region-with-faces (from to) 625(defun ps-spool-region-with-faces (from to)
648 "Generate a PostScript image of the region and spool locally. 626 "Generate a PostScript image of the region and spool locally.
649 627
@@ -655,6 +633,7 @@ Use the command `ps-despool' to send the spooled images to the printer."
655 (ps-generate (current-buffer) from to 633 (ps-generate (current-buffer) from to
656 'ps-generate-postscript-with-faces)) 634 'ps-generate-postscript-with-faces))
657 635
636;;;###autoload
658(defun ps-despool (&optional filename) 637(defun ps-despool (&optional filename)
659 "Send the spooled PostScript to the printer. 638 "Send the spooled PostScript to the printer.
660 639
@@ -666,8 +645,8 @@ More specifically, the FILENAME argument is treated as follows: if it
666is nil, send the image to the printer. If FILENAME is a string, save 645is nil, send the image to the printer. If FILENAME is a string, save
667the PostScript image in a file with that name. If FILENAME is a 646the PostScript image in a file with that name. If FILENAME is a
668number, prompt the user for the name of the file to save in." 647number, prompt the user for the name of the file to save in."
669 (interactive "P") 648 (interactive (list (ps-print-preprint current-prefix-arg)))
670 (ps-do-despool (ps-print-preprint filename))) 649 (ps-do-despool filename))
671 650
672;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 651;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
673;; Utility functions and variables: 652;; Utility functions and variables:
@@ -807,7 +786,7 @@ StandardEncoding 46 82 getinterval aload pop
807 findfont 786 findfont
808 dup /Ascent get /Ascent exch def 787 dup /Ascent get /Ascent exch def
809 dup /Descent get /Descent exch def 788 dup /Descent get /Descent exch def
810 dup /FontHeight get /LineHeight exch def 789 dup /FontHeight get /FontHeight exch def
811 dup /UnderlinePosition get /UnderlinePosition exch def 790 dup /UnderlinePosition get /UnderlinePosition exch def
812 dup /UnderlineThickness get /UnderlineThickness exch def 791 dup /UnderlineThickness get /UnderlineThickness exch def
813 setfont 792 setfont
@@ -930,7 +909,7 @@ StandardEncoding 46 82 getinterval aload pop
930 909
931/h1 F 910/h1 F
932 911
933/HeaderLineHeight LineHeight def 912/HeaderLineHeight FontHeight def
934/HeaderDescent Descent def 913/HeaderDescent Descent def
935/HeaderPad 2 def 914/HeaderPad 2 def
936 915
@@ -1021,7 +1000,7 @@ StandardEncoding 46 82 getinterval aload pop
1021 2 copy 1000 2 copy
1022 /t0 3 1 roll Font 1001 /t0 3 1 roll Font
1023 /t0 F 1002 /t0 F
1024 /lh LineHeight def 1003 /lh FontHeight def
1025 /sw ( ) stringwidth pop def 1004 /sw ( ) stringwidth pop def
1026 /aw (01234567890abcdefghijklmnopqrstuvwxyz) dup length exch 1005 /aw (01234567890abcdefghijklmnopqrstuvwxyz) dup length exch
1027 stringwidth pop exch div def 1006 stringwidth pop exch div def
@@ -1039,7 +1018,7 @@ StandardEncoding 46 82 getinterval aload pop
1039 sw 32 string cvs show 1018 sw 32 string cvs show
1040 (,) show 1019 (,) show
1041 grestore 1020 grestore
1042 0 LineHeight neg rmoveto 1021 0 FontHeight neg rmoveto
1043 (and a crude estimate of average character width is ) show 1022 (and a crude estimate of average character width is ) show
1044 aw 32 string cvs show 1023 aw 32 string cvs show
1045 (.) show 1024 (.) show
@@ -1284,6 +1263,8 @@ StandardEncoding 46 82 getinterval aload pop
1284 (ps-output (format "/PrintWidth %d def\n" ps-print-width)) 1263 (ps-output (format "/PrintWidth %d def\n" ps-print-width))
1285 (ps-output (format "/PrintHeight %d def\n" ps-print-height)) 1264 (ps-output (format "/PrintHeight %d def\n" ps-print-height))
1286 1265
1266 (ps-output (format "/LineHeight %d def\n" ps-line-height))
1267
1287 (ps-output ps-print-prologue) 1268 (ps-output ps-print-prologue)
1288 1269
1289 (ps-output (format "/f0 %d /%s Font\n" ps-font-size ps-font)) 1270 (ps-output (format "/f0 %d /%s Font\n" ps-font-size ps-font))
@@ -1425,7 +1406,7 @@ EndDSCPage\n"))
1425 (chunkfrac (/ q-todo 8)) 1406 (chunkfrac (/ q-todo 8))
1426 (chunksize (if (> chunkfrac 1000) 1000 chunkfrac))) 1407 (chunksize (if (> chunkfrac 1000) 1000 chunkfrac)))
1427 (if (> (- q-done ps-razchunk) chunksize) 1408 (if (> (- q-done ps-razchunk) chunksize)
1428 (progn 1409 (let (foo)
1429 (setq ps-razchunk q-done) 1410 (setq ps-razchunk q-done)
1430 (setq foo 1411 (setq foo
1431 (if (< q-todo 100) 1412 (if (< q-todo 100)
@@ -1437,9 +1418,7 @@ EndDSCPage\n"))
1437 (setq ps-current-font font) 1418 (setq ps-current-font font)
1438 (ps-output (format "/f%d F\n" ps-current-font))) 1419 (ps-output (format "/f%d F\n" ps-current-font)))
1439 1420
1440(defvar ps-print-color-scale (if ps-print-color-p 1421(defvar ps-print-color-scale nil)
1441 (float (car (x-color-values "white")))
1442 1.0))
1443 1422
1444(defun ps-set-bg (color) 1423(defun ps-set-bg (color)
1445 (if (setq ps-current-bg color) 1424 (if (setq ps-current-bg color)
@@ -1571,7 +1550,9 @@ EndDSCPage\n"))
1571(defun ps-face-italic-p (face) 1550(defun ps-face-italic-p (face)
1572 (if (eq emacs-type 'fsf) 1551 (if (eq emacs-type 'fsf)
1573 (ps-fsf-face-kind-p face 'italic "-[io]-" ps-italic-faces) 1552 (ps-fsf-face-kind-p face 'italic "-[io]-" ps-italic-faces)
1574 (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o" ps-italic-faces))) 1553 (or
1554 (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o" ps-italic-faces)
1555 (ps-xemacs-face-kind-p face 'SLANT "i\\|o" ps-italic-faces))))
1575 1556
1576(defun ps-face-underlined-p (face) 1557(defun ps-face-underlined-p (face)
1577 (or (face-underline-p face) 1558 (or (face-underline-p face)
@@ -1613,13 +1594,25 @@ EndDSCPage\n"))
1613 1594
1614(defun ps-sorter (a b) 1595(defun ps-sorter (a b)
1615 (< (car a) (car b))) 1596 (< (car a) (car b)))
1597
1598(defun ps-extent-sorter (a b)
1599 (< (extent-priority a) (extent-priority b)))
1616 1600
1617(defun ps-generate-postscript-with-faces (from to) 1601(defun ps-generate-postscript-with-faces (from to)
1602 ;; Build the reference lists of faces if necessary.
1618 (if (or ps-always-build-face-reference 1603 (if (or ps-always-build-face-reference
1619 ps-build-face-reference) 1604 ps-build-face-reference)
1620 (progn 1605 (progn
1621 (message "Collecting face information...") 1606 (message "Collecting face information...")
1622 (ps-build-reference-face-lists))) 1607 (ps-build-reference-face-lists)))
1608 ;; Set the color scale. We do it here instead of in the defvar so
1609 ;; that ps-print can be dumped into emacs. This expression can't be
1610 ;; evaluated at dump-time because X isn't initialized.
1611 (setq ps-print-color-scale
1612 (if ps-print-color-p
1613 (float (car (x-color-values "white")))
1614 1.0))
1615 ;; Generate some PostScript.
1623 (save-restriction 1616 (save-restriction
1624 (narrow-to-region from to) 1617 (narrow-to-region from to)
1625 (let ((face 'default) 1618 (let ((face 'default)
@@ -1708,64 +1701,66 @@ EndDSCPage\n"))
1708 (ps-plot-region from to 0 nil)) 1701 (ps-plot-region from to 0 nil))
1709 1702
1710(defun ps-generate (buffer from to genfunc) 1703(defun ps-generate (buffer from to genfunc)
1711 (save-restriction 1704 (let ((from (min to from))
1712 (narrow-to-region from to) 1705 (to (max to from)))
1713 (if ps-razzle-dazzle 1706 (save-restriction
1714 (message "Formatting...%d%%" (setq ps-razchunk 0))) 1707 (narrow-to-region from to)
1715 (set-buffer buffer) 1708 (if ps-razzle-dazzle
1716 (setq ps-source-buffer buffer) 1709 (message "Formatting...%d%%" (setq ps-razchunk 0)))
1717 (setq ps-spool-buffer (get-buffer-create ps-spool-buffer-name)) 1710 (set-buffer buffer)
1718 (ps-init-output-queue) 1711 (setq ps-source-buffer buffer)
1719 (let (safe-marker completed-safely needs-begin-file) 1712 (setq ps-spool-buffer (get-buffer-create ps-spool-buffer-name))
1720 (unwind-protect 1713 (ps-init-output-queue)
1721 (progn 1714 (let (safe-marker completed-safely needs-begin-file)
1722 (set-buffer ps-spool-buffer) 1715 (unwind-protect
1716 (progn
1717 (set-buffer ps-spool-buffer)
1723 1718
1724 ;; Get a marker and make it point to the current end of the 1719 ;; Get a marker and make it point to the current end of the
1725 ;; buffer, If an error occurs, we'll delete everything from 1720 ;; buffer, If an error occurs, we'll delete everything from
1726 ;; the end of this marker onwards. 1721 ;; the end of this marker onwards.
1727 (setq safe-marker (make-marker)) 1722 (setq safe-marker (make-marker))
1728 (set-marker safe-marker (point-max)) 1723 (set-marker safe-marker (point-max))
1729 1724
1730 (goto-char (point-min)) 1725 (goto-char (point-min))
1731 (if (looking-at (regexp-quote "%!PS-Adobe-1.0")) 1726 (if (looking-at (regexp-quote "%!PS-Adobe-1.0"))
1732 nil 1727 nil
1733 (setq needs-begin-file t)) 1728 (setq needs-begin-file t))
1734 (save-excursion 1729 (save-excursion
1730 (set-buffer ps-source-buffer)
1731 (if needs-begin-file (ps-begin-file))
1732 (ps-begin-job)
1733 (ps-begin-page))
1735 (set-buffer ps-source-buffer) 1734 (set-buffer ps-source-buffer)
1736 (if needs-begin-file (ps-begin-file)) 1735 (funcall genfunc from to)
1737 (ps-begin-job) 1736 (ps-end-page)
1738 (ps-begin-page))
1739 (set-buffer ps-source-buffer)
1740 (funcall genfunc from to)
1741 (ps-end-page)
1742 1737
1743 (if (and ps-spool-duplex 1738 (if (and ps-spool-duplex
1744 (= (mod ps-page-count 2) 1)) 1739 (= (mod ps-page-count 2) 1))
1745 (ps-dummy-page)) 1740 (ps-dummy-page))
1746 (ps-flush-output) 1741 (ps-flush-output)
1747 1742
1748 ;; Back to the PS output buffer to set the page count 1743 ;; Back to the PS output buffer to set the page count
1749 (set-buffer ps-spool-buffer)
1750 (goto-char (point-max))
1751 (while (re-search-backward "^/PageCount 0 def$" nil t)
1752 (replace-match (format "/PageCount %d def" ps-page-count) t))
1753
1754 ;; Setting this variable tells the unwind form that the
1755 ;; the postscript was generated without error.
1756 (setq completed-safely t))
1757
1758 ;; Unwind form: If some bad mojo ocurred while generating
1759 ;; postscript, delete all the postscript that was generated.
1760 ;; This protects the previously spooled files from getting
1761 ;; corrupted.
1762 (if (and (markerp safe-marker) (not completed-safely))
1763 (progn
1764 (set-buffer ps-spool-buffer) 1744 (set-buffer ps-spool-buffer)
1765 (delete-region (marker-position safe-marker) (point-max)))))) 1745 (goto-char (point-max))
1746 (while (re-search-backward "^/PageCount 0 def$" nil t)
1747 (replace-match (format "/PageCount %d def" ps-page-count) t))
1748
1749 ;; Setting this variable tells the unwind form that the
1750 ;; the postscript was generated without error.
1751 (setq completed-safely t))
1752
1753 ;; Unwind form: If some bad mojo ocurred while generating
1754 ;; postscript, delete all the postscript that was generated.
1755 ;; This protects the previously spooled files from getting
1756 ;; corrupted.
1757 (if (and (markerp safe-marker) (not completed-safely))
1758 (progn
1759 (set-buffer ps-spool-buffer)
1760 (delete-region (marker-position safe-marker) (point-max))))))
1766 1761
1767 (if ps-razzle-dazzle 1762 (if ps-razzle-dazzle
1768 (message "Formatting...done")))) 1763 (message "Formatting...done")))))
1769 1764
1770(defun ps-do-despool (filename) 1765(defun ps-do-despool (filename)
1771 (if (or (not (boundp 'ps-spool-buffer)) 1766 (if (or (not (boundp 'ps-spool-buffer))
@@ -1818,6 +1813,12 @@ EndDSCPage\n"))
1818;; and able to figure out how to use it. It isn't really part of ps- 1813;; and able to figure out how to use it. It isn't really part of ps-
1819;; print, but I'll leave it here in hopes it might be useful: 1814;; print, but I'll leave it here in hopes it might be useful:
1820 1815
1816(defmacro ps-prsc () (list 'if (list 'eq 'emacs-type ''fsf) [f22] ''f22))
1817(defmacro ps-c-prsc () (list 'if (list 'eq 'emacs-type ''fsf) [C-f22]
1818 ''(control f22)))
1819(defmacro ps-s-prsc () (list 'if (list 'eq 'emacs-type ''fsf) [S-f22]
1820 ''(shift f22)))
1821
1821;; Look in an article or mail message for the Subject: line. To be 1822;; Look in an article or mail message for the Subject: line. To be
1822;; placed in ps-left-headers. 1823;; placed in ps-left-headers.
1823(defun ps-article-subject () 1824(defun ps-article-subject ()
@@ -1868,7 +1869,7 @@ EndDSCPage\n"))
1868;; left-headers specially for mail messages. This header setup would 1869;; left-headers specially for mail messages. This header setup would
1869;; also work, I think, for RMAIL. 1870;; also work, I think, for RMAIL.
1870(defun ps-vm-mode-hook () 1871(defun ps-vm-mode-hook ()
1871 (local-set-key 'f22 'ps-vm-print-message-from-summary) 1872 (local-set-key (ps-prsc) 'ps-vm-print-message-from-summary)
1872 (setq ps-header-lines 3) 1873 (setq ps-header-lines 3)
1873 (setq ps-left-header 1874 (setq ps-left-header
1874 ;; The left headers will display the message's subject, its 1875 ;; The left headers will display the message's subject, its
@@ -1899,9 +1900,7 @@ EndDSCPage\n"))
1899;; A hook to bind to bind to gnus-summary-setup-buffer to locally bind 1900;; A hook to bind to bind to gnus-summary-setup-buffer to locally bind
1900;; prsc. 1901;; prsc.
1901(defun ps-gnus-summary-setup () 1902(defun ps-gnus-summary-setup ()
1902 (local-set-key 'f22 'ps-gnus-print-article-from-summary)) 1903 (local-set-key (ps-prsc) 'ps-gnus-print-article-from-summary))
1903
1904;; File: lispref.info, Node: Standard Errors
1905 1904
1906;; Look in an article or mail message for the Subject: line. To be 1905;; Look in an article or mail message for the Subject: line. To be
1907;; placed in ps-left-headers. 1906;; placed in ps-left-headers.
@@ -1927,12 +1926,13 @@ EndDSCPage\n"))
1927 (list 'ps-info-node 'ps-info-file))) 1926 (list 'ps-info-node 'ps-info-file)))
1928 1927
1929(defun ps-jts-ps-setup () 1928(defun ps-jts-ps-setup ()
1930 (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc 1929 (global-set-key (ps-prsc) 'ps-spool-buffer-with-faces) ;f22 is prsc
1931 (global-set-key '(shift f22) 'ps-spool-region-with-faces) 1930 (global-set-key (ps-s-prsc) 'ps-spool-region-with-faces)
1932 (global-set-key '(control f22) 'ps-despool) 1931 (global-set-key (ps-c-prsc) 'ps-despool)
1933 (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook) 1932 (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook)
1934 (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup) 1933 (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup)
1935 (add-hook 'vm-mode-hook 'ps-vm-mode-hook) 1934 (add-hook 'vm-mode-hook 'ps-vm-mode-hook)
1935 (add-hook 'vm-mode-hooks 'ps-vm-mode-hook)
1936 (add-hook 'Info-mode-hook 'ps-info-mode-hook) 1936 (add-hook 'Info-mode-hook 'ps-info-mode-hook)
1937 (setq ps-spool-duplex t) 1937 (setq ps-spool-duplex t)
1938 (setq ps-print-color-p nil) 1938 (setq ps-print-color-p nil)