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#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions Date: Sun, 05 Feb 2023 11:25:52 +0100 Message-ID: References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <83lelcsc2s.fsf@gnu.org> <87lelc796q.fsf@thornhill.no> <83h6w0s9ik.fsf@gnu.org> 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="30245"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 05 11:27:16 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 1pOcEu-0007bB-DX for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Feb 2023 11:27:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOcEi-0008IY-Hj; Sun, 05 Feb 2023 05:27:04 -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 1pOcEg-0008I6-VB for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 05:27:02 -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 1pOcEg-0000Qb-NM for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 05:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOcEg-0004L9-J5 for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 05:27: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: Sun, 05 Feb 2023 10:27: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.167559277016602 (code B ref 61142); Sun, 05 Feb 2023 10:27:02 +0000 Original-Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 10:26:10 +0000 Original-Received: from localhost ([127.0.0.1]:44139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOcDp-0004Jh-QB for submit@debbugs.gnu.org; Sun, 05 Feb 2023 05:26:10 -0500 Original-Received: from out-218.mta0.migadu.com ([91.218.175.218]:31723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOcDk-0004JU-M5 for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 05:26:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1675592762; 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=9IpKRbt6N4qPGKc63mwXvL6kC//L0HslbYVSdlbvCeo=; b=fHgu3KbVniFKal5LXIiG7P5NderCrerszV1TdRlcJWkHuqzCAgSrAO4eXnwkOc0HsP8YYN nGtde24pXKa939XmYaBr1ajO9hN9YgYP9L0o2Ly5gg5hCMUmbBLsUPqslxiO7ruSG8L6G1 bF7swgExyFDzSIfAURKGcmVPoF2Tmqog7mgsqFyVI5yUXwEFDyArz5oPRcRdokO9dXLsXW bSYy6+3PZRitGIIFQzddEdxiL99oBLvcVwsGj0Z2XzEv7lIHoK1X56EzbQdRAqfo/pUVII FSHrmF9uKzS1Woo770db+m9eXdOgpfaLPbg8chb+x53RsRk6Ck8+msuRVnbW1Q== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <83h6w0s9ik.fsf@gnu.org> 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:254839 Archived-At: On 5 February 2023 11:15:47 CET, Eli Zaretskii wrote: >> From: Theodor Thornhill >> Cc: zjyzhaojiyang@hotmail=2Ecom, 61142@debbugs=2Egnu=2Eorg >> Date: Sun, 05 Feb 2023 10:28:29 +0100 >>=20 >> Eli Zaretskii writes: >>=20 >> > >> > The procedure is "git cherry-pick", but I don't think I understand >> > what exactly is the problem here and what is the solution suggested t= o >> > solve it=2E Also, why does it need to be on emacs-29=2E Can you hel= p me >> > understand that? >> > >>=20 >> No need to have the test files on emacs-29=2E I could just as well add= a >> test when emacs-29 is synced to master later=2E The test-files themsel= ves >> don't exist on emacs-29=2E > >OK, but still: what exactly is the problem that your patch is trying >to fix? I didn't understand that from the original report=2E > Oh right!=20 There are some indentation issues where if you have=20 void foo( String foo) { // =2E=2E=2E } Then the normal code will indent like void foo( String foo) { //=2E=2E=2E } Because of the parent-bol anchor=2E When these paired brackets are nested = (and some other cases) we have to find the grand-parent, but that caused so= me other issues with ie c-ts-mode where compound_statements can be nested _= and_ siblings=2E Yuan made an effort to make this work in c-ts-mode due to = the many bug reports=2E He then generalized it into c-ts-common, for use in= other modes, like java=2E This patch adds support for that in java=2E >And one comment to the patch: > >> @@ -300,6 +302,20 @@ java-ts-mode >> (c-ts-common-comment-setup) >> =20 >> ;; Indent=2E >> + (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) >> =20 >> ;; Electric > >Why are we adding a c-ts-common-SOMETHING variable to java-ts-mode=2Eel? >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 c= ode in c-ts-common=2E Theo