我在Emacs中定义了一个新面孔,但是颜色没有效果。下面是~/.emacs中的face和模式定义
(defface sml-highlight-operator-face
'((t (:foreground "red")))
"SML operator highlighting"
:group 'basic-faces)
(defvar sml-font-lock-keywords
((,(regexp-opt '("fun" "fn" "let" "val" "datatype" "type" "case" "of" "end" "structure" "struct" "signature" "sig"))
(0 font-lock-keyword-face))
("[][=|><-+;,{}():]" (0 sml-highlight-operator-face))))
;;;###autoload
(define-derived-mode sml-mode prog-mode "SML"
"SML major mode."
(set (make-local-variable 'comment-start) "(* ")
(set (make-local-variable 'comment-end) " *)")
(set (make-local-variable 'font-lock-defaults)
'(sml-font-lock-keywords)))但是,当我使用font-lock-builtin-face而不是sml-highlight-operator-face时,这些字符会被高亮显示(尽管我不想要颜色)。我做错什么了?
发布于 2016-02-25 18:41:03
字体锁定关键字中的元素(0 sml-highlight-operator-face)没有说“使用face高亮-操作符- face for sub 0”,而是“使用表达式sml-highlight-operator-face的结果作为表示进行子匹配0”。
你需要使用(0 'sml-highlight-operator-face)。
顺便说一句,现在的惯例是不对面孔使用-face后缀(当然,这样的后缀仍然用于持有人脸的变量),因此我们还没有费心将font-lock-foo-face faces重命名为font-lock-foo (尽管这将极大地帮助您看到这样的混乱:许多字体锁定规则都说它指的是font-lock-foo-face faces,而它指的是font-lock-foo-face变量(其值保存了font-lock-foo-face face)。
https://stackoverflow.com/questions/35635201
复制相似问题