【发布时间】:2014-08-06 13:23:35
【问题描述】:
是否可以为 face-remapping-alist 设置全局 和 缓冲区本地值?
mode-line 需要一个全局值才能有效地改变颜色。要更改迷你缓冲区内default 的背景和前景颜色,需要一个本地值。设置全局值会抵消缓冲区局部值,反之亦然。
由于以下链接的线程中讨论的问题,我试图避免使用set-face-attribute 和set-face-background 和set-face-foreground:How to speed-up a custom mode-line face change function in Emacs 使用face-remapping-alist 可以避免这些问题。
(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)))) )))
编辑(2014 年 8 月 5 日):这是基于以下@phils 的有用回答的工作修订:
(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) )))))
【问题讨论】:
-
我没用过,不过好像应该可以。另一种可能性是
let在您的条件下绑定它,我相信这会暂时覆盖全局设置。