all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "赵 纪阳" <zjyzhaojiyang@hotmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: "61142@debbugs.gnu.org" <61142@debbugs.gnu.org>
Subject: bug#61142: 回复: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions
Date: Sun, 5 Feb 2023 13:09:19 +0000	[thread overview]
Message-ID: <OSZP286MB141720BF3D08F8E5195C4FAFA8D59@OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <87r0v47dky.fsf@thornhill.no>

[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

Thanks for the patch.

I've not tested this patch adequately, but I found an issue:
java-ts-mode indents the body of `else if` with one more level of indentation.

```
public class T {
    int f() {
        int a = 0;
        int b = 1;
        if (a == 0
            && b == 1) {
            // indentation ok
            return 0;
        } else if (a == 1 ) {
                // indentation more
                return 1;
            }
    }
}
```
If the second branch of the if-statement is just an `else` (not `else if`), the body of it will be indented correctly.


I've also tested c-ts-mode (use 'linux as c-ts-mode-indent-style) and it also has this kind of problem.
```
int main() {
    int a = 0;
    if (a == 0) {
        // indentation ok
    } else if (a == 2) {
            // indentation more
        }
}
```

________________________________
发件人: Theodor Thornhill <theo@thornhill.no>
发送时间: 2023年2月5日 15:53
收件人: 太阳 <zjyzhaojiyang@hotmail.com>
抄送: 61142@debbugs.gnu.org <61142@debbugs.gnu.org>
主题: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions

Theodor Thornhill <theo@thornhill.no> writes:

> 太阳 <zjyzhaojiyang@hotmail.com> writes:
>
>> After reading treesit's manual, I found that we can use `n-p-gp` as the matcher
>> and `grand-parent` as the anchor to match the body of `if` (and `while`, which
>> has a similar issue).
>>
>> I mean a rule looks like the following:
>>
>> ```
>> ((n-p-gp nil "block" "if_statement") grand-parent java-ts-mode-indent-offset)
>> ```
>>
>>
>
>
> Thanks!  We have a mechanism in place for this, see
> 'c-ts-common-statement-offset' in 'c-ts-common.el'.  I didn't get to it
> yet, but I'll try to look at it this evening, unless you want to?  See
> c-ts-mode for examples of how to use it, if you're interested!
>
> Theo

Hi again!

Can you test this patch for me?

@Eli: Is this ok for emacs-29?  I'd love to add some test for this, but
now they are on the master branch.  What is the common procedure to move
stuff from master branch to the release branch?  I _can_ just add some
test to the master branch, but it would be nice to have them on emacs-29
too :-)

Theo


[-- Attachment #2: Type: text/html, Size: 6518 bytes --]

  parent reply	other threads:[~2023-02-05 13:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <handler.61142.B.16749811447164.ack@debbugs.gnu.org>
2023-02-01  8:46 ` bug#61142: Acknowledgement (29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions) 太阳
2023-02-04 10:45   ` bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05  7:53     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05  7:54       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05  9:20       ` Eli Zaretskii
2023-02-05  9:28         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 10:15           ` Eli Zaretskii
2023-02-05 10:25             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 10:59               ` Eli Zaretskii
2023-02-05 13:09       ` 赵 纪阳 [this message]
2023-02-05 19:19         ` bug#61142: 回复: " Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 19:30           ` Eli Zaretskii
2023-02-05 19:32             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 20:12               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 21:20                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-06  2:34                   ` bug#61142: 回复: " 赵 纪阳
2023-02-06  6:45                     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OSZP286MB141720BF3D08F8E5195C4FAFA8D59@OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM \
    --to=zjyzhaojiyang@hotmail.com \
    --cc=61142@debbugs.gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.