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 12:39:34 +0200 Message-ID: <83o7se2n89.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> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="622"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 08 11:40:22 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 1p3EKD-000AYz-IX for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Dec 2022 11:40:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3EJx-0007o5-3h; Thu, 08 Dec 2022 05:40:05 -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 1p3EJv-0007lq-1O for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 05:40:03 -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 1p3EJu-0007rB-OZ for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 05:40:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3EJu-00006V-52 for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 05:40:02 -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 10:40:02 +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.1670495999387 (code B ref 59662); Thu, 08 Dec 2022 10:40:02 +0000 Original-Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 10:39:59 +0000 Original-Received: from localhost ([127.0.0.1]:55946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3EJp-00006B-DG for submit@debbugs.gnu.org; Thu, 08 Dec 2022 05:39:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3EJl-000065-Gc for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 05:39:56 -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 1p3EJd-0007IZ-GW; Thu, 08 Dec 2022 05:39:45 -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=kLftWve1EDFss/df1QbMkGn5NiL5zVoNX1QsTJXkSSo=; b=roqqJu+cAdp1 Y28Llmy1248k0A4hwDhYIIb3IGyD9hFpmsfhPlaC8ZzMcqw+gDjWEAprN1aBSZNRGfg661mXVpqC0 rhlHZTJlvwHhoiiXqIgi394qtPdZ9oxVM8+ZNBnhfql53md40yIK4aQ9a+N5Q/p3+rRFDUlOOj/tY xTEFlQdjo12XmfCUtrUDyx6q4/n4qk5QfmZvHW1DwlEo+gKiFdbPfnfN8ywbu/tOBDJYEYGItUsxG AIzONgRzj7ubfmPeDv4gBwk+qcnX4btk5Y1oivVUMbZFmetV+Bz3KJjQEnmFxnL/5fkyqIFOmlkaW Jk5HvybFAYjbWpni3UnDKQ==; 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 1p3EJc-00025L-Ps; Thu, 08 Dec 2022 05:39:45 -0500 In-Reply-To: <87zgbyxohf.fsf@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 09:56:44 +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:250266 Archived-At: > From: Theodor Thornhill > Cc: dgutov@yandex.ru, monnier@iro.umontreal.ca, larsi@gnus.org, > 59662@debbugs.gnu.org, casouri@gmail.org > Date: Thu, 08 Dec 2022 09:56:44 +0100 > > Eli Zaretskii writes: > > > 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: > > > > Something like this? If we add a defvar such as the below, similar to > treesit-defun-type-regexp we can use that in the function below: > > ``` > (defvar-local treesit-comment-type-regexp nil > "A regexp that matches the node type of comment nodes. > > For example, \"(line|block)_comment\". ") The intent is that major modes set this variable? SGTM. > (if (or (and (treesit-available-p) > (treesit-ready-p (treesit-language-at (point))) I'd imagine that this kind of test should have an API, so the treesit-ready-p call should not be made explicitly? Yuan, WDYT? Also, isn't it enough to check whether the buffer has a tree-sitter parser or something? > The error handling here is naive, but is this something in the line of > what you're suggesting? Yes, it is what I had in mind, but see above.