From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: luangruo@yahoo.com, 63840@debbugs.gnu.org, theo@thornhill.no
Subject: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension
Date: Tue, 27 Jun 2023 14:05:28 +0300 [thread overview]
Message-ID: <83ilb9w4g7.fsf@gnu.org> (raw)
In-Reply-To: <4CB53EB5-CFBE-40F4-A303-353B3D891FA5@gmail.com> (message from Yuan Fu on Mon, 26 Jun 2023 22:54:16 -0700)
> From: Yuan Fu <casouri@gmail.com>
> Date: Mon, 26 Jun 2023 22:54:16 -0700
> Cc: Theodor Thornhill <theo@thornhill.no>,
> Po Lu <luangruo@yahoo.com>,
> 63840@debbugs.gnu.org
>
>
>
> > On Jun 19, 2023, at 9:23 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> >
> >> From: Yuan Fu <casouri@gmail.com>
> >> Date: Sun, 18 Jun 2023 23:43:51 -0700
> >> Cc: Theodor Thornhill <theo@thornhill.no>,
> >> Po Lu <luangruo@yahoo.com>,
> >> 63840@debbugs.gnu.org
> >>
> >>> 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.
> >
> > 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?
next prev parent reply other threads:[~2023-06-27 11:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87fs7anjwq.fsf.ref@yahoo.com>
2023-06-02 12:11 ` bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-02 12:51 ` Eli Zaretskii
2023-06-08 7:18 ` Yuan Fu
2023-06-08 8:50 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-15 5:56 ` Eli Zaretskii
2023-06-16 5:05 ` Yuan Fu
2023-06-16 6:31 ` Eli Zaretskii
2023-06-19 6:43 ` Yuan Fu
2023-06-19 16:23 ` Eli Zaretskii
2023-06-27 5:54 ` Yuan Fu
2023-06-27 11:05 ` Eli Zaretskii [this message]
2023-06-28 1:46 ` Yuan Fu
2023-06-28 2:33 ` Eli Zaretskii
2023-10-01 21:10 ` Stefan Kangas
2023-10-02 5:55 ` Eli Zaretskii
2023-10-02 6:44 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83ilb9w4g7.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=63840@debbugs.gnu.org \
--cc=casouri@gmail.com \
--cc=luangruo@yahoo.com \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).