unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 4e95291cd1e992999adef00aef9fcf94928085f1 9480 bytes (raw)
name: lisp/ps-def.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
 
;;; ps-def.el --- XEmacs and Emacs definitions for ps-print -*- lexical-binding: t -*-

;; Copyright (C) 2007-2019 Free Software Foundation, Inc.

;; Author: Vinicius Jose Latorre <viniciusjl.gnu@gmail.com>
;;	Kenichi Handa <handa@m17n.org> (multi-byte characters)
;;	Vinicius Jose Latorre <viniciusjl.gnu@gmail.com>
;; Keywords: wp, print, PostScript
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; Package: ps-print

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; See ps-print.el for documentation.

;;; Code:

(declare-function ps-plot-with-face "ps-print" (from to face))
(declare-function ps-plot-string    "ps-print" (string))

(defvar ps-bold-faces)                  ; in ps-print.el
(defvar ps-italic-faces)


\f
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; XEmacs Definitions


(cond
 ((featurep 'xemacs)			; XEmacs

  ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; ps-bdf

  (defvar installation-directory nil)
  (defvar coding-system-for-read)

  ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; ps-mule

  (or (fboundp 'charset-dimension)
      (defun charset-dimension (_charset) 1)) ; ascii

  (or (fboundp 'char-width)
      (defun char-width (_char) 1))	; ascii

  (or (fboundp 'encode-char)
      (defun encode-char (ch _ccs)
	ch))

  ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; ps-print

  ;; GNU Emacs
  (or (fboundp 'line-beginning-position)
      (defun line-beginning-position (&optional n)
	(save-excursion
	  (and n (/= n 1) (forward-line (1- n)))
	  (beginning-of-line)
	  (point))))


  ;; GNU Emacs
  (or (fboundp 'find-composition)
      (defalias 'find-composition 'ignore))


  (defun ps-xemacs-color-name (color)
    (if (color-specifier-p color)
	(color-name color)
      color))


  (defalias 'ps-mark-active-p 'region-active-p)


  (defun ps-face-foreground-name (face)
    (ps-xemacs-color-name (face-foreground face)))


  (defun ps-face-background-name (face)
    (ps-xemacs-color-name (face-background face)))


  (defalias 'ps-frame-parameter 'frame-property)


  ;; Return t if the device (which can be changed during an emacs session)
  ;; can handle colors.
  (defun ps-color-device ()
    (eq (device-class) 'color))

  (defun ps-mapper (extent list)
    (nconc list
	   (list (list (extent-start-position extent) 'push extent)
		 (list (extent-end-position extent) 'pull extent)))
    nil)


  (defun ps-extent-sorter (a b)
    (< (extent-priority a) (extent-priority b)))


  (defun ps-xemacs-face-kind-p (face kind kind-regex)
    (let* ((frame-font (or (face-font-instance face)
			   (face-font-instance 'default)))
	   (kind-cons
	    (and frame-font
		 (assq kind
		       (font-instance-properties frame-font))))
	   (kind-spec (cdr-safe kind-cons))
	   (case-fold-search t))
      (and kind-spec (string-match kind-regex kind-spec))))


  ;; to avoid XEmacs compilation gripes
  (defvar coding-system-for-write)
  (defvar buffer-file-coding-system)


  (and (fboundp 'find-coding-system)
       (or (funcall 'find-coding-system 'raw-text-unix)
	   (funcall 'copy-coding-system 'no-conversion-unix 'raw-text-unix)))


  (defun ps-color-values (x-color)
    (let ((color (ps-xemacs-color-name x-color)))
      (cond
       ((fboundp 'x-color-values)
	(funcall 'x-color-values color))
       ((and (fboundp 'color-instance-rgb-components)
	     (ps-color-device))
	(funcall 'color-instance-rgb-components
		 (if (color-instance-p x-color)
		     x-color
		   (make-color-instance color))))
       (t
	(error "No available function to determine X color values")))))


  (defun ps-face-bold-p (face)
    (or (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold")
	(memq face ps-bold-faces)))	; Kludge-compatible


  (defun ps-face-italic-p (face)
    (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o")
	(ps-xemacs-face-kind-p face 'SLANT "i\\|o")
	(memq face ps-italic-faces)))	; Kludge-compatible


  (defalias 'ps-face-strikeout-p 'ignore)


  (defalias 'ps-face-overline-p 'ignore)


  (defalias 'ps-face-box-p 'ignore)


  ;; XEmacs will have to make do with %s (princ) for floats.
  (defvar ps-color-format "%s %s %s")
  (defvar ps-float-format "%s ")


  (defun ps-generate-postscript-with-faces1 (from to)
    ;; Generate some PostScript.
    (let ((face 'default)
	  (position to)
	  ;; XEmacs
	  ;; Build the list of extents...
	  (a (cons 'dummy nil))
	  record type extent extent-list)
      (map-extents 'ps-mapper nil from to a)
      (setq a (sort (cdr a) 'car-less-than-car)
	    extent-list nil)

      ;; Loop through the extents...
      (while a
	(setq record (car a)
	      position (car record)

	      record (cdr record)
	      type (car record)

	      record (cdr record)
	      extent (car record))

	;; Plot up to this record.
	;; XEmacs 19.12: for some reason, we're getting into a
	;; situation in which some of the records have
	;; positions less than 'from'.  Since we've narrowed
	;; the buffer, this'll generate errors.  This is a hack,
	;; but don't call ps-plot-with-face unless from > point-min.
	(and (>= from (point-min))
	     (ps-plot-with-face from (min position (point-max)) face))

	(cond
	 ((eq type 'push)
	  (and (extent-face extent)
	       (setq extent-list (sort (cons extent extent-list)
				       'ps-extent-sorter))))

	 ((eq type 'pull)
	  (setq extent-list (sort (delq extent extent-list)
				  'ps-extent-sorter))))

	(setq face (if extent-list
		       (extent-face (car extent-list))
		     'default)
	      from position
	      a (cdr a)))

      (ps-plot-with-face from to face)))

  )
 (t					; Emacs
  ;; Do nothing
  ))					; end cond featurep


\f
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs Definitions


(cond
 ((featurep 'xemacs)			; XEmacs
  ;; Do nothing
  )
 (t					; Emacs


  ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; ps-print


  (defun ps-mark-active-p ()
    mark-active)


  (defun ps-face-foreground-name (face)
    (face-foreground face nil t))


  (defun ps-face-background-name (face)
    (face-background face nil t))


  (defalias 'ps-frame-parameter 'frame-parameter)


  ;; Return t if the device (which can be changed during an emacs session) can
  ;; handle colors.  This function is not yet implemented for GNU emacs.
  (defun ps-color-device ()
    (if (fboundp 'color-values)
	(funcall 'color-values "Green")
      t))


  (defun ps-color-values (x-color)
    (cond
     ((fboundp 'color-values)
      (funcall 'color-values x-color))
     ((fboundp 'x-color-values)
      (funcall 'x-color-values x-color))
     (t
      (error "No available function to determine X color values"))))


  (defun ps-face-bold-p (face)
    (or (face-bold-p face)
	(memq face ps-bold-faces)))


  (defun ps-face-italic-p (face)
    (or (face-italic-p face)
	(memq face ps-italic-faces)))


  (defun ps-face-strikeout-p (face)
    (eq (face-attribute face :strike-through) t))


  (defun ps-face-overline-p (face)
    (eq (face-attribute face :overline) t))


  (defun ps-face-box-p (face)
    (not (memq (face-attribute face :box) '(nil unspecified))))


  ;; Emacs understands the %f format; we'll use it to limit color RGB values
  ;; to three decimals to cut down some on the size of the PostScript output.
  (defvar ps-color-format "%0.3f %0.3f %0.3f")
  (defvar ps-float-format "%0.3f ")


  (defun ps-generate-postscript-with-faces1 (from to)
    ;; Generate some PostScript.
    (let ((face 'default)
	  (position to)
	  ;; Emacs
	  (property-change from)
	  (overlay-change from)
	  before-string after-string)
      (while (< from to)
	(and (< property-change to)	; Don't search for property change
					; unless previous search succeeded.
	     (setq property-change (next-property-change from nil to)))
	(and (< overlay-change to)	; Don't search for overlay change
					; unless previous search succeeded.
	     (setq overlay-change (min (next-overlay-change from)
				       to)))
	(setq position (min property-change overlay-change)
	      before-string nil
	      after-string nil)
	(setq face
	      (cond ((invisible-p from)
		     'emacs--invisible--face)
		    ((get-char-property from 'face))
		    (t 'default)))
	;; Plot up to this record.
	(and before-string
	     (ps-plot-string before-string))
	(ps-plot-with-face from position face)
	(and after-string
	     (ps-plot-string after-string))
	(setq from position))
      (ps-plot-with-face from to face)))

  ))					; end cond featurep

\f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(provide 'ps-def)

;;; ps-def.el ends here

debug log:

solving 4e95291cd1 ...
found 4e95291cd1 in https://yhetil.org/emacs-devel/2807078f-19a8-4648-3c65-31772934171c@cs.ucla.edu/
found 2063133890 in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 206313389028313fab5f00d3c96f3426e432ade4	lisp/ps-def.el

applying [1/1] https://yhetil.org/emacs-devel/2807078f-19a8-4648-3c65-31772934171c@cs.ucla.edu/
diff --git a/lisp/ps-def.el b/lisp/ps-def.el
index 2063133890..4e95291cd1 100644

Checking patch lisp/ps-def.el...
Applied patch lisp/ps-def.el cleanly.

index at:
100644 4e95291cd1e992999adef00aef9fcf94928085f1	lisp/ps-def.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).