简体   繁体   中英

Emacs/xterm color annoyance on Linux

I'm using emacs in a console window both on my local Linux box and on the login node of a remote cluster. I use emacs regularly, and I've got the foreground color set to white in my.emacs file like so:

(set-foreground-color "white")
(set-background-color "black")

However, when I run emacs, the foreground isn't white; it's grey and very hard to read. On my Mac, emacs in a console window with the same settings shows up as proper white. But on both linux boxes, in konsole and xterm, it's grey.

In case it matters, I've got TERM set to xterm-color, the desktop is running RHEL 5, and the cluster node is running RHEL 4 (CentOS).

Is this some default with how Linux sets up terminal colors? How do I get white to be white?

Note: this is with console emacs, not emacs under X. That's emacs -nw if you have DISPLAY set.

The color brightwhite looks ok on my Emacs (which is running under a terminal, not X). On RHEL5 I have my TERM environment variable set to xterm-256color . If it's working correctly, you should be able to run these scripts and see 256-color output. Under Emacs, you should see a reasonably smooth color ramp (no obviously duplicated colors) when you do Mx list-colors-display . If not, you are probably missing the right termcap entry (try installing the libtermcap-devel package, I think).

If I change TERM to xterm-color , then brightwhite comes out a bit gray in the output of list-colors-display .

I'm not sure about RHEL4.

What about:

(set-foreground-color "brightwhite")

In response to comment:

Within emacs, run Mx list-colors-display which should show you all of the colors that emacs thinks are available with your terminal.

What if you just used reverse-video for the console version is that good enough?

$ emacs -nw -rv

I also found that I had weird colors in terminal mode and finally traced it down to a font face customization. I had something like this:

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "#000a00" :foreground "#ffffed" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal :foundry "unknown" :family "Droid Sans Mono")))))

I removed the foreground and background properties and everything started looking hunky-dory.

Looks like you're only setting the foreground color.

(set-foreground-color "white")
(set-foreground-color "black")

I'm sure you meant set-background-color on the latter.

I can confirm this when running Emacs as:

$ emacs -nw -bg black -fg white

too.

I did some experiments, and you can set console colors in emacs, but you are limited to this palette:

black                    blue                                         
cyan                     green                                        
magenta                  red                                          
white                    yellow    

The white that you get is somewhat grayed out; full bright white is reserved for bold text. So if you run

M-x facemenu-set-bold

you will get bold (bright white) text for later insertions.

I had no luck trying to force the default face to bold. (I don't really understand how faces work in emacs.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM