To better distinguish between focused window and rest that are not I would love to change this window's fringe color. Discovering customize with fringe keyword I found only how to change its bg color without ability to set different colors for active and not active ones. Is it possible at all? Thx.
Since you want "To better distinguish between focused window", you can use other ways to do that instead of just changing the active window's fringe color.
I combine three ways to better distinguish between active and inactive windows.
- Use different colors of mode line for the active and inactive windows.
- Highlight the current line where the point is in active window.
- Use different background colors for the active and inactive windows.
Note that all the chosen colors mentioned above should be working well with your Emacs theme.
Here are all the three ways:
Use different colors of mode line for the active and inactive windows:
(custom-set-faces '(mode-line ((t (:background "dim gray" :foreground "white")))) '(mode-line-inactive ((t (:background nil)))))
Highlight the current line where the point is in active window:
(global-hl-line-mode 1) ;; underline the current line (set-face-attribute hl-line-face nil :underline t)
Use different background colors for the active and inactive windows:
(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)
You can change the colors in the code snippets to work well with your Emacs theme.
This is the final screenshot:
And there is another function you can manually use to flash the active window:
(global-set-key (kbd "<f12>") 'flash-active-buffer) (make-face 'flash-active-buffer-face) (set-face-attribute 'flash-active-buffer-face nil :background "blue" :foreground nil) (defun flash-active-buffer () (interactive) (run-at-time "100 millisec" nil (lambda (remap-cookie) (face-remap-remove-relative remap-cookie)) (face-remap-add-relative 'default 'flash-active-buffer-face)))
You can change the keybinding in the code snippet, when you want to show the active window, hit the key, the active window will be blue, after you move you point, the color will be gone.
I had the same problem. I resorted to using smart line mode and customize it so I get colours that are very distinctive in the active window. Here is a sample frame. The active window is the one with black mode line with gold letters.
Make sure you require smart-mode-line before using this code. I recommend you customize it to the colours you need:
(deftheme smart-mode-line-dmg "dmg theme for smart-mode-line.") (custom-theme-set-faces 'smart-mode-line-dmg ; '(mode-line-inactive ((t :inverse-video nil))) ; '(mode-line ((t :inverse-video nil))) '(mode-line ((t :foreground "grey70" :background "black" :inverse-video nil))) '(mode-line-inactive ((t :foreground "black" :background "white" :inverse-video nil))) '(sml/global ((t :inherit font-lock-preprocessor-face))) '(sml/filename ((t :inherit sml/global :foreground "gold" :weight bold))) '(sml/prefix ((t :inherit (font-lock-variable-name-face sml/global)))) '(sml/read-only ((t :inherit (font-lock-type-face sml/not-modified)))) '(sml/modes ((t :foreground nil :inherit sml/filename :weight normal)))) (sml/setup)
You can try doing something like the following to highlight the currently selected window. Beware that this doesn't work if the buffers in multiple windows are the same. This dims all other windows except the selected one.
(defvar dim-window-face '((t (:background "grey40"))) "Face for a dimmed window in the current frame.") (defvar current-window-face '((t (:background "black"))) "Face for a dimmed window in the current frame.") (defvar window->overlay (make-hash-table) "A hash table of window to dimmed overlay.") (defun dim-windows () "Dim all windows except the `selected-window' in current frame." (interactive) (walk-windows (lambda (w) ;; Delete existing overlay on window W (when-let ((ol (gethash w window->overlay))) (delete-overlay ol)) (let ((ol (make-overlay (window-start w) (window-end w) (window-buffer w)))) (overlay-put ol 'face (if (eql (selected-window) w) current-window-face dim-window-face)) (puthash w ol window->overlay)))))