views:

84

answers:

1

I use xterm and set its appearance in ~/.Xdefaults:

XTerm*background:       paleTurquoise
XTerm*foreground:       black

I also use emacs, but set its appearance differently in ~/.emacs:

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

I usually run emacs within the terminal emulator with emacs -nw, rather than creating a separate X window. For some reason, this doesn't work properly for emacs23; instead, emacs retains the pale turquoise background of my xterm window. Looking at what's new in emacs23, I noted that:

** When running in a new enough xterm (newer than version 242), Emacs asks xterm what the background color is and it sets up faces accordingly for a dark background if needed (the current default is to consider the background light).

So it's a feature, not a bug? Anyway, is there some way that I can I tell emacs23 to ignore the xterm background settings when running in console mode, and use the settings in ~/.emacs instead?

I'll also note that:

  • It works fine in emacs23 running in a separate X window (without the -nw option).
  • It worked fine in emacs22; and I'm not really sure whether I need to use emacs23...
  • Running M-x set-background-color within emacs23 -nw has no effect.
  • It's not just xterm: the same problem exists with $TERM=cygwin, for example.

UPDATE: the best answer seems to be to use the -fg and -bg command-line options...

+1  A: 

Setting TERM=xterm-256color is what you need.

Xavier Maillard
Thanks, but that didn't work. I think the problem is how to override a default behavior of emacs23 (that didn't exist in emacs22). When I run `emacs23 -nw`, the display shows colors -- but they're the wrong ones. It adopts the settings from my terminal and doesn't allow me to change them.
Anonymous
what about emacs -nw -fg <a color> -bg <another color> ? Does it work ?
Xavier Maillard
Yes, the command-line arguments seem to do it, thanks! It certainly isn't a pretty solution, but I guess I can set an alias in my `.bashrc` and then try to remember that I this particular configuration can't be set in my `.emacs`.
Anonymous