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 17:27:16 -0800 Message-ID: References: <83v8n94ij9.fsf@gnu.org> <87k03pwgf6.fsf@thornhill.no> <83h6yt4c12.fsf@gnu.org> <87v8n9qscd.fsf@thornhill.no> <87pmdhqqni.fsf@thornhill.no> <87tu2tthmr.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="22933"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 59415@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 21 02:28:25 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 1owvbl-0005qL-9g for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Nov 2022 02:28:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owvbP-00031V-Pu; Sun, 20 Nov 2022 20:28:03 -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 1owvbO-00031M-Q9 for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 20: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 1owvbO-0002Nt-Hv for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 20:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1owvbO-0002Hx-Dw for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 20:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Nov 2022 01:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59415 X-GNU-PR-Package: emacs Original-Received: via spool by 59415-submit@debbugs.gnu.org id=B59415.16689940478754 (code B ref 59415); Mon, 21 Nov 2022 01:28:02 +0000 Original-Received: (at 59415) by debbugs.gnu.org; 21 Nov 2022 01:27:27 +0000 Original-Received: from localhost ([127.0.0.1]:44952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvao-0002H7-RN for submit@debbugs.gnu.org; Sun, 20 Nov 2022 20:27:27 -0500 Original-Received: from mail-pj1-f47.google.com ([209.85.216.47]:53873) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvam-0002Gt-4Z for 59415@debbugs.gnu.org; Sun, 20 Nov 2022 20:27:25 -0500 Original-Received: by mail-pj1-f47.google.com with SMTP id t17so8453720pjo.3 for <59415@debbugs.gnu.org>; Sun, 20 Nov 2022 17:27:24 -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=jDq0JYymJMT/MZsR/rcj+QncJQhH0i1TQUhPMp4KGSY=; b=QrH7lnsXE62WOW8Ho0rAxLWBOlaQlbhodgp3/eORotTDJVNUn6wKUn7BwHZ71xi/62 RDk4mCi/2RA+xZVzKnM0JZSEfkgYcsBnu+Ny6j6m85OCkDnNLPkON7s+gcyg2PyEOhgS dkLltbIFt6jpG/OPlwWErqmGclTEeMu/7Cb6DGlvEytsEXFYYy+HBw7yjuY0lr0zMQQS bYNafiGq40MFHsXQMqaSpITUXx/a6TZau7wIOqgZ2GBL/tmxWjvmkuB0jkifRShhgfcK n/YTp1sLo2VTehhwRaTlYcmaYzvymvzSBd17RxtXv9lLmcSYLOQJrcM0ccX5AQ0GwB9l 2tDQ== 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=jDq0JYymJMT/MZsR/rcj+QncJQhH0i1TQUhPMp4KGSY=; b=bEca6gjLibfyQvo2+pQjqMKg3v8qWHAUhj4zqGXpUBdnXkvGC9CkjvhvGlgw/JY4Wn JTXVDI6asCA9DkF5GqRxNgsESPSvYeqI2Vj046znNlmQ2pB8DPPgu3H/uIMXlCA2kOmz VGqgtZea2OhiXhH/Rj7euBUwPrmk50J03G2uS1iHugfD4j9zwk6b8c1RKe9BrFEgEKrx UdQoGf+kTm9TbNNynZRpreN/ZfBXccc+JrJCtuAhMdKPFo35ioUUbNxDNX/nlV4d8/fM mX3o4XadqKlqBfHpzKq7m3vhjdNmljp/A5C3Oz+mqhgDR6G62I0wUvZXKPsSIKqAsIVx MnlA== X-Gm-Message-State: ANoB5plTUmTQmEB4eaqZHJAEvhWpzoC/Thu6ZdvA6mPx351FEZYIj7tx Cr8QJ0DsKd8fsVYatqRax1o= X-Google-Smtp-Source: AA0mqf5LoNkGHaElK5tDEN4SU5BcXkIjgrs2BTSKFu2biXbXNOwdc3jNXMGYDrfi8LA91kcfKY3nRw== X-Received: by 2002:a17:90a:ff84:b0:213:1e05:f992 with SMTP id hf4-20020a17090aff8400b002131e05f992mr24388845pjb.191.1668994038121; Sun, 20 Nov 2022 17:27:18 -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 b12-20020a170903228c00b001811a197797sm8191742plh.194.2022.11.20.17.27.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Nov 2022 17:27:17 -0800 (PST) In-Reply-To: <87tu2tthmr.fsf@thornhill.no> 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:248494 Archived-At: > On Nov 20, 2022, at 1:56 PM, Theodor Thornhill via Bug reports for GNU = Emacs, the Swiss army knife of text editors = wrote: >=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? >>=20 >> 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. >>=20 >=20 > Makes sense! I pushed a change that uses treesit-node-on. Now scrolling in most parts = of the buffer is pretty fast. Scrolling around 194770 is still laggy, = because the node we get from treesit-node-on is still too large. I tried = some heuristics but they didn=E2=80=99t work very well, IMO because = tree-sitter couldn=E2=80=99t parse that part of the code very well. The = code should observe a structure like {{}, {}, {}, {}, {}, =E2=80=A6} = where there are tens thousands of inner brackets, so ideally we only = need to grab the {}=E2=80=99s in the region we want to fontify. But = tree-sitter seems to understand it in some weird structure and we still = end up with very large nodes, which is far larger than the region we = want to fontify and is slow to query. I=E2=80=99ll try to improve it further in the future, but for now I = think it=E2=80=99s good enough (because in most cases fontification is = pretty fast). Also I think we should probably disable fontifying errors in C. C=E2=80=99= s macros just create too much errors. Yuan=