Reputation: 13457
Within the same frame and with an active minibuffer, can anyone think of a way to have switch to other-window
behave similar to a minibuffer-exit-hook
(without completely exiting the minibuffer)?
Essentially, I'd like to have the main windows show an inactive modeline color when focus is in the minibuffer, and then update the modline to active (for a window that has focus) when I move from the semi-active minibuffer to another window using other-window
.
For example, there are two windows open in the same frame (side by side) -- Window # 1 are my notes -- Window # 2 is a Big Brother Database display of a record that I want to modify. So I open the minibuffer to input my record modification and then switch back and forth between my notes in Window # 1 and the minibuffer to copy and paste the relevant portions. When using other-window
to jump between the three areas, it is still difficult to know whether focus is in the minibuffer or another window.
Window # 1 (notes) | Window # 2 (bbdb record display)
|
___________________________|_____________________________________
Name: lawlist . . .
(defun enter-minibuffer-setup ()
(set-face-attribute 'mode-line nil
:height 160 :foreground "gray70" :background "black")
(set (make-local-variable 'face-remapping-alist)
'((default :background "gray10" :foreground "yellow"))))
(defun exit-minibuffer-setup ()
(set-face-attribute 'mode-line nil
:height 160 :foreground "black" :background "gray70"))
(add-hook 'minibuffer-setup-hook 'enter-minibuffer-setup)
(add-hook 'minibuffer-exit-hook 'exit-minibuffer-setup)
Upvotes: 2
Views: 883
Reputation: 13457
Updated draft -- borrowing (minibufferp)
from @Carl Groner
(defun enter-minibuffer-setup ()
(set-face-attribute 'mode-line nil
:height 160 :foreground "gray70" :background "black")
(set (make-local-variable 'face-remapping-alist)
'((default :background "black" :foreground "yellow")))
(set-face-attribute 'minibuffer-prompt nil
:background "black" :foreground "cyan"))
(defun exit-minibuffer-setup ()
(set-face-attribute 'mode-line nil
:height 160 :foreground "black" :background "gray70")
(set-face-attribute 'minibuffer-prompt nil
:background "black" :foreground "cyan"))
(add-hook 'minibuffer-setup-hook 'enter-minibuffer-setup)
(add-hook 'minibuffer-exit-hook 'exit-minibuffer-setup)
(defun lawlist-minibuffer-conditions ()
(cond
((minibufferp)
(set-face-attribute 'mode-line nil
:height 160 :foreground "gray70" :background "black")
(set-face-attribute 'minibuffer-prompt nil
:background "black" :foreground "cyan"))
(t
(set-face-attribute 'mode-line nil
:height 160 :foreground "black" :background "gray70")
(set-face-attribute 'minibuffer-prompt nil
:background "black" :foreground "gray70")) ))
(defun lawlist-forward-window ()
(interactive)
(other-window 1)
(lawlist-minibuffer-conditions))
(defun lawlist-backward-window ()
(interactive)
(other-window -1)
(lawlist-minibuffer-conditions))
Upvotes: 0
Reputation: 4359
One option would be to "advise" the other-window
function to execute some form when switching to the minibuffer.
For example, the following code will turn the minibuffer prompt green when you cycle back to it using other-window
, and if you land on a non minibuffer window it turns the prompt grey:
(defadvice other-window (after adv-other-window-minibuffer
(COUNT &optional ALL-FRAMES))
"Make minibuffer prompt green when switched to"
(if (minibufferp)
(set-face-attribute 'minibuffer-prompt nil
:foreground "green" :background "black")
(set-face-attribute 'minibuffer-prompt nil
:foreground "dark grey" :background "black")))
(ad-activate 'other-window)
Of course you are not limited to just setting the minibuffer prompt, but it's not clear to me exactly what effect your are trying to achieve.
Upvotes: 1