I frequently click on another application when I'm doing something in the minibuffer, and then I've forgotten I was in the minibuffer when I come back to emacs. I would like to highlight the minibuffer when it's active, but I'm in another emacs window. I have a solution that almost works.
(let ((bufs '(("0" . nil) ("1" . nil)))) (defun tg/minibuf-conspicuous-when-active-hook () (dolist (buf bufs) (if (and (not (minibufferp)) (active-minibuffer-window)) (with-current-buffer (get-buffer (concat " *Minibuf-" (car buf) "*")) ;;(message "1-- %s %s" (car buf) bufs) (setcdr buf (face-remap-add-relative 'default :background "#355E3B"))) (when (cdr buf) (with-current-buffer (get-buffer (concat " *Minibuf-" (car buf) "*")) ;;(message "2-- %s %s" (car buf) bufs) (face-remap-remove-relative (cdr buf)))))))) (add-hook 'buffer-list-update-hook 'tg/minibuf-conspicuous-when-active-hook) (add-hook 'window-configuration-change-hook 'tg/minibuf-conspicuous-when-active-hook) The reason I need both buffer-list-update-hook and window-configuration-change-hook is because there are some cases where buffer-list-update-hook is never called. This works if I move to another window within emacs and then back to the minibuffer. However, if I click on another application and then back, the minibuffer gets stuck on the new color I've set until I cancel. I can see from the debug messages that it is calling face-remap-remove-relative, but for some reason, it doesn't seem to work. In fact, I can replace that line with the following, and it works as expected.
(face-remap-add-relative 'default :background "#000000") Is there something I need to do to make it apply face-remap-remove-relative? Is there a simpler way to do this?

