From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Reliable after-change-functions (via: Using incremental parsing in Emacs) Date: Mon, 30 Mar 2020 23:10:57 -0400 Message-ID: References: <83o8sf3r7i.fsf@gnu.org> <2E218879-0F24-4A20-B210-263C8D0BEEA4@gmail.com> <838sjh2red.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="118225"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Yuan Fu , akrl@sdf.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 31 05:11:38 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jJ7JS-000Uge-3R for ged-emacs-devel@m.gmane-mx.org; Tue, 31 Mar 2020 05:11:38 +0200 Original-Received: from localhost ([::1]:59622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ7JR-0002BE-2m for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Mar 2020 23:11:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57517) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ7Iu-0001lN-2K for emacs-devel@gnu.org; Mon, 30 Mar 2020 23:11:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJ7Is-0000vU-Mb for emacs-devel@gnu.org; Mon, 30 Mar 2020 23:11:03 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30109) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJ7Ir-0000ux-72; Mon, 30 Mar 2020 23:11:01 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 8E62581133; Mon, 30 Mar 2020 23:11:00 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 70FC180AB3; Mon, 30 Mar 2020 23:10:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1585624258; bh=/j5lQpRFkRwswd6nC/U+CNzQHYKSTus241bxow0ZEbE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=QO6zdQ5qb/57dFnm6NdaqQPaM1PkqRlD4ahb7J8cU6jHUID0iD3QK2d+7DYaYsEQa 22N/PiRFQNlH5K7twvRg8FBZ8HeRbbQKQScpBDs5vgBwEmbtbvV0LoBJxBP7N9O4Xu J31jyOeFBCJp8H+DIpOHtJQnQ//g/UzB+AR4WmFKkVOIgBpSiaupmuDwFqjQIjMqAJ kj0qyYGkssp3R7xAmtGBJuj1gMrwDvcirDLSUeTVJuRig48tS6UgQaazpmHYRdw4nH MMt/Jgh3xNSebTDWcTgYYWAHkQndyBEfjRPI7Ir1emJjjg0lNAZKyS8WuqDyPOvfx6 cs+4CymqPgh8Q== Original-Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 23E7A120783; Mon, 30 Mar 2020 23:10:58 -0400 (EDT) In-Reply-To: <838sjh2red.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 31 Mar 2020 05:24:10 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246074 Archived-At: > IOW, our goal is not to build the syntax tree, it's to give > tree-sitter enough information to allow us to fontify the part that's > about to be displayed. We need to have tree-sitter play by Emacs > rules, not teach Emacs to play by tree-sitter rules. IIUC, tree-sitter starts by parsing the whole buffer anyway, and then keeps the parse tree up-to-date in response to buffer changes. Its algorithm is tuned so that the time needed to update the tree is more or less proportional to the size of the change. So jit-lock/font-lock doesn't need to pass any part of the buffer to tree-sitter: tree-sitter already has the buffer's content and we can assume its already parsed. What emacs-tree-sitter's proposed tree-sitter-highlight does is provide a function which takes a START..END, then finds which part of the existing parse tree cover that region and "reads the tree" to fontify the corresponding text. Stefan