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.bugs Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Date: Thu, 08 Dec 2022 10:27:39 +0200 Message-ID: <83r0xa2tc4.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17201"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, dgutov@yandex.ru, larsi@gnus.org, casouri@gmail.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 08 09:29:20 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 1p3CHQ-0004Fv-I5 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Dec 2022 09:29:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3CHA-00047D-II; Thu, 08 Dec 2022 03:29:04 -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 1p3CH8-00046y-Ic for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 03:29: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 1p3CH8-0003EI-4V for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 03:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3CH7-0005fL-I1 for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 03:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Dec 2022 08:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59662 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59662-submit@debbugs.gnu.org id=B59662.167048808621761 (code B ref 59662); Thu, 08 Dec 2022 08:29:01 +0000 Original-Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 08:28:06 +0000 Original-Received: from localhost ([127.0.0.1]:55241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3CGD-0005ev-Rf for submit@debbugs.gnu.org; Thu, 08 Dec 2022 03:28:06 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58302) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3CG9-0005eW-5S for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 03:28:04 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3CG0-0002bL-IV; Thu, 08 Dec 2022 03:27:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=3YZ5B3G5YBohp6x7q/pI16WbXRC4ZjOp1JmddUxcAWE=; b=ngO6R3ZLXR75 kpjMmMH75yKTXQBjUMwagJuAt5AItvKinCuxZyt+8AwhkGSqOVmZYr4fV4xJTjf3rVwjoIPzSs7zN KZIlmel9vtRHmQbl2qkgM6j1t+DU/KdPDrxAQ6YH3pfr0pmfPMfD/XU2/jS+OaunGlQc/9DmfrCsn L1Yenqu6bhaYeCQVOwK+rXnAFo9vP5kzp5zDKJCUglXWiROxN2lRKCiguLZbPdxivYe4dpktNZCZ5 WWWIvIIn26U41BAtbCw0x04oGmODdJsEI87mc3c2dp24UcJF+9TLiAId1dL0iuPJJyOQyWMSMbESZ v+YIE7w5oyk/m7pBCRQYAQ==; Original-Received: from [87.69.77.57] (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 1p3CFz-0003gX-Fa; Thu, 08 Dec 2022 03:27:52 -0500 In-Reply-To: <875yemz55b.fsf@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 09:11:28 +0100) 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:250251 Archived-At: > From: Theodor Thornhill > Cc: casouri@gmail.com, 59662@debbugs.gnu.org, casouri@gmail.org > Date: Thu, 08 Dec 2022 09:11:28 +0100 > > > Bonus points for adding something that could use treesit.el > > capabilities, when those are available, instead of syntax-ppss, to > > determine when we are in a comment or in a string. Or maybe Theo or > > Yuan could suggest such an addition. > > This works perfectly as is in *-ts-modes. At least for modes where > syntax-table is set correctly. I don't think there's a reason to enable > treesit.el capabilities, unless there's a case where this doesn't work. My point is that tree-sitter in many cases parses the program better than syntax-ppss. So if we can use its information about comments and strings, why not do that? It's exactly the same logic that Dmitry used: > + (if (or (nth 8 (syntax-ppss)) > + (re-search-forward comment-start-skip (line-end-position) t)) which falls back on regexp search if syntax-ppss cannot help. I'm asking why not try tree-sitter before we fall back on syntax-ppss or regexp search? Does that make sense? If not, why not? > If this ends up in master, should I backport some similar feature for > the *ts-modes? Why do we need this on the release branch? A general indent-or-fill-comment feature for all the progmodes didn't exist until now, which is why we intend to install this on master.