From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter api (Was: Re: How to add pseudo vector types) Date: Sat, 07 Aug 2021 09:26:30 +0300 Message-ID: <83a6ltixd5.fsf@gnu.org> References: <83r1f7hydn.fsf@gnu.org> <95F37923-5BF9-4D81-B361-267CF119FBCA@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25962"; mail-complaints-to="usenet@ciao.gmane.io" Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Fu Yuan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 07 08:27:14 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 1mCFne-0006XN-7B for ged-emacs-devel@m.gmane-mx.org; Sat, 07 Aug 2021 08:27:14 +0200 Original-Received: from localhost ([::1]:59184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCFnc-0000Mk-PV for ged-emacs-devel@m.gmane-mx.org; Sat, 07 Aug 2021 02:27:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCFmu-00086h-8q for emacs-devel@gnu.org; Sat, 07 Aug 2021 02:26:28 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48556) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCFmt-0004xn-El; Sat, 07 Aug 2021 02:26:27 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4175 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCFmt-0006Lc-0T; Sat, 07 Aug 2021 02:26:27 -0400 In-Reply-To: <95F37923-5BF9-4D81-B361-267CF119FBCA@gmail.com> (message from Fu Yuan on Sat, 7 Aug 2021 00:31:36 -0500) 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:272161 Archived-At: > From: Fu Yuan > Date: Sat, 7 Aug 2021 00:31:36 -0500 > Cc: cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, > monnier@iro.umontreal.ca, emacs-devel@gnu.org > > > We should probably start thinking how to integrate TS-related > > functionalities into Emacs in general. E.g., should there be an > > option to activate it? should this option be per major mode? something > > else? > > 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. > > We also need tree-sitter-maximum-buffer-size, so that buffer larger than this size won’t enable tree-sitter. (And we need to make sure we never use tree-sitter on buffers larger than 4GB because tree-sitter uses unint32.) > > And we can provide a function free-sitter-should-activate-p that computes if we should enable tree-sitter in the current buffer by variables mentioned above, that can be used by major-modes when setting up. > > I’m also thinking about having a tree-sitter-defaults that’s analogous to font-lock-defaults, that is set by each major node and used to generate tree-sitter-font-lock-settings. > > As for indentation, we could provide some infrastructure like we do for font-locking, or we can just let major modes implement their indent function with tree-sitter api. SGTM, thanks.