I want to create font locking for string like:
interface Foo extends B, C, D, E {};
And I can't understand why my regexp rule doesn't work for font locking:
(defvar my-font-lock-keywords
`(
;; Some code is omitted for brevity
;; ...
;; Just for example
(,(rx "interface Foo extends B"
(1+ ?,
(syntax whitespace)
(group (or "A" "B" "C" "D"))))
1 font-lock-type-face)
;; Some code is omitted for brevity
;; ...
))
This test fails:
(ert-deftest my-mode-syntax-table/fontify-extends/3 ()
:tags '(fontification syntax-table)
(test-with-temp-buffer
"interface Foo extends B, C, D, E {}; "
(should (eq (test-face-at 23) 'font-lock-type-face))))
As I can see there is no problem with regexp:
ELISP> (require 'rx)
rx
ELISP> (string-match-p
(rx (1+ ?, (syntax whitespace) (group (or "A" "B" "C" "D"))))
"B, C, D, E")
1 (#o1, #x1, ?\C-a)
Of course I'm managed to succeed for other cases e.g.:
interface Foo {};
My real code is more complicated. I tried to give a simple example to show my problem.
How to correctly make font-lock regexp for the comma-separated lists?
Update: I'm managed to debug regexp (thanks to @phils) via M-x re-builder
so as I said before there is no problem with regexp