I am working on Solaris 9 and using the emacs editor version 21.4. The problem is that when I use the emacs -nw command and turn the font-lock-mode on, I don't get the syntax highlighting by color like in the XWindow mode. The syntax highlighting is only done by bolding or by background coloring. The list-colors-display command also gives a blank window. I know that the terminal supports colors because when I use the ls --color command, the directories and executables are displayed in blue and green. Any idea on how I can get colors for emacs in the nw mode?

Dani AI

Generated

As found, the underlying cause is the terminal description that programs see. Emacs running in a text (no-window) tty uses the terminal/terminfo entry named by $TERM to decide whether color faces are available; if that entry does not advertise color capability Emacs will fall back to bold or reverse-video. That also explains why a shell utility can still show colored output even when Emacs does not: some tools emit raw ANSI escapes, while Emacs looks up capabilities from the terminfo/termcap database.

Quick diagnostics and fixes you can try now:

  • Ask the terminal how many colors it advertises (for example with tput colors).
  • Inside Emacs evaluate (display-color-p) to see whether Emacs thinks colors are available.
  • If the terminal reports colors but Emacs does not, make sure the $TERM value really matches your emulator and that the host has a matching terminfo entry that lists color support. If you are connecting to another machine (SSH), ensure that machine contains the same terminfo entry. After changing TERM or installing a terminfo file, restart Emacs.

Caveats: changing $TERM to force colors can break other programs if the entry does not accurately describe the emulator, so prefer installing or using a correct terminfo entry for your terminal. On older systems you may need to add the appropriate terminfo files or use a newer terminal/terminfo package for fuller (e.g., 256-color) support. Thanks to for steering the discussion toward the terminfo side of things; ’s outcome is exactly the expected result when the terminfo entry lacked color capability.

Recommended Answers

All 2 Replies

Well, I haven't used emacs enough to know what I'm doing in regards to syntax coloring... :rolleyes:

I found a few links though:

To run emacs in text mode with syntax coloring

host:~> setenv TERMINFO /home/user/.terminfo
host:~> infocmp
host:~> emacs -nw
global-font-lock-mode
xterm-mouse-mode

I also found this mailing list where the user seemed to have the same problem you experience right now. Perhaps try some of the suggested tips.
http://www.tutorials-blog.com/emacs/emacs-colors-73095/

Thanks for the links. I changed my TERM variable from xterm to xtermc and that did the trick. setenv TERM xtermc emacs -nw

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.