Is there an easy way to change the background color of the active window to easily distinguish which window has the input?
I know of hiwin-mode (https://github.com/masutaka/hiwin-mode). But this mode has problems playing nicely with helm.
I also know of color-theme-buffer-local (https://github.com/vic/color-theme-buffer-local) and I am wondering if it can be customized to do what I want.
You might want to take a look at auto-dim-other-buffers.el
, available from MELPA.
The
auto-dim-other-buffers-mode
is a global minor mode which makes non-current buffer less prominent making it more apparent which window has a focus.The preferred way to install the mode is by installing a package from MELPA:
M-x package-install RET auto-dim-other-buffers RET
Once installed, the mode can be turned on (globally) with:
M-x auto-dim-other-buffers-mode RET
To make the mode enabled every time Emacs starts, add the following to Emacs initialisation file (
~/.emacs
or~/.emacs.d/init.el
):(add-hook 'after-init-hook (lambda () (when (fboundp 'auto-dim-other-buffers-mode) (auto-dim-other-buffers-mode t))))
To configure how dimmed buffers look like, customise
auto-dim-other-buffers-face
. This can be accomplished by:M-x customize-face RET auto-dim-other-buffers-face RET
The
auto-dim-other-buffers-mode
is a global minor mode which makes non-current buffer less prominent making it more apparent which window has a focus.
For a given active window, all other windows that does not show the same buffer will be set to a custom background. I.e., active window and other windows showing the same buffer will have a background color that differs from the rest of the windows. I believe this last part is the specific behaviour you are looking for, based on your comment to the accepted answer.
"Thank you very much. This is very close to what I want. Except for the fact that having two windows opening the same buffer cause both windows to be marked as 'inactive'. It's not super important, but is there an easy way to resolve this?"
(defun highlight-selected-window ()
"Highlight selected window with a different background color."
(walk-windows (lambda (w)
(unless (eq w (selected-window))
(with-current-buffer (window-buffer w)
(buffer-face-set '(:background "#111"))))))
(buffer-face-set 'default))
(add-hook 'buffer-list-update-hook 'highlight-selected-window)
Change the background color ("#111") to suit your taste.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With