views:

239

answers:

2

How can I configure a different background color for the active window in Emacs?

+5  A: 

If by "window" you mean Emacs' definition of windows, i.e., panes, not really.

If by "window" you mean everyone else's conception of windows, which Emacs calls frames, then yes. Here's an example:

(defadvice handle-switch-frame (around switch-frame-set-background)
  (set-background-color "white")
  ad-do-it
  (set-background-color "yellow"))
(ad-activate 'handle-switch-frame)

(defadvice delete-frame (after delete-frame-set-background)
  (set-background-color "yellow"))
(ad-activate 'delete-frame)
Nicholas Riley
And if he wants it per-window, I would just recommend a reverse-video modeline. If you need more of a visual cue than that, open fewer windows.
jrockway
Uh, active modeline, that is.
jrockway
I mean Emacs window. Highlight of mode line is not enough for me. I use large screen, lots of windows are open.. and quite often I've started to edit not the window I wanted to edit. I'll try if reverse-video mode will be some improvement
Medyk
Well, there's always hacking the Emacs source.
Nicholas Riley
A: 

If what you are trying to achieve is to highlight the current buffer/frame, the way I do that is through Highlight-Current-Line. It shows you the line where the cursor is, but a side effect of that is that it also shows you which buffer/frame you are in. You could configure it to highlight the entire buffer, or look into the code to see how they do it.

Singletoned
Yeah, what I meant by "not really" was that you can't highlight a window, just a buffer, because any modifications to the buffer contents will affect every view of the buffer. For me, the modeline color + cursor flashing do fine.
Nicholas Riley
Indeed buffer is better term for that than window. I want to highlight current buffer :)
Medyk