Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to know if it is possible to make emacs, when running in a gnu screen or tmux session, use the same colors as when TERM=xterm. In a gnu screen or tmux session, TERM=screen and emacs uses a different set of colors as compared to when TERM=xterm.

For example, when TERM=xterm-256color, the foreground color of font-lock-comment-face is 'Firebrick'. But when TERM=screen-256color, it is set to 'chocolate1'.

For tmux to work properly, the TERM variable must be set to screen or some derivative, so resetting TERM is not an option for me.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The definition of font-lock-comment-face includes many variants for cases of varying color support.

  • The chocolate1 variant is used when there are at least 88 colors available and the “background” is “dark”.
  • The Firebrick variant is used when there are at least 88 colors available and the “background” is “light”.

The difference is caused by some code that gives special meaning to TERM values that start with xterm, rxvt, dtterm, and eterm: it considers them to have a “light” background.

You should be able to customize frame-background-mode* to its light value to always use the “light” color variants.

If your Emacs is not new enough to have its own term/screen.el, then you will also need to adapt one for yourself that makes the appropriate color-adjusting calls. You might use the one from Emacs trunk, or I have a Gist that includes a .emacs.d/lisp/term/screen.el (with some extra bits to recognize the modifier+arrows/Home/End sequences provided by tmux’s xterm-keys option), and the .emacs modification needed to let it automatically load.

Of course, there could still be other bits of code that directly check the TERM value and do something different for screen- and xterm-like values…

* M-x customize-variable frame-background-mode

share|improve this answer

(Wish I could comment...)

It is unclear to me if you have tried running emacs as:

TERM=xterm emacs to force the TERM variable setting for emacs.

What happens when you do that?

share|improve this answer
    
I'm experimenting with that at the moment. I haven't detected any bad things happening just yet. It seems tmux can be configured to emit xterm key sequences (although TERM=xterm is still unsupported). Based on the tmux FAQ, tmux might come to support xterm in the future instead of only screen. –  ALiX Nov 20 '12 at 1:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.