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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23266 in the body.
You can then email your comments to 23266 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23266; Package emacs. (Sun, 10 Apr 2016 23:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dima Kogan <dima <at> secretsauce.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 10 Apr 2016 23:04:02 GMT) Full text and rfc822 format available.

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

From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.92; GNUmakefile mode incorrect syntax highlighting
Date: Sun, 10 Apr 2016 16:02:46 -0700
[Message part 1 (text/plain, inline)]
Hi. I'm running an emacs built from the emacs-25 branch on 2016/04/05
(a05fb21). I'm seeing Makefiles incorrectly rendered at times. Example.
I load the following Makefile:

===================================
XXX :=						\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb					\
$(DIR)/aaa/bbb
===================================

Things look correct here. In particular all the DIR are rendered with
font-lock-variable-name-face

I then kill (with C-k) any of the DIR lines. Two of the DIR around the
line being killed then lose the font-lock-variable-name-face. The buffer
needs to be reverted to get proper highlighting back. I'm attaching
screenshots (emacs -Q -nw) before and after the kill.

Thanks


[before.png (image/png, attachment)]
[after.png (image/png, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23266; Package emacs. (Mon, 11 Apr 2016 09:16:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> suse.de>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 23266 <at> debbugs.gnu.org
Subject: Re: bug#23266: 25.0.92; GNUmakefile mode incorrect syntax highlighting
Date: Mon, 11 Apr 2016 11:15:08 +0200
Dima Kogan <dima <at> secretsauce.net> writes:

> I then kill (with C-k) any of the DIR lines. Two of the DIR around the
> line being killed then lose the font-lock-variable-name-face. The buffer
> needs to be reverted to get proper highlighting back.

Does M-o M-o also restore proper highlighting?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23266; Package emacs. (Mon, 11 Apr 2016 12:48:02 GMT) Full text and rfc822 format available.

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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23266; Package emacs. (Thu, 08 Jul 2021 00:59:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Anders Lindgren <andlind <at> gmail.com>
Cc: Andreas Schwab <schwab <at> suse.de>, 23266 <at> debbugs.gnu.org,
 Dima Kogan <dima <at> secretsauce.net>
Subject: Re: bug#23266: 25.0.92; GNUmakefile mode incorrect syntax highlighting
Date: Thu, 08 Jul 2021 02:58:11 +0200
Anders Lindgren <andlind <at> gmail.com> writes:

> This can be fixed in a number of ways:
>
>  * Replace "[^$]" with "\\(^\\|[^$]\\)", which mean to match the beginning of a
> line or any non-$ character.

Thanks; I did this in Emacs 28, and it seems to fix the issue.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 23266 <at> debbugs.gnu.org and Dima Kogan <dima <at> secretsauce.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 08 Jul 2021 00:59:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 05 Aug 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 257 days ago.

Previous Next


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