color prompt



Looking for a way to display maxima prompt with colors I found the
following solution in the archive of the mailing list

file colorterm.lisp
===================

(defvar *prompt-color* 35)
(defvar *input-color*  37)
(defvar *output-color* 37)

(defun $colorterm ()
  (let ((escape-char (code-char 27)))
    (setf *prompt-prefix*
          (format nil "~a[00;~am" escape-char *prompt-color*))
    (setf *prompt-suffix*
          (format nil "~a[00;~am" escape-char *input-color*))
    (setf *general-display-prefix*
          (format nil "~a[00;~am" escape-char *output-color*))
    (setf *maxima-epilog*
          (format nil "~a[00;m" escape-char))))

file maxima-init.mac
====================
load( "colorterm.lisp" ); colorterm();

It seems to work at the beginning but there are a few problems :
1) when the cursor reaches the end of line we never go to the following
line
2) when using history (with arrow keys) some parts of lines can't be
erased
...

It doesn't surprise me, since I think there's something missing in the
solution. When colorizing prompts (bash, lftp or octave for instance) I
usually use a string like this one
start: "\[\e[35m\]"
end: "\[\e[m\]"
In the previous example the \[ and \] around text are missing.

Here is my question, how can add these caracters in lisp (I don't know
lisp at all).

Thank you.