I'm trying to create my own major mode. So far I've been able to set all the syntax highlighting that I need, but I'm struggling with this one.
Basically I need to color any word before an equal sign. Like this:
< action name="set_button">
Like the face nxml-attribute-local-name in nxml-mode.
To do this I'm using a regular expression to find that word and then set font-lock-variable-name-face.
I've tried the following regular expressions, but they didn't work. I don't know if it's because I'm not escaping them correctly or because emacs doesn't support them.
("\\(\w+\\)\\(?=\s*=\\)" . font-lock-variable-name-face)
("\b\\(\w+\\)\b=" . font-lock-variable-name-face)
There is nothing wrong with the elisp code. When I try a more simple regex it works.
Any ideas?
Thanks
"\\w+="
would have worked (but it would also capture the equals sign. Your first regexp doesn't work because Emacs regexp doesn't implement non-capturing groups, other than that, it's fine.