emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 613d384 1/2: Remove XEmacs compat code from ansi-co


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 613d384 1/2: Remove XEmacs compat code from ansi-color.el
Date: Wed, 19 Jun 2019 16:08:28 -0400 (EDT)

branch: master
commit 613d3848b8cd09bd8f9ec94362c210d23e788cdd
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 lisp/ansi-color.el | 69 ++++++++++++++++++++----------------------------------
 1 file changed, 26 insertions(+), 43 deletions(-)

diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index fe8cada..31bed60 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -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)))))
-
-(defun ansi-color-make-extent (from to &optional object)
-  "Make an extent for the range [FROM, TO) in OBJECT.
-
-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)))
+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 buffer)
+  "Make an extent for the range [FROM, TO) in BUFFER.
+
+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
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]