我正在为 emacs 开发 pamcrash-mode.el 以简化我的生活。通过使用突出显示单个短语可以正常工作
(defvar pamcrash-keywords_red
'("NAME" "SENSOR" "DATACHECK" "UNIT" "TITLE" "TIME" "INCLU"))
(defvar pamcrash-docu
'("Autor" "Datum" "Basis" "VARIANTE" "BASISVAR." "DATUM"
"BEARBEITER" "BESCHREIBUNG" "HISTORY" "VERSION" "CAEBENCH" ))
(defvar pamcrash-font-lock-defaults
`((
( ,(regexp-opt pamcrash-keywords_red 'words) . font-lock-warning-face)
( ,(regexp-opt pamcrash-docu 'words) . font-lock-comment-face)
)))
(define-derived-mode pamcrash-mode fundamental-mode "PAM-Crash mode"
(setq font-lock-defaults pamcrash-font-lock-defaults) )
(provide 'pamcrash-mode)
但是 Pam-Crash 文件中的某些行如下所示:
NAME This is a string including the keyword SENSOR
NAME This is a string including the keyword Autor
SENSOR/Autor 通常是关键字,必须突出显示,但这里有字符串的一部分,不应该。如何在 NAME 之后停用关键字的颜色对比?