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#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions Date: Sun, 05 Feb 2023 12:59:43 +0200 Message-ID: <83bkm8s7hc.fsf@gnu.org> References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <83lelcsc2s.fsf@gnu.org> <87lelc796q.fsf@thornhill.no> <83h6w0s9ik.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24089"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.com To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 05 12:00:18 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 1pOckr-0006A8-SP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Feb 2023 12:00:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOckf-0001YA-0Z; Sun, 05 Feb 2023 06:00: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 1pOckd-0001Xx-Cd for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 06:00: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 1pOckc-0005M2-SI for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 06:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOckc-0005CI-GO for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 06:00: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: Sun, 05 Feb 2023 11:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61142 X-GNU-PR-Package: emacs Original-Received: via spool by 61142-submit@debbugs.gnu.org id=B61142.167559478419923 (code B ref 61142); Sun, 05 Feb 2023 11:00:02 +0000 Original-Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 10:59:44 +0000 Original-Received: from localhost ([127.0.0.1]:44151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOckK-0005BH-5V for submit@debbugs.gnu.org; Sun, 05 Feb 2023 05:59:44 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOckG-0005B2-7L for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 05:59:42 -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 1pOckA-0005IZ-BX; Sun, 05 Feb 2023 05:59:34 -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=yTREXRK+SdHynRUwSr3Z5uM+uUICesnJxY4y9I1S32Q=; b=aUoXEA/G1sC2 Y7LIO9y8m8ll6jf1D6iX3sRcdFT88UlE/m/wBS0oxsqc+1aCtRAm51d6/1d7U4fwLXTwzp8dGe66M QyTWhYZJj3CL++yyPj9BsblowiLQYUEzHWKfgS2z/oPgS5cZfAfw5pa0HPgBmmh7OaAodNM+pkGoz MzdGS1cM/6SwxVfOpL2c272q0+msSb6c4pvmS0B6xF8MGnToVzmFczeRhFjvcMrzz0ycJU3mfT0f2 JPg6noTMLemsilxVwLtNLsBklK8jWQMYo2olyFjB5ILZ+fb+6PX/vwixoeHcywnmPxgpWme2aa9qc NfMAPhk3FxJpeoSqSm8teg==; 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 1pOck9-0006pt-Ly; Sun, 05 Feb 2023 05:59:33 -0500 In-Reply-To: (message from Theodor Thornhill on Sun, 05 Feb 2023 11:25:52 +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:254840 Archived-At: > Date: Sun, 05 Feb 2023 11:25:52 +0100 > From: Theodor Thornhill > CC: zjyzhaojiyang@hotmail.com, 61142@debbugs.gnu.org > > There are some indentation issues where if you have > > void foo( > String foo) { > // ... > } > > Then the normal code will indent like > > void foo( > String foo) { > //... > } > > Because of the parent-bol anchor. When these paired brackets are nested (and some other cases) we have to find the grand-parent, but that caused some other issues with ie c-ts-mode where compound_statements can be nested _and_ siblings. Yuan made an effort to make this work in c-ts-mode due to the many bug reports. He then generalized it into c-ts-common, for use in other modes, like java. > > This patch adds support for that in java. > > > >And one comment to the patch: > > > >> @@ -300,6 +302,20 @@ java-ts-mode > >> (c-ts-common-comment-setup) > >> > >> ;; Indent. > >> + (setq-local c-ts-common-indent-block-type-regexp > >> + (rx (or "class_body" > >> + "\\`array_initializer" > >> + "annotation_type_body" > >> + "interface_body" > >> + "interface_constructor_body" > >> + "enum_body" > >> + "switch_block" > >> + "record_declaration_body" > >> + "block"))) > >> + (setq-local c-ts-common-indent-bracketless-type-regexp > >> + (rx (or "if_statement" "do_statement" > >> + "for_statement" "while_statement"))) > >> + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) > >> (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) > >> > >> ;; Electric > > > >Why are we adding a c-ts-common-SOMETHING variable to java-ts-mode.el? > >Shouldn't it be named java-ts-SOMETHING instead? Or am I missing > >something? > > This is because there is some setup involved in the new bracket-counting code in c-ts-common. OK, please install on emacs-29, and thanks.