Take the 2-minute tour ×

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!

share|improve this question
I think that SLIME scratch-buffer already has colouring, wouldn't that be an alternative? Some faces in the REPL have meaning unrelated to the language semantics (used to invoke some SLIME functions for introspection / reflection), so I'd not rush into changing them. –  user797257 Oct 6 '13 at 13:03
@wvxvw What's the SLIME scratch buffer? Is this something different from the scratch buffer in emacs? If so, how do I invoke it? The reason I want to control the color in my repl is to help my test my program - I am doing a board game. –  S4M Oct 6 '13 at 13:08
M-x slime-scratch common-lisp.net/project/slime/doc/html/Scratch-Buffer.html –  Baggers Oct 6 '13 at 13:42
@Baggers I must be missing something obvious, but your link doesn't tell me how to install that package slime-scratch, and googling it is not helping. –  S4M Oct 6 '13 at 14:37
Well I don’t know how slime scratch will help with colours but if you have slime installed then you already have slime scratch. If you don’t use emacs and slime then it isn’t something that can be installed separately. If you want to look into how to install slime and emacs then have a look here: youtube.com/… do note though that this is about lisp devlopment, I have no idea how slime scratch relates to coloured output –  Baggers Oct 6 '13 at 20:08
show 3 more comments

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
Yes, it works fine. Thanks a lot! –  S4M Oct 6 '13 at 16:30
add comment

Your Answer


