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

匿名 (未验证) 提交于 2019-12-03 02:50:02

问题:

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:

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

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?

回答1:

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.



回答2:

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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!