From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: <87pmdhqqni.fsf@thornhill.no> References: <83v8n94ij9.fsf@gnu.org> <87k03pwgf6.fsf@thornhill.no> <83h6yt4c12.fsf@gnu.org> <87v8n9qscd.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 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="29706"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, 59415@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 20 22:10:13 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 1owrZr-0007We-G9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Nov 2022 22:10:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owrZl-00082i-Ss; Sun, 20 Nov 2022 16:10:05 -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 1owrZi-00082X-TP for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:10: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 1owrZi-0006c8-LC for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1owrZi-00023i-As for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Nov 2022 21:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59415 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: Eli Zaretskii , Bug Report Emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.16689785937893 (code B ref -1); Sun, 20 Nov 2022 21:10:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Nov 2022 21:09:53 +0000 Original-Received: from localhost ([127.0.0.1]:44764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owrZY-00023F-ON for submit@debbugs.gnu.org; Sun, 20 Nov 2022 16:09:53 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:47384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owrZW-000237-D7 for submit@debbugs.gnu.org; Sun, 20 Nov 2022 16:09:50 -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 1owrZV-00081q-ME for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:09:49 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owrZT-0006Zr-6d; Sun, 20 Nov 2022 16:09:49 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668978584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MMJz15Q46Dwcg5BMSVIat+bcYe1rc7e2nkt8FZeRwcs=; b=aW3uEFF2LvFPDApk3xu07UhxGEtJm9zHVS3q9PVyqu+4QtE0e8rpbV6+w76aWjFQW/dfju 6zm6d7zAFrUIQiBnLas5QPJSh2xet37M5cK+avjxb5Pf41u96EB8B0XOHKxbm3qMjZKzTn UF1MwsmC9leZmy3Kb++96V3WB5iy8YbHGIAwQKgZOV6HwuKXT1gqfn4wERDznCjGECqmkt 2fh2A/5lsworrgLMRS5RYGx6/2Mj7RTngM51hJYtp541G8NL/TwaCQ+ocrcwd/bPuBq27R 5C+6UIPJIHlXBQitKBpmw3hhfgSSczrv3dxj4425u/sY24sW5TfKa/viQ4G6zw== In-Reply-To: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:248477 Archived-At: >> This diff fixes the font-lock issues: >>=20 >> 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) >>=20 >>=20 >> 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=E2=80=99t be fontified. We = can > use some heuristic to get a node =E2=80=9Clarge enough=E2=80=9D and not t= he 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?