From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Date: Wed, 07 Dec 2022 22:53:03 +0100 Message-ID: <6AD2610D-8A71-4F34-A8CC-119C2FB55C40@thornhill.no> References: <87a63zyo4k.fsf@thornhill.no> <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32049"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 07 22:54:27 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 1p32Mz-00085A-C6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Dec 2022 22:54:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p32Mf-0005vl-8v; Wed, 07 Dec 2022 16:54: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 1p32Md-0005vU-FL for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 16:54: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 1p32Md-0006Is-5H for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 16:54:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p32Mc-0003nE-H5 for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 16:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Dec 2022 21:54: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.167045001914566 (code B ref 59662); Wed, 07 Dec 2022 21:54:02 +0000 Original-Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 21:53:39 +0000 Original-Received: from localhost ([127.0.0.1]:52419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p32ME-0003ms-SP for submit@debbugs.gnu.org; Wed, 07 Dec 2022 16:53:39 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:11275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p32MC-0003mm-D0 for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 16:53:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670450014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nzfyyMfOH1kVaCQe9Oo2rxwOBR9/3fTMSzXYxIHhJRg=; b=O6GjR4QEEvVXdhgG4RTsR/oJpSb26qLaviHKSmjGd3hcaV7usi90vGdggK2XKVAeGj4xu6 X8IKLX1IxZE4+ElfiQfZ4Jtgt16pjlONbXFdqugrLz21d70gVMd7S3GL90Wl93CCPq9SUB PvlMpBKjy4Y987vzp90tKHzDpN5AGByvdvFVzReyUgn3l82fOCoZVCclIflaQ1bBibFgUf KTp2aoQVvPkN/OeyHjouX1cQ93de04CO4E+R5/wq6gxTMRJJWEHUDW98kLgL7wKmQOh+qo ibjFCW31wOy6xDbq1eIk84Ajk+wMMVUiUIp73qSLAfwRTMNM2Ol1iipwAmlBog== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> X-Migadu-Flow: FLOW_OUT 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:250219 Archived-At: On 7 December 2022 22:40:31 CET, Yuan Fu wrote: > > >> On Dec 7, 2022, at 12:06 PM, Theodor Thornhill wr= ote: >>=20 >> Yuan Fu writes: >>=20 >>> Theodor Thornhill writes: >>>=20 >>>> Eli Zaretskii writes: >>>>=20 >>>>>> From: Theodor Thornhill >>>>>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss arm= y knife >>>>>> of text editors" , Eli Zaretskii , >>>>>> casouri@gmail=2Ecom, 59662@debbugs=2Egnu=2Eorg >>>>>> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>>>>>=20 >>>>>> Theodor Thornhill writes: >>>>>>=20 >>>>>>> On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" wrote: >>>>>>>> Theodor Thornhill writes: >>>>>>>>=20 >>>>>>>>> Right - thanks=2E However, this makes me wonder - should we rea= lly be >>>>>>>>> setting mark here? I see that c-indent-defun does not, and it fe= els >>>>>>>>> weird that indenting adds to the mark ring=2E What do you think= ? My >>>>>>>>> first patch used >>>>>>>>>=20 >>>>>>>>> (indent-region >>>>>>>>> (treesit-node-start node) >>>>>>>>> (treesit-node-end node)) >>>>>>>>>=20 >>>>>>>>> Which behaves similarly to c-indent-defun=2E >>>>>>>>>=20 >>>>>>>>> See attached patch=2E >>>>>>>>=20 >>>>>>>> I don't have a strong opinion, but if we can indent without setti= ng the >>>>>>>> mark, I think it'd be a cleaner command=2E Specially if c-indent= -defun >>>>>>>> doesn't set the mark either=2E >>>>>>>=20 >>>>>>> Yeah, we don't need to set the mark=2E Thanks for the feedback :) >>>>>>> Theo >>>>>>=20 >>>>>> Eli, do you have any opinion on this matter? Should we implement th= is >>>>>> function without using marks? That will make the function a smidge >>>>>> bigger, but would not mess up the mark-ring=2E I think that's desi= rable, >>>>>> at least=2E >>>>>=20 >>>>> IMO, it is better not to set the mark, indeed=2E >>>>=20 >>>> Agreed, see attached patch=2E What do you think, Yuan and Eli? >>>>=20 >>>> Should we expose the internal helper I used, or maybe this function >>>> could just as well live in treesit=2Ec? >>>>=20 >>>> Theo >>>>=20 >>>=20 >>> Very nice, I applied this patch with some changes to the function=2E I >>> think using treesit-beginning/end-of-defun is more robust=2E >>>=20 >>> Yuan >>=20 >> Thanks! Would you mind describing why? > >Yes, sorry=2E I=E2=80=99m planning to change treesit-beginning-of-defun a= nd treesit-end-of-defun so they can behave differently according to user co= nfiguration, basically they can decide whether to skip nested defuns or not= =2E If we use these functions rather than re-implementing their logic (to s= ome extent) in c-ts-mode-indent-defun, any improvement to defun navigation = would automatically benefit c-ts-mode-indent-defun=2E > >Yuan Thanks for explaining your rationale=2E=20 By the way, there's an issue with the patch you applied: void foo() { =2E=2E=2E } If point is at the v in void, the current implementation will not reinvent= =2E I didn't get time to debug yet, though=2E Possibly that will be fixed a= fter your rework as well=2E Theo