GNU bug report logs - #23266
25.0.92; GNUmakefile mode incorrect syntax highlighting

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Sun, 10 Apr 2016 23:04:02 UTC

Severity: minor

Found in version 25.0.92

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 23266 <at> debbugs.gnu.org (full text, mbox):

From: Anders Lindgren <andlind <at> gmail.com>
To: 23266 <at> debbugs.gnu.org, Dima Kogan <dima <at> secretsauce.net>, 
 Andreas Schwab <schwab <at> suse.de>
Subject: Re: bug#23266: 25.0.92; GNUmakefile mode incorrect syntax highlighting
Date: Mon, 11 Apr 2016 14:47:30 +0200
[Message part 1 (text/plain, inline)]
Hi!

I think it's the following font-lock keyword that is broken:

    ("[^$]\\$[({]\\([-a-zA-Z0-9_.]+\\|[@%<?^+*][FD]?\\)"
      (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
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.