Is it possible to set both global and buffer-local values for the face-remapping-alist
?
The mode-line
requires a global value to effectively change the color. To change the colors of the background and foreground of the default
within the mini-buffer, a local value is needed. Setting a global value cancels out the buffer-local value, and visa versa.
I am trying to avoid using set-face-attribute
and set-face-background
and set-face-foreground
due to the problems discussed in the thread of the following link: How to speed-up a custom mode-line face change function in Emacs Using the face-remapping-alist
avoids those issues.
(defun my-modeline-face-function ()
(cond
((minibufferp)
(with-selected-window (minibuffer-window)
(set (make-local-variable 'face-remapping-alist) '(
(default :background "black" :foreground "yellow")
(minibuffer-prompt :background "black" :foreground "cyan" :weight bold)
(mode-line :height 140 :foreground "gray70" :background "black" :box nil)))))
(t
(with-selected-window (minibuffer-window)
(set (make-local-variable 'face-remapping-alist) '(
(default :background "black" :foreground "grey50")
(minibuffer-prompt :background "black" :foreground "white")
(mode-line :height 140 :foreground "black" :background "gray70" :box nil)))) )))
EDIT (August 5, 2014): Here is the working revision based upon the helpful answer of @phils below:
(defun my-modeline-face-function ()
(cond
((minibufferp)
(with-selected-window (minibuffer-window)
(setq-local face-remapping-alist '(
(default :background "black" :foreground "yellow")
(minibuffer-prompt :background "black" :foreground "cyan" :weight bold) )))
(setq-default face-remapping-alist '(
(mode-line :height 140 :foreground "gray70" :background "black" :box nil))))
(t
(with-selected-window (minibuffer-window)
(setq-local face-remapping-alist '(
(default :background "black" :foreground "grey50")
(minibuffer-prompt :background "black" :foreground "white"))))
(setq-default face-remapping-alist '(
(mode-line :height 140 :foreground "black" :background "gray70" :box nil) )))))