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: Mon, 19 Jun 2023 19:23:51 +0300 [thread overview]
Message-ID: <835y7j8lpk.fsf@gnu.org> (raw)
In-Reply-To: <6871B1D5-9B52-47C0-BB6F-5C41655CD33B@gmail.com> (message from Yuan Fu on Sun, 18 Jun 2023 23:43:51 -0700)
> 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.
next prev parent reply other threads:[~2023-06-19 16:23 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 [this message]
2023-06-27 5:54 ` Yuan Fu
2023-06-27 11:05 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=835y7j8lpk.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.