GNU bug report logs - #63840
29.0.91; c-ts-mode fails to fontify common C extension

Previous Next

Package: emacs;

Reported by: Po Lu <luangruo <at> yahoo.com>

Date: Fri, 2 Jun 2023 12:12:01 UTC

Severity: normal

Tags: notabug

Found in version 29.0.91

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 63840 in the body.
You can then email your comments to 63840 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#63840; Package emacs. (Fri, 02 Jun 2023 12:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Po Lu <luangruo <at> yahoo.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 02 Jun 2023 12:12:01 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Fri, 02 Jun 2023 20:11:33 +0800
A common extension to the C language is the use of the `$' sign inside
external identifier names.

This is permitted by GNU CC on most systems it supports, and also
supported by CC Mode.  However, it does not work on c-ts-mode:

sl$loadarena ()
{
  struct FAB fab;
  register int status;
  extern char *sl$dfname;

  fab = cc$rms_fab;
  fab.fab$b_fac = FAB$M_BIO | FAB$M_GET;
  fab.fab$l_fna = sl$dfname;
  fab.fab$b_fns = strlen (sl$dfname);
  status = sys$open (&fab);
  if (status != RMS$_NORMAL)
    return status;
  /* More code below.  */
}

in the identifier name of this function declarator, `sl' is fontified as
a type.  `$' is not fontified at all.  `loadarena' is fontified as an
identifier name, as it should be.  In:

  extern char *sl$defname;

only `dfname' is fontified as a variable name; in CC Mode, all
fontification is correct.

This should be a simple change in c-ts-mode's identifier fontifying
regexp to include `$', right?  I don't know enough about tree-sitter to
fix it myself.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Fri, 02 Jun 2023 12:53:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>, Yuan Fu <casouri <at> gmail.com>,
 Theodor Thornhill <theo <at> thornhill.no>
Cc: 63840 <at> debbugs.gnu.org
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Fri, 02 Jun 2023 15:51:53 +0300
> Date: Fri, 02 Jun 2023 20:11:33 +0800
> From:  Po Lu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> A common extension to the C language is the use of the `$' sign inside
> external identifier names.
> 
> This is permitted by GNU CC on most systems it supports, and also
> supported by CC Mode.  However, it does not work on c-ts-mode:
> 
> sl$loadarena ()
> {
>   struct FAB fab;
>   register int status;
>   extern char *sl$dfname;
> 
>   fab = cc$rms_fab;
>   fab.fab$b_fac = FAB$M_BIO | FAB$M_GET;
>   fab.fab$l_fna = sl$dfname;
>   fab.fab$b_fns = strlen (sl$dfname);
>   status = sys$open (&fab);
>   if (status != RMS$_NORMAL)
>     return status;
>   /* More code below.  */
> }
> 
> in the identifier name of this function declarator, `sl' is fontified as
> a type.  `$' is not fontified at all.  `loadarena' is fontified as an
> identifier name, as it should be.  In:
> 
>   extern char *sl$defname;
> 
> only `dfname' is fontified as a variable name; in CC Mode, all
> fontification is correct.
> 
> This should be a simple change in c-ts-mode's identifier fontifying
> regexp to include `$', right?  I don't know enough about tree-sitter to
> fix it myself.

I'm not sure this can be fixed unless the tree-sitter's C grammar
supports such identifiers, but if we can fix it in our code, we
should.

Yuan and Theo, can you please look into this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Thu, 08 Jun 2023 07:19:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 63840 <at> debbugs.gnu.org,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Thu, 8 Jun 2023 00:18:17 -0700

> On Jun 2, 2023, at 5:51 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> Date: Fri, 02 Jun 2023 20:11:33 +0800
>> From:  Po Lu via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> A common extension to the C language is the use of the `$' sign inside
>> external identifier names.
>> 
>> This is permitted by GNU CC on most systems it supports, and also
>> supported by CC Mode.  However, it does not work on c-ts-mode:
>> 
>> sl$loadarena ()
>> {
>>  struct FAB fab;
>>  register int status;
>>  extern char *sl$dfname;
>> 
>>  fab = cc$rms_fab;
>>  fab.fab$b_fac = FAB$M_BIO | FAB$M_GET;
>>  fab.fab$l_fna = sl$dfname;
>>  fab.fab$b_fns = strlen (sl$dfname);
>>  status = sys$open (&fab);
>>  if (status != RMS$_NORMAL)
>>    return status;
>>  /* More code below.  */
>> }
>> 
>> in the identifier name of this function declarator, `sl' is fontified as
>> a type.  `$' is not fontified at all.  `loadarena' is fontified as an
>> identifier name, as it should be.  In:
>> 
>>  extern char *sl$defname;
>> 
>> only `dfname' is fontified as a variable name; in CC Mode, all
>> fontification is correct.
>> 
>> This should be a simple change in c-ts-mode's identifier fontifying
>> regexp to include `$', right?  I don't know enough about tree-sitter to
>> fix it myself.
> 
> I'm not sure this can be fixed unless the tree-sitter's C grammar
> supports such identifiers, but if we can fix it in our code, we
> should.
> 
> Yuan and Theo, can you please look into this?

Yeah. So is this the only way $ is used in C? Could it appear in contexts other than identifiers?

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Thu, 08 Jun 2023 08:51:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 63840 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Thu, 08 Jun 2023 16:50:21 +0800
Yuan Fu <casouri <at> gmail.com> writes:

> Yeah. So is this the only way $ is used in C?

Yes.

> Could it appear in contexts other than identifiers?

No.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Thu, 15 Jun 2023 05:57:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: casouri <at> gmail.com, theo <at> thornhill.no
Cc: Po Lu <luangruo <at> yahoo.com>, 63840 <at> debbugs.gnu.org
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Thu, 15 Jun 2023 08:56:22 +0300
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  Theodor Thornhill <theo <at> thornhill.no>,
>   63840 <at> debbugs.gnu.org
> Date: Thu, 08 Jun 2023 16:50:21 +0800
> 
> Yuan Fu <casouri <at> gmail.com> writes:
> 
> > Yeah. So is this the only way $ is used in C?
> 
> Yes.
> 
> > Could it appear in contexts other than identifiers?
> 
> No.

Ping!  Any progress with this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Fri, 16 Jun 2023 05:06:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 63840 <at> debbugs.gnu.org,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Thu, 15 Jun 2023 22:05:33 -0700

> On Jun 14, 2023, at 10:56 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Po Lu <luangruo <at> yahoo.com>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,  Theodor Thornhill <theo <at> thornhill.no>,
>>  63840 <at> debbugs.gnu.org
>> Date: Thu, 08 Jun 2023 16:50:21 +0800
>> 
>> Yuan Fu <casouri <at> gmail.com> writes:
>> 
>>> Yeah. So is this the only way $ is used in C?
>> 
>> Yes.
>> 
>>> Could it appear in contexts other than identifiers?
>> 
>> No.
> 
> 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].

Fixing it ourselves involves checking every identifier during fontification. Is that something we want to do?

[1] https://github.com/tree-sitter/tree-sitter-c/pull/114

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Fri, 16 Jun 2023 06:32:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Fri, 16 Jun 2023 09:31:38 +0300
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Thu, 15 Jun 2023 22:05:33 -0700
> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>  Po Lu <luangruo <at> yahoo.com>,
>  63840 <at> 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?

> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Mon, 19 Jun 2023 06:45:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 63840 <at> debbugs.gnu.org,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: 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 <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Thu, 15 Jun 2023 22:05:33 -0700
>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>> Po Lu <luangruo <at> yahoo.com>,
>> 63840 <at> 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



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Mon, 19 Jun 2023 16:24:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Mon, 19 Jun 2023 19:23:51 +0300
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Sun, 18 Jun 2023 23:43:51 -0700
> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>  Po Lu <luangruo <at> yahoo.com>,
>  63840 <at> debbugs.gnu.org
> 
> > On Jun 15, 2023, at 11:31 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> > 
> >> From: Yuan Fu <casouri <at> gmail.com>
> >> Date: Thu, 15 Jun 2023 22:05:33 -0700
> >> Cc: Theodor Thornhill <theo <at> thornhill.no>,
> >> Po Lu <luangruo <at> yahoo.com>,
> >> 63840 <at> 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.

Thanks.  This sounds like a lot of hair, so let's first see how the
developers of the tree-sitter-c grammar respond.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Tue, 27 Jun 2023 05:55:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 63840 <at> debbugs.gnu.org,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Mon, 26 Jun 2023 22:54:16 -0700

> On Jun 19, 2023, at 9:23 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Sun, 18 Jun 2023 23:43:51 -0700
>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>> Po Lu <luangruo <at> yahoo.com>,
>> 63840 <at> debbugs.gnu.org
>> 
>>> On Jun 15, 2023, at 11:31 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>> 
>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>> Date: Thu, 15 Jun 2023 22:05:33 -0700
>>>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>>>> Po Lu <luangruo <at> yahoo.com>,
>>>> 63840 <at> 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.
> 
> Thanks.  This sounds like a lot of hair, so let's first see how the
> developers of the tree-sitter-c grammar respond.

Cool. (Not surprisingly) I didn’t get any reply on GitHub as for now. It would be nice if tree-sitter-c (and other grammars) can have a separate maintainer other than tree-sitter’s author. He seems to be heavily overloaded right now (tree-sitter, a dozen grammars, Zed editor).

Yuan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Tue, 27 Jun 2023 11:06:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Tue, 27 Jun 2023 14:05:28 +0300
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Mon, 26 Jun 2023 22:54:16 -0700
> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>  Po Lu <luangruo <at> yahoo.com>,
>  63840 <at> debbugs.gnu.org
> 
> 
> 
> > On Jun 19, 2023, at 9:23 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> > 
> >> From: Yuan Fu <casouri <at> gmail.com>
> >> Date: Sun, 18 Jun 2023 23:43:51 -0700
> >> Cc: Theodor Thornhill <theo <at> thornhill.no>,
> >> Po Lu <luangruo <at> yahoo.com>,
> >> 63840 <at> debbugs.gnu.org
> >> 
> >>> On Jun 15, 2023, at 11:31 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> >>> 
> >>>> From: Yuan Fu <casouri <at> gmail.com>
> >>>> Date: Thu, 15 Jun 2023 22:05:33 -0700
> >>>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
> >>>> Po Lu <luangruo <at> yahoo.com>,
> >>>> 63840 <at> 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.
> > 
> > Thanks.  This sounds like a lot of hair, so let's first see how the
> > developers of the tree-sitter-c grammar respond.
> 
> Cool. (Not surprisingly) I didn’t get any reply on GitHub as for now. It would be nice if tree-sitter-c (and other grammars) can have a separate maintainer other than tree-sitter’s author. He seems to be heavily overloaded right now (tree-sitter, a dozen grammars, Zed editor).

Would it be possible for you or someone else of the interested Emacs
users to submit a patch for the grammar library to support $, either
as an option or as an extension?  IOW, is it hard to modify the
TS grammar definitions for such relatively simple and straightforward
extensions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Wed, 28 Jun 2023 01:47:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 63840 <at> debbugs.gnu.org,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Tue, 27 Jun 2023 18:46:24 -0700

> On Jun 27, 2023, at 4:05 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Mon, 26 Jun 2023 22:54:16 -0700
>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>> Po Lu <luangruo <at> yahoo.com>,
>> 63840 <at> debbugs.gnu.org
>> 
>> 
>> 
>>> On Jun 19, 2023, at 9:23 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>> 
>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>> Date: Sun, 18 Jun 2023 23:43:51 -0700
>>>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>>>> Po Lu <luangruo <at> yahoo.com>,
>>>> 63840 <at> debbugs.gnu.org
>>>> 
>>>>> On Jun 15, 2023, at 11:31 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>> 
>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>> Date: Thu, 15 Jun 2023 22:05:33 -0700
>>>>>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>>>>>> Po Lu <luangruo <at> yahoo.com>,
>>>>>> 63840 <at> 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.
>>> 
>>> Thanks.  This sounds like a lot of hair, so let's first see how the
>>> developers of the tree-sitter-c grammar respond.
>> 
>> Cool. (Not surprisingly) I didn’t get any reply on GitHub as for now. It would be nice if tree-sitter-c (and other grammars) can have a separate maintainer other than tree-sitter’s author. He seems to be heavily overloaded right now (tree-sitter, a dozen grammars, Zed editor).
> 
> Would it be possible for you or someone else of the interested Emacs
> users to submit a patch for the grammar library to support $, either
> as an option or as an extension?  IOW, is it hard to modify the
> TS grammar definitions for such relatively simple and straightforward
> extensions?

There is a PR for it on GitHub (under which I left a comment). Judging from the PR, it’s simple to add support for $.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Wed, 28 Jun 2023 02:34:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Wed, 28 Jun 2023 05:33:41 +0300
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Tue, 27 Jun 2023 18:46:24 -0700
> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>  Po Lu <luangruo <at> yahoo.com>,
>  63840 <at> debbugs.gnu.org
> 
> > Would it be possible for you or someone else of the interested Emacs
> > users to submit a patch for the grammar library to support $, either
> > as an option or as an extension?  IOW, is it hard to modify the
> > TS grammar definitions for such relatively simple and straightforward
> > extensions?
> 
> There is a PR for it on GitHub (under which I left a comment). Judging from the PR, it’s simple to add support for $.

If so, perhaps just pinging about it from time to time is all that
should be done.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Sun, 01 Oct 2023 21:11:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Yuan Fu <casouri <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Sun, 1 Oct 2023 14:10:15 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Tue, 27 Jun 2023 18:46:24 -0700
>> Cc: Theodor Thornhill <theo <at> thornhill.no>,
>>  Po Lu <luangruo <at> yahoo.com>,
>>  63840 <at> debbugs.gnu.org
>>
>> > Would it be possible for you or someone else of the interested Emacs
>> > users to submit a patch for the grammar library to support $, either
>> > as an option or as an extension?  IOW, is it hard to modify the
>> > TS grammar definitions for such relatively simple and straightforward
>> > extensions?
>>
>> There is a PR for it on GitHub (under which I left a comment). Judging from the PR, it’s simple to add support for $.
>
> If so, perhaps just pinging about it from time to time is all that
> should be done.

Does it make sense to keep this bug open on our side if we only intend
to wait for upstream support?  Or should we close it as wontfix?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Mon, 02 Oct 2023 05:56:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, casouri <at> gmail.com,
 theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Mon, 02 Oct 2023 08:55:01 +0300
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Sun, 1 Oct 2023 14:10:15 -0700
> Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, theo <at> thornhill.no
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Yuan Fu <casouri <at> gmail.com>
> >> Date: Tue, 27 Jun 2023 18:46:24 -0700
> >> Cc: Theodor Thornhill <theo <at> thornhill.no>,
> >>  Po Lu <luangruo <at> yahoo.com>,
> >>  63840 <at> debbugs.gnu.org
> >>
> >> > Would it be possible for you or someone else of the interested Emacs
> >> > users to submit a patch for the grammar library to support $, either
> >> > as an option or as an extension?  IOW, is it hard to modify the
> >> > TS grammar definitions for such relatively simple and straightforward
> >> > extensions?
> >>
> >> There is a PR for it on GitHub (under which I left a comment). Judging from the PR, it’s simple to add support for $.
> >
> > If so, perhaps just pinging about it from time to time is all that
> > should be done.
> 
> Does it make sense to keep this bug open on our side if we only intend
> to wait for upstream support?  Or should we close it as wontfix?

We could indeed close it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63840; Package emacs. (Mon, 02 Oct 2023 06:45:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: luangruo <at> yahoo.com, 63840 <at> debbugs.gnu.org, casouri <at> gmail.com,
 theo <at> thornhill.no
Subject: Re: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Sun, 1 Oct 2023 23:44:08 -0700
tags 63840 notabug
close 63840
thanks

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

>> Does it make sense to keep this bug open on our side if we only intend
>> to wait for upstream support?  Or should we close it as wontfix?
>
> We could indeed close it.

Done.




Added tag(s) notabug. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 02 Oct 2023 06:45:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 63840 <at> debbugs.gnu.org and Po Lu <luangruo <at> yahoo.com> Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 02 Oct 2023 06:45: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. (Mon, 30 Oct 2023 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 151 days ago.

Previous Next


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