GNU bug report logs - #75650
30.0.93; Unexpected indentation of members of inner classes in java-ts-mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Hennes Märtins <hennes@HIDDEN>; dated Sat, 18 Jan 2025 17:04:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 75650 <at> debbugs.gnu.org:


Received: (at 75650) by debbugs.gnu.org; 18 Jan 2025 23:32:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 18:32:53 2025
Received: from localhost ([127.0.0.1]:44135 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tZIJA-0006vI-RG
	for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 18:32:53 -0500
Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:61852)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1tZIJ6-0006uw-2Q
 for 75650 <at> debbugs.gnu.org; Sat, 18 Jan 2025 18:32:50 -0500
Received: by mail-ed1-x533.google.com with SMTP id
 4fb4d7f45d1cf-5d3d0205bd5so5098472a12.3
 for <75650 <at> debbugs.gnu.org>; Sat, 18 Jan 2025 15:32:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1737243162; x=1737847962; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Shuurnq5CWmEffFOje8WxiUWmzWGQLde8oX+koDNkcM=;
 b=UJvSRUxfW5zenzY64XUASLqDNNmJIef1PcZO/Klu+uu00zGEUHs0sQ/F2pbe1ptCad
 uN4J7/4nuN/wb/LRk65BvdYVaodO0JFzCi9WFofHI3u5WUEmDYmzoBwT4VIrau2WTMTk
 3Pbc4074EApmRidIqulPDEsrthBE38Jz0sVHI2QHtefHX+zcXFhc6akjC9qtBIXzmkl4
 GMIWG9SL7318VPjnk5TUEsOlpoRUwpD0QeawFpgBjKBIAHg+kzJWRbL2YiyPl28AkSP8
 JQ1kyldajGLP3KWj3Iz1433BLKtY8SbuxmTpQsMQwyq6eAKdvHEuJNAkpr/jfwPeQ+XV
 531Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737243162; x=1737847962;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=Shuurnq5CWmEffFOje8WxiUWmzWGQLde8oX+koDNkcM=;
 b=If9q/0eviOe+fVge8lfnwk/cR5b9uissVF+SZE/2JkewtFc/7FNbZiFaY6teSLtwMk
 vkk3s93Da9NFAh8mc3PMSsBMTv3OL2kpXmQCfd5DXy/4sNXa/lNLoz8hB7sQVBCUIRkn
 yEmXMRAU6HqmPeaDAc08JEehEDRGS/pf3Fc9fgoIShR0uskK7jIpINCVaqbIEHxI7I2E
 xCQ2hsPLv5zD0Hs3ZfQSwY8RUEo6CO5I5T0R82nu9Ry4Cz0UPy6TfJOPhPUA15cFVOJ+
 ZU8BmR64eBmS6Q1SV+min+jsb/XbHa0AhFKk0+2pOmT9P81GpqvogbnI8ytfklSJizNc
 2p1w==
X-Forwarded-Encrypted: i=1;
 AJvYcCU8POuvRIdV/yJw9kaT4G1BAmLroA7MugL2LA1Egx+2nZsjZvKx1RcNuVfj39cixyLGi1o4+Q==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Ywm5YNjN6xBdGDLBH2HDwsgPCZleE1cea0OqjgCrRgwMn5rJQjs
 eDSyKxNGhb6iSlfuJvmdidM4hBbgAeyMoMoKErePNwt3XJo9hbL5+DYeo/1glB9lTlGaBiZyWHG
 Kv6PG1fV/6a/EkqyaCvy4B+u4ebg=
X-Gm-Gg: ASbGncvIbDCHG8M/hqB/KRJ6FxLtN8/1UyKNoJf9PYcsOgdy8vO4SL90Lx1hxCbtcAq
 t61cTnUvNILrD62n8rRXTiYxep8IxNRQOha9j8zNX4HgTF9Q50gqO
X-Google-Smtp-Source: AGHT+IEGHn2uNULltDWR580eOJwcEnBYbJd+ksrT4FHJztiK3HVKd1cJ8p2O2Gc4KmXeAYIyqEh9viq97T7kJIee1no=
X-Received: by 2002:a05:6402:270d:b0:5cf:e9d6:cc8a with SMTP id
 4fb4d7f45d1cf-5db7db148e2mr5654928a12.20.1737243161832; Sat, 18 Jan 2025
 15:32:41 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sat, 18 Jan 2025 15:32:41 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <86ikqcp1gm.fsf@HIDDEN>
References: <86ikqcp1gm.fsf@HIDDEN>
MIME-Version: 1.0
Date: Sat, 18 Jan 2025 15:32:41 -0800
X-Gm-Features: AbW1kvYOGZIZ92GiWdqKWPmyAqQtXE7aqz5fYePYQF1iBcPru80eev_YTaUmTx8
Message-ID: <CADwFkmkr7wig9Xm9a0ma_=S+7QJO0iwndnxapqoH6ciWtRdOeg@HIDDEN>
Subject: Re: bug#75650: 30.0.93; Unexpected indentation of members of inner
 classes in java-ts-mode
To: =?UTF-8?Q?Hennes_M=C3=A4rtins?= <hennes@HIDDEN>, 
 75650 <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 75650
Cc: Theodor Thornhill <theo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hennes M=C3=A4rtins <hennes@HIDDEN> writes:

> Create a new java-ts-mode buffer with the following content:
>
> class Foo
> {
>     class Bar
>     {
>         int baz;
>     }
> }
>
> Indent the whole buffer (C-x h <tab>) and it becomes:
>
> class Foo
> {
>     class Bar
>     {
>             int baz;
>     }
> }
>
> The indentation level for baz becomes three, but I would expect it to be
> two. A level of two is used in java-mode too.
>
> If I put the opening curly brace to the end of the previous line, the
> indentation level becomes two as expected:
>
> class Foo {
>     class Bar {
> 	int baz;
>     }
> }
>
> I found a personal workaround for this by modifying the variable
> java-ts-mode--indent-rules. I replace the entry:
>
> ((parent-is "class_body") column-0 c-ts-common-statement-offset)
>
> with:
>
> ((parent-is "class_body") parent-bol java-ts-mode-indent-offset)
>
> That works for me, but I am not sure if that is the correct solution.
>
> I can reproduce this also in:
> GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, ca=
iro version 1.16.0) of 2025-01-18

Theodor, any comments here?

> In GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
>  version 1.16.0) of 2024-12-27 built on starlight
> Repository revision: 186ea407326166ee4669ce6fe84871c1e16c657c
> Repository branch: emacs-30
> Windowing system distributor 'The X.Org Foundation', version 11.0.1210100=
4
> System Description: Ubuntu 22.04.5 LTS




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#75650; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Jan 2025 17:03:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 12:03:56 2025
Received: from localhost ([127.0.0.1]:43565 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tZCEk-0001nF-2E
	for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 12:03:56 -0500
Received: from lists.gnu.org ([2001:470:142::17]:55286)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <hennes@HIDDEN>)
 id 1tZB4e-0006o8-M0
 for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 10:49:25 -0500
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 <hennes@HIDDEN>)
 id 1tZB4X-0004Im-J3
 for bug-gnu-emacs@HIDDEN; Sat, 18 Jan 2025 10:49:17 -0500
Received: from relay.yourmailgateway.de ([188.68.63.162])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <hennes@HIDDEN>)
 id 1tZB4N-000139-0u
 for bug-gnu-emacs@HIDDEN; Sat, 18 Jan 2025 10:49:17 -0500
Received: from mors-relay-8201.netcup.net (localhost [127.0.0.1])
 by mors-relay-8201.netcup.net (Postfix) with ESMTPS id 4Yb1HJ0PHsz3wWm
 for <bug-gnu-emacs@HIDDEN>; Sat, 18 Jan 2025 16:49:00 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=maertins-zone.de;
 s=key2; t=1737215340;
 bh=zsZ4zSbEwO6pT65Eid2S/7dj8h+ok2GKyEtKHhjiPcQ=;
 h=From:To:Subject:Date:From;
 b=cRaLihvMyfXiBzJMb7ihXVr/uNeWYCt4CM8JuuEk8+zELfuEnq5lLE6lXgpQYhXxD
 e0fri656OtwjdZ2puvLkpkFcECBDyFCB7R5WCegj43PUmeIseOn4ISWVFcGLFmGW2S
 siE39tJb1yYsWr36Gzbrrc76xHsWUmEqXQI67ptAXH0b5wqmbfmFCt9FpaOAORj4VC
 KwGaCRvSnqumJOXRsacvFCKMxVqR4t/Znei35VQhhPNaq0G91smCLysFRmhKX5qZ8M
 uvJVFdaUVgIISCNvS1fKJn4CrvKquivrmULxx294L5nBRLDUhYCluHOdoM8rFXQruB
 YlqlZ3+zrnPog==
Received: from policy02-mors.netcup.net (unknown [46.38.225.35])
 by mors-relay-8201.netcup.net (Postfix) with ESMTPS id 4Yb1HH6nNtz3wVv
 for <bug-gnu-emacs@HIDDEN>; Sat, 18 Jan 2025 16:48:59 +0100 (CET)
Received: from mxe8e7.netcup.net (unknown [10.243.12.53])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest
 SHA256) (No client certificate requested)
 by policy02-mors.netcup.net (Postfix) with ESMTPS id 4Yb1HH52Q3z8scM
 for <bug-gnu-emacs@HIDDEN>; Sat, 18 Jan 2025 16:48:59 +0100 (CET)
Received: from starlight (host-091-097-159-133.ewe-ip-backbone.de
 [91.97.159.133])
 by mxe8e7.netcup.net (Postfix) with ESMTPSA id 1400760572
 for <bug-gnu-emacs@HIDDEN>; Sat, 18 Jan 2025 16:48:55 +0100 (CET)
Authentication-Results: mxe8e7;
 spf=pass (sender IP is 91.97.159.133) smtp.mailfrom=hennes@HIDDEN
 smtp.helo=starlight
Received-SPF: pass (mxe8e7: connection is authenticated)
From: =?utf-8?Q?Hennes_M=C3=A4rtins?= <hennes@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.93; Unexpected indentation of members of inner classes in
 java-ts-mode
X-Debbugs-Cc: 
Date: Sat, 18 Jan 2025 16:48:41 +0100
Message-ID: <86ikqcp1gm.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-PPP-Message-ID: <173721533526.50849.14971674869846870325@HIDDEN>
X-Rspamd-Queue-Id: 1400760572
X-Rspamd-Server: rspamd-worker-8404
X-NC-CID: cLFfEZKct2ZhwQXrw8R37jnHrwDVULTDYisdqHc0I7K2+8RmS8k9
Received-SPF: pass client-ip=188.68.63.162;
 envelope-from=hennes@HIDDEN; helo=relay.yourmailgateway.de
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_PASS=-0.001,
 T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 18 Jan 2025 12:03:50 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)


Create a new java-ts-mode buffer with the following content:

class Foo
{
    class Bar
    {
        int baz;
    }
}

Indent the whole buffer (C-x h <tab>) and it becomes:

class Foo
{
    class Bar
    {
            int baz;
    }
}

The indentation level for baz becomes three, but I would expect it to be
two. A level of two is used in java-mode too.

If I put the opening curly brace to the end of the previous line, the
indentation level becomes two as expected:

class Foo {
    class Bar {
	int baz;
    }
}

I found a personal workaround for this by modifying the variable
java-ts-mode--indent-rules. I replace the entry:

((parent-is "class_body") column-0 c-ts-common-statement-offset)

with:

((parent-is "class_body") parent-bol java-ts-mode-indent-offset)

That works for me, but I am not sure if that is the correct solution.

I can reproduce this also in:
GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2025-01-18



In GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0) of 2024-12-27 built on starlight
Repository revision: 186ea407326166ee4669ce6fe84871c1e16c657c
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.5 LTS

Configured using:
 'configure --with-x-toolkit=lucid --without-toolkit-scroll-bars
 --with-mailutils --with-json --with-tree-sitter
 --with-native-compilation --with-imagemagick'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ IMAGEMAGICK
JPEG LCMS2 LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TREE_SITTER WEBP X11 XDBE
XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: de_DE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty move-toolbar make-network-process native-compile
emacs)

Memory information:
((conses 16 49847 24349) (symbols 48 5370 0) (strings 32 14514 1668)
 (string-bytes 1 391591) (vectors 16 8999)
 (vector-slots 8 126175 11702) (floats 8 24 3) (intervals 56 288 0)
 (buffers 992 10))




Acknowledgement sent to Hennes Märtins <hennes@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#75650; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 21 Jan 2025 02:30:02 UTC

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