我正在尝试在 Emacs 中设置一个主要模式,我想在其中突出显示某些关键字。使用此页面中的模板:http: //ergoemacs.org/emacs/elisp_syntax_coloring.html我试过:
(setq testing-font-lock-keywords
`((font-lock-keyword-face)
))
(define-derived-mode testing-mode fundamental-mode
"testing file mode"
"Major mode for editing test files"
(setq font-lock-defaults '(testing-font-lock-keywords))
(setq mode-name "testing")
)
(provide 'testing-mode)
如果我在一个简单的测试文件上使用这种模式,并且键入"hello"
的文本hello
用不同的颜色标记。也就是说,双引号内的任何文本都会突出显示。为什么会这样?
我认为这与变量有关font-lock-keyword-face
。但是,如果我输入C-h v并font-lock-keyword-face
显示:
font-lock-keyword-face is a variable defined in `font-lock.el'.
Its value is font-lock-keyword-face
更新
似乎它与font-lock-keyword-face
无论如何都无关,因为定义testing-font-lock-keywords
如下:
(setq test-keywords '("TEST"))
(setq testing-font-lock-keywords
`((,test-keywords)))
给出相同的行为。