256 colors in emacs on terminal mode in debian

As I mentioned in a previous post, I like using emacs both in graphical mode and text mode, specially because I like calling emacs from within mutt. The problem is I want to use emacsclient, and I also wanted to have different colors in the terminal mode. In my quest for the perfect configuration, i fixed today the problem in Debian to have 256 colors withing emacs in terminal mode.

Archaic terminals offered for some time limited color choices, the best example being the 8 color terminals. But today you can have more, 256 colors being a popular standard. And programs like vim and emacs can make use of that. Emacs supports multiple colors in the graphical mode too, of course.

To know the color palette that your emacs instance supports you can use M-x list-colors-display. I tested that in my graphical mode and, of course, saw lots of colors. In my terminal, only 8… That’s when I had the insight: maybe if I fix that I can choose a single decent color configuration for both modes, and not have to care anymore about having different color modes!… In the meantime I found out about color-theme, which seems to even eases the task of having different themes for the graphical and terminal display, but I haven tested that yet.

To make xterm support 265 colors you need to install some stuff. It seems all kinds of problems used to happen some years ago… One thing you have to so for example is installing the ncurses-term package (I use Debian). Anyway, to find out if your terminal does in fact support 256 colors you can use this perl test script. I used it in my xterm and did see lots of colors, but emacs was still offering me just a few.

That’s when I heard about using TERM=xterm-256color, and liked to hear that because I have just learned about how emacs uses the TERM variable. I tried, and emacs did load, so it was indeed finding an “xterm-256color” to load… But it was still displaying only 8 colors when I tested!

It only worked for me when I found the xterm-256color.el file from somewhere else, and installed it in my /.local/elisp/term/ directory. Then it worked!

So for some reason the file in Debian that implements the xterm-256color that emacs is looking for is broken. But using the file from somewhere else works…

Now I am having trouble with color-themes, because it’s not switching all colors correctly… Let’s see what happens.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s