From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs 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 Message-ID: <813B3BC7-BD3C-4327-A175-DEB43B2EB11E@gmail.com> References: <2e1e12123516721aed9e7e4ba8fe5409@ronanarraes.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1875"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60223@debbugs.gnu.org To: ronisbr@ronanarraes.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 21 05:18:15 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p7qYZ-0000H0-4Z for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Dec 2022 05:18:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7qYN-0002S6-Up; Tue, 20 Dec 2022 23:18:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7qYM-0002Rr-Ov for bug-gnu-emacs@gnu.org; Tue, 20 Dec 2022 23:18:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7qYM-00051c-Bq for bug-gnu-emacs@gnu.org; Tue, 20 Dec 2022 23:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7qYM-0000wU-1V for bug-gnu-emacs@gnu.org; Tue, 20 Dec 2022 23:18:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <2e1e12123516721aed9e7e4ba8fe5409@ronanarraes.com> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Dec 2022 04:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60223 X-GNU-PR-Package: emacs Original-Received: via spool by 60223-submit@debbugs.gnu.org id=B60223.16715962563611 (code B ref 60223); Wed, 21 Dec 2022 04:18:02 +0000 Original-Received: (at 60223) by debbugs.gnu.org; 21 Dec 2022 04:17:36 +0000 Original-Received: from localhost ([127.0.0.1]:49133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7qXw-0000wB-0u for submit@debbugs.gnu.org; Tue, 20 Dec 2022 23:17:36 -0500 Original-Received: from mail-pj1-f54.google.com ([209.85.216.54]:35336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7qXu-0000w5-Do for 60223@debbugs.gnu.org; Tue, 20 Dec 2022 23:17:35 -0500 Original-Received: by mail-pj1-f54.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso967118pjt.0 for <60223@debbugs.gnu.org>; Tue, 20 Dec 2022 20:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=28xbfhGxE3f/dKt6eD1DtXMWcqBs0BWoL7XPYRg5lCs=; b=J6N9D50TZIM7J1P9Ar1fbnYRtyGIeYNc/9IlZgONwYyOovDbSnCU0PukQjVhpnZtiB l4wyyBKUOadlZGPD7gWy5uhpXz3/va1VyO5BZI4kdbpcgQX743cgAkCPxY/s0eoZdL4e NYMEI8ap1X08IfThR3oAFp5uQFY9qU/HQ6zDA9Wb7myEHWkviEDYJPBE2Zxjf9eIDfHT 5s6B3VMzLDldqz4hRAn8OX+9p157gYz39PW6S9NwvDOsUVB3qRQhISO5VMhKA4ZIOveB dRWbBi/dneNWIKO7lSEnQSbNwteIZG8hdKHPDVRBfD7qfRpGF5p1uq6/FObdHWRX9Acd uVXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=28xbfhGxE3f/dKt6eD1DtXMWcqBs0BWoL7XPYRg5lCs=; b=M893rF6+E8mTBnyTaHBWtizoqJvCF44YP/ADj+jKEVGlaH1+IeLi8L0kRqrjEfJi8O 6XDzJfsZQtZGAF2dRwQeojpQlpbY907PXOejkR93xsaIZTAamfxbnIupCIpbnG8eBjS7 fa8VKIfhsu3EaXF9LolJaNgpNAFoSA/7OeQww79rMTTqdkH3ibazI7nNDvHGjTac2MFW LWquyEr3VC3RVpYY9+nzK8uJW/cLkAz8XDiMKxxx9nEctglEDoXEj1two+uq0i5KnxKD DmqNHT7hP02ErlXfehhAtXqk55TRYWNC2C+xphr7KYcwJhOxS3Y/69i8BJoSsaQ8j/VS DViw== X-Gm-Message-State: AFqh2kr6LL0qNLKKaWEx6OBAFSaf/bGkZz8Eiab24flO65Gny+BaFohF YTFgQV3fsqHahUO8NqzwNYo= X-Google-Smtp-Source: AMrXdXu9kZfzh4HhonzMdcqD8kYdZnp7SNVcyfpnNrKSEBtF60dJcPliSRTp4dRai4NZAfWRgKvHKA== X-Received: by 2002:a17:902:7d92:b0:191:460e:84e1 with SMTP id a18-20020a1709027d9200b00191460e84e1mr629478plm.2.1671596248451; Tue, 20 Dec 2022 20:17:28 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id p8-20020a170902780800b001870dc3b4c0sm10196804pll.74.2022.12.20.20.17.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2022 20:17:28 -0800 (PST) X-Mailer: Apple Mail (2.3696.120.41.1.1) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251559 Archived-At: ronisbr 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=E2=80=99t 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=E2=80=99t 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=E2=80=99s the real cause, and if this can be = solved by better solutions than making the threshold customizable. We can=E2=80=99t = expect everyone to be able to pinpoint the culprit like you did :-) Yuan