bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension


From: Yuan Fu
Subject: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Sun, 18 Jun 2023 23:43:51 -0700


> On Jun 15, 2023, at 11:31 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Thu, 15 Jun 2023 22:05:33 -0700
>> Cc: Theodor Thornhill <theo@thornhill.no>,
>> Po Lu <luangruo@yahoo.com>,
>> 63840@debbugs.gnu.org
>> 
>>> Ping!  Any progress with this?
>> 
>> The best option is to ask tree-sitter-c to recognize $. I see a PR for it 
>> but the author closed it shortly after posting, not sure what was going 
>> on[1].
> 
> Any hope of re-opening it, or at least asking why it was closed
> without fixing?

I asked on GitHub.

> 
>> Fixing it ourselves involves checking every identifier during fontification. 
>> Is that something we want to do?
> 
> How would that work?  Can you describe how could this be implemented?
> It is hard to decide whether it's something we want to do without
> knowing the implications.

I was going to write a demo implementation, but that actually would change 
quite some lines. So let me just describe it for now. In 
c-ts-mode--font-lock-settings, I would replace all the different types of faces 
used for all the identifiers to a function. (If you search for identifier in 
c-ts-mode--font-lock-settings, there are quite a few of them.) This function 
would obviously receive the beg and end of the identifier tree-sitter detects, 
and it would check if there are $ right before or after the given range, if 
there is, it would extend the range fontified.

For example, for a code like abc$de, tree-sitter might consider abc as an 
identifier, and $ de to be error. The function I mentioned would look at abc’s 
beg and end, and see that c is immediately followed by a $, so it would extend 
the fontification range to include abc$de.

Yuan




reply via email to

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