aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-19 22:30:10 +0200
committerLars Ingebrigtsen2019-06-19 22:30:10 +0200
commit8064f64eb14882f68851cc8f91b86fb287589499 (patch)
tree3c292780e1b3ca9da228d930f24c90c97b1872be /lisp
parent43a251ccf3e54e519572f431a415fc121450d2b0 (diff)
downloademacs-8064f64eb14882f68851cc8f91b86fb287589499.tar.gz
emacs-8064f64eb14882f68851cc8f91b86fb287589499.zip
Remove XEmacs compat code from ps-print
* lisp/ps-print.el: (ps-print-color-p, ps-postscript-code-directory, ps-setup): * lisp/ps-def.el: (ps-mark-active-p, ps-face-foreground-name) (ps-face-background-name, ps-color-device, ps-color-values) (ps-face-bold-p, ps-face-italic-p, ps-face-strikeout-p) (ps-face-overline-p, ps-face-box-p) (ps-generate-postscript-with-faces1): Remove XEmacs compat code and some outdated Emacs compat code.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ps-def.el348
-rw-r--r--lisp/ps-print.el31
2 files changed, 73 insertions, 306 deletions
diff --git a/lisp/ps-def.el b/lisp/ps-def.el
index 0f3b2f7fee8..f33f81770dd 100644
--- a/lisp/ps-def.el
+++ b/lisp/ps-def.el
@@ -1,4 +1,4 @@
1;;; ps-def.el --- XEmacs and Emacs definitions for ps-print -*- lexical-binding: t -*- 1;;; ps-def.el --- Emacs definitions for ps-print -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2007-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
4 4
@@ -37,316 +37,104 @@
37 37
38 38
39 39
40;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42;; XEmacs Definitions
43
44
45(cond
46 ((featurep 'xemacs) ; XEmacs
47
48 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49 ;; ps-bdf
50
51 (defvar installation-directory nil)
52 (defvar coding-system-for-read)
53
54 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55 ;; ps-mule
56
57 (or (fboundp 'charset-dimension)
58 (defun charset-dimension (_charset) 1)) ; ascii
59
60 (or (fboundp 'char-width)
61 (defun char-width (_char) 1)) ; ascii
62
63 (or (fboundp 'encode-char)
64 (defun encode-char (ch _ccs)
65 ch))
66
67 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68 ;; ps-print
69
70 ;; GNU Emacs
71 (or (fboundp 'line-beginning-position)
72 (defun line-beginning-position (&optional n)
73 (save-excursion
74 (and n (/= n 1) (forward-line (1- n)))
75 (beginning-of-line)
76 (point))))
77
78
79 ;; GNU Emacs
80 (or (fboundp 'find-composition)
81 (defalias 'find-composition 'ignore))
82
83
84 (defun ps-xemacs-color-name (color)
85 (if (color-specifier-p color)
86 (color-name color)
87 color))
88
89
90 (defalias 'ps-mark-active-p 'region-active-p)
91
92
93 (defun ps-face-foreground-name (face)
94 (ps-xemacs-color-name (face-foreground face)))
95
96
97 (defun ps-face-background-name (face)
98 (ps-xemacs-color-name (face-background face)))
99
100
101 (defalias 'ps-frame-parameter 'frame-property)
102
103
104 ;; Return t if the device (which can be changed during an emacs session)
105 ;; can handle colors.
106 (defun ps-color-device ()
107 (eq (device-class) 'color))
108
109 (defun ps-mapper (extent list)
110 (nconc list
111 (list (list (extent-start-position extent) 'push extent)
112 (list (extent-end-position extent) 'pull extent)))
113 nil)
114
115
116 (defun ps-extent-sorter (a b)
117 (< (extent-priority a) (extent-priority b)))
118
119
120 (defun ps-xemacs-face-kind-p (face kind kind-regex)
121 (let* ((frame-font (or (face-font-instance face)
122 (face-font-instance 'default)))
123 (kind-cons
124 (and frame-font
125 (assq kind
126 (font-instance-properties frame-font))))
127 (kind-spec (cdr-safe kind-cons))
128 (case-fold-search t))
129 (and kind-spec (string-match kind-regex kind-spec))))
130
131
132 ;; to avoid XEmacs compilation gripes
133 (defvar coding-system-for-write)
134 (defvar buffer-file-coding-system)
135
136 40
137 (and (fboundp 'find-coding-system)
138 (or (funcall 'find-coding-system 'raw-text-unix)
139 (funcall 'copy-coding-system 'no-conversion-unix 'raw-text-unix)))
140
141
142 (defun ps-color-values (x-color)
143 (let ((color (ps-xemacs-color-name x-color)))
144 (cond
145 ((fboundp 'x-color-values)
146 (funcall 'x-color-values color))
147 ((and (fboundp 'color-instance-rgb-components)
148 (ps-color-device))
149 (funcall 'color-instance-rgb-components
150 (if (color-instance-p x-color)
151 x-color
152 (make-color-instance color))))
153 (t
154 (error "No available function to determine X color values")))))
155
156
157 (defun ps-face-bold-p (face)
158 (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
159 (memq face ps-bold-faces))) ; Kludge-compatible
160
161
162 (defun ps-face-italic-p (face)
163 (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o")
164 (ps-xemacs-face-kind-p face 'SLANT "i\\|o")
165 (memq face ps-italic-faces))) ; Kludge-compatible
166
167
168 (defalias 'ps-face-strikeout-p 'ignore)
169
170
171 (defalias 'ps-face-overline-p 'ignore)
172
173
174 (defalias 'ps-face-box-p 'ignore)
175
176
177 ;; XEmacs will have to make do with %s (princ) for floats.
178 (defvar ps-color-format "%s %s %s")
179 (defvar ps-float-format "%s ")
180
181
182 (defun ps-generate-postscript-with-faces1 (from to)
183 ;; Generate some PostScript.
184 (let ((face 'default)
185 (position to)
186 ;; XEmacs
187 ;; Build the list of extents...
188 (a (cons 'dummy nil))
189 record type extent extent-list)
190 (map-extents 'ps-mapper nil from to a)
191 (setq a (sort (cdr a) 'car-less-than-car)
192 extent-list nil)
193
194 ;; Loop through the extents...
195 (while a
196 (setq record (car a)
197 position (car record)
198
199 record (cdr record)
200 type (car record)
201
202 record (cdr record)
203 extent (car record))
204
205 ;; Plot up to this record.
206 ;; XEmacs 19.12: for some reason, we're getting into a
207 ;; situation in which some of the records have
208 ;; positions less than 'from'. Since we've narrowed
209 ;; the buffer, this'll generate errors. This is a hack,
210 ;; but don't call ps-plot-with-face unless from > point-min.
211 (and (>= from (point-min))
212 (ps-plot-with-face from (min position (point-max)) face))
213
214 (cond
215 ((eq type 'push)
216 (and (extent-face extent)
217 (setq extent-list (sort (cons extent extent-list)
218 'ps-extent-sorter))))
219
220 ((eq type 'pull)
221 (setq extent-list (sort (delq extent extent-list)
222 'ps-extent-sorter))))
223
224 (setq face (if extent-list
225 (extent-face (car extent-list))
226 'default)
227 from position
228 a (cdr a)))
229
230 (ps-plot-with-face from to face)))
231
232 )
233 (t ; Emacs
234 ;; Do nothing
235 )) ; end cond featurep
236
237
238
239;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 41;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
240;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 42;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
241;; Emacs Definitions 43;; Emacs Definitions
242 44
243 45
244(cond 46(defun ps-mark-active-p ()
245 ((featurep 'xemacs) ; XEmacs 47 mark-active)
246 ;; Do nothing
247 )
248 (t ; Emacs
249
250
251 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
252 ;; ps-print
253
254
255 (defun ps-mark-active-p ()
256 mark-active)
257
258 48
259 (defun ps-face-foreground-name (face)
260 (face-foreground face nil t))
261 49
50(defun ps-face-foreground-name (face)
51 (face-foreground face nil t))
262 52
263 (defun ps-face-background-name (face)
264 (face-background face nil t))
265 53
54(defun ps-face-background-name (face)
55 (face-background face nil t))
266 56
267 (defalias 'ps-frame-parameter 'frame-parameter)
268 57
58(defalias 'ps-frame-parameter 'frame-parameter)
269 59
270 ;; Return t if the device (which can be changed during an emacs session) can 60;; Return t if the device (which can be changed during an emacs session) can
271 ;; handle colors. This function is not yet implemented for GNU emacs. 61;; handle colors. This function is not yet implemented for GNU emacs.
272 (defun ps-color-device () 62(defun ps-color-device ()
273 (if (fboundp 'color-values) 63 (if (fboundp 'color-values)
274 (funcall 'color-values "Green") 64 (funcall 'color-values "Green")
275 t)) 65 t))
276 66
277 67
278 (defun ps-color-values (x-color) 68(defun ps-color-values (x-color)
279 (cond 69 (cond
280 ((fboundp 'color-values) 70 ((fboundp 'color-values)
281 (funcall 'color-values x-color)) 71 (funcall 'color-values x-color))
282 ((fboundp 'x-color-values) 72 ((fboundp 'x-color-values)
283 (funcall 'x-color-values x-color)) 73 (funcall 'x-color-values x-color))
284 (t 74 (t
285 (error "No available function to determine X color values")))) 75 (error "No available function to determine X color values"))))
286 76
287 77
288 (defun ps-face-bold-p (face) 78(defun ps-face-bold-p (face)
289 (or (face-bold-p face) 79 (or (face-bold-p face)
290 (memq face ps-bold-faces))) 80 (memq face ps-bold-faces)))
291 81
292 82
293 (defun ps-face-italic-p (face) 83(defun ps-face-italic-p (face)
294 (or (face-italic-p face) 84 (or (face-italic-p face)
295 (memq face ps-italic-faces))) 85 (memq face ps-italic-faces)))
296 86
297 87
298 (defun ps-face-strikeout-p (face) 88(defun ps-face-strikeout-p (face)
299 (eq (face-attribute face :strike-through) t)) 89 (eq (face-attribute face :strike-through) t))
300 90
301 91
302 (defun ps-face-overline-p (face) 92(defun ps-face-overline-p (face)
303 (eq (face-attribute face :overline) t)) 93 (eq (face-attribute face :overline) t))
304 94
305 95
306 (defun ps-face-box-p (face) 96(defun ps-face-box-p (face)
307 (not (memq (face-attribute face :box) '(nil unspecified)))) 97 (not (memq (face-attribute face :box) '(nil unspecified))))
308 98
309 99
310 ;; Emacs understands the %f format; we'll use it to limit color RGB values 100;; Emacs understands the %f format; we'll use it to limit color RGB values
311 ;; to three decimals to cut down some on the size of the PostScript output. 101;; to three decimals to cut down some on the size of the PostScript output.
312 (defvar ps-color-format "%0.3f %0.3f %0.3f") 102(defvar ps-color-format "%0.3f %0.3f %0.3f")
313 (defvar ps-float-format "%0.3f ") 103(defvar ps-float-format "%0.3f ")
314 104
315 105
316 (defun ps-generate-postscript-with-faces1 (from to) 106(defun ps-generate-postscript-with-faces1 (from to)
317 ;; Generate some PostScript. 107 ;; Generate some PostScript.
318 (let ((face 'default) 108 (let ((face 'default)
319 (position to) 109 (position to)
320 ;; Emacs 110 ;; Emacs
321 (property-change from) 111 (property-change from)
322 (overlay-change from) 112 (overlay-change from)
323 before-string after-string) 113 before-string after-string)
324 (while (< from to) 114 (while (< from to)
325 (and (< property-change to) ; Don't search for property change 115 (and (< property-change to) ; Don't search for property change
326 ; unless previous search succeeded. 116 ; unless previous search succeeded.
327 (setq property-change (next-property-change from nil to))) 117 (setq property-change (next-property-change from nil to)))
328 (and (< overlay-change to) ; Don't search for overlay change 118 (and (< overlay-change to) ; Don't search for overlay change
329 ; unless previous search succeeded. 119 ; unless previous search succeeded.
330 (setq overlay-change (min (next-overlay-change from) 120 (setq overlay-change (min (next-overlay-change from)
331 to))) 121 to)))
332 (setq position (min property-change overlay-change) 122 (setq position (min property-change overlay-change)
333 before-string nil 123 before-string nil
334 after-string nil) 124 after-string nil)
335 (setq face 125 (setq face
336 (cond ((invisible-p from) 126 (cond ((invisible-p from)
337 'emacs--invisible--face) 127 'emacs--invisible--face)
338 ((get-char-property from 'face)) 128 ((get-char-property from 'face))
339 (t 'default))) 129 (t 'default)))
340 ;; Plot up to this record. 130 ;; Plot up to this record.
341 (and before-string 131 (and before-string
342 (ps-plot-string before-string)) 132 (ps-plot-string before-string))
343 (ps-plot-with-face from position face) 133 (ps-plot-with-face from position face)
344 (and after-string 134 (and after-string
345 (ps-plot-string after-string)) 135 (ps-plot-string after-string))
346 (setq from position)) 136 (setq from position))
347 (ps-plot-with-face from to face))) 137 (ps-plot-with-face from to face)))
348
349 )) ; end cond featurep
350 138
351 139
352;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 140;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 994048d2b16..8dd1d1e2bf2 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -47,7 +47,7 @@ Please send all bug fixes and enhancements to
47;; 47;;
48;; This package provides printing of Emacs buffers on PostScript printers; the 48;; This package provides printing of Emacs buffers on PostScript printers; the
49;; buffer's bold and italic text attributes are preserved in the printer 49;; buffer's bold and italic text attributes are preserved in the printer
50;; output. ps-print is intended for use with Emacs or XEmacs, together with a 50;; output. ps-print is intended for use with Emacs, together with a
51;; fontifying package such as font-lock or hilit. 51;; fontifying package such as font-lock or hilit.
52;; 52;;
53;; ps-print uses the same face attributes defined through font-lock or hilit to 53;; ps-print uses the same face attributes defined through font-lock or hilit to
@@ -1464,16 +1464,7 @@ Please send all bug fixes and enhancements to
1464 1464
1465(require 'lpr) 1465(require 'lpr)
1466 1466
1467 1467;; Load Emacs definitions
1468(if (featurep 'xemacs)
1469 (or (featurep 'lisp-float-type)
1470 (error "`ps-print' requires floating point support"))
1471 (unless (and (boundp 'emacs-major-version)
1472 (>= emacs-major-version 23))
1473 (error "`ps-print' only supports Emacs 23 and higher")))
1474
1475
1476;; Load XEmacs/Emacs definitions
1477(require 'ps-def) 1468(require 'ps-def)
1478 1469
1479;; autoloads for secondary file 1470;; autoloads for secondary file
@@ -2951,13 +2942,8 @@ Either a float or a cons of floats (LANDSCAPE-SIZE . PORTRAIT-SIZE)."
2951;;; Colors 2942;;; Colors
2952 2943
2953;; Printing color requires x-color-values. 2944;; Printing color requires x-color-values.
2954;; XEmacs change: Need autoload for the "Options->Printing->Color Printing"
2955;; widget to work.
2956;;;###autoload 2945;;;###autoload
2957(defcustom ps-print-color-p 2946(defcustom ps-print-color-p (fboundp 'x-color-values)
2958 (or (fboundp 'x-color-values) ; Emacs
2959 (fboundp 'color-instance-rgb-components))
2960 ; XEmacs
2961 "Specify how buffer's text color is printed. 2947 "Specify how buffer's text color is printed.
2962 2948
2963Valid values are: 2949Valid values are:
@@ -3381,13 +3367,7 @@ It's like the very first character of buffer (or region) is ^L (\\014)."
3381 :version "20" 3367 :version "20"
3382 :group 'ps-print-headers) 3368 :group 'ps-print-headers)
3383 3369
3384(defcustom ps-postscript-code-directory 3370(defcustom ps-postscript-code-directory data-directory
3385 (cond ((fboundp 'locate-data-directory) ; XEmacs
3386 (locate-data-directory "ps-print"))
3387 ((boundp 'data-directory) ; XEmacs and Emacs.
3388 data-directory)
3389 (t ; don't know what to do
3390 (error "`ps-postscript-code-directory' isn't set properly")))
3391 "Directory where it's located the PostScript prologue file used by ps-print. 3371 "Directory where it's located the PostScript prologue file used by ps-print.
3392By default, this directory is the same as in the variable `data-directory'." 3372By default, this directory is the same as in the variable `data-directory'."
3393 :type 'directory 3373 :type 'directory
@@ -3632,8 +3612,7 @@ The table depends on the current ps-print setup."
3632 (mapconcat 3612 (mapconcat
3633 #'ps-print-quote 3613 #'ps-print-quote
3634 (list 3614 (list
3635 (concat "\n;;; (" (if (featurep 'xemacs) "XEmacs" "Emacs") 3615 (concat "\n;;; (Emacs) ps-print version " ps-print-version "\n")
3636 ") ps-print version " ps-print-version "\n")
3637 ";; internal vars" 3616 ";; internal vars"
3638 (ps-comment-string "emacs-version " emacs-version) 3617 (ps-comment-string "emacs-version " emacs-version)
3639 (ps-comment-string "lpr-windows-system" lpr-windows-system) 3618 (ps-comment-string "lpr-windows-system" lpr-windows-system)