From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#62717: 29.0.60; c-ts-mode does not indent the first line in a function after RET Date: Sun, 9 Apr 2023 19:30:43 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14259"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Cc: 62717@debbugs.gnu.org, Yuan Fu , Theodor Thornhill , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Alan Mackenzie To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 09 18:31:19 2023 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 1plXwj-0003R8-6q for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Apr 2023 18:31:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plXwW-0008R5-HI; Sun, 09 Apr 2023 12:31:04 -0400 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 1plXwU-0008Qf-EV for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 12:31:02 -0400 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 1plXwU-0007Ft-6i for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 12:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1plXwT-0008Cy-Nf for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 12:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Apr 2023 16:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62717 X-GNU-PR-Package: emacs Original-Received: via spool by 62717-submit@debbugs.gnu.org id=B62717.168105785431534 (code B ref 62717); Sun, 09 Apr 2023 16:31:01 +0000 Original-Received: (at 62717) by debbugs.gnu.org; 9 Apr 2023 16:30:54 +0000 Original-Received: from localhost ([127.0.0.1]:33575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plXwL-0008CY-ND for submit@debbugs.gnu.org; Sun, 09 Apr 2023 12:30:54 -0400 Original-Received: from new3-smtp.messagingengine.com ([66.111.4.229]:59991) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plXwJ-0008CJ-TG for 62717@debbugs.gnu.org; Sun, 09 Apr 2023 12:30:52 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 8E7F5581F8E; Sun, 9 Apr 2023 12:30:46 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 09 Apr 2023 12:30:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1681057846; x=1681061446; bh=uJmSuKYqztw3zNRUdqu5PPFTBuAF6YaNOnW /o8JXQJ4=; b=jCdyrUhl/V0XXk8gFMnFN4xhghN/TrXMeMFpHop0n1jXIyQevsE 5ZkjSqXZxWCqk9gNadUhvihB9PCkps+CxN6CYX6sK3k6sD8QEnkTuvnSMvb8+LUB +NXjPe79Mhu1LgpVIRbE1PLVCy9RWqKTl9Cxra6NHm51cihbBBsSptfw74n58jHy irgd6cabc05Iuc3PKL87/n//R61JSamD3IoBXIcfMiMCIUdP0gkmtIe96bot6Edx aAcKgYdM+a+TXuBYPsVTh8NQJZoVvD+EY0B3hg6jCe1/QT+72wIju+kWhkhuVHhf 6rwultGhiVgcQoI/VRJMFjcAYberSAH8Ktg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1681057846; x=1681061446; bh=uJmSuKYqztw3zNRUdqu5PPFTBuAF6YaNOnW /o8JXQJ4=; b=rnP+dDr3xA7/hJkI6SiOZcut99Sny4ebEY5GRixRdHMeUiRkUCS SRFUQ38LPwgTuEnL5OuOXdtDwrfoWIC6Ma11+LmSYcz0Z4nqXlXDws82o/5iX/40 lC5vKOi+Df88qvZr++u1y6IMfPqETX8T9QtJQ5+tXoFgU6WXBtHeivzoXuPosPB9 DkT8m1RSEE4VLgz9ZGaAEZA6j6xnIVqlXOYPeWVlwxbp2Z3N9HaULMVi4KEEnG8n pyJw75qAJRoDJVIkJKJV+P4APNWhJgbf/SaVnrv2ECyqH8kQ7iUlFNSg+5qBEdfh J04Fnsp57bWAwhWH9Trpb25o+JjGvuecSqA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdektddguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpefhffehleejffegffeugefhkeektdffgfehjedvgeejtedtudehueffgffg feejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 9 Apr 2023 12:30:44 -0400 (EDT) Content-Language: en-US In-Reply-To: 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:259526 Archived-At: On 09/04/2023 14:05, Daniel Martín wrote: > Dmitry Gutov writes: > >> >> I'm not sure, though, what is the big deal with adding the top-level >> function's closing curly first thing before writing the body (after >> that the parser starts working much better), so as far as I'm >> concerned this patch is very optional. It does add some complexity, >> after all. > > I think this problem also affects languages without curly braces like > Ruby or Python. Python -- no, because it doesn't have closers. And its indentation doesn't use tree-sitter anyway. > For example, if I insert this Ruby code in a buffer with ruby-ts-mode > enabled > > def sample RET > > The newline is not indented, but it is indented in ruby-mode. Right. I mentioned that in the previous email: a fix for ruby-ts-mode will involve a similar (but slightly different) advice together with a new indentation rule. I'm not quite certain yet we want to go there, because a top-level function is more rare in Ruby than in C/C++. And, again, as soon as there is at least once 'end' below the current line in the buffer, things start working much better. The user can either type is manually, or use ruby-end-mode. >> Adding Alan and Joao, who were interested in this scenario as well. >> >> diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el >> index 981c7766375..9aaa8b32c73 100644 >> --- a/lisp/progmodes/c-ts-mode.el >> +++ b/lisp/progmodes/c-ts-mode.el > > Thanks for the patch. It works correctly and the existing c-ts-mode > tests pass. I suggest adding a test to prevent regressions: > > diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts > index 5cdefe2122c..221b3d809af 100644 > --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts > +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts > @@ -464,3 +464,17 @@ main (void) > | > } > =-=-= > + > +Name: Empty Line (Block Start) > + > +=-= > +int > +main (void) > +{ > +| > +=-= > +int > +main (void) > +{ > + | > +=-=-= Good idea, thanks.