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
2009-10-04 16:54:45
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
2009-10-04 20:38:11
Uh, active modeline, that is.
jrockway
2009-10-04 20:38:58
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
2010-06-24 11:59:48
Well, there's always hacking the Emacs source.
Nicholas Riley
2010-06-24 13:46:02
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
2009-10-05 14:32:52
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
2009-10-05 18:03:50
Indeed buffer is better term for that than window. I want to highlight current buffer :)
Medyk
2010-06-24 12:03:21