在Emacs中更改文本外观:重叠工作,文本属性不 [英] Changing text appearance in Emacs: overlays work, text properties don't
问题描述
我今天在Emacs中试用了文本属性。如果我将光标放在一条文字上,然后使用 M - :
执行以下代码,该行将以粗体重新显示。
I've been experimenting today with text properties in Emacs. If I position the cursor on a line with some text on it and then execute the following code with M-:
, the line is redisplayed in bold.
(overlay-put
(make-overlay
(line-beginning-position)
(line-end-position))
'face 'bold)
但是,如果我擦除叠加层使用(remove-overlays)
并执行以下代码,没有任何反应(除了nil一词出现在minibuffer中)。
If, however, I wipe out the overlay with (remove-overlays)
and execute the following code, nothing happens (except that the word "nil" appears in the minibuffer).
(put-text-property
(line-beginning-position)
(line-end-position)
'face 'bold)
从我迄今收集的内容中,我期望这两个片段应该产生相同的视觉效果。为什么不这样?
From what I've gleaned so far, I'd expect that these two snippets should produce the same visual results. Why don't they?
推荐答案
当 font-lock-mode
开启, face
属性将被覆盖。
When font-lock-mode
is on, the face
attribute will be overridden. Try font-lock-face
instead:
(put-text-property
(line-beginning-position)
(line-end-position)
'font-lock-face 'bold)
这篇关于在Emacs中更改文本外观:重叠工作,文本属性不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!