14

I'm using emacs 24 on OS X and have the strange problem that I'm unable to see any color codes. Emacs seems to just ignore them. My motivation is to see colored output from cmake, llvm and the googletest framework for a C++ project. I'd like to see the colors in compile mode, however it would probably suffice to fix the display for comint or shell modes.

My problem differs from many others in the fact that I can neither see the raw ansi color sequences nor the colors they should produce. It seems that the codes are just stripped away from the output, but I can't find out where.

ANSI codes not rendered correctly

I tried out the obvious things like

  • requiring 'ansi-color
  • turning ansi-color-for-comint-mode on
  • unsuccessfully trying to produce any ansi-colored output in either shell, eshell, multi-term, ansi-term
  • setting my TERM to various settings, including xterm, xterm-color, xterm-256color

all to no avail.

Edit:

My emacs configuration is divided into my personal settings and a fork of emacs prelude in which I modified some minor settings, mainly adding packages

jupp0r
  • 4,502
  • 1
  • 27
  • 34
  • There was a [similar question](http://stackoverflow.com/questions/3072648/cucumbers-ansi-colors-messing-up-emacs-compilation-buffer) – syohex Feb 12 '12 at 04:01
  • 1
    @syohex: No, it's covered by the "this is different from" clause in the question! – tripleee Feb 12 '12 at 06:50
  • Looks to me from your screenshot like the output from the `echo` *is* colored, probably by the regular `compile-mode` highlighting. – tripleee Feb 12 '12 at 06:53
  • The last line is colored as part of compile-mode's regular highlighting, but it's not the blue/bold combination that I would expect from the ansi codes. – jupp0r Feb 12 '12 at 07:56
  • Have you tried to start emacs without your configuration (e.g. start it as `emacs -q`) to see if you get colors? – N.N. Feb 16 '12 at 16:28
  • Ok, I tried it. This now yields the raw escape color codes, and using the fix from the linked question, I am now able to see the color codes. Of course I'd like to keep my config :) I suspect that my problem might be font-lock related, any Idea on how to proceed further? I'm using emacs-prelude, can some theme settings strip away both the escape sequences and the colors? – jupp0r Feb 16 '12 at 18:29
  • 3
    I'm the author of Emacs Prelude and there are none settings there that would strip the colors. I've just tried both shell-mode and ansi-term and the output there is colored nicely. I'll investigate further. – Bozhidar Batsov Feb 17 '12 at 09:55
  • Since you only see this problem when you enable your configuration, I think you should post that configuration as part of your question. – ruakh Feb 20 '12 at 21:50
  • @ruakh : I updated my post, thanks for looking into this. – jupp0r Feb 20 '12 at 23:54
  • What do you have in `/usr/local/bin` .. Could there be anything in there that overrides the shell you expect? Try to load the ansi color setting as last thing in you dot emacs. `(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)` – sebs Feb 21 '12 at 00:13
  • `/usr/local/bin` contains a lot of links to programs installed with homebrew, but no zsh (my shell). The output should not depend on the shell anyway, because the color codes are stripped away from all command outputs, even thase that do not involve a shell. I added the lines at the end of my config, unfortunately everything stays the same. – jupp0r Feb 21 '12 at 00:21
  • It seems you've localized the problem to jupp.el or your fork of prelude. I'd move jupp.el and see if the problem goes away. If so, then start commenting sections out to see what fixes the problem. (Apologies if you've already tried this) – Vinod Kurup Feb 24 '12 at 01:33
  • the problem is not in jupp.el, I'm checking my prelude fork ... – jupp0r Feb 28 '12 at 12:03

2 Answers2

3

So it turned out that the problem was caused by zenburn-theme 1.2. There was a bug there with the ansi-color-names-vector that's fixed in version 1.3 (released just now). If you're experiencing a similar problem make sure you upgrade your version of zenburn.

Bozhidar Batsov
  • 55,802
  • 13
  • 100
  • 117
2

I can definitely say it's working fine for me with just (ansi-color-for-comint-mode-on). FWIW you can browse my emacs config, but it's fairly big :)

https://github.com/aufflick/emacs.d

Mark
  • 1,304
  • 12
  • 22