GNU bug report logs - #62951
29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE

Previous Next

Package: emacs;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Wed, 19 Apr 2023 16:41:01 UTC

Severity: normal

Found in version 29.0.90

Fixed in version 29.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62951 <at> debbugs.gnu.org
Subject: bug#62951: 29.0.90; c-ts-mode: Incorrect fontification due to  FOR_EACH_TAIL_SAFE
Date: Fri, 21 Apr 2023 13:37:08 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

> To reproduce:
>
>   emacs -Q
>   C-x C-f src/fns.c RET
>   C-u 3365 M-g g
>
> Observe that "if" and "STRINGP" in the body of FOR_EACH_TAIL_SAFE are
> fontified in font-lock-function-name-face.  This is because the
> FOR_EACH_TAIL_SAFE macro is misparsed by tree-sitter as a declaration.
>
> Can we teach c-ts-mode to recognize FOR_EACH_TAIL_SAFE and
> FOR_EACH_TAIL for what they are, perhaps conditioned on
> c-ts-mode-emacs-sources-support being non-nil?

I’m aware of this issue, but the truth is there isn’t a good solution to
it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix arbitrary
code after it (hard). In this case it’s a if statement, with macro calls
and AND operation in it’s condition, it’s already three things we need
to recognize and somehow handle. It can also be a for loop, a switch
case, a function call, a while loop. If we want to fix FOR_EACH_TAIL we
would need to handle every possible thing, at that point we might as
well have wrote a parser :-)

We can probably fix this very particular case, but it’s still work and
overhead, and doesn’t mean much.

Yuan




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

Previous Next


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