Change Emacs Mode-Line color based on major-mode

旧城冷巷雨未停 提交于 2019-12-05 06:39:35

You probably want something like:

(add-hook 'emacs-lisp-mode-hook
          (lambda ()
            (face-remap-add-relative
             'mode-line '((:foreground "ivory" :background "DarkOrange2") mode-line))))

You might want to use face-remap for the mode-line-inactive face as well.

"The logic" you are talking about is something like this:

(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)))

Alternatively, you can do that from mode-specific hooks, as suggested by Stefan.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!