From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter api Date: Sun, 08 Aug 2021 19:24:38 -0400 Message-ID: References: <83r1f7hydn.fsf@gnu.org> <95F37923-5BF9-4D81-B361-267CF119FBCA@gmail.com> <68AF72EA-8662-4508-B46C-0ACA94A20E86@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34085"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Eli Zaretskii , =?windows-1252?Q?Cl=E9ment?= Pit-Claudel , Stephen Leake , emacs-devel To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 09 01:25:36 2021 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 1mCsAi-0008er-3a for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Aug 2021 01:25:36 +0200 Original-Received: from localhost ([::1]:36062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCsAf-0003sz-R3 for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Aug 2021 19:25:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCs9t-0003DA-0m for emacs-devel@gnu.org; Sun, 08 Aug 2021 19:24:45 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCs9r-0007L0-4x; Sun, 08 Aug 2021 19:24:44 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1E90D440213; Sun, 8 Aug 2021 19:24:41 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BB9DF4407D1; Sun, 8 Aug 2021 19:24:39 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1628465079; bh=XakfjLI9D2OrH8cIGehOGjoOHeM9++54uN0qVui0VrQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=ZM+YxE9iEv2jLxNGKvzZcyjmZDZUSZ8TF1r6MJ/cJB8KV8SM4B7aZe0+Z8rKTVsEX /ba/X8ygxf+SCnZ2TiTqLAnzKNUrOWVdmBxxktwdM7CbG2mttjq0Ax/+K//keG+Z8y T0JwHntMAKO1H9Ps3t8fWGnnaXuMnVXmQ+jh7uy282yxatsEpySbR3WiLTtDuzgJNe BBQ0HxQIylzpvCbuV2H3zjZIeEaFsAWvhSg4NnqtQWezFzSPi4w9v30Qh9pMK4EZ5y EIr7bzMUN2OB9cytlSciXqnj45vhm1Z5G0va822lp0+hdGfJgRXzH8mVeCP1vYLPyc ukPHCjHpvpH6Q== Original-Received: from alfajor (unknown [216.154.29.138]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6AD7C12020A; Sun, 8 Aug 2021 19:24:39 -0400 (EDT) In-Reply-To: <68AF72EA-8662-4508-B46C-0ACA94A20E86@gmail.com> (Yuan Fu's message of "Sun, 8 Aug 2021 17:56:33 -0500") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:272215 Archived-At: Yuan Fu [2021-08-08 17:56:33] wrote: >> On Aug 7, 2021, at 10:47 AM, Stefan Monnier wrote: >>> We should have a user option to control tree-sitter on major mode >>> level. Maybe an alist where each car is a major node symbol and each cdr is >>> a Boolean value toggling tree-sitter for that node. >> The more traditional approach is to use a buffer-local var set by the >> major mode or set via (add-hook '-hook ...). > The major-mode would setup things like font-lock-defaults and > tree-sitter-defaults before major-mode-hook runs, so I think > enabling/disabling tree-sitter in the hook is too late, no? I don't see why. Presumably the major mode would set some vars relevant to the tree-sitter support, but then whether those vars are used will depend on the buffer-local boolean var (let's call it `tree-sitter-mode`). I'm sure there will be issues w.r.t initialization order, e.g. in case `font-lock-mode` is enabled before `tree-sitter-mode`, but that doesn't seem very serious (`font-lock-mode` doesn't do much anyway, since the real work is postponed until the next redisplay by jit-lock, so we could "refresh" font-lock settings fairly cheaply within `tree-sitter-mode`). Stefan