annotate lisp/printer.el @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents
children de805c49cfc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
1 ;;; printer.el --- support for hard-copy printing in XEmacs
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
2
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
3 ;; Copyright (C) 2000 Ben Wing.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
4 ;; Copyright (C) 2000 Kirill Katsnelson.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
5
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
7 ;; Keywords: printer, printing, internal, dumped
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
8
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
10
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
14 ;; any later version.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
15
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
19 ;; General Public License for more details.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
20
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
25
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
27
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
28 ;;; Authorship:
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
29
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
30 ;; Created 2000 by Ben Wing, to provide the high-level interface onto the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
31 ;; print support implemented by Kirill Katsnelson.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
32
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
33 ;;; Commentary:
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
34
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
35 ;; This file is dumped with XEmacs.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
36
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
37
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
39 ;; generic printing code ;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
41
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
42 ;; #### should be named print-buffer, but that's currently in
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
43 ;; lpr-buffer with some horrible definition: print-buffer == "print with
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
44 ;; headings", lpr-buffer == "print without headings", and the headings are
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
45 ;; generated by calling the external program "pr"! This is major stone-age
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
46 ;; here!
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
47 ;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
48 ;; I propose junking that package entirely and creating a unified,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
49 ;; modern API here that will work well with modern GUI's on top of it,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
50 ;; and with various different actual implementations (e.g. lpr or the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
51 ;; pretty-print package on Unix, built-in msprinter support on
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
52 ;; Windows), where the workings of a particular implementation is
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
53 ;; hidden from the user and there is a consistent set of options to
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
54 ;; control how to print, which works across all implementations.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
55 ;;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
56 ;; The code here is just a start and needs a huge amount of work. Probably
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
57 ;; the interfaces below will change and the functions renamed.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
58
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
59 (defgroup printing nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
60 "Generic printing support."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
61 :group 'wp)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
62
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
63 (defcustom printer-name nil ; "Okidata OL610e/PS PostScript"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
64 "*Name of printer to print to.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
65 If nil, use default.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
66 Under MS Windows, this can have the form `\\\\STOLI\\HP-345-PS'."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
67 :type 'string
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
68 :group 'printing)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
69
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
70 (defcustom printer-page-header '(date buffer-name)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
71 "*Controls printed page header.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
72
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
73 #### not yet implemented.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
74
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
75 This can be:
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
76 - nil. Header is not printed.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
77 - An fbound symbol or lambda expression. The function is called with
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
78 one parameter, a print-context object, every time the headers need
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
79 to be set up. It can use the function `print-context-property' to
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
80 query the properties of this object. The return value is treated as
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
81 if it was literally specified: i.e. it will be reprocessed.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
82 - A list of up to three elements, for left, center and right portions
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
83 of the header. Each of these can be
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
84 - nil, not to print the portion
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
85 - A string, which will be printed literally.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
86 - A predefined symbol, on of the following:
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
87 short-file-name File name only, no path
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
88 long-file-name File name with its path
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
89 buffer-name Buffer name
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
90 date Date current when printing started
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
91 time Time current when printing started
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
92 page Current printout page number, 1-based
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
93 user-id User logon id
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
94 user-name User full name
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
95 - A cons of an extent and any of the items given here. The item will
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
96 be displayed using the extent's face, begin-glyph and end-glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
97 properties.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
98 - A list, each element of which is any of the items given here.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
99 Each element of the list is rendered in sequence. For example,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
100 '(\"Page \" page) is rendered as \"Page 5\" on the fifth page.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
101 - An fbound symbol or lambda expression, called with one parameter,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
102 a print-context object, as above. The return value is treated as
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
103 if it was literally specified: i.e. it will be reprocessed."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
104 :type 'sexp
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
105 :group 'printing)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
106
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
107 (defcustom printer-page-footer '(nil page)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
108 "*Controls printed page footer.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
109
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
110 #### not yet implemented.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
111
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
112 Format is the same as `printer-page-header'."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
113 :type 'sexp
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
114 :group 'printing)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
115
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
116 (defun print-context-property (print-context prop)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
117 "Return property PROP of PRINT-CONTEXT.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
118
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
119 Valid properties are
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
120
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
121 print-buffer Buffer being printed.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
122 print-window Window on printer device containing print buffer.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
123 print-frame Frame on printer device corresponding to current page.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
124 print-device Device referring to printer.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
125 printer-name Name of printer being printed to.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
126 short-file-name File name only, no path
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
127 long-file-name File name with its path
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
128 buffer-name Buffer name
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
129 date Date current when printing started
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
130 time Time current when printing started
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
131 page Current printout page number, 1-based
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
132 user-id User logon id
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
133 user-name User full name"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
134 (error "not yet implemented"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
135
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
136 (defun generic-print-buffer (&optional buf)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
137 "Print buffer BUF using a printing method appropriate to the O.S. being run.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
138 Under Unix, `lpr' is normally used to spool out a no-frills version of the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
139 buffer, or the `ps-print' package is used to pretty-print the buffer to a
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
140 PostScript printer. Under MS Windows, the built-in printing support is used.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
141
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
142 If BUF is nil or omitted, the current buffer is used."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
143 (interactive)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
144 (generic-print-region (point-min buf) (point-max buf) buf))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
145
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
146 (defun generic-print-region (b e &optional buf)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
147 "Print region using a printing method appropriate to the O.S. being run.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
148 The region between B and E of BUF (defaults to the current buffer) is printed.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
149
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
150 Under Unix, `lpr' is normally used to spool out a no-frills version of the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
151 buffer, or the `ps-print' package is used to pretty-print the buffer to a
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
152 PostScript printer. Under MS Windows, the built-in printing support is used."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
153 (cond ((valid-specifier-tag-p 'msprinter)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
154 (or (stringp printer-name)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
155 (error "Please set `printer-name'"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
156 (let (d f)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
157 (setq buf (decode-buffer buf))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
158 (unwind-protect
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
159 (progn
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
160 (setq d (make-device 'msprinter printer-name))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
161 (setq f (make-frame
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
162 '(name "Test!"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
163 menubar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
164 has-modeline-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
165 default-toolbar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
166 default-gutter-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
167 minibuffer none
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
168 modeline-shadow-thickness 0
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
169 vertical-scrollbar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
170 horizontal-scrollbar-visible-p nil)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
171 d))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
172 (let* ((w (frame-root-window f))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
173 (vertdpi (cdr (device-system-metric d 'device-dpi)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
174 (pixel-vertical-clip-threshold (/ vertdpi 2))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
175 (last-end 0)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
176 done)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
177 (set-window-buffer w (or buf (current-buffer)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
178 (set-window-start w b)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
179 (while (not done)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
180 (redisplay-frame f)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
181 (print-job-eject-page f)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
182 (let ((end (window-end w))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
183 (pixvis (window-last-line-visible-height w)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
184 ;; in case we get stuck somewhere, bow out
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
185 ;; rather than printing an infinite number of
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
186 ;; pages. #### this will fail with an image
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
187 ;; bigger than an entire page. but we really
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
188 ;; need this check here. we should be more
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
189 ;; clever in our check, to deal with this case.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
190 (if (or (= end last-end)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
191 ;; #### fuckme! window-end returns a value
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
192 ;; outside of the valid range of buffer
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
193 ;; positions!!!
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
194 (>= end e))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
195 (setq done t)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
196 (setq last-end end)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
197 (set-window-start w end)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
198 (if pixvis
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
199 (save-selected-window
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
200 (select-window w)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
201 ;; #### scroll-down should take a window arg.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
202 (let ((window-pixel-scroll-increment pixvis))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
203 (scroll-down 1)))))))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
204 (and f (delete-frame f))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
205 (and d (delete-device d))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
206 )))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
207 ((and (not (eq system-type 'windows-nt))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
208 (fboundp 'lpr-buffer))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
209 (lpr-region buf))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
210 (t (error "No print support available"))))