Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asking Emacs to highlight more clearly which window (pane) has the focus (cursor)

Tags:

emacs

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?

like image 224
Amelio Vazquez-Reina Avatar asked Feb 25 '12 18:02

Amelio Vazquez-Reina


2 Answers

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.

like image 90
Chris McMahan Avatar answered Oct 23 '22 12:10

Chris McMahan


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.

like image 44
Vicky Chijwani Avatar answered Oct 23 '22 13:10

Vicky Chijwani