From debbugs-submit-bounces@debbugs.gnu.org Thu May 01 08:56:36 2025 Received: (at submit) by debbugs.gnu.org; 1 May 2025 12:56:36 +0000 Received: from localhost ([127.0.0.1]:49619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uATSt-00078v-Kv for submit@debbugs.gnu.org; Thu, 01 May 2025 08:56:35 -0400 Received: from lists.gnu.org ([2001:470:142::17]:36380) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uATSp-00078R-LK for submit@debbugs.gnu.org; Thu, 01 May 2025 08:56:33 -0400 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 1uATSi-0006H9-GE for bug-gnu-emacs@gnu.org; Thu, 01 May 2025 08:56:25 -0400 Received: from forward102a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uATSg-0006bG-Dd for bug-gnu-emacs@gnu.org; Thu, 01 May 2025 08:56:24 -0400 Received: from mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:1a98:0:640:f7e1:0]) by forward102a.mail.yandex.net (Yandex) with ESMTPS id 3A15660D8A for ; Thu, 1 May 2025 15:56:16 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id CuWA5cpLbGk0-jhVujrlr; Thu, 01 May 2025 15:56:15 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1746104175; bh=fo73gDznEsVd5libAxZ/d51seGdFCe9OGmhAsg/jmJs=; h=Date:To:From:Subject:Message-ID; b=LN/chyKIisvvWzWxkFGN2nai6lUIxsB1qY12EciudeR3Dh6QgQeOePcLefHcBPDLE 4ImiAbly3jTr8oo0qq2pJCCtqAQz32ksYrIQBsFEKWu6p5knbMayFhb1CrEeNXg/EE 5h84Ca63GC2/fxDkxxpBm4y/YBhbBkQHKG+gMnQk= Authentication-Results: mail-nwsmtp-smtp-production-main-74.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Subject: tsx-ts-mode: wrong indentation of object parameters From: Konstantin Kharlamov To: bug-gnu-emacs@gnu.org Date: Thu, 01 May 2025 19:56:12 +0700 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:d102; envelope-from=hi-angel@yandex.ru; helo=forward102a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Given this snippet indented as expected: interface iface { f1: string, f2: string } indenting `f2` gives: interface iface { f1: string, f2: string } May not be the best example, but JavaScript/TypeScript are heavy users of c= urly braces, and sometimes I do want to write the first field on the line w= ith opening curly brace, which usually implies aligning other fields to it. --------- I spent quite some time trying to write a patch for this, but I am at loss.= The closest I come to a solution is a rule: ((node-is "property_signature") prev-sibling 0) it works correctly for every param starting with 2nd, but it misindents the= 1st parameter. Probably some condition required like "for the 1st paramete= r do the offset, for consequent ones follow previous siblings indentation".= But I have no idea how to do that. I looked at `c++-ts-mode` (which does it right) for inspiration, but couldn= 't figure out what it does in the same situation. From debbugs-submit-bounces@debbugs.gnu.org Thu May 01 09:10:17 2025 Received: (at 78187) by debbugs.gnu.org; 1 May 2025 13:10:18 +0000 Received: from localhost ([127.0.0.1]:49670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uATg9-0007tR-MP for submit@debbugs.gnu.org; Thu, 01 May 2025 09:10:17 -0400 Received: from forward102a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d102]:43324) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uATg6-0007p4-L3 for 78187@debbugs.gnu.org; Thu, 01 May 2025 09:10:16 -0400 Received: from mail-nwsmtp-smtp-production-main-60.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-60.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1d:5b1c:0:640:ee42:0]) by forward102a.mail.yandex.net (Yandex) with ESMTPS id 041FD608F4 for <78187@debbugs.gnu.org>; Thu, 1 May 2025 16:10:06 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-60.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 2AXDnepLjKo0-e5wyf9zC; Thu, 01 May 2025 16:10:05 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1746105005; bh=qOTdCSZVtxJgEckwevgOgHRY5Qk8IKAU/KrgxUWWl2c=; h=Date:To:From:Subject:Message-ID; b=F/0ocQozvmeeLatEjbFUwf1TBOKLZFXL3pSeSZ4IbzE8KrWoJ8sSE529rOxLHd2dC 2mhMWdwKQg+Q8c4Cby3G/yzSEZ3xKeYlNsItpg54C3SlgWpOLqfZj+vsxCCZpMFs4o Fgfe4demuQXi4WDSE9B5o90qno+VSabw0Ub7CGHU= Authentication-Results: mail-nwsmtp-smtp-production-main-60.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Subject: bug#78187: tsx-ts-mode: wrong indentation of object parameters From: Konstantin Kharlamov To: 78187@debbugs.gnu.org Date: Thu, 01 May 2025 20:10:01 +0700 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.1 MIME-Version: 1.0 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78187 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Looking at c++-ts-mode more, I found it seems to do that with a rule function (c-ts-mode--parenthesized-expression-indent-rule). Makes me wonder: can't it be made into a general rule, similar to prev-sibling, like "prev-same-sibling-or-offset"? The situation it seems pretty common for all programming languages. From debbugs-submit-bounces@debbugs.gnu.org Sat May 10 06:17:36 2025 Received: (at 78187) by debbugs.gnu.org; 10 May 2025 10:17:36 +0000 Received: from localhost ([127.0.0.1]:44248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uDhGy-0002hU-9r for submit@debbugs.gnu.org; Sat, 10 May 2025 06:17:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40426) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uDhGw-0002hF-S2 for 78187@debbugs.gnu.org; Sat, 10 May 2025 06:17:35 -0400 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 1uDhGr-00060H-Hg; Sat, 10 May 2025 06:17:29 -0400 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=nPxGvnl1l3oCrqFddI7hqSlw53T80KvvKEg2yXU3I3c=; b=K4sV2MQ+7aH9 PU9N+yBANiqew+Itb/ZBWhx64ER+FE0WvyYDGLKkEDWhsCE9H+QLGCNpbiS6zRsNAbLeH9L6G+FlH RrJcB0Hd9Q+77+2xPltyDhs5zvUpghMkHFaKblMdUjhE9BGgs1vAes7MhOVLeKXijuBMqjfIt5n9h OO6bmOVQ8cHkCkOt2J/bYFszgvKnRcmUKNrPaYaG3ANa38N8rlfs0xyb3Au2hDusgABdEl+bLnoJ9 /hfliLbY/IaLitbAfp+mEkNE7FnP9/U+zXqTWJ6GC+Fal7xlsClKsTRkQffyHcJnNovlKO+gg8Bao e7eRU9I0mSEvrBSqSN0LRw==; Date: Sat, 10 May 2025 13:17:26 +0300 Message-Id: <86h61sahxl.fsf@gnu.org> From: Eli Zaretskii To: Konstantin Kharlamov , Yuan Fu In-Reply-To: (message from Konstantin Kharlamov on Thu, 01 May 2025 19:56:12 +0700) Subject: Re: bug#78187: tsx-ts-mode: wrong indentation of object parameters References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78187 Cc: 78187@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Konstantin Kharlamov > Date: Thu, 01 May 2025 19:56:12 +0700 > > Given this snippet indented as expected: > > interface iface { f1: string, > f2: string > } > > indenting `f2` gives: > > interface iface { f1: string, > f2: string > } > > May not be the best example, but JavaScript/TypeScript are heavy users of curly braces, and sometimes I do want to write the first field on the line with opening curly brace, which usually implies aligning other fields to it. > > --------- > > I spent quite some time trying to write a patch for this, but I am at loss. The closest I come to a solution is a rule: > > ((node-is "property_signature") prev-sibling 0) > > it works correctly for every param starting with 2nd, but it misindents the 1st parameter. Probably some condition required like "for the 1st parameter do the offset, for consequent ones follow previous siblings indentation". But I have no idea how to do that. > > I looked at `c++-ts-mode` (which does it right) for inspiration, but couldn't figure out what it does in the same situation. Yuan, any comments? From debbugs-submit-bounces@debbugs.gnu.org Tue May 13 15:56:52 2025 Received: (at 78187) by debbugs.gnu.org; 13 May 2025 19:56:52 +0000 Received: from localhost ([127.0.0.1]:34543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uEvkC-0005Oj-3T for submit@debbugs.gnu.org; Tue, 13 May 2025 15:56:52 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:48447) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uEvk9-0005OF-F8 for 78187@debbugs.gnu.org; Tue, 13 May 2025 15:56:50 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7396f13b750so6726370b3a.1 for <78187@debbugs.gnu.org>; Tue, 13 May 2025 12:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747166203; x=1747771003; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=W4If/O4AKSm2XGcw/Sx9ZZmElXO5V1E2mL4ZwdU9COM=; b=If3uhC64eVenw3cKDDUDchb3ogvrbsoRCKVfUDFm8H8oc+SpYzqwaDqJw063uuV7At kebEd58x7p49LjCZsbLR3nR5W86dJ7n28TVNdISAXNvhJtkmvCRvjtENqEJTDfDuy49D jZott4t7+p6xKG/8uRkjOeJOHwMs5Pnwyspg2OdqtyJEK7yiqLMibP8PzI+Sl9vshuFN 6y2yNOkJfRCjjhU+3OXqKShXb0ZO/yNx6xY8i9idlz67DvtOKxkBF2PIf/7ECNeCHIUd ee7oSf5Rzy7xyv+sMiltUEfnMcSZ242XxdymInJVrjBPuFR6WmORbC1gQX7SgRAnAviX xizg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747166203; x=1747771003; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W4If/O4AKSm2XGcw/Sx9ZZmElXO5V1E2mL4ZwdU9COM=; b=vmztHS4Aqg11jIZaiB6Vbje+kkGTrZ9QPrUtr7hBU2JCiifjEnXg9kE8t8UcoO/fU6 aOghXA8PahGbUbAdBaNPEgi86YymchOYospNgQP/isovxNX420riH4fgTcTN9lX9P0MM Dn9pOn476fxAgsVrOlbD/TIo0GlTpQ3rnpscYyWZNh52iWFR8hgxFQ/BJJHhYZJy0rfD LlR0VKW2qcdrwCDVk6kLQsJHI+MCcbFKtku2CTbZx3pjm1NwPqfrqn3U22G5Sy/lGE4G oFZjg+tdYPueWn+l6TY6m13sFGpglR4AWDeXWJF2VpQ4HjTwHz4TLbBnG2xfDxfKPSha DoCg== X-Forwarded-Encrypted: i=1; AJvYcCXN2X8SDUQor7IEOg5Y/A6Dj/6tryhkQwt4DLKlidhNLt+KAG2k9+6jVnfXhMswR9uBEbISHQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yy2tTYp6LKhk9HZMKv2+t1/yLg+5lFQ2jR2VnNKAohzt0OSyNfY bxdY01Xd5gIr4bA/5VQL+DcMYJ18tiavBFnwnnFITJ/7l1nbWZWt X-Gm-Gg: ASbGncvjnTzwD8rVKJQ4IZ7/Hm/O3T3+uSmwvyh1Q1JNyv6Iy5r4NTB8MyRP7FWC7MQ Nq1q9pdLsnr/lQwBvSX/6ESM/sEIQjCiH7KsUPQ37xdaPU7PXIyAQTVpPh7qhzjJlNIPny8u0w+ 35iCz0rGUr2ZCiBQCkfMIZHvNZyB8MrJGogF0m71ie6mDOjlsZUfxj+ZqqL54/y43slHWY+S0IU vv1BuupQhoSXSsLDhvbSawlxbcmqieQVzS7s8D+MZtQ1vstqPdTNyF30nvOe6rMM9wza4ypLUc4 aypsGgvmKbSncceAXASeN0PpY9s0aCAE39NcqZ/Ivjm8Py57SNd0kxv/15a0ZnJc2+sjE+K0l3o = X-Google-Smtp-Source: AGHT+IGZ9s36SAV7Svu5NgzdNnv3FoNXcUAEHlkOPWDXDfY7fcZ38SIqr+HlLBSQ9jWC33uYeP3lWQ== X-Received: by 2002:a05:6a20:d045:b0:1f5:889c:3cbd with SMTP id adf61e73a8af0-215ff1b230fmr895797637.35.1747166203232; Tue, 13 May 2025 12:56:43 -0700 (PDT) Received: from smtpclient.apple ([2601:646:8f81:6120:fc6f:318d:bb8d:99b2]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74237a38c7bsm8127702b3a.123.2025.05.13.12.56.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2025 12:56:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.500.181.1.5\)) Subject: Re: bug#78187: tsx-ts-mode: wrong indentation of object parameters From: Yuan Fu In-Reply-To: <86h61sahxl.fsf@gnu.org> Date: Tue, 13 May 2025 12:56:31 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <97DE36D5-78EC-4441-9C74-B16DE8118F2D@gmail.com> References: <86h61sahxl.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3826.500.181.1.5) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78187 Cc: 78187@debbugs.gnu.org, Konstantin Kharlamov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On May 10, 2025, at 3:17=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >> From: Konstantin Kharlamov >> Date: Thu, 01 May 2025 19:56:12 +0700 >>=20 >> Given this snippet indented as expected: >>=20 >> interface iface { f1: string, >> f2: string >> } >>=20 >> indenting `f2` gives: >>=20 >> interface iface { f1: string, >> f2: string >> } >>=20 >> May not be the best example, but JavaScript/TypeScript are heavy = users of curly braces, and sometimes I do want to write the first field = on the line with opening curly brace, which usually implies aligning = other fields to it. >>=20 >> --------- >>=20 >> I spent quite some time trying to write a patch for this, but I am at = loss. The closest I come to a solution is a rule: >>=20 >> ((node-is "property_signature") prev-sibling 0) >>=20 >> it works correctly for every param starting with 2nd, but it = misindents the 1st parameter. Probably some condition required like "for = the 1st parameter do the offset, for consequent ones follow previous = siblings indentation". But I have no idea how to do that. The =E2=80=9Cmatch=E2=80=9D matcher allow you to do that. You probably = want to modify this rule: ((parent-is "interface_body") parent-bol = typescript-ts-mode-indent-offset) So each property aligns to the first non-comment sibling. And the first = sibling aligns to the parent + 1 indent level. I don=E2=80=99t think we have an existing anchor to find the first = non-comment sibling, we might need to add something like = (first-sibling-excluding =E2=80=9Cregexp=E2=80=9D) >>=20 >> I looked at `c++-ts-mode` (which does it right) for inspiration, but = couldn't figure out what it does in the same situation. You can set treesit--indent-verbose to t and indent the line, then the = matched rule will be printed in the echo area. Right now on master = build, that indentation is handled by the = c-ts-common-baseline-indent-rule, which is a smart baseline rule I = created recently that can handle 90% of the indentation for C-like = languages. We should probably migrate other C-like languages to use this = rule, but that=E2=80=99s the topic for another discussion. Yuan=