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 21:06:51 +0100 Message-ID: <87a63zyo4k.fsf@thornhill.no> References: 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="15569"; 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 21:07:19 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 1p30hK-0003ip-02 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Dec 2022 21:07:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p30h7-0001gZ-0K; Wed, 07 Dec 2022 15:07: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 1p30h5-0001gM-67 for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 15:07: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 1p30h4-0000Zl-TI for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 15:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p30h4-0002uo-D6 for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 15:07: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 20:07: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.167044361611198 (code B ref 59662); Wed, 07 Dec 2022 20:07:02 +0000 Original-Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 20:06:56 +0000 Original-Received: from localhost ([127.0.0.1]:51999 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p30gy-0002uY-CY for submit@debbugs.gnu.org; Wed, 07 Dec 2022 15:06:56 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:33898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p30gv-0002uS-GN for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 15:06:56 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670443612; 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=o1DISV8e771Dd1FztYPgz+T5WXMox2KZnvOPp2y07+U=; b=0j3bSBh4BOhhDswys3KYD44jhwI/9j0axcAOJcs2etera08CdBpcG/KgZBbZl6qCuPubHz bc3+PhlXXF0XLrT3QKxtQKlnleR8lfzVg/khZcO7MHm4fyj8zDis9M06OQ9qqv/K060UiX bfBSK/aGeaMxNWP7nozTxaizMFwxrXsDq0pvMER764g697be/jBpfYKZOCcm9vKP4CFhCq bH8RLkMZtOS3TYq/np6zTyOPylxSIrCJABEMj7bPNioO7dKAIzXhVtumNpYI7x/+xuAlM6 fWDwJIubv9Gl32OLklduMb5XJO9m+txFSAHhYe92Kww9ukROJwrhnnBU+n/xRg== In-Reply-To: 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:250217 Archived-At: Yuan Fu writes: > Theodor Thornhill writes: > >> Eli Zaretskii writes: >> >>>> From: Theodor Thornhill >>>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army k= nife >>>> of text editors" , Eli Zaretskii , >>>> casouri@gmail.com, 59662@debbugs.gnu.org >>>> 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: >>>> >> >>>> >>> Right - thanks. However, this makes me wonder - should we really = be >>>> >>> setting mark here? I see that c-indent-defun does not, and it feels >>>> >>> weird that indenting adds to the mark ring. What do you think? My >>>> >>> first patch used >>>> >>> >>>> >>> (indent-region >>>> >>> (treesit-node-start node) >>>> >>> (treesit-node-end node)) >>>> >>> >>>> >>> Which behaves similarly to c-indent-defun. >>>> >>> >>>> >>> See attached patch. >>>> >> >>>> >>I don't have a strong opinion, but if we can indent without setting = the >>>> >>mark, I think it'd be a cleaner command. Specially if c-indent-defun >>>> >>doesn't set the mark either. >>>> > >>>> > Yeah, we don't need to set the mark. Thanks for the feedback :) >>>> > Theo >>>>=20 >>>> Eli, do you have any opinion on this matter? Should we implement this >>>> function without using marks? That will make the function a smidge >>>> bigger, but would not mess up the mark-ring. I think that's desirable, >>>> at least. >>> >>> IMO, it is better not to set the mark, indeed. >> >> Agreed, see attached patch. What do you think, Yuan and Eli? >> >> Should we expose the internal helper I used, or maybe this function >> could just as well live in treesit.c? >> >> Theo >> > > Very nice, I applied this patch with some changes to the function. I > think using treesit-beginning/end-of-defun is more robust. > > Yuan Thanks! Would you mind describing why? Theo