aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-19 21:56:43 +0200
committerLars Ingebrigtsen2019-06-19 22:08:19 +0200
commit613d3848b8cd09bd8f9ec94362c210d23e788cdd (patch)
treea4222d89ffe1ea5ebba5c4ebc5702b36a5b84b92
parent598d167f40693dd5b5ed27c579c433a3c23b8472 (diff)
downloademacs-613d3848b8cd09bd8f9ec94362c210d23e788cdd.tar.gz
emacs-613d3848b8cd09bd8f9ec94362c210d23e788cdd.zip
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.
-rw-r--r--lisp/ansi-color.el69
1 files changed, 26 insertions, 43 deletions
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index fe8cadacda7..31bed6028cc 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -424,9 +424,7 @@ this."
424 "Make an overlay from BEG to END, and apply face FACE. 424 "Make an overlay from BEG to END, and apply face FACE.
425If FACE is nil, do nothing." 425If FACE is nil, do nothing."
426 (when face 426 (when face
427 (ansi-color-set-extent-face 427 (overlay-put (ansi-color-make-extent beg end) 'face face)))
428 (ansi-color-make-extent beg end)
429 face)))
430 428
431(defun ansi-color-apply-text-property-face (beg end face) 429(defun ansi-color-apply-text-property-face (beg end face)
432 "Set the `font-lock-face' property to FACE in region BEG..END. 430 "Set the `font-lock-face' property to FACE in region BEG..END.
@@ -454,45 +452,32 @@ If FACE is nil, do nothing."
454; (message "Reached %d." pos))) 452; (message "Reached %d." pos)))
455; (setq pos (next-overlay-change pos))))) 453; (setq pos (next-overlay-change pos)))))
456 454
457;; Emacs/XEmacs compatibility layer
458
459(defun ansi-color-make-face (property color) 455(defun ansi-color-make-face (property color)
460 "Return a face with PROPERTY set to COLOR. 456 "Return a face with PROPERTY set to COLOR.
461PROPERTY can be either symbol `foreground' or symbol `background'. 457PROPERTY can be either symbol `foreground' or symbol `background'.
462 458
463For Emacs, we just return the cons cell (PROPERTY . COLOR). 459For Emacs, we just return the cons cell (PROPERTY . COLOR)."
464For XEmacs, we create a temporary face and return it." 460 (cond ((eq property 'foreground)
465 (if (featurep 'xemacs) 461 (cons 'foreground-color color))
466 (let ((face (make-face (intern (concat color "-" (symbol-name property))) 462 ((eq property 'background)
467 "Temporary face created by ansi-color." 463 (cons 'background-color color))
468 t))) 464 (t
469 (set-face-property face property color) 465 (cons property color))))
470 face) 466
471 (cond ((eq property 'foreground) 467(defun ansi-color-make-extent (from to &optional buffer)
472 (cons 'foreground-color color)) 468 "Make an extent for the range [FROM, TO) in BUFFER.
473 ((eq property 'background) 469
474 (cons 'background-color color)) 470BUFFER defaults to the current buffer."
475 (t 471 ;; The overlay might end at the process-mark in comint
476 (cons property color))))) 472 ;; buffers. In that case, new text will be inserted before the
477 473 ;; process-mark, ie. inside the overlay (using insert-before-marks).
478(defun ansi-color-make-extent (from to &optional object) 474 ;; In order to avoid this, we use the `insert-behind-hooks' overlay
479 "Make an extent for the range [FROM, TO) in OBJECT. 475 ;; property to make sure it works.
480 476 (let ((overlay (make-overlay from to buffer)))
481OBJECT defaults to the current buffer. XEmacs uses `make-extent', Emacs 477 (overlay-put overlay 'evaporate t)
482uses `make-overlay'. XEmacs can use a buffer or a string for OBJECT, 478 (overlay-put overlay 'modification-hooks '(ansi-color-freeze-overlay))
483Emacs requires OBJECT to be a buffer." 479 (overlay-put overlay 'insert-behind-hooks '(ansi-color-freeze-overlay))
484 (if (fboundp 'make-extent) 480 overlay))
485 (make-extent from to object)
486 ;; In Emacs, the overlay might end at the process-mark in comint
487 ;; buffers. In that case, new text will be inserted before the
488 ;; process-mark, ie. inside the overlay (using insert-before-marks).
489 ;; In order to avoid this, we use the `insert-behind-hooks' overlay
490 ;; property to make sure it works.
491 (let ((overlay (make-overlay from to object)))
492 (overlay-put overlay 'evaporate t)
493 (overlay-put overlay 'modification-hooks '(ansi-color-freeze-overlay))
494 (overlay-put overlay 'insert-behind-hooks '(ansi-color-freeze-overlay))
495 overlay)))
496 481
497(defun ansi-color-freeze-overlay (overlay is-after begin end &optional len) 482(defun ansi-color-freeze-overlay (overlay is-after begin end &optional len)
498 "Prevent OVERLAY from being extended. 483 "Prevent OVERLAY from being extended.
@@ -506,11 +491,9 @@ property."
506 (move-overlay overlay (overlay-start overlay) begin))) 491 (move-overlay overlay (overlay-start overlay) begin)))
507 492
508(defun ansi-color-set-extent-face (extent face) 493(defun ansi-color-set-extent-face (extent face)
509 "Set the `face' property of EXTENT to FACE. 494 "Set the `face' property of EXTENT to FACE."
510XEmacs uses `set-extent-face', Emacs uses `overlay-put'." 495 (declare (obsolete overlay-put "27.1"))
511 (if (featurep 'xemacs) 496 (overlay-put extent 'face face))
512 (set-extent-face extent face)
513 (overlay-put extent 'face face)))
514 497
515;; Helper functions 498;; Helper functions
516 499