Customizing highlighting faces in Emacs: Only change the background color

感情迁移 提交于 2019-12-06 02:50:52

问题


Is there any way to define a face in Emacs (e.g. highlight such as hl-line) so that it only changes the background color (and have Emacs use the foreground color as if the word was not highlighted).

More specifically, I tried the following on the tango-dark theme

(custom-set-faces
 '(region ((t (:inherit nil :background "RoyalBlue4"))))
 '(highlight ((t (:inherit region :background "dark olive green"))))
 '(hl-line ((t (:inherit highlight)))))

and, as can be seen below, region highlighting does respect the foreground font (i.e. it only changes the background color):

                     

but the highlighting of the current line does't:

                       

Why? and how can I get the same effect with hl-line?

Update:

This seems to a bug in the tango-dark theme (a builtin theme of Emacs). The code works well with the default theme (which loads with emacs -Q). I posted this on the official bugs mailing list.


回答1:


I struggled with this some time ago, and it seems to be a bug of the color theme.

I've come up with a workaround, however. This works for me:

(load-theme 'tango-dark t)
(set-face-attribute 'highlight nil :foreground 'unspecified)


来源:https://stackoverflow.com/questions/15733873/customizing-highlighting-faces-in-emacs-only-change-the-background-color

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