-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathslime-repl-ansi-color.el
36 lines (28 loc) · 1.01 KB
/
slime-repl-ansi-color.el
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
(require 'ansi-color)
(define-slime-contrib slime-repl-ansi-color
"Turn on ANSI colors in REPL output"
(:authors "Max Mikhanosha")
(:license "GPL")
(:slime-dependencies slime-repl)
(:on-load
(add-hook 'slime-repl-mode-hook
(lambda ()
(slime-repl-ansi-on)))))
(defvar slime-repl-ansi-color nil
"When Non-NIL will process ANSI colors in the lisp output")
(make-variable-buffer-local 'slime-repl-ansi-color)
(defun slime-repl-ansi-on ()
"Set `ansi-color-for-comint-mode' to t."
(interactive)
(setq slime-repl-ansi-color t))
(defun slime-repl-ansi-off ()
"Set `ansi-color-for-comint-mode' to t."
(interactive)
(setq slime-repl-ansi-color nil))
(defadvice slime-repl-emit (around slime-repl-ansi-colorize activate compile)
(with-current-buffer (slime-output-buffer)
(let ((start slime-output-start))
(setq ad-return-value ad-do-it)
(when slime-repl-ansi-color
(ansi-color-apply-on-region start slime-output-end)))))
(provide 'slime-repl-ansi-color)