23

Say I have my Emacs window split into multiple tiles, e.g.:

---------------------------
|            |            |
|            |            |
---------------------------
|                         |
|                         |
---------------------------

When I switch between tiles (aka windows in Emacs) to edit my files (e.g. using C-x o), I can see on which tile I am by visually locating the cursor (point) on the screen and checking the difference in shading in the status bar of each tile:

However, locating the cursor on a large screen is not easy AND the difference in shading on the status bar where the cursor is is almost negligible:

This is what a status bar looks like when the corresponding window is selected:

              Img1

This is what it looks like when the corresponding window is not selected (notice the green is a bit dimmer)

              enter image description here

The above is with the color theme zenburn on GNU Emacs 23.3.1.

My question is: Is there a way to have Emacs more clearly indicate which window/tile/buffer is the one that has the focus?

Singletoned
  • 5,089
  • 3
  • 30
  • 32
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
  • 1
    Near duplicate: http://stackoverflow.com/questions/1516830/custom-background-for-active-window – Oleg Pavliv Feb 25 '12 at 18:59
  • 2
    I choose to highlight the mode-line of current window and set the mode-line of other windows the same background as the theme. – CodyChan Jan 22 '15 at 10:05

2 Answers2

24

Absolutely!

You can change the modeline to highlight the active bar using the following in your .emacs (change colors and style to suit your preferences of course).

(set-face-attribute  'mode-line
                 nil 
                 :foreground "gray80"
                 :background "gray25" 
                 :box '(:line-width 1 :style released-button))
(set-face-attribute  'mode-line-inactive
                 nil 
                 :foreground "gray30"
                 :background MY_BG_COLOR 
                 :box '(:line-width 1 :style released-button))

Since it seems you are using the Zenburn color theme, you can also fix it within there. Just open the file within your color-theme library named zenburn.el (or it might be color-theme-zenburn.el) and search for the following lines:

`(mode-line
  ((,class (:foreground ,zenburn-green+1
                       :background ,zenburn-bg-1
                       :box (:line-width -1 :style released-button)))))
`(mode-line-buffer-id ((,class (:foreground ,zenburn-yellow :weight bold))))
`(mode-line-inactive
  ((,class (:foreground ,zenburn-green-1
                       :background ,zenburn-bg-05
                       :box (:line-width -1 :style released-button)))))

and change the values of the background and foreground colors as you see fit.

N.N.
  • 8,336
  • 12
  • 54
  • 94
Chris McMahan
  • 2,640
  • 1
  • 17
  • 10
  • Thanks! This is pretty good. Is there a way to highlight the current line on the active buffer? It would help a lot to have Emacs do so since it would make it even easier to localize the cursor. I have seen this feature in IDEs and it would be fantastic to have this in Emacs. – Amelio Vazquez-Reina Feb 25 '12 at 21:56
  • 2
    @roseck: `(global-hl-line-mode 1)` – jfs Feb 25 '12 at 22:55
  • 2
    Note that the `global-hl-line-sticky-flag` variable determines whether it highlights only for the active buffer, or for all buffers, but this should be set as you want it by default. `M-x customize-group RET hl-line RET` for more. – phils Feb 26 '12 at 00:51
6

For a quicker solution, you can use the Smart Mode Line plugin for Emacs: a color-coded, fixed width mode line. Works great with the Zenburn theme (I'm using both right now).

It's available in the ELPA, by the way.

Vicky Chijwani
  • 10,191
  • 6
  • 56
  • 79