Dim Unfocused Minibuffer Prompts
I can easily tell if an Emacs buffer is focused by looking at the buffer’s mode-line. On the other hand, the only indicator that the minibuffer is focused or not is the cursor, and that’s pretty easy to miss.
I wanted to avoid making any intrusive changes to the minibuffer, so I decided to style the prompt based on whether the minibuffer is focused. When not focused, I remap the minibuffer prompt face to shadow
.
Focused:
Unfocused:
The code is pretty simple:
(defvar-local steb/focused-minibuffer-face-remap nil
"Face-remapping for a dimmed-minibuffer prompt.")
(defun steb/focused-minibuffer-update (w)
(when (eq w (minibuffer-window))
(when steb/focused-minibuffer-face-remap
(face-remap-remove-relative steb/focused-minibuffer-face-remap)
(setq steb/focused-minibuffer-face-remap nil))
(unless (eq w (selected-window))
(with-selected-window (minibuffer-window)
(setq steb/focused-minibuffer-face-remap
(face-remap-add-relative 'minibuffer-prompt 'shadow))))))
(defun steb/minibuffer-setup-focus-indicator ()
(add-hook 'window-state-change-functions 'steb/focused-minibuffer-update nil t))
(add-hook 'minibuffer-setup-hook #'steb/minibuffer-setup-focus-indicator)
My approach was heavily inspired by this Emacs Stack Exchange answer, but I tried to simplify the implementation and make the styling a bit less intrusive.