【发布时间】:2014-04-02 06:16:00
【问题描述】:
我正在尝试在 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)))
给出相同的行为。
【问题讨论】:
-
看起来您的
testing-font-lock-keywords定义已损坏;再次检查您提供的链接以及C-h vfont-lock-defaults以查看它期望的格式 -
@assem 查看我更新的问题。所以也许这种行为是由于
font-lock-defaults? -
如果你正在编写新的字体锁定关键字,何不试试我的新字体锁定调试器font-lock-studio