I'm interested in making a major mode to display PGN files nicely. I'm trying to create my own faces since the defaults don't seem super-appropriate.
My mode definition looks like this:
(defface my-r-face `((t (:foreground "red"))) "Red highlight")
(setq pgn-highlights
'(("Pi\\|Infinity" . font-lock-constant-face)
("Sin\\|Cos" . font-lock-string-face)
("[0-9]+\\." . font-lock-keyword-face)
;; ("%.*" . my-r-face) ;; This doesn't show up (the relevant text appears just like the default text
("%.*" . font-lock-comment-face) ;; works great - relevant text looks like the comment face
))
(define-derived-mode pgn-mode fundamental-mode "mymath"
"major mode for editing mymath language code."
(setq font-lock-defaults '(pgn-highlights)))
A typical file that I'd like to use this on is:
[Event "?"]
[Site "?"]
[Date "2019.6.3"]
[Round "?"]
[White "Mike"]
[Black "Mikey"]
[Result "*"]
[WhiteELO "?"]
[BlackELO "?"]
%Created by Caissa's Web PGN Editor
1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. O-O Nf6 5. d3 d6 6. Nc3 a6 7. a3 Be6 8.
Bxe6 fxe6 9. h3 O-O 10. Be3 Ba7 11. Ra2 Qe8 12. Qc1 Nh5 13. Qd2 Nf4 14. g3
Nxh3+ 15. Kg2 Qh5 16. Rh1 Qxf3+ 17. Kh2 Nxf2 18. Rf1 Qh5+ 19. Kg2 Qf3+ 20.
Kg1 Qh1#
The issue is the line with the comment (%Created by...
). If I use the built-in font-lock-comment-face
then everything is highlighted nicely and the comment looks like the normal comment. But if I change it to use my-r-face
then the comment is not highlighted, and instead appears be be the default font face.
What am I doing wrong here?