Change the color of the text in the Common Lisp RE

2019-05-07 10:58发布

问题:

I'd like to control the color of the text displayed in Common Lisp. Something like this pseudo-code:

(print-color (:red "hello") (:blue "world"))

Is there any way this can be done? I use SBCL and my repl is inside emacs. Thanks!

回答1:

You can use ANSI escape code to print colorful texts:

(format t "~c[31mabc~c[0m~%" #\ESC #\ESC) ; this prints a red "abc" for most modern terminals

I'm not sure whether this works in slime, although.