Subject: Re: bug#11883: shell-mode doesn't colorize the prompt

From: Stefan Monnier <[email-masked]>
Date: Fri, 09 Nov 2012 14:05:47 -0500

severity 11883 wishlist
thanks

The behavior you see is due to the following:
- the prompt is highlighted with an overlay that uses
  a comint-highlight-prompt face.
- "the prompt" is determined dynamically as "the last
  non-line-terminated output of the process".
- the ansi-color escapes used to be applied using overlays but are now
  applied using text-properties.

When you use ansi escapes to color the prompt, you clearly have
a conflict with the comint-highlight-prompt face that is to be used for
the prompt.

If you do C-u C-x = on the "t" of "test" in your test case, you'll see
that it does have a `font-lock-face' text-property that stipulates the
use of a red foreground, but the overlay takes precedence.

Emacs-23's use of overlays for ansi colors worked better in this
respect, because those overlays took precedence by virtue of
being smaller.

You can by revert to the Emacs-23 behavior with the following hack:

   (add-hook 'shell-mode-hook
             (lambda ()
               (kill-local-variable 'ansi-color-apply-face-function)))

But the reason Emacs-24 stopped using overlays is because they can slow
things down significantly if you have many such colored chunks and your
shell buffer grows large.

        Stefan

PS: Yes, that's an implementation defect in Emacs which should use more
efficient algorithms for its overlays.  I have a pretty good idea how to
fix this, so if someone's interested, I'd be happy to help them write
a patch for it.