unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: eliz@gnu.org, 59415@debbugs.gnu.org
Subject: bug#59415: 29.0.50; [feature/tree-sitter] c-ts-mode fails to fontify a portion of a large C file
Date: Sun, 20 Nov 2022 22:09:37 +0100	[thread overview]
Message-ID: <87pmdhqqni.fsf@thornhill.no> (raw)
In-Reply-To: <BBE9584B-B584-4CE3-BC36-93BBEB4054BE@gmail.com>

>> This diff fixes the font-lock issues:
>> 
>> diff --git a/lisp/treesit.el b/lisp/treesit.el
>> index 674c984dfe..0f84d8b83e 100644
>> --- a/lisp/treesit.el
>> +++ b/lisp/treesit.el
>> @@ -774,12 +774,12 @@ treesit-font-lock-fontify-region
>>       ;; will give you that quote node.  We want to capture the string
>>       ;; and apply string face to it, but querying on the quote node
>>       ;; will not give us the string node.
>> -      (when-let ((root (treesit-buffer-root-node language))
>> +      (when-let (
>>                  ;; Only activate if ENABLE flag is t.
>>                  (activate (eq t enable)))
>>         (ignore activate)
>>         (let ((captures (treesit-query-capture
>> -                         root query start end))
>> +                         (treesit-node-on start end) query start end))
>>               (inhibit-point-motion-hooks t))
>>           (with-silent-modifications
>>             (dolist (capture captures)
>> 
>> 
>> However, the comment right above makes a case for why we should have
>> this.  BUT, is this still relevant, Yuan, after the changes in treesit
>> reporting what has changed etc?  What exact case is that an issue?  And
>> is it more severe than the behavior this bug is exhibiting?
>
> The case described by the comment is still relevant. With this patch,
> the quote described in that case still wouldn’t be fontified. We can
> use some heuristic to get a node “large enough” and not the root
> node. Eg, find some top-level node. That should make query-capture
> much faster.
>

I appreciate the explanation.  I think getting the root is a bit
excessive.  I got the same results as you in the capture.  Maybe reuse
the treesit-defun-type-regexp, and default to root if none found?





  reply	other threads:[~2022-11-20 21:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 17:55 bug#59415: 29.0.50; [feature/tree-sitter] c-ts-mode fails to fontify a portion of a large C file Eli Zaretskii
2022-11-20 19:54 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 20:16   ` Eli Zaretskii
2022-11-20 20:33     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 20:51       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-20 20:59       ` Yuan Fu
2022-11-20 21:09         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-11-20 21:27           ` Yuan Fu
2022-11-20 21:56             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-21  1:27               ` Yuan Fu
2022-11-21 11:00                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-21 13:44                 ` Eli Zaretskii
2022-11-21 15:15                 ` Eli Zaretskii
2022-11-21 16:53                   ` Yuan Fu
2022-11-21 17:17                     ` Eli Zaretskii
2022-11-22  7:31                       ` Yuan Fu
2022-11-21 12:41               ` Eli Zaretskii
2022-11-20 20:17 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=87pmdhqqni.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59415@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --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).