unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: ronisbr@ronanarraes.com
Cc: 60223@debbugs.gnu.org
Subject: bug#60223: 29.0.60; Improve how tree-sitter changes to  treesit--font-lock-fast-mode
Date: Tue, 20 Dec 2022 20:17:26 -0800	[thread overview]
Message-ID: <813B3BC7-BD3C-4327-A175-DEB43B2EB11E@gmail.com> (raw)
In-Reply-To: <2e1e12123516721aed9e7e4ba8fe5409@ronanarraes.com>


ronisbr <ronisbr@ronanarraes.com> writes:

> Hi!
>
> First of all, this is my very first interaction with Emacs mailing
> list. I have
> a problem in the tree-sitter module that leads to a bug (Emacs 29).
> Hence, I am
> not even sure if this is the right place to report it.
>
> treesit.el has a fast font-lock mode that is also used to avoid
> locking if some
> a query is taking too long:
>
>             ;; If for any query the query time is strangely long,
>             ;; switch to fast mode (see comments above).
>             (when (> (time-to-seconds (time-subtract end-time
>             start-time))
>                      0.01)
>               (setq-local treesit--font-lock-fast-mode t))
>
> When coding Julia major mode using tree-sitter
> (https://github.com/ronisbr/julia-ts-mode/blob/main/julia-ts-mode.el),
> I found a
> strange behavior in my setup (Doom Emacs) that is caused precisely by
> that
> feature.
>
> If I open this file together with Emacs (first initialization):
>
> https://github.com/ronisbr/PrettyTables.jl/blob/master/src/print.jl
>
> The file has almost no font decoration and
> `treesit--font-lock-fast-mode` is set
> to t. If I manually set it to nil and recompute everything, the font
> locking
> works perfectly again.
>
> However, everything works as expected if I open any other Julia code
> before
> opening that file (print.jl). In this case,
> `treesit--font-lock-fast-mode`
> remains nil.
>
> My guess is that due to something that might or might not be related
> to my
> setup, the query is taking longer than the 0.01s if I open that file
> during the
> initialization of Julia mode. It is caused by that enormous string
> used to
> document the function that seems to slow down tree-sitter parsing.
> Thus, I think
> it would be very important to have a variable to customize this time
> interval
> depending on the situation.
>
> Best regards,
> Ronan Arraes
>

Thanks for the report!

The "fast mode" should be buffer-local, so that particular file
shouldn’t affect other buffers. Just to make sure, you said that if you
open print.jl first, all other files are affected?

And I agree that the 0.01 second criterion is a crude one, but a long
string shouldn’t affect the _query_ time, and that string is not long at
all, far from enough to make tree-sitter query to slow down. Let me
investigate and see what’s the real cause, and if this can be solved by
better solutions than making the threshold customizable. We can’t expect
everyone to be able to pinpoint the culprit like you did :-)

Yuan





  reply	other threads:[~2022-12-21  4:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 14:08 bug#60223: 29.0.60; Improve how tree-sitter changes to treesit--font-lock-fast-mode ronisbr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-21  4:17 ` Yuan Fu [this message]
2022-12-21 15:59   ` ronisbr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-24  9:33 ` Yuan Fu
2022-12-27  3:16   ` ronisbr 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=813B3BC7-BD3C-4327-A175-DEB43B2EB11E@gmail.com \
    --to=casouri@gmail.com \
    --cc=60223@debbugs.gnu.org \
    --cc=ronisbr@ronanarraes.com \
    /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).