在Emacs中自定义高亮面:仅更改背景颜色 [英] Customizing highlighting faces in Emacs: Only change the background color
问题描述
hl-line
),以便它只改变背景颜色(并且Emacs使用前景颜色,好像这个词没有突出显示)。 更具体地说,我在探戈黑暗
主题
(custom-set-faces
'(region((t(:inherit nil:backgroundRoyalBlue4 )))
'(highlight((t(:inherit region:backgrounddark olive green)))
'(hl-line((t(:inherit highlight)))
,如下所示,区域突出显示确实尊重前景字体(即只改变背景色):
但突出显示目前的行不会:
为什么?如何获得与 hl-line
相同的效果?
更新:
这似乎是探戈黑暗
主题(内建Emacs主题)的错误。该代码适用于默认主题(加载 emacs -Q
)。我发布了这个官方的错误邮件列表。
我很久以前一直在努力,似乎是一个bug的颜色主题。
然而,我想出了一个解决方法。这对我有用:
(加载主题探戈暗t
(set-face-attribute'突出显示nil:foreground'unspecified)
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.
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)
这篇关于在Emacs中自定义高亮面:仅更改背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!