Remove XEmacs compat code from ansi-color.el

* lisp/ansi-color.el (ansi-color-apply-overlay-face)
(ansi-color-make-face, ansi-color-make-extent)
(ansi-color-set-extent-face): Remove XEmacs compat code.
This commit is contained in:
Lars Ingebrigtsen 2019-06-19 21:56:43 +02:00
parent 598d167f40
commit 613d3848b8

View file

@ -424,9 +424,7 @@ this."
"Make an overlay from BEG to END, and apply face FACE.
If FACE is nil, do nothing."
(when face
(ansi-color-set-extent-face
(ansi-color-make-extent beg end)
face)))
(overlay-put (ansi-color-make-extent beg end) 'face face)))
(defun ansi-color-apply-text-property-face (beg end face)
"Set the `font-lock-face' property to FACE in region BEG..END.
@ -454,45 +452,32 @@ If FACE is nil, do nothing."
; (message "Reached %d." pos)))
; (setq pos (next-overlay-change pos)))))
;; Emacs/XEmacs compatibility layer
(defun ansi-color-make-face (property color)
"Return a face with PROPERTY set to COLOR.
PROPERTY can be either symbol `foreground' or symbol `background'.
For Emacs, we just return the cons cell (PROPERTY . COLOR).
For XEmacs, we create a temporary face and return it."
(if (featurep 'xemacs)
(let ((face (make-face (intern (concat color "-" (symbol-name property)))
"Temporary face created by ansi-color."
t)))
(set-face-property face property color)
face)
(cond ((eq property 'foreground)
(cons 'foreground-color color))
((eq property 'background)
(cons 'background-color color))
(t
(cons property color)))))
For Emacs, we just return the cons cell (PROPERTY . COLOR)."
(cond ((eq property 'foreground)
(cons 'foreground-color color))
((eq property 'background)
(cons 'background-color color))
(t
(cons property color))))
(defun ansi-color-make-extent (from to &optional object)
"Make an extent for the range [FROM, TO) in OBJECT.
(defun ansi-color-make-extent (from to &optional buffer)
"Make an extent for the range [FROM, TO) in BUFFER.
OBJECT defaults to the current buffer. XEmacs uses `make-extent', Emacs
uses `make-overlay'. XEmacs can use a buffer or a string for OBJECT,
Emacs requires OBJECT to be a buffer."
(if (fboundp 'make-extent)
(make-extent from to object)
;; In Emacs, the overlay might end at the process-mark in comint
;; buffers. In that case, new text will be inserted before the
;; process-mark, ie. inside the overlay (using insert-before-marks).
;; In order to avoid this, we use the `insert-behind-hooks' overlay
;; property to make sure it works.
(let ((overlay (make-overlay from to object)))
(overlay-put overlay 'evaporate t)
(overlay-put overlay 'modification-hooks '(ansi-color-freeze-overlay))
(overlay-put overlay 'insert-behind-hooks '(ansi-color-freeze-overlay))
overlay)))
BUFFER defaults to the current buffer."
;; The overlay might end at the process-mark in comint
;; buffers. In that case, new text will be inserted before the
;; process-mark, ie. inside the overlay (using insert-before-marks).
;; In order to avoid this, we use the `insert-behind-hooks' overlay
;; property to make sure it works.
(let ((overlay (make-overlay from to buffer)))
(overlay-put overlay 'evaporate t)
(overlay-put overlay 'modification-hooks '(ansi-color-freeze-overlay))
(overlay-put overlay 'insert-behind-hooks '(ansi-color-freeze-overlay))
overlay))
(defun ansi-color-freeze-overlay (overlay is-after begin end &optional len)
"Prevent OVERLAY from being extended.
@ -506,11 +491,9 @@ property."
(move-overlay overlay (overlay-start overlay) begin)))
(defun ansi-color-set-extent-face (extent face)
"Set the `face' property of EXTENT to FACE.
XEmacs uses `set-extent-face', Emacs uses `overlay-put'."
(if (featurep 'xemacs)
(set-extent-face extent face)
(overlay-put extent 'face face)))
"Set the `face' property of EXTENT to FACE."
(declare (obsolete overlay-put "27.1"))
(overlay-put extent 'face face))
;; Helper functions