I'm trying to write a small new mode for some input files to a specific computational physics program. I'm doing it the define-derived-mode
way, and was specifying the syntax highlighting by setting the font-lock-defaults
variable, when I realized I needed a regex that does "match any lone words between a line start and an equals sign, not including the equals sign."
This is relatively straightforward with extended regex; I found a quite popular SO answer that gave a short solution in terms of a zero-width assertion. However, I don't see any extended regex support in the manual.
Is there a way to do this with Emacs' regex? If not, is there a way to do it with rx (with which I'm an absolue novice)? Failing that, how do packages like cc-mode which need to do something similar to identify different parts of e.g. a variable declaration in their syntax highlighting do this?
rx
is excellent, but its purpose is to compile structured forms into regexp strings -- there isn't a separate regexp engine involved. Everything you can express inrx
can, by definition, also be expressed in the normal string regexp syntax.