comparison lisp/ps-print.el @ 51007:c3f9aa88ed68

Avoid unnecessary calls to funs in header and footer variables
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Thu, 15 May 2003 02:32:03 +0000
parents ff9f693543fd
children 6edc2212d82e
comparison
equal deleted inserted replaced
51006:ea8655d397d6 51007:c3f9aa88ed68
8 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> 8 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
9 ;; Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 9 ;; Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
10 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 10 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
11 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> 11 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
12 ;; Keywords: wp, print, PostScript 12 ;; Keywords: wp, print, PostScript
13 ;; Time-stamp: <2003/03/05 21:54:55 vinicius> 13 ;; Time-stamp: <2003/05/14 22:34:05 vinicius>
14 ;; Version: 6.6 14 ;; Version: 6.6.1
15 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ 15 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
16 16
17 (defconst ps-print-version "6.6" 17 (defconst ps-print-version "6.6.1"
18 "ps-print.el, v 6.6 <2003/03/05 vinicius> 18 "ps-print.el, v 6.6.1 <2003/05/14 vinicius>
19 19
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
838 ;; 20 XXXXX + 20 XXXXXXXX + 18 XXXXXX + 18 + 838 ;; 20 XXXXX + 20 XXXXXXXX + 18 XXXXXX + 18 +
839 ;; 21 + 21 XXXXXXXX + 839 ;; 21 + 21 XXXXXXXX +
840 ;; 22 + 22 + 840 ;; 22 + 22 +
841 ;; -------- ----------- --------- ---------------- 841 ;; -------- ----------- --------- ----------------
842 ;; 842 ;;
843 ;; Any other value is treated as `nil'. 843 ;; Any other value is treated as nil.
844 ;; 844 ;;
845 ;; See also section How Ps-Print Has A Text And/Or Image On Background. 845 ;; See also section How Ps-Print Has A Text And/Or Image On Background.
846 ;; 846 ;;
847 ;; 847 ;;
848 ;; Hooks 848 ;; Hooks
4663 (ps-flush-output) 4663 (ps-flush-output)
4664 (save-excursion 4664 (save-excursion
4665 (set-buffer ps-spool-buffer) 4665 (set-buffer ps-spool-buffer)
4666 (goto-char (point-max)) 4666 (goto-char (point-max))
4667 (insert-file fname))) 4667 (insert-file fname)))
4668
4669 ;; These functions are used in `ps-mule' to get charset of header and footer.
4670 ;; To avoid unnecessary calls to functions in `ps-left-header',
4671 ;; `ps-right-header', `ps-left-footer' and `ps-right-footer'.
4672
4673 (defun ps-generate-string-list (content)
4674 (let (str)
4675 (while content
4676 (setq str (cons (cond
4677 ((stringp (car content))
4678 (car content))
4679 ((and (symbolp (car content)) (fboundp (car content)))
4680 (concat "(" (funcall (car content)) ")"))
4681 ((and (symbolp (car content)) (boundp (car content)))
4682 (concat "(" (symbol-value (car content)) ")"))
4683 (t
4684 ""))
4685 str)
4686 content (cdr content)))
4687 (nreverse str)))
4688
4689 (defvar ps-lh-cache nil)
4690 (defvar ps-rh-cache nil)
4691 (defvar ps-lf-cache nil)
4692 (defvar ps-rf-cache nil)
4693
4694 (defun ps-header-footer-string ()
4695 (and ps-print-header
4696 (setq ps-lh-cache (ps-generate-string-list ps-left-header)
4697 ps-rh-cache (ps-generate-string-list ps-right-header)))
4698 (and ps-print-footer
4699 (setq ps-lf-cache (ps-generate-string-list ps-left-footer)
4700 ps-rf-cache (ps-generate-string-list ps-right-footer)))
4701 (mapconcat 'identity
4702 (append ps-lh-cache ps-rh-cache ps-lf-cache ps-rf-cache)
4703 ""))
4668 4704
4669 ;; These functions insert the arrays that define the contents of the headers. 4705 ;; These functions insert the arrays that define the contents of the headers.
4670 4706
4671 (defun ps-generate-header-line (fonttag &optional content) 4707 (defun ps-generate-header-line (fonttag &optional content)
4672 (ps-output " [" fonttag " ") 4708 (ps-output " [" fonttag " ")
5807 5843
5808 (ps-output (format "/LineNumber %d def\n" ps-showline-count) 5844 (ps-output (format "/LineNumber %d def\n" ps-showline-count)
5809 (format "/PageNumber %d def\n" (ps-page-number))) 5845 (format "/PageNumber %d def\n" (ps-page-number)))
5810 5846
5811 (when ps-print-header 5847 (when ps-print-header
5812 (ps-generate-header "HeaderLinesLeft" "/h0" "/h1" ps-left-header) 5848 (ps-generate-header "HeaderLinesLeft" "/h0" "/h1"
5813 (ps-generate-header "HeaderLinesRight" "/h0" "/h1" ps-right-header) 5849 (or ps-lh-cache ps-left-header))
5814 (ps-output (format "%d SetHeaderLines\n" ps-header-lines))) 5850 (ps-generate-header "HeaderLinesRight" "/h0" "/h1"
5851 (or ps-rh-cache ps-right-header))
5852 (ps-output (format "%d SetHeaderLines\n" ps-header-lines))
5853 (setq ps-lh-cache nil
5854 ps-rh-cache nil))
5815 5855
5816 (when ps-print-footer 5856 (when ps-print-footer
5817 (ps-generate-header "FooterLinesLeft" "/H0" "/H0" ps-left-footer) 5857 (ps-generate-header "FooterLinesLeft" "/H0" "/H0"
5818 (ps-generate-header "FooterLinesRight" "/H0" "/H0" ps-right-footer) 5858 (or ps-lf-cache ps-left-footer))
5819 (ps-output (format "%d SetFooterLines\n" ps-footer-lines))) 5859 (ps-generate-header "FooterLinesRight" "/H0" "/H0"
5860 (or ps-rf-cache ps-right-footer))
5861 (ps-output (format "%d SetFooterLines\n" ps-footer-lines))
5862 (setq ps-lf-cache nil
5863 ps-rf-cache nil))
5820 5864
5821 (ps-output (number-to-string ps-lines-printed) " BeginPage\n") 5865 (ps-output (number-to-string ps-lines-printed) " BeginPage\n")
5822 (ps-set-font ps-current-font) 5866 (ps-set-font ps-current-font)
5823 (ps-set-bg ps-current-bg) 5867 (ps-set-bg ps-current-bg)
5824 (ps-set-color ps-current-color) 5868 (ps-set-color ps-current-color)