Emacs custom background color by mode

后端 未结 3 1190
予麋鹿
予麋鹿 2021-01-12 17:06

I use emacs to edit a number of file types, and would like an easy visual queue to tell .c files from .vhd or .py files, for instance. How can I add a custom background col

3条回答
  •  梦谈多话
    2021-01-12 17:17

    For posterity, as this thread is 4 years old, it is now possible in Emacs 24.4+ to change faces on a buffer local level. Simply define a face and use (face-remap-add-relative) to swap out whatever face you want with it.

    Define a defface:

    (defface my-special-face '((t :background "aqua")))
    

    Then add a hook to the mode of your choice:

    (add-hook 'python-mode-hook
              (lambda ()
                (face-remap-add-relative 'default 'my-special-face)))
    

提交回复
热议问题