GNU bug report logs - #61142
29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions

Previous Next

Package: emacs;

Reported by: 太阳 <zjyzhaojiyang <at> hotmail.com>

Date: Sun, 29 Jan 2023 08:33:03 UTC

Severity: normal

Found in version 29.0.60

Fixed in version 29.1

Done: Theodor Thornhill <theo <at> thornhill.no>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 61142 <at> debbugs.gnu.org, zjyzhaojiyang <at> hotmail.com
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
> Date: Sun, 05 Feb 2023 11:25:52 +0100
> From: Theodor Thornhill <theo <at> thornhill.no>
> CC: zjyzhaojiyang <at> hotmail.com, 61142 <at> 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.




This bug report was last modified 2 years and 112 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.