I think it's the following font-lock keyword that is broken:
(1 font-lock-variable-name-face prepend))
The regexp match constructs like $(NAME). However, in an attempt not to match $$(NAME), it tries to match any other character besides $ before $(NAME). When $(NAME) is at the beginning of a line, at the beginning of the search, this fails.
The reason why the buffer originally is colored correctly is that the [^$] match the newline of the previous line. However, after an edit, font-lock only highlights the edited parts. When the search resumes on a line starting with $(NAME), the regexp no longer match.
You can verify this in Font-Lock Studio (https://github.com/Lindydancer/font-lock-studio
) by first single-stepping (SPC) the rule in the whole buffer, then mark a single line and step only that line, using `font-lock-studio' and `font-lock-studio-region', respectively.
This can be fixed in a number of ways:
* Replace "[^$]" with "\\(^\\|[^$]\\)", which mean to match the beginning of a line or any non-$ character.
* Implement the search in a function that would search for the regex (except the "[^$]" part) plus code to check that it's not preceded by a "$".
* Extend the region that should be highlighted to include all lines that end with the "\" character. This can be done by adding a mode-specific function to `font-lock-extend-region-functions'.
Note that there seems to be six rules in Makefile mode using this pattern, I guess all of them needs to be fixes.
-- Anders Lindgren