If I define font lock keywords using existing faces, I can highlight the string 'foo'.
(defconst my-mode-font-lock-keywords
(list
(cons "foo" 'font-lock-type-face)))
(define-derived-mode my-mode fundamental-mode "My mode"
"A demo mode."
(set (make-local-variable 'font-lock-defaults) '(my-mode-font-lock-keywords)))
This highlights correctly:
However, if I define my own face:
(defface my-mode-foo-face
'((t :inherit font-lock-preprocessor-face))
"Face for highlighting 'foo'.")
(defconst my-mode-font-lock-keywords
(list
(cons "foo" 'my-mode-foo-face)))
(define-derived-mode my-mode fundamental-mode "My mode"
"A demo mode."
(set (make-local-variable 'font-lock-defaults) '(my-mode-font-lock-keywords)))
No highlighting is applied:
How can I use font-lock-defaults
with a face I've defined myself?