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#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 13:27:04 -0800 Message-ID: References: <83v8n94ij9.fsf@gnu.org> <87k03pwgf6.fsf@thornhill.no> <83h6yt4c12.fsf@gnu.org> <87v8n9qscd.fsf@thornhill.no> <87pmdhqqni.fsf@thornhill.no> 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="33195"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, 59415@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 20 22:28:29 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 1owrrY-0008Ts-WD for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Nov 2022 22:28:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owrrA-0002Cr-9K; Sun, 20 Nov 2022 16:28: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 1owrr8-0002CJ-9w for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:28: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 1owrr8-0003WY-0a for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1owrr7-0002TY-N9 for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Nov 2022 21:28:01 +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.16689796339449 (code B ref -1); Sun, 20 Nov 2022 21:28:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Nov 2022 21:27:13 +0000 Original-Received: from localhost ([127.0.0.1]:44773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owrqK-0002SL-RZ for submit@debbugs.gnu.org; Sun, 20 Nov 2022 16:27:13 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:59204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owrqH-0002SC-R5 for submit@debbugs.gnu.org; Sun, 20 Nov 2022 16:27:12 -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 1owrqH-00029D-Lh for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 16:27:09 -0500 Original-Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owrqG-0003SY-0h; Sun, 20 Nov 2022 16:27:09 -0500 Original-Received: by mail-pj1-x102e.google.com with SMTP id v3-20020a17090ac90300b00218441ac0f6so11843310pjt.0; Sun, 20 Nov 2022 13:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ko52a8Pv0sPC0ckS+htv8lxAFZwkMBwOJE8X+I9oJAo=; b=coXZJWWD49y0lxJkBW9ItqWxfI9ATlRAhwtA7UsXQY1viTrlfIgJlOCGKvqaGOMn2y 7I4QydO8FxsaqyAZKz56scPO4hlpSPjioHZwf5p3Cq+ht1bMjMj3hsj4g9zvT9qNyOKb EdUjxCRvB6QdHfQqhtNs+h0JmOAH79ac+09FQxdw5h8BL6jJPPxt6qQM/0P9NaFi8j1P t9f6VJzazLFP491kpPU9u1Z4eGxnOwCE8sFRWWuzz5IPeRHDAQvfrKHGNzz7dz3nDnya pI4ugL9aBUjBJiTfnBfqiXgwje8adFN6V+rAYgKoyiUPXEfQAkTCgt9fpUIzez5qlgAn WvFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ko52a8Pv0sPC0ckS+htv8lxAFZwkMBwOJE8X+I9oJAo=; b=3riX6THPSEZ5fTaM3hqksWHGcxD2df4s6LEYFzu1/m00laY2i33DtyyzkMTVX2KvGu MEz+uF+VWBRLEXKhXSe6eLM//AuRQKj6YSH7bgWzhkBZed+wZgGzjJKvl3G2oqZPcDw1 zzKLkQ7qcjA6GT1RYkjU3DzFZU9t9lR0ovJMjIGnAPVNkgc9RL/XctUFnqPeg6y3Ein7 qudi1vXe+9ISfLrvDrEDEUTmrWTlhFh4RLLH18Aybe54SoAfAPpWQRxiJKgpZSwinNZy DjstQ/hEQCSADMAPfM4v6uDih8I8HBH5tJJv851N92sT80K50kLUioeVCfzvPpdEb9Di yebA== X-Gm-Message-State: ANoB5pnqi4j0hdfOXSx8k79C84aBJssEgvB+Ili5H/i/EGhe9AWupnGU 5qp0XH/5N31yM/uufzECjPg5CRHv/oc= X-Google-Smtp-Source: AA0mqf66kSVHp+230l97CecUvceaLF9iw9v/A0QlnOUNPVrs53YV78lLgyy4OQNW4AD7PcAz+9ps9g== X-Received: by 2002:a17:90a:4049:b0:210:5de0:f3e3 with SMTP id k9-20020a17090a404900b002105de0f3e3mr17291438pjg.61.1668979626017; Sun, 20 Nov 2022 13:27:06 -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 x15-20020aa7940f000000b0056bfd4a2702sm7075842pfo.45.2022.11.20.13.27.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Nov 2022 13:27:05 -0800 (PST) In-Reply-To: <87pmdhqqni.fsf@thornhill.no> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=casouri@gmail.com; helo=mail-pj1-x102e.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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:248478 Archived-At: > On Nov 20, 2022, at 1:09 PM, Theodor Thornhill = wrote: >=20 >>> 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? >>=20 >> 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 the root >> node. Eg, find some top-level node. That should make query-capture >> much faster. >>=20 >=20 > 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? I tried the "top-level node=E2=80=9D approach, and it didn=E2=80=99t = help in package-rrc.c: the top-level node (a function definition) is = still too large (spans 7680306-9936062). Since the case I described in = the comment against using treesit-node-on is the exception rather than = the norm, maybe we can go the other way around: use treesit-node-on = first, and if the node seems too small (by some heuristic), enlarge it = to some degree. Yuan=