[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23266: 25.0.92; GNUmakefile mode incorrect syntax highlighting

From: Anders Lindgren
Subject: bug#23266: 25.0.92; GNUmakefile mode incorrect syntax highlighting
Date: Mon, 11 Apr 2016 14:47:30 +0200


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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]