summaryrefslogtreecommitdiff
path: root/lisp/ansi-color.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-05-04 14:47:29 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-05-04 15:33:20 -0400
commit4fd9048e940d38364caf4abe9b209f9288c78544 (patch)
treea89d315f7671b1369c90bb3b7c503ca78193ea3f /lisp/ansi-color.el
parent37963ed4991823fd1ee5cd2c485f22ac988259e2 (diff)
downloademacs-4fd9048e940d38364caf4abe9b209f9288c78544.tar.gz
Avoid slow overlay ansi coloring in eshell (Bug#29854)
* lisp/ansi-color.el (ansi-color-apply-on-region): Reset temporary markers after finishing with them. (ansi-color-apply-text-property-face): New function. * lisp/eshell/esh-mode.el (eshell-handle-ansi-color): * lisp/man.el (Man-fontify-manpage): Use it as the `ansi-color-apply-face-function' while calling `ansi-color-apply-on-region'. Use `font-lock-face' to propertize instead of `face'.
Diffstat (limited to 'lisp/ansi-color.el')
-rw-r--r--lisp/ansi-color.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index d3b8d06604c..136e69f9a76 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -415,7 +415,11 @@ this."
;; if the rest of the region should have a face, put it there
(funcall ansi-color-apply-face-function
start-marker end-marker (ansi-color--find-face codes))
- (setq ansi-color-context-region (if codes (list codes)))))))
+ (setq ansi-color-context-region (if codes (list codes)))))
+ ;; Clean up our temporary markers.
+ (unless (eq start-marker (cadr ansi-color-context-region))
+ (set-marker start-marker nil))
+ (set-marker end-marker nil)))
(defun ansi-color-apply-overlay-face (beg end face)
"Make an overlay from BEG to END, and apply face FACE.
@@ -425,6 +429,12 @@ If FACE is nil, do nothing."
(ansi-color-make-extent beg end)
face)))
+(defun ansi-color-apply-text-property-face (beg end face)
+ "Set the `font-lock-face' property to FACE in region BEG..END.
+If FACE is nil, do nothing."
+ (when face
+ (put-text-property beg end 'font-lock-face face)))
+
;; This function helps you look for overlapping overlays. This is
;; useful in comint-buffers. Overlapping overlays should not happen!
;; A possible cause for bugs are the markers. If you create an overlay