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: Sat, 07 Aug 2021 15:53:24 -0400 Message-ID: References: <83r1f7hydn.fsf@gnu.org> <95F37923-5BF9-4D81-B361-267CF119FBCA@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="1837"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Fu Yuan , Eli Zaretskii , cpitclaudel@gmail.com, stephen_leake@stephe-leake.org, emacs-devel@gnu.org To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 07 21:54:11 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 1mCSOY-0000H8-NA for ged-emacs-devel@m.gmane-mx.org; Sat, 07 Aug 2021 21:54:10 +0200 Original-Received: from localhost ([::1]:44948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCSOX-0002Lj-FM for ged-emacs-devel@m.gmane-mx.org; Sat, 07 Aug 2021 15:54:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCSO1-0001UC-5w for emacs-devel@gnu.org; Sat, 07 Aug 2021 15:53:37 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCSNx-0004a0-6p; Sat, 07 Aug 2021 15:53:35 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C1A371001F4; Sat, 7 Aug 2021 15:53:31 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id BBD0F1000CF; Sat, 7 Aug 2021 15:53:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1628366005; bh=iDs4YYb6V1+p6sC4BNU8jcxj0C7iLn2iG7iJiVQ6nu8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=SGeUeHtCOOiGweVeKpzxAsP+sv74IK6BIlWSjSyeqhYXYrsxp3eELHHeHHUg8wl0d GIxdmuPB376B+8mLwbl2BMYNk4sufSjAIxiIAIbJNfoYjRNY0gimCOIyNMcrhpAbjZ mK30hVdjuFp6FGeZ0fTuEYmvV3TrfOwA9nRDJBkccZfX8ScS2LReMI+5vhv2/rUIhu 5tHt4LMuPs1mJSfCzQ7qcTPchkHrIkg1+knMW1e6/ovgqaIdtdxJbNI94WkPCyqQ1w XfGU8ztkQr80zrL+ZyKHGZF7Fp6/I88sHhLhRp5rS1+jMq9/W/ejzkaMS9CXzyTmq/ txYTJ78PnEYDA== Original-Received: from alfajor (unknown [216.154.29.138]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6D91612027F; Sat, 7 Aug 2021 15:53:25 -0400 (EDT) In-Reply-To: (Theodor Thornhill's message of "Sat, 07 Aug 2021 20:40:34 +0200") 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:272178 Archived-At: > Yeah, though that quickly becomes not so simple, considering that > different languages have their own idiosyncrasies with indentation. C#, > for instance, is a rats nest of particularities. And this is not > considering variations of style guides etc. It would be nice to get an > api similar to what CC mode has. I'm thinking of rules specified via a function that takes a TS node (from which the function can explore the rest of the TS tree) and return the indentation to use, represented as a pair (POSITION . OFFSET) (meaning to indent OFFSET columns further than the column position of POSITION). The infrastructure would limit itself to making sure we have an uptodate tree (computed from a properly widened buffer), find the node corresponding to point pass it to the function and then turn the return value into an actual column and indent the text accordingly (paying attention to the usual difference between when point is "within the indentation" vs "within the text"). Stefan