我想看看是否有办法在主模式下更改模式链接前景色和背景色,
我正在考虑在
中添加逻辑(add-hook 'after-change-major-mode-hook
但是,我没有所有emacs lisp经验来做出这样的改变。这是逻辑:
switch major-mode:
case "emacs-lisp-mode":
(set-face-foreground 'mode-line "ivory")
(set-face-background 'mode-line "DarkOrange2")
case "ruby-mode":
(set-face-foreground 'mode-line "white")
(set-face-background 'mode-line "red")
...
default:
(set-face-foreground 'mode-line "black")
(set-face-background 'mode-line "white")
end switch
非常感谢提前!
答案 0 :(得分:9)
您可能需要以下内容:
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(face-remap-add-relative
'mode-line '((:foreground "ivory" :background "DarkOrange2") mode-line))))
您可能还想对mode-line-inactive
脸部使用脸部重新映射。
答案 1 :(得分:3)
(add-hook 'after-change-major-mode-hook 'my-set-mode-line-colors)
(defvar my-mode-line-colors
'((emacs-lisp-mode :foreground "ivory" :background "DarkOrange2")
(ruby-mode :foreground "white" :background "red")))
(defun my-set-mode-line-colors ()
(face-remap-add-relative
'mode-line (list (or (cdr (assq major-mode my-mode-line-colors))
'(:foreground "black" :background "white"))
'mode-line)))
或者,你可以按照Stefan的建议,从模式特定的钩子中做到这一点。