aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinicius Jose Latorre2007-01-26 02:30:28 +0000
committerVinicius Jose Latorre2007-01-26 02:30:28 +0000
commitc97a3f22ed5841f1c8bcdbb80df2bd49635c6a56 (patch)
tree58dc384c3b980f45c7a8c839a0ef74bb37b28758
parent830f437ef1cf048448706d9d935dfbf8823dea86 (diff)
downloademacs-c97a3f22ed5841f1c8bcdbb80df2bd49635c6a56.tar.gz
emacs-c97a3f22ed5841f1c8bcdbb80df2bd49635c6a56.zip
Split XEmacs/Emacs definitions and sample setup code into separate files
-rw-r--r--lisp/ChangeLog.unicode58
-rw-r--r--lisp/ps-bdf.el6
-rw-r--r--lisp/ps-def.el461
-rw-r--r--lisp/ps-mule.el64
-rw-r--r--lisp/ps-print.el525
-rw-r--r--lisp/ps-samp.el249
6 files changed, 779 insertions, 584 deletions
diff --git a/lisp/ChangeLog.unicode b/lisp/ChangeLog.unicode
index 7d2b53b680b..0f439efb050 100644
--- a/lisp/ChangeLog.unicode
+++ b/lisp/ChangeLog.unicode
@@ -1,3 +1,61 @@
12007-01-25 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2
3 * ps-print.el: Split XEmacs/Emacs definitions and sample setup code
4 into separate files.
5 (ps-print-version): New Version 7.2.
6 (ps-postscript-code-directory): Fix XEmacs initialization.
7 (ps-generate-postscript-with-faces): Call
8 ps-generate-postscript-with-faces1 (new fun).
9 (ps-color-format, ps-float-format): Vars moved to ps-def.el.
10 (ps-xemacs-color-name, ps-mapper, ps-extent-sorter)
11 (ps-xemacs-face-kind-p, ps-mark-active-p, ps-face-foreground-name)
12 (ps-face-background-name, ps-frame-parameter, ps-color-device)
13 (ps-color-values, ps-face-bold-p, ps-face-italic-p): Funs moved to
14 ps-def.el.
15 (ps-prsc, ps-c-prsc, ps-s-prsc, ps-rmail-mode-hook)
16 (ps-rmail-print-message-from-summary, ps-print-message-from-summary)
17 (ps-article-subject, ps-article-author, ps-gnus-article-prepare-hook)
18 (ps-vm-mode-hook, ps-gnus-print-article-from-summary)
19 (ps-vm-print-message-from-summary, ps-gnus-summary-setup, ps-info-file)
20 (ps-info-node, ps-info-mode-hook, ps-jts-ps-setup, ps-jack-setup): Funs
21 moved to ps-samp.el.
22
23 * ps-bdf.el (installation-directory, coding-system-for-read): Vars
24 moved to ps-def.el.
25
26 * ps-mule.el (leading-code-private-22): Var moved to ps-def.el.
27 (charset-bytes, charset-dimension, charset-id, charset-width)
28 (find-charset-region, char-width, chars-in-region, forward-point)
29 (decompose-composite-char, encode-coding-string, coding-system-p)
30 (ccl-execute-on-string, define-ccl-program, multibyte-string-p)
31 (string-make-multibyte, encode-char): Funs moved to ps-def.el.
32
33 * ps-def.el: New file. XEmacs/Emacs definitions.
34 (ps-generate-postscript-with-faces1): New fun.
35 (ps-color-format, ps-float-format): Vars moved from ps-print.el.
36 (ps-xemacs-color-name, ps-mapper, ps-extent-sorter)
37 (ps-xemacs-face-kind-p, ps-mark-active-p, ps-face-foreground-name)
38 (ps-face-background-name, ps-frame-parameter, ps-color-device)
39 (ps-color-values, ps-face-bold-p, ps-face-italic-p): Funs moved from
40 ps-print.el.
41 (installation-directory, coding-system-for-read): Vars moved from
42 ps-bdf.el.
43 (leading-code-private-22): Var moved from ps-mule.el.
44 (charset-bytes, charset-dimension, charset-id, charset-width)
45 (find-charset-region, char-width, chars-in-region, forward-point)
46 (decompose-composite-char, encode-coding-string, coding-system-p)
47 (ccl-execute-on-string, define-ccl-program, multibyte-string-p)
48 (string-make-multibyte, encode-char): Funs moved from ps-mule.el.
49
50 * ps-samp.el: New file. Sample setup code.
51 (ps-prsc, ps-c-prsc, ps-s-prsc, ps-rmail-mode-hook)
52 (ps-rmail-print-message-from-summary, ps-print-message-from-summary)
53 (ps-article-subject, ps-article-author, ps-gnus-article-prepare-hook)
54 (ps-vm-mode-hook, ps-gnus-print-article-from-summary)
55 (ps-vm-print-message-from-summary, ps-gnus-summary-setup, ps-info-file)
56 (ps-info-node, ps-info-mode-hook, ps-jts-ps-setup, ps-jack-setup): Funs
57 moved from ps-print.el.
58
12007-01-21 Vinicius Jose Latorre <viniciusjl@ig.com.br> 592007-01-21 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2 60
3 * ps-print.el: Handle frame parameters (background and/or foreground 61 * ps-print.el: Handle frame parameters (background and/or foreground
diff --git a/lisp/ps-bdf.el b/lisp/ps-bdf.el
index 615f98b950b..568baf38afd 100644
--- a/lisp/ps-bdf.el
+++ b/lisp/ps-bdf.el
@@ -38,11 +38,7 @@
38;;; Code: 38;;; Code:
39 39
40(eval-and-compile 40(eval-and-compile
41 (require 'ps-mule) 41 (require 'ps-mule))
42
43 ;; to avoid XEmacs compilation gripes
44 (defvar installation-directory nil)
45 (defvar coding-system-for-read nil))
46 42
47;;;###autoload 43;;;###autoload
48(defvar bdf-directory-list 44(defvar bdf-directory-list
diff --git a/lisp/ps-def.el b/lisp/ps-def.el
new file mode 100644
index 00000000000..ffd8a7bd6c1
--- /dev/null
+++ b/lisp/ps-def.el
@@ -0,0 +1,461 @@
1;;; ps-def.el --- XEmacs and Emacs definitions for ps-print
2
3;; Copyright (C) 2007 Free Software Foundation, Inc.
4
5;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Kenichi Handa <handa@m17n.org> (multi-byte characters)
7;; Maintainer: Kenichi Handa <handa@m17n.org> (multi-byte characters)
8;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
9;; Keywords: wp, print, PostScript
10;; Version: 7.2
11;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
12
13;; This file is part of GNU Emacs.
14
15;; GNU Emacs is free software; you can redistribute it and/or modify it under
16;; the terms of the GNU General Public License as published by the Free
17;; Software Foundation; either version 2, or (at your option) any later
18;; version.
19
20;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY
21;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23;; details.
24
25;; You should have received a copy of the GNU General Public License along with
26;; GNU Emacs; see the file COPYING. If not, write to the Free Software
27;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
29;;; Commentary:
30
31;; See ps-print.el for documentation.
32
33;;; Code:
34
35
36
37;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39;; XEmacs Definitions
40
41
42(cond
43 ((featurep 'xemacs) ; xemacs
44
45
46 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 ;; ps-bdf
48
49 (defvar installation-directory nil)
50 (defvar coding-system-for-read nil)
51
52
53 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54 ;; ps-mule
55
56 (defvar leading-code-private-22 157)
57
58 (or (fboundp 'charset-bytes)
59 (defun charset-bytes (charset) 1)) ; ascii
60
61 (or (fboundp 'charset-dimension)
62 (defun charset-dimension (charset) 1)) ; ascii
63
64 (or (fboundp 'charset-id)
65 (defun charset-id (charset) 0)) ; ascii
66
67 (or (fboundp 'charset-width)
68 (defun charset-width (charset) 1)) ; ascii
69
70 (or (fboundp 'find-charset-region)
71 (defun find-charset-region (beg end &optional table)
72 (list 'ascii)))
73
74 (or (fboundp 'char-width)
75 (defun char-width (char) 1)) ; ascii
76
77 (or (fboundp 'chars-in-region)
78 (defun chars-in-region (beg end)
79 (- (max beg end) (min beg end))))
80
81 (or (fboundp 'forward-point)
82 (defun forward-point (arg)
83 (save-excursion
84 (let ((count (abs arg))
85 (step (if (zerop arg)
86 0
87 (/ arg arg))))
88 (while (and (> count 0)
89 (< (point-min) (point)) (< (point) (point-max)))
90 (forward-char step)
91 (setq count (1- count)))
92 (+ (point) (* count step))))))
93
94 (or (fboundp 'decompose-composite-char)
95 (defun decompose-composite-char (char &optional type
96 with-composition-rule)
97 nil))
98
99 (or (fboundp 'encode-coding-string)
100 (defun encode-coding-string (string coding-system &optional nocopy)
101 (if nocopy
102 string
103 (copy-sequence string))))
104
105 (or (fboundp 'coding-system-p)
106 (defun coding-system-p (obj) nil))
107
108 (or (fboundp 'ccl-execute-on-string)
109 (defun ccl-execute-on-string (ccl-prog status str
110 &optional contin unibyte-p)
111 str))
112
113 (or (fboundp 'define-ccl-program)
114 (defmacro define-ccl-program (name ccl-program &optional doc)
115 `(defconst ,name nil ,doc)))
116
117 (or (fboundp 'multibyte-string-p)
118 (defun multibyte-string-p (str)
119 (let ((len (length str))
120 (i 0)
121 multibyte)
122 (while (and (< i len) (not (setq multibyte (> (aref str i) 255))))
123 (setq i (1+ i)))
124 multibyte)))
125
126 (or (fboundp 'string-make-multibyte)
127 (defalias 'string-make-multibyte 'copy-sequence))
128
129 (or (fboundp 'encode-char)
130 (defun encode-char (ch ccs)
131 ch))
132
133
134 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
135 ;; ps-print
136
137 ;; GNU Emacs
138 (or (fboundp 'line-beginning-position)
139 (defun line-beginning-position (&optional n)
140 (save-excursion
141 (and n (/= n 1) (forward-line (1- n)))
142 (beginning-of-line)
143 (point))))
144
145
146 ;; GNU Emacs
147 (or (fboundp 'find-composition)
148 (defalias 'find-composition 'ignore))
149
150
151 (defun ps-xemacs-color-name (color)
152 (if (color-specifier-p color)
153 (color-name color)
154 color))
155
156
157 (defalias 'ps-mark-active-p 'region-active-p)
158
159
160 (defun ps-face-foreground-name (face)
161 (ps-xemacs-color-name (face-foreground face)))
162
163
164 (defun ps-face-background-name (face)
165 (ps-xemacs-color-name (face-background face)))
166
167
168 (defun ps-frame-parameter (param)
169 (frame-property nil param))
170
171
172 ;; Return t if the device (which can be changed during an emacs session)
173 ;; can handle colors.
174 ;; XEmacs change: Need to check for emacs-major-version too.
175 (if (or (> emacs-major-version 19)
176 (and (= emacs-major-version 19)
177 (>= emacs-minor-version 12)))
178 ;; xemacs >= 19.12
179 (defun ps-color-device ()
180 (eq (device-class) 'color))
181 ;; xemacs < 19.12
182 (setq ps-print-color-p nil)
183 (defalias 'ps-color-device 'ignore))
184
185
186 (defun ps-mapper (extent list)
187 (nconc list
188 (list (list (extent-start-position extent) 'push extent)
189 (list (extent-end-position extent) 'pull extent)))
190 nil)
191
192
193 (defun ps-extent-sorter (a b)
194 (< (extent-priority a) (extent-priority b)))
195
196
197 (defun ps-xemacs-face-kind-p (face kind kind-regex)
198 (let* ((frame-font (or (face-font-instance face)
199 (face-font-instance 'default)))
200 (kind-cons
201 (and frame-font
202 (assq kind
203 (font-instance-properties frame-font))))
204 (kind-spec (cdr-safe kind-cons))
205 (case-fold-search t))
206 (and kind-spec (string-match kind-regex kind-spec))))
207
208
209 ;; to avoid XEmacs compilation gripes
210 (defvar coding-system-for-write nil)
211 (defvar coding-system-for-read nil)
212 (defvar buffer-file-coding-system nil)
213
214
215 (and (fboundp 'find-coding-system)
216 (or (funcall 'find-coding-system 'raw-text-unix)
217 (funcall 'copy-coding-system 'no-conversion-unix 'raw-text-unix)))
218
219
220 (defun ps-color-values (x-color)
221 (let ((color (ps-xemacs-color-name x-color)))
222 (cond
223 ((fboundp 'x-color-values)
224 (funcall 'x-color-values color))
225 ((and (fboundp 'color-instance-rgb-components)
226 (ps-color-device))
227 (funcall 'color-instance-rgb-components
228 (if (color-instance-p x-color)
229 x-color
230 (make-color-instance color))))
231 (t
232 (error "No available function to determine X color values")))))
233
234
235 (defun ps-face-bold-p (face)
236 (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
237 (memq face ps-bold-faces))) ; Kludge-compatible
238
239
240 (defun ps-face-italic-p (face)
241 (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o")
242 (ps-xemacs-face-kind-p face 'SLANT "i\\|o")
243 (memq face ps-italic-faces))) ; Kludge-compatible
244
245
246 ;; XEmacs will have to make do with %s (princ) for floats.
247 (defvar ps-color-format "%s %s %s")
248 (defvar ps-float-format "%s ")
249
250
251 (defun ps-generate-postscript-with-faces1 (from to)
252 ;; Generate some PostScript.
253 (let ((face 'default)
254 (position to)
255 ;; XEmacs
256 ;; Build the list of extents...
257 (a (cons 'dummy nil))
258 record type extent extent-list)
259 (map-extents 'ps-mapper nil from to a)
260 (setq a (sort (cdr a) 'car-less-than-car)
261 extent-list nil)
262
263 ;; Loop through the extents...
264 (while a
265 (setq record (car a)
266 position (car record)
267
268 record (cdr record)
269 type (car record)
270
271 record (cdr record)
272 extent (car record))
273
274 ;; Plot up to this record.
275 ;; XEmacs 19.12: for some reason, we're getting into a
276 ;; situation in which some of the records have
277 ;; positions less than 'from'. Since we've narrowed
278 ;; the buffer, this'll generate errors. This is a hack,
279 ;; but don't call ps-plot-with-face unless from > point-min.
280 (and (>= from (point-min))
281 (ps-plot-with-face from (min position (point-max)) face))
282
283 (cond
284 ((eq type 'push)
285 (and (extent-face extent)
286 (setq extent-list (sort (cons extent extent-list)
287 'ps-extent-sorter))))
288
289 ((eq type 'pull)
290 (setq extent-list (sort (delq extent extent-list)
291 'ps-extent-sorter))))
292
293 (setq face (if extent-list
294 (extent-face (car extent-list))
295 'default)
296 from position
297 a (cdr a)))
298
299 (ps-plot-with-face from to face)))
300
301 )
302 (t ; emacs
303 ;; Do nothing
304 )) ; end cond featurep
305
306
307
308;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
309;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
310;; Emacs Definitions
311
312
313(cond
314 ((featurep 'xemacs) ; xemacs
315 ;; Do nothing
316 )
317 (t ; emacs
318
319
320 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
321 ;; ps-print
322
323 (defvar mark-active nil)
324
325
326 (defun ps-mark-active-p ()
327 mark-active)
328
329
330 (defun ps-face-foreground-name (face)
331 (face-foreground face nil t))
332
333
334 (defun ps-face-background-name (face)
335 (face-background face nil t))
336
337
338 (defun ps-frame-parameter (param)
339 (frame-parameter nil param))
340
341
342 ;; Return t if the device (which can be changed during an emacs session) can
343 ;; handle colors. This function is not yet implemented for GNU emacs.
344 (defun ps-color-device ()
345 (if (fboundp 'color-values)
346 (funcall 'color-values "Green")
347 t))
348
349
350 (defun ps-color-values (x-color)
351 (cond
352 ((fboundp 'color-values)
353 (funcall 'color-values x-color))
354 ((fboundp 'x-color-values)
355 (funcall 'x-color-values x-color))
356 (t
357 (error "No available function to determine X color values"))))
358
359
360 (defun ps-face-bold-p (face)
361 (or (face-bold-p face)
362 (memq face ps-bold-faces)))
363
364
365 (defun ps-face-italic-p (face)
366 (or (face-italic-p face)
367 (memq face ps-italic-faces)))
368
369
370 ;; Emacs understands the %f format; we'll use it to limit color RGB values
371 ;; to three decimals to cut down some on the size of the PostScript output.
372 (defvar ps-color-format "%0.3f %0.3f %0.3f")
373 (defvar ps-float-format "%0.3f ")
374
375
376 (defun ps-generate-postscript-with-faces1 (from to)
377 ;; Generate some PostScript.
378 (let ((face 'default)
379 (position to)
380 ;; Emacs
381 (property-change from)
382 (overlay-change from)
383 (save-buffer-invisibility-spec buffer-invisibility-spec)
384 (buffer-invisibility-spec nil)
385 before-string after-string)
386 (while (< from to)
387 (and (< property-change to) ; Don't search for property change
388 ; unless previous search succeeded.
389 (setq property-change (next-property-change from nil to)))
390 (and (< overlay-change to) ; Don't search for overlay change
391 ; unless previous search succeeded.
392 (setq overlay-change (min (next-overlay-change from)
393 to)))
394 (setq position (min property-change overlay-change)
395 before-string nil
396 after-string nil)
397 ;; The code below is not quite correct,
398 ;; because a non-nil overlay invisible property
399 ;; which is inactive according to the current value
400 ;; of buffer-invisibility-spec nonetheless overrides
401 ;; a face text property.
402 (setq face
403 (cond ((let ((prop (get-text-property from 'invisible)))
404 ;; Decide whether this invisible property
405 ;; really makes the text invisible.
406 (if (eq save-buffer-invisibility-spec t)
407 (not (null prop))
408 (or (memq prop save-buffer-invisibility-spec)
409 (assq prop save-buffer-invisibility-spec))))
410 'emacs--invisible--face)
411 ((get-text-property from 'face))
412 (t 'default)))
413 (let ((overlays (overlays-at from))
414 (face-priority -1)) ; text-property
415 (while (and overlays
416 (not (eq face 'emacs--invisible--face)))
417 (let* ((overlay (car overlays))
418 (overlay-invisible
419 (overlay-get overlay 'invisible))
420 (overlay-priority
421 (or (overlay-get overlay 'priority) 0)))
422 (and (> overlay-priority face-priority)
423 (setq before-string
424 (or (overlay-get overlay 'before-string)
425 before-string)
426 after-string
427 (or (and (<= (overlay-end overlay) position)
428 (overlay-get overlay 'after-string))
429 after-string)
430 face-priority overlay-priority
431 face
432 (cond
433 ((if (eq save-buffer-invisibility-spec t)
434 (not (null overlay-invisible))
435 (or (memq overlay-invisible
436 save-buffer-invisibility-spec)
437 (assq overlay-invisible
438 save-buffer-invisibility-spec)))
439 'emacs--invisible--face)
440 ((overlay-get overlay 'face))
441 (t face)
442 ))))
443 (setq overlays (cdr overlays))))
444 ;; Plot up to this record.
445 (and before-string
446 (ps-plot-string before-string))
447 (ps-plot-with-face from position face)
448 (and after-string
449 (ps-plot-string after-string))
450 (setq from position))
451 (ps-plot-with-face from to face)))
452
453 )) ; end cond featurep
454
455
456;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
457
458(provide 'ps-def)
459
460;;; arch-tag: fb06a585-1112-4206-885d-a57d95d50579
461;;; ps-def.el ends here
diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el
index 5223e751d6c..04eb19a6bca 100644
--- a/lisp/ps-mule.el
+++ b/lisp/ps-mule.el
@@ -91,69 +91,7 @@
91;;; Code: 91;;; Code:
92 92
93(eval-and-compile 93(eval-and-compile
94 (require 'ps-print) 94 (require 'ps-print))
95
96 ;; to avoid XEmacs compilation gripes
97 (defvar leading-code-private-22 157)
98 (or (fboundp 'charset-bytes)
99 (defun charset-bytes (charset) 1)) ; ascii
100 (or (fboundp 'charset-dimension)
101 (defun charset-dimension (charset) 1)) ; ascii
102 (or (fboundp 'charset-id)
103 (defun charset-id (charset) 0)) ; ascii
104 (or (fboundp 'charset-width)
105 (defun charset-width (charset) 1)) ; ascii
106 (or (fboundp 'find-charset-region)
107 (defun find-charset-region (beg end &optional table)
108 (list 'ascii)))
109 (or (fboundp 'char-width)
110 (defun char-width (char) 1)) ; ascii
111 (or (fboundp 'chars-in-region)
112 (defun chars-in-region (beg end)
113 (- (max beg end) (min beg end))))
114 (or (fboundp 'forward-point)
115 (defun forward-point (arg)
116 (save-excursion
117 (let ((count (abs arg))
118 (step (if (zerop arg)
119 0
120 (/ arg arg))))
121 (while (and (> count 0)
122 (< (point-min) (point)) (< (point) (point-max)))
123 (forward-char step)
124 (setq count (1- count)))
125 (+ (point) (* count step))))))
126 (or (fboundp 'decompose-composite-char)
127 (defun decompose-composite-char (char &optional type
128 with-composition-rule)
129 nil))
130 (or (fboundp 'encode-coding-string)
131 (defun encode-coding-string (string coding-system &optional nocopy)
132 (if nocopy
133 string
134 (copy-sequence string))))
135 (or (fboundp 'coding-system-p)
136 (defun coding-system-p (obj) nil))
137 (or (fboundp 'ccl-execute-on-string)
138 (defun ccl-execute-on-string (ccl-prog status str
139 &optional contin unibyte-p)
140 str))
141 (or (fboundp 'define-ccl-program)
142 (defmacro define-ccl-program (name ccl-program &optional doc)
143 `(defconst ,name nil ,doc)))
144 (or (fboundp 'multibyte-string-p)
145 (defun multibyte-string-p (str)
146 (let ((len (length str))
147 (i 0)
148 multibyte)
149 (while (and (< i len) (not (setq multibyte (> (aref str i) 255))))
150 (setq i (1+ i)))
151 multibyte)))
152 (or (fboundp 'string-make-multibyte)
153 (defalias 'string-make-multibyte 'copy-sequence))
154 (or (fboundp 'encode-char)
155 (defun encode-char (ch ccs)
156 ch)))
157 95
158 96
159;;;###autoload 97;;;###autoload
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 1003015aee0..e50342dac91 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -10,11 +10,11 @@
10;; Maintainer: Kenichi Handa <handa@m17n.org> (multi-byte characters) 10;; Maintainer: Kenichi Handa <handa@m17n.org> (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;; Version: 7.1 13;; Version: 7.2
14;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre 14;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
15 15
16(defconst ps-print-version "7.1" 16(defconst ps-print-version "7.2"
17 "ps-print.el, v 7.1 <2007/01/21 vinicius> 17 "ps-print.el, v 7.2 <2007/01/19 vinicius>
18 18
19Vinicius's last change version -- this file may have been edited as part of 19Vinicius's last change version -- this file may have been edited as part of
20Emacs without changes to the version number. When reporting bugs, please also 20Emacs without changes to the version number. When reporting bugs, please also
@@ -1445,6 +1445,7 @@ Please send all bug fixes and enhancements to
1445 1445
1446(require 'lpr) 1446(require 'lpr)
1447 1447
1448
1448(or (featurep 'lisp-float-type) 1449(or (featurep 'lisp-float-type)
1449 (error "`ps-print' requires floating point support")) 1450 (error "`ps-print' requires floating point support"))
1450 1451
@@ -1463,82 +1464,14 @@ Please send all bug fixes and enhancements to
1463 'emacs)))) 1464 'emacs))))
1464 1465
1465 1466
1466;; GNU Emacs
1467(or (fboundp 'line-beginning-position)
1468 (defun line-beginning-position (&optional n)
1469 (save-excursion
1470 (and n (/= n 1) (forward-line (1- n)))
1471 (beginning-of-line)
1472 (point))))
1473
1474
1475;; to avoid compilation gripes
1476
1477;; XEmacs
1478(defalias 'ps-x-color-instance-p 'color-instance-p)
1479(defalias 'ps-x-color-instance-rgb-components 'color-instance-rgb-components)
1480(defalias 'ps-x-color-name 'color-name)
1481(defalias 'ps-x-color-specifier-p 'color-specifier-p)
1482(defalias 'ps-x-copy-coding-system 'copy-coding-system)
1483(defalias 'ps-x-device-class 'device-class)
1484(defalias 'ps-x-extent-end-position 'extent-end-position)
1485(defalias 'ps-x-extent-face 'extent-face)
1486(defalias 'ps-x-extent-priority 'extent-priority)
1487(defalias 'ps-x-extent-start-position 'extent-start-position)
1488(defalias 'ps-x-face-font-instance 'face-font-instance)
1489(defalias 'ps-x-find-coding-system 'find-coding-system)
1490(defalias 'ps-x-font-instance-properties 'font-instance-properties)
1491(defalias 'ps-x-make-color-instance 'make-color-instance)
1492(defalias 'ps-x-map-extents 'map-extents)
1493(defalias 'ps-x-frame-property 'frame-property)
1494
1495;; GNU Emacs
1496(defalias 'ps-e-face-bold-p 'face-bold-p)
1497(defalias 'ps-e-face-italic-p 'face-italic-p)
1498(defalias 'ps-e-next-overlay-change 'next-overlay-change)
1499(defalias 'ps-e-overlays-at 'overlays-at)
1500(defalias 'ps-e-overlay-get 'overlay-get)
1501(defalias 'ps-e-overlay-end 'overlay-end)
1502(defalias 'ps-e-x-color-values 'x-color-values)
1503(defalias 'ps-e-color-values 'color-values)
1504(defalias 'ps-e-frame-parameter 'frame-parameter)
1505(if (fboundp 'find-composition)
1506 (defalias 'ps-e-find-composition 'find-composition)
1507 (defalias 'ps-e-find-composition 'ignore))
1508
1509
1510(defconst ps-windows-system 1467(defconst ps-windows-system
1511 (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt))) 1468 (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt)))
1512(defconst ps-lp-system 1469(defconst ps-lp-system
1513 (memq system-type '(usg-unix-v dgux hpux irix))) 1470 (memq system-type '(usg-unix-v dgux hpux irix)))
1514 1471
1515 1472
1516(defun ps-xemacs-color-name (color) 1473;; Load XEmacs/Emacs definitions
1517 (if (ps-x-color-specifier-p color) 1474(eval-and-compile (require 'ps-def))
1518 (ps-x-color-name color)
1519 color))
1520
1521
1522(cond ((featurep 'xemacs) ; xemacs
1523 (defalias 'ps-mark-active-p 'region-active-p)
1524 (defun ps-face-foreground-name (face)
1525 (ps-xemacs-color-name (face-foreground face)))
1526 (defun ps-face-background-name (face)
1527 (ps-xemacs-color-name (face-background face)))
1528 (defun ps-frame-parameter (param)
1529 (ps-x-frame-property nil param))
1530 )
1531 (t ; emacs 23 or higher
1532 (defvar mark-active nil)
1533 (defun ps-mark-active-p ()
1534 mark-active)
1535 (defun ps-face-foreground-name (face)
1536 (face-foreground face nil t))
1537 (defun ps-face-background-name (face)
1538 (face-background face nil t))
1539 (defun ps-frame-parameter (param)
1540 (ps-e-frame-parameter nil param))
1541 ))
1542 1475
1543 1476
1544;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1477;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3344,9 +3277,9 @@ It's like the very first character of buffer (or region) is ^L (\\014)."
3344(defcustom ps-postscript-code-directory 3277(defcustom ps-postscript-code-directory
3345 (or (if (featurep 'xemacs) 3278 (or (if (featurep 'xemacs)
3346 (cond ((fboundp 'locate-data-directory) ; xemacs 3279 (cond ((fboundp 'locate-data-directory) ; xemacs
3347 (locate-data-directory "ps-print")) 3280 (funcall 'locate-data-directory "ps-print"))
3348 ((boundp 'data-directory) ; xemacs 3281 ((boundp 'data-directory) ; xemacs
3349 data-directory) 3282 (symbol-value 'data-directory))
3350 (t ; don't know what to do 3283 (t ; don't know what to do
3351 nil)) 3284 nil))
3352 data-directory) ; emacs 3285 data-directory) ; emacs
@@ -3838,107 +3771,6 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'."
3838 (format-time-string "%T")) 3771 (format-time-string "%T"))
3839 3772
3840 3773
3841(and (featurep 'xemacs)
3842 ;; XEmacs change: Need to check for emacs-major-version too.
3843 (or (< emacs-major-version 19)
3844 (and (= emacs-major-version 19) (< emacs-minor-version 12)))
3845 (setq ps-print-color-p nil))
3846
3847
3848;; Return t if the device (which can be changed during an emacs session)
3849;; can handle colors.
3850;; This function is not yet implemented for GNU emacs.
3851(cond ((and (featurep 'xemacs)
3852 ;; XEmacs change: Need to check for emacs-major-version too.
3853 (or (> emacs-major-version 19)
3854 (and (= emacs-major-version 19)
3855 (>= emacs-minor-version 12)))) ; xemacs >= 19.12
3856 (defun ps-color-device ()
3857 (eq (ps-x-device-class) 'color)))
3858
3859 (t ; emacs
3860 (defun ps-color-device ()
3861 (if (fboundp 'color-values)
3862 (ps-e-color-values "Green")
3863 t))))
3864
3865
3866(defun ps-mapper (extent list)
3867 (nconc list
3868 (list (list (ps-x-extent-start-position extent) 'push extent)
3869 (list (ps-x-extent-end-position extent) 'pull extent)))
3870 nil)
3871
3872(defun ps-extent-sorter (a b)
3873 (< (ps-x-extent-priority a) (ps-x-extent-priority b)))
3874
3875(defun ps-xemacs-face-kind-p (face kind kind-regex)
3876 (let* ((frame-font (or (ps-x-face-font-instance face)
3877 (ps-x-face-font-instance 'default)))
3878 (kind-cons
3879 (and frame-font
3880 (assq kind
3881 (ps-x-font-instance-properties frame-font))))
3882 (kind-spec (cdr-safe kind-cons))
3883 (case-fold-search t))
3884 (and kind-spec (string-match kind-regex kind-spec))))
3885
3886(cond ((featurep 'xemacs) ; xemacs
3887
3888 ;; to avoid XEmacs compilation gripes
3889 (defvar coding-system-for-write nil)
3890 (defvar coding-system-for-read nil)
3891 (defvar buffer-file-coding-system nil)
3892
3893 (and (fboundp 'find-coding-system)
3894 (or (ps-x-find-coding-system 'raw-text-unix)
3895 (ps-x-copy-coding-system 'no-conversion-unix 'raw-text-unix)))
3896
3897 (defun ps-color-values (x-color)
3898 (let ((color (ps-xemacs-color-name x-color)))
3899 (cond
3900 ((fboundp 'x-color-values)
3901 (ps-e-x-color-values color))
3902 ((and (fboundp 'color-instance-rgb-components)
3903 (ps-color-device))
3904 (ps-x-color-instance-rgb-components
3905 (if (ps-x-color-instance-p x-color)
3906 x-color
3907 (ps-x-make-color-instance color))))
3908 (t
3909 (error "No available function to determine X color values")))))
3910
3911 (defun ps-face-bold-p (face)
3912 (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
3913 (memq face ps-bold-faces))) ; Kludge-compatible
3914
3915 (defun ps-face-italic-p (face)
3916 (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o")
3917 (ps-xemacs-face-kind-p face 'SLANT "i\\|o")
3918 (memq face ps-italic-faces))) ; Kludge-compatible
3919 )
3920
3921 (t ; emacs
3922
3923 (defun ps-color-values (x-color)
3924 (cond
3925 ((fboundp 'color-values)
3926 (ps-e-color-values x-color))
3927 ((fboundp 'x-color-values)
3928 (ps-e-x-color-values x-color))
3929 (t
3930 (error "No available function to determine X color values"))))
3931
3932 (defun ps-face-bold-p (face)
3933 (or (ps-e-face-bold-p face)
3934 (memq face ps-bold-faces)))
3935
3936 (defun ps-face-italic-p (face)
3937 (or (ps-e-face-italic-p face)
3938 (memq face ps-italic-faces)))
3939 ))
3940
3941
3942(defvar ps-print-color-scale 1.0) 3774(defvar ps-print-color-scale 1.0)
3943 3775
3944(defun ps-color-scale (color) 3776(defun ps-color-scale (color)
@@ -4018,15 +3850,6 @@ Note: No major/minor-mode is activated and no local variables are evaluated for
4018(defvar ps-razchunk 0) 3850(defvar ps-razchunk 0)
4019 3851
4020(defvar ps-color-p nil) 3852(defvar ps-color-p nil)
4021(defvar ps-color-format
4022 (if (featurep 'xemacs)
4023 ;; XEmacs will have to make do with %s (princ) for floats.
4024 "%s %s %s"
4025
4026 ;; Emacs understands the %f format; we'll use it to limit color RGB
4027 ;; values to three decimals to cut down some on the size of the
4028 ;; PostScript output.
4029 "%0.3f %0.3f %0.3f"))
4030 3853
4031;; These values determine how much print-height to deduct when headers/footers 3854;; These values determine how much print-height to deduct when headers/footers
4032;; are turned on. This is a pretty clumsy way of handling it, but it'll do for 3855;; are turned on. This is a pretty clumsy way of handling it, but it'll do for
@@ -4906,15 +4729,6 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
4906 (vector 0 0 0 0))))) 4729 (vector 0 0 0 0)))))
4907 4730
4908 4731
4909;; Emacs understands the %f format; we'll use it to limit color RGB values
4910;; to three decimals to cut down some on the size of the PostScript output.
4911;; XEmacs will have to make do with %s (princ) for floats.
4912
4913(defvar ps-float-format (if (featurep 'xemacs)
4914 "%s " ; xemacs
4915 "%0.3f ")) ; emacs
4916
4917
4918(defun ps-float-format (value &optional default) 4732(defun ps-float-format (value &optional default)
4919 (let ((literal (or value default))) 4733 (let ((literal (or value default)))
4920 (cond ((null literal) 4734 (cond ((null literal)
@@ -6442,125 +6256,7 @@ If FACE is not a valid face name, it is used default face."
6442 (save-restriction 6256 (save-restriction
6443 (narrow-to-region from to) 6257 (narrow-to-region from to)
6444 (ps-print-ensure-fontified from to) 6258 (ps-print-ensure-fontified from to)
6445 (let ((face 'default) 6259 (ps-generate-postscript-with-faces1 from to)))
6446 (position to))
6447 (cond
6448 ((featurep 'xemacs) ; xemacs
6449 ;; Build the list of extents...
6450 (let ((a (cons 'dummy nil))
6451 record type extent extent-list)
6452 (ps-x-map-extents 'ps-mapper nil from to a)
6453 (setq a (sort (cdr a) 'car-less-than-car)
6454 extent-list nil)
6455
6456 ;; Loop through the extents...
6457 (while a
6458 (setq record (car a)
6459 position (car record)
6460
6461 record (cdr record)
6462 type (car record)
6463
6464 record (cdr record)
6465 extent (car record))
6466
6467 ;; Plot up to this record.
6468 ;; XEmacs 19.12: for some reason, we're getting into a
6469 ;; situation in which some of the records have
6470 ;; positions less than 'from'. Since we've narrowed
6471 ;; the buffer, this'll generate errors. This is a hack,
6472 ;; but don't call ps-plot-with-face unless from > point-min.
6473 (and (>= from (point-min))
6474 (ps-plot-with-face from (min position (point-max)) face))
6475
6476 (cond
6477 ((eq type 'push)
6478 (and (ps-x-extent-face extent)
6479 (setq extent-list (sort (cons extent extent-list)
6480 'ps-extent-sorter))))
6481
6482 ((eq type 'pull)
6483 (setq extent-list (sort (delq extent extent-list)
6484 'ps-extent-sorter))))
6485
6486 (setq face (if extent-list
6487 (ps-x-extent-face (car extent-list))
6488 'default)
6489 from position
6490 a (cdr a)))))
6491
6492 (t ; emacs
6493 (let ((property-change from)
6494 (overlay-change from)
6495 (save-buffer-invisibility-spec buffer-invisibility-spec)
6496 (buffer-invisibility-spec nil)
6497 before-string after-string)
6498 (while (< from to)
6499 (and (< property-change to) ; Don't search for property change
6500 ; unless previous search succeeded.
6501 (setq property-change (next-property-change from nil to)))
6502 (and (< overlay-change to) ; Don't search for overlay change
6503 ; unless previous search succeeded.
6504 (setq overlay-change (min (ps-e-next-overlay-change from)
6505 to)))
6506 (setq position (min property-change overlay-change)
6507 before-string nil
6508 after-string nil)
6509 ;; The code below is not quite correct,
6510 ;; because a non-nil overlay invisible property
6511 ;; which is inactive according to the current value
6512 ;; of buffer-invisibility-spec nonetheless overrides
6513 ;; a face text property.
6514 (setq face
6515 (cond ((let ((prop (get-text-property from 'invisible)))
6516 ;; Decide whether this invisible property
6517 ;; really makes the text invisible.
6518 (if (eq save-buffer-invisibility-spec t)
6519 (not (null prop))
6520 (or (memq prop save-buffer-invisibility-spec)
6521 (assq prop save-buffer-invisibility-spec))))
6522 'emacs--invisible--face)
6523 ((get-text-property from 'face))
6524 (t 'default)))
6525 (let ((overlays (ps-e-overlays-at from))
6526 (face-priority -1)) ; text-property
6527 (while (and overlays
6528 (not (eq face 'emacs--invisible--face)))
6529 (let* ((overlay (car overlays))
6530 (overlay-invisible
6531 (ps-e-overlay-get overlay 'invisible))
6532 (overlay-priority
6533 (or (ps-e-overlay-get overlay 'priority) 0)))
6534 (and (> overlay-priority face-priority)
6535 (setq before-string
6536 (or (ps-e-overlay-get overlay 'before-string)
6537 before-string)
6538 after-string
6539 (or (and (<= (ps-e-overlay-end overlay) position)
6540 (ps-e-overlay-get overlay 'after-string))
6541 after-string)
6542 face-priority overlay-priority
6543 face
6544 (cond
6545 ((if (eq save-buffer-invisibility-spec t)
6546 (not (null overlay-invisible))
6547 (or (memq overlay-invisible
6548 save-buffer-invisibility-spec)
6549 (assq overlay-invisible
6550 save-buffer-invisibility-spec)))
6551 'emacs--invisible--face)
6552 ((ps-e-overlay-get overlay 'face))
6553 (t face)
6554 ))))
6555 (setq overlays (cdr overlays))))
6556 ;; Plot up to this record.
6557 (and before-string
6558 (ps-plot-string before-string))
6559 (ps-plot-with-face from position face)
6560 (and after-string
6561 (ps-plot-string after-string))
6562 (setq from position)))))
6563 (ps-plot-with-face from to face))))
6564 6260
6565(defun ps-generate-postscript (from to) 6261(defun ps-generate-postscript (from to)
6566 (ps-plot-region from to 0 nil)) 6262 (ps-plot-region from to 0 nil))
@@ -6756,209 +6452,6 @@ If FACE is not a valid face name, it is used default face."
6756 6452
6757 6453
6758;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 6454;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6759;;; Sample Setup Code:
6760
6761
6762;; This stuff is for anybody that's brave enough to look this far,
6763;; and able to figure out how to use it. It isn't really part of
6764;; ps-print, but I'll leave it here in hopes it might be useful:
6765
6766;; WARNING!!! The following code is *sample* code only.
6767;; Don't use it unless you understand what it does!
6768
6769(defmacro ps-prsc ()
6770 `(if (featurep 'xemacs) 'f22 [f22]))
6771(defmacro ps-c-prsc ()
6772 `(if (featurep 'xemacs) '(control f22) [C-f22]))
6773(defmacro ps-s-prsc ()
6774 `(if (featurep 'xemacs) '(shift f22) [S-f22]))
6775
6776;; A hook to bind to `rmail-mode-hook' to locally bind prsc and set the
6777;; `ps-left-headers' specially for mail messages.
6778(defun ps-rmail-mode-hook ()
6779 (local-set-key (ps-prsc) 'ps-rmail-print-message-from-summary)
6780 (setq ps-header-lines 3
6781 ps-left-header
6782 ;; The left headers will display the message's subject, its
6783 ;; author, and the name of the folder it was in.
6784 '(ps-article-subject ps-article-author buffer-name)))
6785
6786;; See `ps-gnus-print-article-from-summary'. This function does the
6787;; same thing for rmail.
6788(defun ps-rmail-print-message-from-summary ()
6789 (interactive)
6790 (ps-print-message-from-summary 'rmail-summary-buffer "RMAIL"))
6791
6792;; Used in `ps-rmail-print-article-from-summary',
6793;; `ps-gnus-print-article-from-summary' and `ps-vm-print-message-from-summary'.
6794(defun ps-print-message-from-summary (summary-buffer summary-default)
6795 (let ((ps-buf (or (and (boundp summary-buffer)
6796 (symbol-value summary-buffer))
6797 summary-default)))
6798 (and (get-buffer ps-buf)
6799 (save-excursion
6800 (set-buffer ps-buf)
6801 (ps-spool-buffer-with-faces)))))
6802
6803;; Look in an article or mail message for the Subject: line. To be
6804;; placed in `ps-left-headers'.
6805(defun ps-article-subject ()
6806 (save-excursion
6807 (goto-char (point-min))
6808 (if (re-search-forward "^Subject:[ \t]+\\(.*\\)$" nil t)
6809 (buffer-substring (match-beginning 1) (match-end 1))
6810 "Subject ???")))
6811
6812;; Look in an article or mail message for the From: line. Sorta-kinda
6813;; understands RFC-822 addresses and can pull the real name out where
6814;; it's provided. To be placed in `ps-left-headers'.
6815(defun ps-article-author ()
6816 (save-excursion
6817 (goto-char (point-min))
6818 (if (re-search-forward "^From:[ \t]+\\(.*\\)$" nil t)
6819 (let ((fromstring (buffer-substring (match-beginning 1) (match-end 1))))
6820 (cond
6821
6822 ;; Try first to match addresses that look like
6823 ;; thompson@wg2.waii.com (Jim Thompson)
6824 ((string-match ".*[ \t]+(\\(.*\\))" fromstring)
6825 (substring fromstring (match-beginning 1) (match-end 1)))
6826
6827 ;; Next try to match addresses that look like
6828 ;; Jim Thompson <thompson@wg2.waii.com> or
6829 ;; "Jim Thompson" <thompson@wg2.waii.com>
6830 ((string-match "\\(\"?\\)\\(.*\\)\\1[ \t]+<.*>" fromstring)
6831 (substring fromstring (match-beginning 2) (match-end 2)))
6832
6833 ;; Couldn't find a real name -- show the address instead.
6834 (t fromstring)))
6835 "From ???")))
6836
6837;; A hook to bind to `gnus-article-prepare-hook'. This will set the
6838;; `ps-left-headers' specially for gnus articles. Unfortunately,
6839;; `gnus-article-mode-hook' is called only once, the first time the *Article*
6840;; buffer enters that mode, so it would only work for the first time
6841;; we ran gnus. The second time, this hook wouldn't get set up. The
6842;; only alternative is `gnus-article-prepare-hook'.
6843(defun ps-gnus-article-prepare-hook ()
6844 (setq ps-header-lines 3
6845 ps-left-header
6846 ;; The left headers will display the article's subject, its
6847 ;; author, and the newsgroup it was in.
6848 '(ps-article-subject ps-article-author gnus-newsgroup-name)))
6849
6850;; A hook to bind to `vm-mode-hook' to locally bind prsc and set the
6851;; `ps-left-headers' specially for mail messages.
6852(defun ps-vm-mode-hook ()
6853 (local-set-key (ps-prsc) 'ps-vm-print-message-from-summary)
6854 (setq ps-header-lines 3
6855 ps-left-header
6856 ;; The left headers will display the message's subject, its
6857 ;; author, and the name of the folder it was in.
6858 '(ps-article-subject ps-article-author buffer-name)))
6859
6860;; Every now and then I forget to switch from the *Summary* buffer to
6861;; the *Article* before hitting prsc, and a nicely formatted list of
6862;; article subjects shows up at the printer. This function, bound to
6863;; prsc for the gnus *Summary* buffer means I don't have to switch
6864;; buffers first.
6865;; sb: Updated for Gnus 5.
6866(defun ps-gnus-print-article-from-summary ()
6867 (interactive)
6868 (ps-print-message-from-summary 'gnus-article-buffer "*Article*"))
6869
6870;; See `ps-gnus-print-article-from-summary'. This function does the
6871;; same thing for vm.
6872(defun ps-vm-print-message-from-summary ()
6873 (interactive)
6874 (ps-print-message-from-summary 'vm-mail-buffer ""))
6875
6876;; A hook to bind to bind to `gnus-summary-setup-buffer' to locally bind
6877;; prsc.
6878(defun ps-gnus-summary-setup ()
6879 (local-set-key (ps-prsc) 'ps-gnus-print-article-from-summary))
6880
6881;; Look in an article or mail message for the Subject: line. To be
6882;; placed in `ps-left-headers'.
6883(defun ps-info-file ()
6884 (save-excursion
6885 (goto-char (point-min))
6886 (if (re-search-forward "File:[ \t]+\\([^, \t\n]*\\)" nil t)
6887 (buffer-substring (match-beginning 1) (match-end 1))
6888 "File ???")))
6889
6890;; Look in an article or mail message for the Subject: line. To be
6891;; placed in `ps-left-headers'.
6892(defun ps-info-node ()
6893 (save-excursion
6894 (goto-char (point-min))
6895 (if (re-search-forward "Node:[ \t]+\\([^,\t\n]*\\)" nil t)
6896 (buffer-substring (match-beginning 1) (match-end 1))
6897 "Node ???")))
6898
6899(defun ps-info-mode-hook ()
6900 (setq ps-left-header
6901 ;; The left headers will display the node name and file name.
6902 '(ps-info-node ps-info-file)))
6903
6904;; WARNING! The following function is a *sample* only, and is *not*
6905;; meant to be used as a whole unless you understand what the effects
6906;; will be! (In fact, this is a copy of Jim's setup for ps-print --
6907;; I'd be very surprised if it was useful to *anybody*, without
6908;; modification.)
6909
6910(defun ps-jts-ps-setup ()
6911 (global-set-key (ps-prsc) 'ps-spool-buffer-with-faces) ;f22 is prsc
6912 (global-set-key (ps-s-prsc) 'ps-spool-region-with-faces)
6913 (global-set-key (ps-c-prsc) 'ps-despool)
6914 (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook)
6915 (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup)
6916 (add-hook 'vm-mode-hook 'ps-vm-mode-hook)
6917 (add-hook 'vm-mode-hooks 'ps-vm-mode-hook)
6918 (add-hook 'Info-mode-hook 'ps-info-mode-hook)
6919 (setq ps-spool-duplex t
6920 ps-print-color-p nil
6921 ps-lpr-command "lpr"
6922 ps-lpr-switches '("-Jjct,duplex_long"))
6923 'ps-jts-ps-setup)
6924
6925;; WARNING! The following function is a *sample* only, and is *not*
6926;; meant to be used as a whole unless it corresponds to your needs.
6927;; (In fact, this is a copy of Jack's setup for ps-print --
6928;; I would not be that surprised if it was useful to *anybody*,
6929;; without modification.)
6930
6931(defun ps-jack-setup ()
6932 (setq ps-print-color-p nil
6933 ps-lpr-command "lpr"
6934 ps-lpr-switches nil
6935
6936 ps-paper-type 'a4
6937 ps-landscape-mode t
6938 ps-number-of-columns 2
6939
6940 ps-left-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
6941 ps-right-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
6942 ps-inter-column (/ (* 72 1.0) 2.54) ; 1.0 cm
6943 ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
6944 ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
6945 ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
6946 ps-header-line-pad .15
6947 ps-print-header t
6948 ps-print-header-frame t
6949 ps-header-lines 2
6950 ps-show-n-of-n t
6951 ps-spool-duplex nil
6952
6953 ps-font-family 'Courier
6954 ps-font-size 5.5
6955 ps-header-font-family 'Helvetica
6956 ps-header-font-size 6
6957 ps-header-title-font-size 8)
6958 'ps-jack-setup)
6959
6960
6961;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6962;; To make this file smaller, some commands go in a separate file. 6455;; To make this file smaller, some commands go in a separate file.
6963;; But autoload them here to make the separation invisible. 6456;; But autoload them here to make the separation invisible.
6964 6457
diff --git a/lisp/ps-samp.el b/lisp/ps-samp.el
new file mode 100644
index 00000000000..60f2c2b2d34
--- /dev/null
+++ b/lisp/ps-samp.el
@@ -0,0 +1,249 @@
1;;; ps-samp.el --- ps-print sample setup code
2
3;; Copyright (C) 2007 Free Software Foundation, Inc.
4
5;; Author: Jim Thompson (was <thompson@wg2.waii.com>)
6;; Jacques Duthen (was <duthen@cegelec-red.fr>)
7;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Kenichi Handa <handa@m17n.org> (multi-byte characters)
9;; Maintainer: Kenichi Handa <handa@m17n.org> (multi-byte characters)
10;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
11;; Keywords: wp, print, PostScript
12;; Version: 7.2
13;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
14
15;; This file is part of GNU Emacs.
16
17;; GNU Emacs is free software; you can redistribute it and/or modify it under
18;; the terms of the GNU General Public License as published by the Free
19;; Software Foundation; either version 2, or (at your option) any later
20;; version.
21
22;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY
23;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
25;; details.
26
27;; You should have received a copy of the GNU General Public License along with
28;; GNU Emacs; see the file COPYING. If not, write to the Free Software
29;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31;;; Commentary:
32
33;; See ps-print.el for documentation.
34
35;;; Code:
36
37
38(eval-and-compile (require 'ps-print))
39
40
41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42;;; Sample Setup Code:
43
44
45;; This stuff is for anybody that's brave enough to look this far,
46;; and able to figure out how to use it. It isn't really part of
47;; ps-print, but I'll leave it here in hopes it might be useful:
48
49;; WARNING!!! The following code is *sample* code only.
50;; Don't use it unless you understand what it does!
51
52(defmacro ps-prsc ()
53 `(if (featurep 'xemacs) 'f22 [f22]))
54(defmacro ps-c-prsc ()
55 `(if (featurep 'xemacs) '(control f22) [C-f22]))
56(defmacro ps-s-prsc ()
57 `(if (featurep 'xemacs) '(shift f22) [S-f22]))
58
59;; A hook to bind to `rmail-mode-hook' to locally bind prsc and set the
60;; `ps-left-headers' specially for mail messages.
61(defun ps-rmail-mode-hook ()
62 (local-set-key (ps-prsc) 'ps-rmail-print-message-from-summary)
63 (setq ps-header-lines 3
64 ps-left-header
65 ;; The left headers will display the message's subject, its
66 ;; author, and the name of the folder it was in.
67 '(ps-article-subject ps-article-author buffer-name)))
68
69;; See `ps-gnus-print-article-from-summary'. This function does the
70;; same thing for rmail.
71(defun ps-rmail-print-message-from-summary ()
72 (interactive)
73 (ps-print-message-from-summary 'rmail-summary-buffer "RMAIL"))
74
75;; Used in `ps-rmail-print-article-from-summary',
76;; `ps-gnus-print-article-from-summary' and `ps-vm-print-message-from-summary'.
77(defun ps-print-message-from-summary (summary-buffer summary-default)
78 (let ((ps-buf (or (and (boundp summary-buffer)
79 (symbol-value summary-buffer))
80 summary-default)))
81 (and (get-buffer ps-buf)
82 (save-excursion
83 (set-buffer ps-buf)
84 (ps-spool-buffer-with-faces)))))
85
86;; Look in an article or mail message for the Subject: line. To be
87;; placed in `ps-left-headers'.
88(defun ps-article-subject ()
89 (save-excursion
90 (goto-char (point-min))
91 (if (re-search-forward "^Subject:[ \t]+\\(.*\\)$" nil t)
92 (buffer-substring (match-beginning 1) (match-end 1))
93 "Subject ???")))
94
95;; Look in an article or mail message for the From: line. Sorta-kinda
96;; understands RFC-822 addresses and can pull the real name out where
97;; it's provided. To be placed in `ps-left-headers'.
98(defun ps-article-author ()
99 (save-excursion
100 (goto-char (point-min))
101 (if (re-search-forward "^From:[ \t]+\\(.*\\)$" nil t)
102 (let ((fromstring (buffer-substring (match-beginning 1) (match-end 1))))
103 (cond
104
105 ;; Try first to match addresses that look like
106 ;; thompson@wg2.waii.com (Jim Thompson)
107 ((string-match ".*[ \t]+(\\(.*\\))" fromstring)
108 (substring fromstring (match-beginning 1) (match-end 1)))
109
110 ;; Next try to match addresses that look like
111 ;; Jim Thompson <thompson@wg2.waii.com> or
112 ;; "Jim Thompson" <thompson@wg2.waii.com>
113 ((string-match "\\(\"?\\)\\(.*\\)\\1[ \t]+<.*>" fromstring)
114 (substring fromstring (match-beginning 2) (match-end 2)))
115
116 ;; Couldn't find a real name -- show the address instead.
117 (t fromstring)))
118 "From ???")))
119
120;; A hook to bind to `gnus-article-prepare-hook'. This will set the
121;; `ps-left-headers' specially for gnus articles. Unfortunately,
122;; `gnus-article-mode-hook' is called only once, the first time the *Article*
123;; buffer enters that mode, so it would only work for the first time
124;; we ran gnus. The second time, this hook wouldn't get set up. The
125;; only alternative is `gnus-article-prepare-hook'.
126(defun ps-gnus-article-prepare-hook ()
127 (setq ps-header-lines 3
128 ps-left-header
129 ;; The left headers will display the article's subject, its
130 ;; author, and the newsgroup it was in.
131 '(ps-article-subject ps-article-author gnus-newsgroup-name)))
132
133;; A hook to bind to `vm-mode-hook' to locally bind prsc and set the
134;; `ps-left-headers' specially for mail messages.
135(defun ps-vm-mode-hook ()
136 (local-set-key (ps-prsc) 'ps-vm-print-message-from-summary)
137 (setq ps-header-lines 3
138 ps-left-header
139 ;; The left headers will display the message's subject, its
140 ;; author, and the name of the folder it was in.
141 '(ps-article-subject ps-article-author buffer-name)))
142
143;; Every now and then I forget to switch from the *Summary* buffer to
144;; the *Article* before hitting prsc, and a nicely formatted list of
145;; article subjects shows up at the printer. This function, bound to
146;; prsc for the gnus *Summary* buffer means I don't have to switch
147;; buffers first.
148;; sb: Updated for Gnus 5.
149(defun ps-gnus-print-article-from-summary ()
150 (interactive)
151 (ps-print-message-from-summary 'gnus-article-buffer "*Article*"))
152
153;; See `ps-gnus-print-article-from-summary'. This function does the
154;; same thing for vm.
155(defun ps-vm-print-message-from-summary ()
156 (interactive)
157 (ps-print-message-from-summary 'vm-mail-buffer ""))
158
159;; A hook to bind to bind to `gnus-summary-setup-buffer' to locally bind
160;; prsc.
161(defun ps-gnus-summary-setup ()
162 (local-set-key (ps-prsc) 'ps-gnus-print-article-from-summary))
163
164;; Look in an article or mail message for the Subject: line. To be
165;; placed in `ps-left-headers'.
166(defun ps-info-file ()
167 (save-excursion
168 (goto-char (point-min))
169 (if (re-search-forward "File:[ \t]+\\([^, \t\n]*\\)" nil t)
170 (buffer-substring (match-beginning 1) (match-end 1))
171 "File ???")))
172
173;; Look in an article or mail message for the Subject: line. To be
174;; placed in `ps-left-headers'.
175(defun ps-info-node ()
176 (save-excursion
177 (goto-char (point-min))
178 (if (re-search-forward "Node:[ \t]+\\([^,\t\n]*\\)" nil t)
179 (buffer-substring (match-beginning 1) (match-end 1))
180 "Node ???")))
181
182(defun ps-info-mode-hook ()
183 (setq ps-left-header
184 ;; The left headers will display the node name and file name.
185 '(ps-info-node ps-info-file)))
186
187;; WARNING! The following function is a *sample* only, and is *not*
188;; meant to be used as a whole unless you understand what the effects
189;; will be! (In fact, this is a copy of Jim's setup for ps-print --
190;; I'd be very surprised if it was useful to *anybody*, without
191;; modification.)
192
193(defun ps-jts-ps-setup ()
194 (global-set-key (ps-prsc) 'ps-spool-buffer-with-faces) ;f22 is prsc
195 (global-set-key (ps-s-prsc) 'ps-spool-region-with-faces)
196 (global-set-key (ps-c-prsc) 'ps-despool)
197 (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook)
198 (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup)
199 (add-hook 'vm-mode-hook 'ps-vm-mode-hook)
200 (add-hook 'vm-mode-hooks 'ps-vm-mode-hook)
201 (add-hook 'Info-mode-hook 'ps-info-mode-hook)
202 (setq ps-spool-duplex t
203 ps-print-color-p nil
204 ps-lpr-command "lpr"
205 ps-lpr-switches '("-Jjct,duplex_long"))
206 'ps-jts-ps-setup)
207
208;; WARNING! The following function is a *sample* only, and is *not*
209;; meant to be used as a whole unless it corresponds to your needs.
210;; (In fact, this is a copy of Jack's setup for ps-print --
211;; I would not be that surprised if it was useful to *anybody*,
212;; without modification.)
213
214(defun ps-jack-setup ()
215 (setq ps-print-color-p nil
216 ps-lpr-command "lpr"
217 ps-lpr-switches nil
218
219 ps-paper-type 'a4
220 ps-landscape-mode t
221 ps-number-of-columns 2
222
223 ps-left-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
224 ps-right-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
225 ps-inter-column (/ (* 72 1.0) 2.54) ; 1.0 cm
226 ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
227 ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
228 ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
229 ps-header-line-pad .15
230 ps-print-header t
231 ps-print-header-frame t
232 ps-header-lines 2
233 ps-show-n-of-n t
234 ps-spool-duplex nil
235
236 ps-font-family 'Courier
237 ps-font-size 5.5
238 ps-header-font-family 'Helvetica
239 ps-header-font-size 6
240 ps-header-title-font-size 8)
241 'ps-jack-setup)
242
243
244;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245
246(provide 'ps-samp)
247
248;;; arch-tag: fb06a585-1112-4206-885d-a57d95d50579
249;;; ps-samp.el ends here