From unknown Sat Aug 16 11:12:09 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#76704 <76704@debbugs.gnu.org> To: bug#76704 <76704@debbugs.gnu.org> Subject: Status: 30.1; Indentation of braces on separate line in js-ts-mode Reply-To: bug#76704 <76704@debbugs.gnu.org> Date: Sat, 16 Aug 2025 18:12:09 +0000 retitle 76704 30.1; Indentation of braces on separate line in js-ts-mode reassign 76704 emacs submitter 76704 Fabian Brosda severity 76704 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 02 23:32:29 2025 Received: (at submit) by debbugs.gnu.org; 3 Mar 2025 04:32:29 +0000 Received: from localhost ([127.0.0.1]:42408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1toxTg-0004kJ-9t for submit@debbugs.gnu.org; Sun, 02 Mar 2025 23:32:29 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40948) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1topFE-0004Gq-7M for submit@debbugs.gnu.org; Sun, 02 Mar 2025 14:45:01 -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 ) id 1topF5-0006aC-Gq for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2025 14:44:52 -0500 Received: from mout.gmx.net ([212.227.17.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1topF2-0002wr-PG for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2025 14:44:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1740944683; x=1741549483; i=f.brosda@gmx.de; bh=QCFlf7ilhII+7tS/JX3Yi+c7vmnOROffbhWCoCyaTt8=; h=X-UI-Sender-Class:From:To:Subject:Date:Message-ID:MIME-Version: Content-Type:cc:content-transfer-encoding:content-type:date:from: message-id:mime-version:reply-to:subject:to; b=DUDJ2PtF1HzTxcFJuupWqxlN+7j/iuhAh0BAMVbcaqP6VbyuuVWNihlhX7BzXEG+ w0AOp/bpjD2STaLN6EgV3TbYYiY09ixFJBFsj3WdIASkFw+KsvyfVv4uF+Wm+esKI a9RwRs6ZEA1dE/sOADyNBV/C6wz+6Ew+pYnzdPR+Mj16g1jhcbKhG1TMmced42G+3 hH9F5M1NP2LH/3QwznOdEpfWKsDEpuDfDWgQSAoPp5ILqWNl6kvn5wCAanmKrLmM9 ckNjRRbHn6/mEihDSHSvLSe44ZOfLzK0AAc+jzgjmdTUDj1CiHn9sE7qFQNONer36 oO/yGJnWAI3LjucVBQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([93.195.180.29]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MsYqp-1t0zlw0YLj-0179I4 for ; Sun, 02 Mar 2025 20:44:43 +0100 From: Fabian Brosda To: bug-gnu-emacs@gnu.org Subject: 30.1; Indentation of braces on separate line in js-ts-mode X-Debbugs-Cc: Date: Sun, 02 Mar 2025 20:44:39 +0100 Message-ID: <871pvfkyjc.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:lfnmKodBZqZlylb5rFNrTBvrnLMhQLfpS6dsJWNsWFsgkCw8Rwq gUGteCuLHVvAF8nMO7i86xwhCfnYydlVYReqldoKS7aPXoufHs79mv/7h2yQEqM45kBtR0d NRVbcrUe0yIhXAtCZfsGCdbznId5isK8lSINfml51KALQibzQlGVz5VLMU0kAaJ1PmmxyG5 mop7g7AIU51pcttLvtTzA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:D2XF7NTEHa8=;94gfrWJTdUHg0jj3HBkAzREtNjM A+gosHG8Lb0lCVdkaSx3zkrDqLL6d9Eh5L7CgdwBgCS6iEdRRaGggXl/oivrwzJxc5SnOVkt7 oFYef2gkRqFwrv5pMS5UQFLK8MUFA7YA1k4PdnUY5Fi/Y309Bojohci4hVt31y17xnlaApAiU LEwamBJn3hd3e+mP5vlBBaxr3CseMRkosGt6frTvbo1p6nNcjMODZYk7BOykxd8BhUDWP/0ZV iRww57we0xy78Y9w8YkAtKUTySMN30bDKZJhl2rvaTf3ojZPr14q2JD4tbWRFv1aYyJArfGEb i+JFzIdOPArKjLpEe/MNr6CZFNsZaBkb/Kz5R8eTUJpA7oLvWWJj6ERW151oqnNXK7S2lWI// 4hn2SIEWLj2tR5WTUVdkAU8bCwVmeNRAt5BbkkXnrftfaIk81AelDxHo05cVvc6XOTxAQTYL4 G7548zTyW5KN+NbrtqGnpn//hTo0ojZvyz98tVS/rpO9AdHbAOCuw6vU4kOP5w1wXOi4iM0tl we5vsBY87em3JQqRR+DdKLkCYa9qpZu+hNw+u+NPXYJCYjs99GMz+W9nqmrHXZiqSVLkE39Py HiDKXgzmlAVauJCLeCPxKcYj59uPuMLmDxv6mTyoKqccPPn16NVpfKTbM7u5x8M7FK3N9FX3F LiZ8dP1rSon7kRbHWX8pjfYJiDodNU1CgusYwf2jbDab7AnQa9Ogxzd1BfZYoKEO82rcK9W2H RhHPWw0K9lEn2ZutAQhz5natIM8AZP0H8WskZHKrDMCQy6y/m/nXfL1w6fLe9XyQz8lkp0T5j jcPJQxkRdDh1QYlfLXnfhGGah4bKKh0dwRFzGzn57M9GRmpgG5b+fDUeBP4yZQxOfuWagfppW jwTNU06FtGZ6gunB/s6NtSYFmKT3CPVmYTrmNgEcKRtnocSifOgk1/ULj3/Ow4+SDPbjn3hfr 1PxTkbVXg3rzwnr3SXyFxoWCZw5nlID1QpOf7yfFsaPjPLjNsEf1al1rAlTMgpYt4beiN9ZWd M1mzJvFCOF7PEn8En+R+b1UsahUTg0Z3vPgKpZk09LOyPgs/jFA0eAMvxmqeWD6v8lHVubstV Kz5ZiVwCbXINPEVrPEH+37Ff4t5F25SfF3Q+qgm4PsfZkzvzL6sccMjtNazkspBlG/hNbvsjl TOuA/+MLo1LAdgqCJli6SWlNDl07sRv4MOk0yflkZiQRV18d+jjxHMTekeXatqXwR9xu3kURG ujaqNkEDNlOU5iexWoBadbxMR9QO0ZVYGyTSvG7bfG4h1x1uxIKKTDVw5Xz8cth034fR7u1jF mcs92icIrKr0xmXu6gSBfcHrbdSuYAnZnQo12kr4BN0Cl+xI7E0wt7XrLprwfXTAYncOpf+pJ E0jv4hrp6tMaeA2KVxDyl4WjhCd+V8IEKYPTTx7SlZp1RQ2ma3F3yZSsEFtY6vO8jbrpbd6Zt oqUIb1GCvQ0CuI2t40EKqgY24rY8= Received-SPF: pass client-ip=212.227.17.22; envelope-from=f.brosda@gmx.de; helo=mout.gmx.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, RCVD_IN_MSPIKE_H2=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 02 Mar 2025 23:32:18 -0500 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 (-) Hi, when using js-ts-mode instead of js-mode, braces, which are put on a separate line are indented one level too much. Here is a simple example of how the indentation looks like, after using indent-region on the whole function: ``` function test(x) { if(x) { return a; } else { return b; } } ``` The used tree-sitter grammar is downloaded from https://github.com/tree-sitter/tree-sitter-javascript. Having braces on a separate line is probably not the most common for javascript, but using indent-region in the js-mode, does yield the expected result. The js.el file does already contain a comment mentioning braces in js--treesit-indent-rules. But even based on the git history it is not clear to me, what exactly is meant: ``` ;; "{" on the newline. ((node-is "statement_block") parent-bol js-indent-level) ``` Link: https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/js.el#L3457 If I replace 'js-indent-level' with '0' in this line, the indentation would be correct, but this might have unwanted side-effects I overlooked. My current emacs version: GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, cairo version 1.18.2) Thanks for looking into this. Fabian From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 20:24:24 2025 Received: (at control) by debbugs.gnu.org; 4 Mar 2025 01:24:24 +0000 Received: from localhost ([127.0.0.1]:53296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tpH1E-0002nK-2g for submit@debbugs.gnu.org; Mon, 03 Mar 2025 20:24:24 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:52239) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tpH1B-0002mt-8T for control@debbugs.gnu.org; Mon, 03 Mar 2025 20:24:21 -0500 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-abfe7b5fbe8so227573466b.0 for ; Mon, 03 Mar 2025 17:24:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741051455; x=1741656255; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=JAVj80lYKtKcK7k+x0HyvG1LkKpncXSdAX4R6HOgv3I=; b=esGxhLTbyRrv/efwJ9zaprIoO2ulKgmAH12LvyBkkp3R08fI/NI62YJwQL9tko3IQD qYZjHM0DC49BScbjS1tDNvSp+zrhKEAF+w5/1JdFfewpZ95s+VyrUUszF5U7o4lpquqA gRmxPlFGnxXBjkf6zExDQyEOlJv1kPnOrQ0a4JgwUZpNOWE+5wvEnpYGQAlnNweMvryD AyjoZpKMCzZ6IsAvohgSF5nPUeEi4kaG4SWbxpJ1xk0Rj3MFUijyvVfaAI+P1EJbyCCS 0O65z42qlPkyLij7hcGH5wsP/McxeOwpUheDEwgkhEjCOtwBVy0HvXgZG+yyrj5oWU6i 0Cfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741051455; x=1741656255; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JAVj80lYKtKcK7k+x0HyvG1LkKpncXSdAX4R6HOgv3I=; b=jG3ZNnMhNWJk9K56KrPvgc3sDRrdp76JmgvboxZQvinBInUzoMjvF+13RONJWrOO3g 9Tz5lWrVHt9ufVfse8ef74SFmXlQZ+Qy3cwqtr0tIFQC9/Ro8lX9J6j2To33ub1WwVIW l/tJ7V0tGuV6s70QrmIiyeSg4QD+du+gdjraWWDJBSy2fM7Sn5xbzD0RqjucvB1Q+zLF CVRP9noY8pVulS273DpfJHOnWIIY4p3gc1h6YF33Xqj8UFIGbG7qvH0zq3DDyRsbsN6G jJPaM5/4GDcBHjX8DPeWjYVGwSkkjMBUxi4oAaVVxL2OrFZrIho00oN3jYKFK4XbjfZu u9xg== X-Gm-Message-State: AOJu0Yz/k21brOQE8j+wupylRXIGbGuhmP/m7yBXBjQ5gGdFQxP5FmPn B9JaFD8O85rNtBFHKcFb+Hkg3RncLjgf91xpWUdxttI7HDpokg3QIx8j7GipYT4cus/4ww/xaPb XUC+dWYfl0X/jHJvNwwwIlD3DrwPQmH8oEXQ= X-Gm-Gg: ASbGncuGb0+0j/ntEf2t/dtb1DsZlSUkgWPO39byOhL49KUTmjiTjOYz7OSE9gshkgm Ma38DPOzRTZ061/2L5olW/8ggZ8srHng+fai/KJgdl1Mp51WaKSsdOjc7uQMNthD1d6m+LN0Hzo KHmMZ13pkdu2CBpnL7h2J7hOJQKA== X-Google-Smtp-Source: AGHT+IFOz4LtL2OORQV7VWZuoRgGt41YGGb8l9ITyssd8QLLDlDzkx8U3KxKvTjupTNce7LFda8HiC9WNGIXIBogqlc= X-Received: by 2002:a05:6402:350e:b0:5e4:92ca:34d0 with SMTP id 4fb4d7f45d1cf-5e4d6b4bb17mr41998783a12.20.1741051455087; Mon, 03 Mar 2025 17:24:15 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 3 Mar 2025 17:24:14 -0800 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 3 Mar 2025 17:24:14 -0800 X-Gm-Features: AQ5f1JoWUG8GgvU8hgyCDNiRWxJvD7m9ioXdkFVgkEBf8cp2-nV2FIWFt7lQ2Gg Message-ID: Subject: control message for bug #76704 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) severity 76704 minor quit From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 09 06:00:29 2025 Received: (at 76704) by debbugs.gnu.org; 9 Mar 2025 10:00:29 +0000 Received: from localhost ([127.0.0.1]:58440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1trDSO-00065G-Pg for submit@debbugs.gnu.org; Sun, 09 Mar 2025 06:00:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48564) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1trDSN-000650-7N for 76704@debbugs.gnu.org; Sun, 09 Mar 2025 06:00:27 -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 1trDSH-0001sq-31; Sun, 09 Mar 2025 06:00:21 -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=Z6Qqot/kDbyo5g5CPGNeWs2GCwsIe9N/BwZCxfQ0/zU=; b=n67fXmLiF+rs MgBvDWBJlGAFtVnXyoj9B0C1rj2vN4iyIQSAUfad0M1V/+J0IzQ6J3AZbJnQH9x/wl59nobOFR/ND GPBLAQZAxsvbJy+8DiDa2z9OJcPE2etCwPv1lybTObHutdQ6gFWb/szSRJ0fIJI5mgPozki3sZ4j2 zRK93GXJm0FvDt8fcMa826z008qL2sAzSmknTCXNqj2e23KUJ2UIc8MgD9HSzji38mk8m5d6BqG0B 52AEtDq7ucbregb3M8Sd/9uTPZueCAOqKliN0C39TTFUN/wBJ63o+icTZL9yc8msukLShStKPeRpi gw8x8qiWmvIAotufuqhXlQ==; Date: Sun, 09 Mar 2025 12:00:16 +0200 Message-Id: <861pv6h6bz.fsf@gnu.org> From: Eli Zaretskii To: Fabian Brosda , Juri Linkov , Vincenzo Pupillo In-Reply-To: <871pvfkyjc.fsf@gmx.de> (bug-gnu-emacs@gnu.org) Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode References: <871pvfkyjc.fsf@gmx.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76704 Cc: 76704@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 (---) > Date: Sun, 02 Mar 2025 20:44:39 +0100 > From: Fabian Brosda via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Hi, > > when using js-ts-mode instead of js-mode, braces, which are put on a > separate line are indented one level too much. Here is a simple example > of how the indentation looks like, after using indent-region on the > whole function: > > ``` > function test(x) > { > if(x) > { > return a; > } > else > { > return b; > } > } > > ``` > > The used tree-sitter grammar is downloaded from > https://github.com/tree-sitter/tree-sitter-javascript. > > Having braces on a separate line is probably not the most common for > javascript, but using indent-region in the js-mode, does yield the > expected result. The js.el file does already contain a comment > mentioning braces in js--treesit-indent-rules. But even based on the > git history it is not clear to me, what exactly is meant: > > ``` > ;; "{" on the newline. > ((node-is "statement_block") parent-bol js-indent-level) > ``` > > Link: https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/js.el#L3457 > > If I replace 'js-indent-level' with '0' in this line, the indentation would > be correct, but this might have unwanted side-effects I overlooked. > > My current emacs version: > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, > cairo version 1.18.2) > > Thanks for looking into this. Juri and Vincenzo, any comments? From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 22 08:24:34 2025 Received: (at 76704) by debbugs.gnu.org; 22 Mar 2025 12:24:35 +0000 Received: from localhost ([127.0.0.1]:41390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tvxtu-0002Kp-8e for submit@debbugs.gnu.org; Sat, 22 Mar 2025 08:24:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37968) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tvxtq-0002KX-QV for 76704@debbugs.gnu.org; Sat, 22 Mar 2025 08:24:27 -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 1tvxtk-00058Q-6q; Sat, 22 Mar 2025 08:24:20 -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=aOh7m+S66UM0FZlJKcf9HZx110U+uDq2XBxPiiYGGGo=; b=IgqmxmhgF9Ny 660+J3SC39EJbN2/nwfkgSja97kA7ZjaEQCjwUY0UiwWENN97ls2Hjd0YrnggcgA6uib+GYIl/SBP Ht+Pj7QOOXrgCODO8qtmObAkwWzZI7B5XZKd4hRpbx+16JxEvPDzdNqC2gJtRwP1oGYgfQlL56lGa hMadNm4tfqNN1oRE45R8irhUlSLIR6pQGTCcpOwE0u0dzp/QQts/i4f181TA0VWAdLechuaoSAjP4 egNquDDuTCwWOZR5gajHYInJDRxcKaUoeVlvJzaHb5/wTSjtP9IasdTdKDjIqyINi/nni2tukWT8M 3mY443ZsIoW4hYq1JPWrNQ==; Date: Sat, 22 Mar 2025 14:24:16 +0200 Message-Id: <86wmchi77z.fsf@gnu.org> From: Eli Zaretskii To: juri@linkov.net, v.pupillo@gmail.com In-Reply-To: <861pv6h6bz.fsf@gnu.org> (message from Eli Zaretskii on Sun, 09 Mar 2025 12:00:16 +0200) Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode References: <871pvfkyjc.fsf@gmx.de> <861pv6h6bz.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76704 Cc: f.brosda@gmx.de, 76704@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 (---) Ping! Juri and Vincenzo, please chime in. > Cc: 76704@debbugs.gnu.org > Date: Sun, 09 Mar 2025 12:00:16 +0200 > From: Eli Zaretskii > > > Date: Sun, 02 Mar 2025 20:44:39 +0100 > > From: Fabian Brosda via "Bug reports for GNU Emacs, > > the Swiss army knife of text editors" > > > > Hi, > > > > when using js-ts-mode instead of js-mode, braces, which are put on a > > separate line are indented one level too much. Here is a simple example > > of how the indentation looks like, after using indent-region on the > > whole function: > > > > ``` > > function test(x) > > { > > if(x) > > { > > return a; > > } > > else > > { > > return b; > > } > > } > > > > ``` > > > > The used tree-sitter grammar is downloaded from > > https://github.com/tree-sitter/tree-sitter-javascript. > > > > Having braces on a separate line is probably not the most common for > > javascript, but using indent-region in the js-mode, does yield the > > expected result. The js.el file does already contain a comment > > mentioning braces in js--treesit-indent-rules. But even based on the > > git history it is not clear to me, what exactly is meant: > > > > ``` > > ;; "{" on the newline. > > ((node-is "statement_block") parent-bol js-indent-level) > > ``` > > > > Link: https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/js.el#L3457 > > > > If I replace 'js-indent-level' with '0' in this line, the indentation would > > be correct, but this might have unwanted side-effects I overlooked. > > > > My current emacs version: > > > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, > > cairo version 1.18.2) > > > > Thanks for looking into this. > > Juri and Vincenzo, any comments? > > > > From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 22 18:49:09 2025 Received: (at 76704) by debbugs.gnu.org; 22 Mar 2025 22:49:09 +0000 Received: from localhost ([127.0.0.1]:46146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tw7eP-0005by-0F for submit@debbugs.gnu.org; Sat, 22 Mar 2025 18:49:09 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:54714) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tw7eL-0005aI-DG for 76704@debbugs.gnu.org; Sat, 22 Mar 2025 18:49:06 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-ac25313ea37so343394966b.1 for <76704@debbugs.gnu.org>; Sat, 22 Mar 2025 15:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742683739; x=1743288539; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=95V8r4r4AQcdEx0fd/cu9CO4FmXfQ3lvk+TRkefSbJ8=; b=DXcrgWYcxfWd5sL6UNJWy6B115RfDeiFBPKYjfyQ+ZwuvyuiWeT4zyPDVJnZ3d8ZfZ gWbjMW+zKwh2zdAMGO4wE5yhqLc7f3sUGlCSwlf3alzfx7DoWed14AyN3pUYnoL26u5f x5OyEyToAczs1C8T6RsgOIpgS80qts3veTZhbFeJ//PnUghyT+6Opj+RcYdQoHZVvX6V i0gzIsXtJ3fARJ3JvPlQfwxoaRaPrF+st5Ng0ObVoMhhTPHoaiCGvBwTXv9dATaQxJDp JODaFxmEDUVqeyCtuVjGNbfybuC9AqZMkO/u5RNWUMAJa0tpswtfpVopIpPr8n4a6PX5 gTzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742683739; x=1743288539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=95V8r4r4AQcdEx0fd/cu9CO4FmXfQ3lvk+TRkefSbJ8=; b=ETPh0RTc+/xgod5mQHrbhJDWU3eOvWVxtbIny+ssV7w8t37Wdasayr901s13WXmgnT DCLEtrkWlwqGYifEENI4AGeWelgzd+m6dUl2WjTlYTw/H3rj6qBs2DoF7EW0Fy7ocWP2 tpMYnfJfbS751pRlpeMmwS6QpvQ9JAMcdgeAImjABSyBUMycKpl9EWEzJLl9JOenkQ64 MBcsCs6TNOMayn/iQrxdELZ1XDyAw2NcSsJMQqYibX3Cx/Lf26W8DyfCX7OlAuT70kMX cfWuA2hv5KySncj5UNUG8uw2VaWxgj62zZPPjNJsI4IMJPqmFw5BZsGuCiTjHFBcj5Pz r79A== X-Forwarded-Encrypted: i=1; AJvYcCUuCIeIKGeK1YBFkHfIzKaINvtvTEe1jjyabRYH9v6uOtCN1jL/LSmgjOIe+QR9y/HDesc9Pw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzYLhYRVZ1Gb3vVfUH8ZVM0a0/D+DxHC0ang7S0/36fbx4+q6ql ZXzqBIDyFwJS7o539trCe6a+6qkxDYQJrkPdq8yX1uyqA4O+S0x1 X-Gm-Gg: ASbGncuIB09n3doZRMQwdpeF+cLlk40kymEUUlhGlgh2ujsnaf8Di07QzWyyEgI5qYt HN/y8DinmHFfRuSkzJzMEJhPfhNLM/6AVVvK89kLmIZ+6JB9PCikj/6l0jLgQAKx6/b1UUrgIRI 91QnUgicZT5YRe/6pJsEsxna7qXOY4eOcewv0sBSY5YYZhmD9YYzV1ErfMnCqprAQgz4OGhYgJV XXaxQ7oWE124c39LHbVG8//9iS0p2nU+pyShLKaqL/2I6o1cQ3XK8LPBkBk4cGaOQzWdbUXSEK4 yRktiS8i4x8lXcDw22bVlg1BCnpPjWS7DvsGj4NEhUW9koggGi05blHXRCzmPrcls1dPcBlPbgh xSCNVDn+f X-Google-Smtp-Source: AGHT+IF4syerKu7fmeVVGjKnjYi/tMskzPqH0Xi4w+E1kv6HE02os1giFmNTjRQE4p8JKnkVknw6pQ== X-Received: by 2002:a17:907:7241:b0:ac2:a473:4186 with SMTP id a640c23a62f3a-ac3f229f53dmr743484266b.34.1742683738743; Sat, 22 Mar 2025 15:48:58 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3efbdecedsm424545066b.140.2025.03.22.15.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Mar 2025 15:48:58 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Sat, 22 Mar 2025 23:48:57 +0100 Message-ID: <4873433.vXUDI8C0e8@fedora> In-Reply-To: <86wmchi77z.fsf@gnu.org> References: <871pvfkyjc.fsf@gmx.de> <861pv6h6bz.fsf@gnu.org> <86wmchi77z.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2263782.9o76ZdvQCi" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: f.brosda@gmx.de, 76704@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: -1.0 (-) This is a multi-part message in MIME format. --nextPart2263782.9o76ZdvQCi Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ciao, a rule like this: ((node-is "statement_block") parent-bol 0) works for function but brakes the indentation of expressione like this: const Geek =3D (a, b) =3D> { return (a + " " + b); } In the attached patch, I have added a new rule specifically for this case. Vincenzo In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99Europa cent= rale, Eli=20 Zaretskii ha scritto: > Ping! Juri and Vincenzo, please chime in. >=20 > > Cc: 76704@debbugs.gnu.org > > Date: Sun, 09 Mar 2025 12:00:16 +0200 > > From: Eli Zaretskii > >=20 > > > Date: Sun, 02 Mar 2025 20:44:39 +0100 > > > From: Fabian Brosda via "Bug reports for GNU Emacs, > > >=20 > > > the Swiss army knife of text editors" > > >=20 > > > Hi, > > >=20 > > > when using js-ts-mode instead of js-mode, braces, which are put on a > > > separate line are indented one level too much. Here is a simple exam= ple > > > of how the indentation looks like, after using indent-region on the > > > whole function: > > >=20 > > > ``` > > > function test(x) > > >=20 > > > { > > > =20 > > > if(x) > > > =20 > > > { > > > =20 > > > return a; > > > =20 > > > } > > > =20 > > > else > > > =20 > > > { > > > =20 > > > return b; > > > =20 > > > } > > > =20 > > > } > > >=20 > > > ``` > > >=20 > > > The used tree-sitter grammar is downloaded from > > > https://github.com/tree-sitter/tree-sitter-javascript. > > >=20 > > > Having braces on a separate line is probably not the most common for > > > javascript, but using indent-region in the js-mode, does yield the > > > expected result. The js.el file does already contain a comment > > > mentioning braces in js--treesit-indent-rules. But even based on the > > > git history it is not clear to me, what exactly is meant: > > >=20 > > > ``` > > >=20 > > > ;; "{" on the newline. > > > ((node-is "statement_block") parent-bol js-indent-level) > > >=20 > > > ``` > > >=20 > > > Link: > > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/js.e= l# > > > L3457 > > >=20 > > > If I replace 'js-indent-level' with '0' in this line, the indentation > > > would > > > be correct, but this might have unwanted side-effects I overlooked. > > >=20 > > > My current emacs version: > > >=20 > > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, > > > cairo version 1.18.2) > > >=20 > > > Thanks for looking into this. > >=20 > > Juri and Vincenzo, any comments? --nextPart2263782.9o76ZdvQCi Content-Disposition: attachment; filename="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" >From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 22 Mar 2025 23:43:52 +0100 Subject: [PATCH] Fix indentation of "{" when on a new line of a function declaration. * lisp/progmodes/js.el (js--treesit-indent-rules): New rule for the indentation of "{" when of a new line of a function declaration. (bug#76704) --- lisp/progmodes/js.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 3e789218fde..6943ffc2d28 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3464,7 +3464,10 @@ js--treesit-indent-rules ((parent-is "ternary_expression") parent-bol js-indent-level) ((parent-is "member_expression") parent-bol js-indent-level) ((node-is ,switch-case) parent-bol 0) - ;; "{" on the newline. + ;; "{" on the newline for functions. + ((query "(function_declaration body: (statement_block \"{\") @indent)") + parent-bol 0) + ;; "{" on the newline in other cases. ((node-is "statement_block") parent-bol js-indent-level) ((parent-is "named_imports") parent-bol js-indent-level) ((parent-is "statement_block") parent-bol js-indent-level) -- 2.49.0 --nextPart2263782.9o76ZdvQCi-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 06:18:23 2025 Received: (at 76704) by debbugs.gnu.org; 23 Mar 2025 10:18:23 +0000 Received: from localhost ([127.0.0.1]:47763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twIPO-0004mD-DB for submit@debbugs.gnu.org; Sun, 23 Mar 2025 06:18:23 -0400 Received: from mout.gmx.net ([212.227.17.20]:33011) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twIPL-0004kl-4o for 76704@debbugs.gnu.org; Sun, 23 Mar 2025 06:18:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1742725084; x=1743329884; i=f.brosda@gmx.de; bh=fALceIODTHbWgX4hgh7rWEVxmc88jxNhxS7W17LTPOs=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=uFbCIScCt0ZVvLvhMwHYGGevuXuJSNLjoCOj+oR6d132axk3y3KYowMX8Lo0gb2I bpv822kgNVBs3aP/HAi/MOEHonNFqfiPVZxBHk6gM3HetI6exhGmCREspkjJW4rtV Kn1w+/NLgV3g81a/+Ke0F7fMsqO4GkC24+LvEvKHQw3a4aEdvSenJwQImgU8Psw0Z /bE2+O99uhPgVyjDANkScwJl2D5nJsy7xNe/ZemsuKH0hWCgFa3D5zV1kxmjsGChV +9HJo7v/bceXKjhcVW7xWmxb2Ov9NDjW3Aa6OmRtxILTobykW9FawlQnFBrNvyqep dG153q4rK998SIpFBw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([84.136.46.158]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MV67y-1tlo0Q09Pq-00N2ye; Sun, 23 Mar 2025 11:18:04 +0100 From: Fabian Brosda To: Vincenzo Pupillo , juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode In-Reply-To: <4873433.vXUDI8C0e8@fedora> References: <871pvfkyjc.fsf@gmx.de> <861pv6h6bz.fsf@gnu.org> <86wmchi77z.fsf@gnu.org> <4873433.vXUDI8C0e8@fedora> Date: Sun, 23 Mar 2025 11:18:02 +0100 Message-ID: <87sen4f3tx.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:PVmOhgn/XnYhlm5La7UyLCxw5KRL5PYbfvrxuG4+8gRF4vqtK8f pM4tFkDQn7nnf8p7hVXpJECK6rWSmss7T2Y02AdY+rjjhNV5UogoiG/f3DdLaY55KfXsbZC eOV3yHxflL4lVs/+jmmeSbJH+W9oz4IisjG4TzZ4kLjMSyns5YhtuOfxxQbdydAF7IrmRJy ZB/eCDSw/5fLM9tjOq7fg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:x8IleclvArA=;axiZGNeyyeGaxJJfrdRobGbb+NH vrk7NgHBQNj3No7p4iPC+ngD8t1TGhRNL6EXBHEkeVvSy/y3HWiLNe7l3qwKF9BA8V8/S6NdZ p6L6GTkWdF1ac+m4SobJx4KEJXFwMPG/tZ7ALjVfBv0f5rj+toh5Pdkgg2JtCLPODL3GazSaO 22GKeKU5SOQf6bRIBDwwXsgfpETxy3bNMIPXGYKYLFQhIveVxVEA6WznQTPD/ct2HJacznNvO hD7sJgbxghMr5386CtWPdYeb08uZ0qWuSrzfMiNfbfOAKdV3QIRQT/Tgta5llcS/vGw6lPBaZ v4Pmi3XrQdFlfiy3wRTVtqlIDXjDSIoepuC2AfLcb9Y+KbYi8D6fQfn8MdaJLSt9qmZ9ghXjX IzJzIsdOB6IdRqardHAQwxkrhYdjgch3jaxKiplCVVt0sfk9bw2mPAk9WgKiljLz0Qf5maM6D lz/7Xocm0w4b+4gCiGgBTtMTn3qMT8fPnRdjGRh3y1N38WG3Z0Yh4K62Vbw0AMDVagT5IetuF hA3fBCyoDCAHGlxsoyTz4d/6I0kmonjRXRyd/HmMFCjmBCUoeMiUSDZ00kq41Rcz05F9FRvza B+s1XNftJ2I6DT8fvAzOVU5fw0+mU/MjA6aNmQPbugiJqn9wg9XkgeiHC8wJIgmpD822IpqXf uTUffo0x/nj/veIfgqkAdYf/8jt59EOjlpVIqGHZHV2jIHZh5fCim7kR1dpurgXFIBHuq1Nx0 InbkDHzJPTmmg5tI1ogOtNnKQOJCGE7jNBfilweyJ0mKk5FXwM/VKB51MpfE9cnm6xgHjNoUZ rN+YckBz3Xt7IMJpfgfSzDdsIx+6TZvo2OACDvuoyN93DpRNJG4Fqtdbhd9H/+fkBo7EaHQJT CuebxSqNLy49PP4dmjZ7GU1zbolbMEAhc6eo5NZoh6rUnjxWZAkUzA40/b4uwOoHx2Iz3X6Ch ZuvxQIXmDUPD4NCW+ORy1goIEltEqxosCaZClX4xnXIAQNLZhN6xnRGP0fNVdY02AsiIAzy+2 EyWc0JfLyIODWjkRJrwCVy6uiUibMG6JJc0eQIUS0cD/XL89FL5Agf5h1o9KOzt9KDnSl46lU OgAyE63vgU/1y+jCla7fS7b83U6OYWVmReNsnXJK5+/Yyv7SzlbCUc0QiFfjR2FVgSgfMrBIx aILL8tdnWwK2FGbE6hk8xc3a2QusF3KkcgNqW1t4Grh+ur+dX4PB9577nEO21epbhPOMzdc15 S9sPp+cnAEFBEVGQUIbdEbOjyxocrQ/M8JtlSMzjl2ImSJcC3n55sR44Yil2jMLAY6v6YmIN0 drHfBoUzevKsniDAE36r9Xj3neHChKJJlnR6u1K5kdW+AXsvwINfm2gofhNnfqg7QSTvyE+bW ibFIP4KpdBzjHIl9+RyagR7GVO7jPD/AioDvhvVOLl3U5ZzEBeb4ymGwbH2whPKFx7hKY0o4h 080UrzdrMi7J2sdL9nyh/+bRrq9Bp8WEn3ux00PmaC0ATpGTmVn5WmaC7FO1Nr08agv1yfg== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.7 (-) Hi, thanks for the explanation and the patch. The result from the patch is a GNU-style indentation, where only the braces for functions are not indented, while braces for other blocks (if/else, loops, arrow functions) are indented. What I would like to have is Allman style indentation, where the braces for blocks like if/else indent the same as for functions. This also seems the default behavior in the old js-mode. In this case I think it would be correct to not indent the brace for the arrow function. For reference, I found an issue in eslint regarding this indentation: https://github.com/eslint/eslint/issues/8493 Would it be possible to also support the later? Fabian Vincenzo Pupillo writes: > Ciao, > a rule like this: > ((node-is "statement_block") parent-bol 0) > > works for function but brakes the indentation of expressione like this: > const Geek =3D (a, b) =3D> > { > return (a + " " + b); > } > > > In the attached patch, I have added a new rule specifically for this case. > > Vincenzo > > In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99Europa ce= ntrale, Eli=20 > Zaretskii ha scritto: >> Ping! Juri and Vincenzo, please chime in. >>=20 >> > Cc: 76704@debbugs.gnu.org >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 >> > From: Eli Zaretskii >> >=20 >> > > Date: Sun, 02 Mar 2025 20:44:39 +0100 >> > > From: Fabian Brosda via "Bug reports for GNU Emacs, >> > >=20 >> > > the Swiss army knife of text editors" >> > >=20 >> > > Hi, >> > >=20 >> > > when using js-ts-mode instead of js-mode, braces, which are put on a >> > > separate line are indented one level too much. Here is a simple exa= mple >> > > of how the indentation looks like, after using indent-region on the >> > > whole function: >> > >=20 >> > > ``` >> > > function test(x) >> > >=20 >> > > { >> > >=20=20=20=20=20 >> > > if(x) >> > >=20=09=20=20=20=20 >> > > { >> > >=20=09=20=20=20=20=20=20=20=20 >> > > return a; >> > >=20=09=20=20=20=20=20=20=20=20 >> > > } >> > >=20=09=20=20=20=20 >> > > else >> > >=20=09=20=20=20=20 >> > > { >> > >=20=09=20=20=20=20=20=20=20=20 >> > > return b; >> > >=20=09=20=20=20=20=20=20=20=20 >> > > } >> > >=20=20=20=20=20 >> > > } >> > >=20 >> > > ``` >> > >=20 >> > > The used tree-sitter grammar is downloaded from >> > > https://github.com/tree-sitter/tree-sitter-javascript. >> > >=20 >> > > Having braces on a separate line is probably not the most common for >> > > javascript, but using indent-region in the js-mode, does yield the >> > > expected result. The js.el file does already contain a comment >> > > mentioning braces in js--treesit-indent-rules. But even based on the >> > > git history it is not clear to me, what exactly is meant: >> > >=20 >> > > ``` >> > >=20 >> > > ;; "{" on the newline. >> > > ((node-is "statement_block") parent-bol js-indent-level) >> > >=20 >> > > ``` >> > >=20 >> > > Link: >> > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/js.= el# >> > > L3457 >> > >=20 >> > > If I replace 'js-indent-level' with '0' in this line, the indentation >> > > would >> > > be correct, but this might have unwanted side-effects I overlooked. >> > >=20 >> > > My current emacs version: >> > >=20 >> > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, >> > > cairo version 1.18.2) >> > >=20 >> > > Thanks for looking into this. >> >=20 >> > Juri and Vincenzo, any comments? > > From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 2001 > From: Vincenzo Pupillo > Date: Sat, 22 Mar 2025 23:43:52 +0100 > Subject: [PATCH] Fix indentation of "{" when on a new line of a function > declaration. > > * lisp/progmodes/js.el > (js--treesit-indent-rules): New rule for the indentation of "{" when > of a new line of a function declaration. (bug#76704) > --- > lisp/progmodes/js.el | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > index 3e789218fde..6943ffc2d28 100644 > --- a/lisp/progmodes/js.el > +++ b/lisp/progmodes/js.el > @@ -3464,7 +3464,10 @@ js--treesit-indent-rules > ((parent-is "ternary_expression") parent-bol js-indent-level) > ((parent-is "member_expression") parent-bol js-indent-level) > ((node-is ,switch-case) parent-bol 0) > - ;; "{" on the newline. > + ;; "{" on the newline for functions. > + ((query "(function_declaration body: (statement_block \"{\") @ind= ent)") > + parent-bol 0) > + ;; "{" on the newline in other cases. > ((node-is "statement_block") parent-bol js-indent-level) > ((parent-is "named_imports") parent-bol js-indent-level) > ((parent-is "statement_block") parent-bol js-indent-level) > --=20 > 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 14:21:16 2025 Received: (at 76704) by debbugs.gnu.org; 23 Mar 2025 18:21:16 +0000 Received: from localhost ([127.0.0.1]:52587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twPwi-0002pO-9E for submit@debbugs.gnu.org; Sun, 23 Mar 2025 14:21:16 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:48474) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1twPwe-0002p8-Sg for 76704@debbugs.gnu.org; Sun, 23 Mar 2025 14:21:13 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-ac2a81e41e3so785184266b.1 for <76704@debbugs.gnu.org>; Sun, 23 Mar 2025 11:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742754066; x=1743358866; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ga8zgPa/+ZInUMQKlhoQNqF2g/akTcla5J4rF2cNwGY=; b=KnJJ6JcgHZbRkx071yuPPtPJtvFcBcIa4IoaA7vmO4VKLHCKNTiqLumWPE2kqUFxfa MUkddVFbIVCYSi5e5dNarC178jJ1WeuYVWvfYSiHNpeLMY8JGgnpq7sTO6sWVJsjD5Zz 5HwDamlDUN6YMd6F6J+vZthL8ZUJi59bxfNcczGdqUvMz3yKGu4d8Ga5/gTWCk+gIs2d 7kR5x8JPrBNvnzkTqpF9ickRqC/V9VziL2/SkILRvyqH05ju0bFzZPFekjV1CHtGJ/6a Kmfnjq1+M+hVkWUHE5Ei16Jco53dSe4VcIFXPiq2Z8w2eJfPc/fXqGL0lzoxV11LIcn1 RBKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742754066; x=1743358866; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ga8zgPa/+ZInUMQKlhoQNqF2g/akTcla5J4rF2cNwGY=; b=gNdzHAPvYptPJpzQ9hJmLCmvbQRRfScqKiFfA6xvTW4zCoZjUB1Gzxx9I0JeCSEZa3 PJ4Umgqseg2mop3L+FFvvVf8dYsD80hsX1r0cyyNH+B2jgXX8jy7qkoZzPr8Tev4c22E X1BRg4pWfSFL+zXoyDyVkK+jCgga9NbQPDC5jN3nJZdM79Odmr9H0ZKvvF+b/ywmCOg/ wBEZ4yWILB5g43xN6HGkiRUSeDH0NHgJPnd2y7cz6HuT1mpPKnMvs6UNdW+gWrbdCwO2 JHeETz8rybMui6lds5VmBVx7vp2AdjDaSXzUyqOIg/iNXZ+UCc9V680GyiwtXR8bWxos Y40Q== X-Gm-Message-State: AOJu0YzPkUVUk0qlqalKWRwcOI+Nkl6m8sSdJNZIAebczfJ9c5YMoMIG bPULt0T1PWdr87Nm71orLebyuji4Ieoj5jgky/19cn74YduUt8SP X-Gm-Gg: ASbGncvwGSk893ozSunVs+wsytnS3K16CNwWXBHdAo1OlMs7j7BHtwaipZABCib/aBC AY5M9UMrNha3UvXCgEvKU7VaBTT70x7nyeYBucWq50Rd28ad+k6L5S+soLSd0F1E7xzOwukEjwj 8pKB371jTPQPH6yMoKs1Kt73fLexuQSvIcIKJgflmEI89QGnH8++1qpLTyqxffM5gCy5WL3/htx 1IIXSF23pHGXJTQq0YioUojwx6gXnAT90CDJ66cQMai/Hei0ha5prIsA2P5+pf1Y3KvjwNdIfi9 AB5Ssi4LyY0pPcnYy1pWiTQQjVc0+vTYpMzbjiCvzCIL6SuULSimAgX/GCqTsCRDKSEBk9wYrFZ 3awZibk2j X-Google-Smtp-Source: AGHT+IG1UPPli21SoLt7jEFc7wZyI5ZEQH876I5jbhXguFVp+o9d1wWy/RGErxcRAwlcEwdM+lXBng== X-Received: by 2002:a17:907:7e98:b0:ac4:545:66cf with SMTP id a640c23a62f3a-ac405456ac4mr717296066b.42.1742754066239; Sun, 23 Mar 2025 11:21:06 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3ef86e46bsm544356766b.13.2025.03.23.11.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Mar 2025 11:21:05 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii , Fabian Brosda Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Sun, 23 Mar 2025 19:21:04 +0100 Message-ID: <2191042.9o76ZdvQCi@fedora> In-Reply-To: <87sen4f3tx.fsf@gmx.de> References: <871pvfkyjc.fsf@gmx.de> <4873433.vXUDI8C0e8@fedora> <87sen4f3tx.fsf@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.0 (-) Ciao Fabian, thank you.=20 In fact, there are other cases where it does not work, and especially the=20 behavior is different from js-mode. I need to think about this a bit more.. Vincenzo In data domenica 23 marzo 2025 11:18:02 Ora standard dell=E2=80=99Europa ce= ntrale,=20 =46abian Brosda ha scritto: > Hi, > thanks for the explanation and the patch. The result from the patch is > a GNU-style indentation, where only the braces for functions are not > indented, while braces for other blocks (if/else, loops, arrow > functions) are indented. >=20 > What I would like to have is Allman style indentation, where the braces > for blocks like if/else indent the same as for functions. This also > seems the default behavior in the old js-mode. In this case I think it > would be correct to not indent the brace for the arrow function. For > reference, I found an issue in eslint regarding this indentation: >=20 > https://github.com/eslint/eslint/issues/8493 >=20 > Would it be possible to also support the later? >=20 > Fabian >=20 > Vincenzo Pupillo writes: > > Ciao, > > a rule like this: > > ((node-is "statement_block") parent-bol 0) > >=20 > > works for function but brakes the indentation of expressione like this: > > const Geek =3D (a, b) =3D> > >=20 > > { > > =09 > > return (a + " " + b); > > =09 > > } > >=20 > > In the attached patch, I have added a new rule specifically for this ca= se. > >=20 > > Vincenzo > >=20 > > In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99Europa = centrale, > > Eli>=20 > > Zaretskii ha scritto: > >> Ping! Juri and Vincenzo, please chime in. > >>=20 > >> > Cc: 76704@debbugs.gnu.org > >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 > >> > From: Eli Zaretskii > >> >=20 > >> > > Date: Sun, 02 Mar 2025 20:44:39 +0100 > >> > > From: Fabian Brosda via "Bug reports for GNU Emacs, > >> > >=20 > >> > > the Swiss army knife of text editors" > >> > >=20 > >> > > Hi, > >> > >=20 > >> > > when using js-ts-mode instead of js-mode, braces, which are put on= a > >> > > separate line are indented one level too much. Here is a simple > >> > > example > >> > > of how the indentation looks like, after using indent-region on the > >> > > whole function: > >> > >=20 > >> > > ``` > >> > > function test(x) > >> > >=20 > >> > > { > >> > > =20 > >> > > if(x) > >> > > =20 > >> > > { > >> > > =20 > >> > > return a; > >> > > =20 > >> > > } > >> > > =20 > >> > > else > >> > > =20 > >> > > { > >> > > =20 > >> > > return b; > >> > > =20 > >> > > } > >> > > =20 > >> > > } > >> > >=20 > >> > > ``` > >> > >=20 > >> > > The used tree-sitter grammar is downloaded from > >> > > https://github.com/tree-sitter/tree-sitter-javascript. > >> > >=20 > >> > > Having braces on a separate line is probably not the most common f= or > >> > > javascript, but using indent-region in the js-mode, does yield the > >> > > expected result. The js.el file does already contain a comment > >> > > mentioning braces in js--treesit-indent-rules. But even based on = the > >> > > git history it is not clear to me, what exactly is meant: > >> > >=20 > >> > > ``` > >> > >=20 > >> > > ;; "{" on the newline. > >> > > ((node-is "statement_block") parent-bol js-indent-level) > >> > >=20 > >> > > ``` > >> > >=20 > >> > > Link: > >> > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/j= s.e > >> > > l# > >> > > L3457 > >> > >=20 > >> > > If I replace 'js-indent-level' with '0' in this line, the indentat= ion > >> > > would > >> > > be correct, but this might have unwanted side-effects I overlooked. > >> > >=20 > >> > > My current emacs version: > >> > >=20 > >> > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, > >> > > cairo version 1.18.2) > >> > >=20 > >> > > Thanks for looking into this. > >> >=20 > >> > Juri and Vincenzo, any comments? > >=20 > > From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 2001 > > From: Vincenzo Pupillo > > Date: Sat, 22 Mar 2025 23:43:52 +0100 > > Subject: [PATCH] Fix indentation of "{" when on a new line of a function > >=20 > > declaration. > >=20 > > * lisp/progmodes/js.el > > (js--treesit-indent-rules): New rule for the indentation of "{" when > > of a new line of a function declaration. (bug#76704) > > --- > >=20 > > lisp/progmodes/js.el | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > >=20 > > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > > index 3e789218fde..6943ffc2d28 100644 > > --- a/lisp/progmodes/js.el > > +++ b/lisp/progmodes/js.el > > @@ -3464,7 +3464,10 @@ js--treesit-indent-rules > >=20 > > ((parent-is "ternary_expression") parent-bol js-indent-level) > > ((parent-is "member_expression") parent-bol js-indent-level) > > ((node-is ,switch-case) parent-bol 0) > >=20 > > - ;; "{" on the newline. > > + ;; "{" on the newline for functions. > > + ((query "(function_declaration body: (statement_block \"{\") > > @indent)") + parent-bol 0) > > + ;; "{" on the newline in other cases. > >=20 > > ((node-is "statement_block") parent-bol js-indent-level) > > ((parent-is "named_imports") parent-bol js-indent-level) > > ((parent-is "statement_block") parent-bol js-indent-level) From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 23 15:21:11 2025 Received: (at 76704) by debbugs.gnu.org; 23 Mar 2025 19:21:11 +0000 Received: from localhost ([127.0.0.1]:52706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twQsg-0000NB-Js for submit@debbugs.gnu.org; Sun, 23 Mar 2025 15:21:11 -0400 Received: from mout.gmx.net ([212.227.15.18]:32861) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twQsa-0000Ly-Q2 for 76704@debbugs.gnu.org; Sun, 23 Mar 2025 15:21:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1742757658; x=1743362458; i=f.brosda@gmx.de; bh=M7REY2zYKC6/7WOL6lCeQzfo4ReBj5hLXbi1JMfp3iA=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=GJtCEdjSmBQZXy2hn8H8fA4IBIQGm/bdd6e25QDEoMFYLLcds6zEI560pj0epGQQ 7krHQAyL4MRtLSDZaAJnF6LRjs2SlYZLl32AFBMPMrSMz9jMAI1IMaHbMjJnvQgmN 4SUKxouiILUCzjBAtrzkZpebMV9JnBhm6uWzPEqifuTRNZrJaw7/5LcLnCnsFoqIM xnVPTnCcq0Du2rzA86j/VfhC9t4/fZ6qsji/FzXrbYG4ruC3lNzyoIY1Nr//4MqNk 05K4+9WAbcQtgEJmL+40vN74zVo/I9mFCLXUYrDqGMzp8ud/1RC75DkialVnHJfa+ BDVNoyrLarvAi29TbA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([84.136.46.158]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M3DO3-1tzzeB1Udh-0068Sq; Sun, 23 Mar 2025 20:20:58 +0100 From: Fabian Brosda To: Vincenzo Pupillo , juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode In-Reply-To: <2191042.9o76ZdvQCi@fedora> References: <871pvfkyjc.fsf@gmx.de> <4873433.vXUDI8C0e8@fedora> <87sen4f3tx.fsf@gmx.de> <2191042.9o76ZdvQCi@fedora> Date: Sun, 23 Mar 2025 20:20:56 +0100 Message-ID: <87msdb8sfb.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:jWGuegjEH8DE1JW2Qm3EInjPCi/EWa9W+5fq+se8bMFUF2tEcwB or1Uyl3rL66zoq4h7ej+IKCvOPU/4aXHh+26daEHMxmLopCj3VynjI3XD+wlLG/foRR8KGB JvFq5sx54k8HnRGMg+Jwg0FeElmdGDxsb3eVLTIfzm6P5s2/Ru0xDMqRGiOBmwVBasmO8aK JGeY5IS4H/vOqaXRRVKSg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:aCrrEJ10Zes=;1jUpIs1Dd6uq9yY3ssiH6BF/kYs kmdOAqYwDPlB24Eh2EPVUgZVrGHrii0j3UAkcDpsWxwHvZQ/9ckznrpv3CbalucrNuUSy+Wcm I+lvHGGFsYbrXzu1LjhwceCF17qISj68ChJFt44h+u75K87M+wgiAsj2mQBzwrSWVDDJkdpKN 2giad/2vh21foRu7qTEt9ze+XTc3ZVFZKexwmon0B9Yg7GV4DcOIoH2fL4UAtCJARJ7xITWmu ido7kC0Tv/mPXRIRDLCu+tYxh6PO6EWPTFbHYSp7rwR4t/F3pDn3tNMtqu8BCZUNHRtgw819G 6AXAyqbM60+l2HfwUKsGSLgIh9HqNnH7zuOhe8ZgP8/A2owB0HquqCnKAovuhRfSHy0f7W28q NYps25x3BYzqC7tTfyYkPI0BTd7k7Ho8dWwnxE/zubC7Hm9mhpsiRIRpeG1SeLQdZdtF6eE8y V92Rgu//Z3YNnp+OmMp3s2xnkjLnN4hlkHQI6i6M3tkKs4PbUbXDTj3NAHSc2drK77asPbZWI uzFZ7sFZ1B8/nR3mEtWZ8mnGigRiRJcigHMrgY7x3BqfKVyi6a4sc3mlhPplt2Wb61HGuA5+d YFs/b8OvCeJSZiSWrlpdABClpxhorm56myCoydJqbwVjN03oErX0Y0qLo2BkTPu+KBK8D0KTW 5ClcDxMYmruqJzm1PyG7RthMPHZBadRbwuSFv7E3crGKrCCzhdb5Fe65L9OKTPJBEjfeCeTeN 4RraBFovhjcbbGOlPam3k7UvD24uDyW4x2/wtjAKmaIkZBPjbPSkrb+Fk5ccp6Jo9f5NCNBs3 UWa5crwPgiOP8oyfNP8/r7MESgUrC/B7/bwZdUdZI6B71MaocRrrI181lu7FotQanuj4QNmO5 MSnu3dH/0q/bb+/blq6jkXvEZdZRjqlLdRIg+WwgkwZinbDKKAzmMxeoNyQkf6gE1KV7HlBzj lsLqWgYrh28Ij63Q0oFNA9dA4MsZUjgDkCCy1T8mleDX8clvrd04nPqkBAi6pR9vf53lWuicL Z7+6xYbLDYOLa6YMRbBbSISyzu53GwkTX2IZzgT1YYZQEpETo/2NNRhVmm5Bj7g7YT6MJ0ZOB HdxCCpj0/QclPSwJt3FXMVkuCQeVNL8BgWnv/kGAlUURqrlFS6U6MRTkO4cgnsv/Zo+j4qF2S IubSCkzeNKi+BZX9o3NS4b1mETW6vhjvK6WdjrKjQo188ppuV71tBiylatFNJqj0leS2YYk5e kK4TXp1M4+cI8pLducfJedbMlcA+LW5jpH/68EoW+iBsh5yMtti7XMQffw+j9KJXemV+onztp MBP3opdEwRqqiDWk52YWuWorfjsyeeiDW0esl3tqKt1agbeNOpAZv2Qa3wi1A+BNDbFYTDiDD ZEEGwpEOHEjNFIqMC68L0eP9D+tcmlRXZG0jwGmf2b7FcF0oymlXtbj1J3plUk7zhEm/+dID1 HhMKujCrkcEgQ7o1pBUog/eEZuCGC0XIEoJLU9bCEbFmyw3Yufij3dU8xo6e6Hn1dcXkukA== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.7 (-) Hi Vincenzo, all right, thanks for taking care of it. Just in case you don't already know and maybe interesting, if the indentation should in fact be exactly the same as in js-mode, I noticed, that your arrow function example is indented differently. In js-mode: const Geek =3D (a, b) =3D> { return (a + " " + b); } In js-ts-mode: const Geek =3D (a, b) =3D> { return (a + " " + b); } js-indent-level is set to 4 in both cases. Looks like js-mode in general aligns the part of a variable declaration, with the start of the variable if you add a line break somewhere. Fabian =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 Vincenzo Pupillo writes: > Ciao Fabian, thank you.=20 > In fact, there are other cases where it does not work, and especially the= =20 > behavior is different from js-mode. I need to think about this a bit more= .. > > Vincenzo > > In data domenica 23 marzo 2025 11:18:02 Ora standard dell=E2=80=99Europa = centrale,=20 > Fabian Brosda ha scritto: >> Hi, >> thanks for the explanation and the patch. The result from the patch is >> a GNU-style indentation, where only the braces for functions are not >> indented, while braces for other blocks (if/else, loops, arrow >> functions) are indented. >>=20 >> What I would like to have is Allman style indentation, where the braces >> for blocks like if/else indent the same as for functions. This also >> seems the default behavior in the old js-mode. In this case I think it >> would be correct to not indent the brace for the arrow function. For >> reference, I found an issue in eslint regarding this indentation: >>=20 >> https://github.com/eslint/eslint/issues/8493 >>=20 >> Would it be possible to also support the later? >>=20 >> Fabian >>=20 >> Vincenzo Pupillo writes: >> > Ciao, >> > a rule like this: >> > ((node-is "statement_block") parent-bol 0) >> >=20 >> > works for function but brakes the indentation of expressione like this: >> > const Geek =3D (a, b) =3D> >> >=20 >> > { >> >=20=09 >> > return (a + " " + b); >> >=20=09 >> > } >> >=20 >> > In the attached patch, I have added a new rule specifically for this c= ase. >> >=20 >> > Vincenzo >> >=20 >> > In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99Europa= centrale, >> > Eli>=20 >> > Zaretskii ha scritto: >> >> Ping! Juri and Vincenzo, please chime in. >> >>=20 >> >> > Cc: 76704@debbugs.gnu.org >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 >> >> > From: Eli Zaretskii >> >> >=20 >> >> > > Date: Sun, 02 Mar 2025 20:44:39 +0100 >> >> > > From: Fabian Brosda via "Bug reports for GNU Emacs, >> >> > >=20 >> >> > > the Swiss army knife of text editors" >> >> > >=20 >> >> > > Hi, >> >> > >=20 >> >> > > when using js-ts-mode instead of js-mode, braces, which are put o= n a >> >> > > separate line are indented one level too much. Here is a simple >> >> > > example >> >> > > of how the indentation looks like, after using indent-region on t= he >> >> > > whole function: >> >> > >=20 >> >> > > ``` >> >> > > function test(x) >> >> > >=20 >> >> > > { >> >> > >=20=20=20=20=20 >> >> > > if(x) >> >> > >=20=09=20=20=20=20 >> >> > > { >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> > > return a; >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> > > } >> >> > >=20=09=20=20=20=20 >> >> > > else >> >> > >=20=09=20=20=20=20 >> >> > > { >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> > > return b; >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> > > } >> >> > >=20=20=20=20=20 >> >> > > } >> >> > >=20 >> >> > > ``` >> >> > >=20 >> >> > > The used tree-sitter grammar is downloaded from >> >> > > https://github.com/tree-sitter/tree-sitter-javascript. >> >> > >=20 >> >> > > Having braces on a separate line is probably not the most common = for >> >> > > javascript, but using indent-region in the js-mode, does yield the >> >> > > expected result. The js.el file does already contain a comment >> >> > > mentioning braces in js--treesit-indent-rules. But even based on= the >> >> > > git history it is not clear to me, what exactly is meant: >> >> > >=20 >> >> > > ``` >> >> > >=20 >> >> > > ;; "{" on the newline. >> >> > > ((node-is "statement_block") parent-bol js-indent-level) >> >> > >=20 >> >> > > ``` >> >> > >=20 >> >> > > Link: >> >> > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/= js.e >> >> > > l# >> >> > > L3457 >> >> > >=20 >> >> > > If I replace 'js-indent-level' with '0' in this line, the indenta= tion >> >> > > would >> >> > > be correct, but this might have unwanted side-effects I overlooke= d. >> >> > >=20 >> >> > > My current emacs version: >> >> > >=20 >> >> > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.4= 8, >> >> > > cairo version 1.18.2) >> >> > >=20 >> >> > > Thanks for looking into this. >> >> >=20 >> >> > Juri and Vincenzo, any comments? >> >=20 >> > From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 2001 >> > From: Vincenzo Pupillo >> > Date: Sat, 22 Mar 2025 23:43:52 +0100 >> > Subject: [PATCH] Fix indentation of "{" when on a new line of a functi= on >> >=20 >> > declaration. >> >=20 >> > * lisp/progmodes/js.el >> > (js--treesit-indent-rules): New rule for the indentation of "{" when >> > of a new line of a function declaration. (bug#76704) >> > --- >> >=20 >> > lisp/progmodes/js.el | 5 ++++- >> > 1 file changed, 4 insertions(+), 1 deletion(-) >> >=20 >> > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el >> > index 3e789218fde..6943ffc2d28 100644 >> > --- a/lisp/progmodes/js.el >> > +++ b/lisp/progmodes/js.el >> > @@ -3464,7 +3464,10 @@ js--treesit-indent-rules >> >=20 >> > ((parent-is "ternary_expression") parent-bol js-indent-level) >> > ((parent-is "member_expression") parent-bol js-indent-level) >> > ((node-is ,switch-case) parent-bol 0) >> >=20 >> > - ;; "{" on the newline. >> > + ;; "{" on the newline for functions. >> > + ((query "(function_declaration body: (statement_block \"{\") >> > @indent)") + parent-bol 0) >> > + ;; "{" on the newline in other cases. >> >=20 >> > ((node-is "statement_block") parent-bol js-indent-level) >> > ((parent-is "named_imports") parent-bol js-indent-level) >> > ((parent-is "statement_block") parent-bol js-indent-level) From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 26 10:58:22 2025 Received: (at 76704) by debbugs.gnu.org; 26 Mar 2025 14:58:23 +0000 Received: from localhost ([127.0.0.1]:43844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1txSD0-0000Kd-1u for submit@debbugs.gnu.org; Wed, 26 Mar 2025 10:58:22 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:51298) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1txSCw-0000KB-CY for 76704@debbugs.gnu.org; Wed, 26 Mar 2025 10:58:19 -0400 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5e61da95244so11614355a12.2 for <76704@debbugs.gnu.org>; Wed, 26 Mar 2025 07:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743001092; x=1743605892; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t+b94bRjDLqadC2xJjv/RmltkEjQkeN2hO9IYDOH7Pk=; b=YIM5UOTskFs1X7qFp+ckXq5PHNbg2eOU0I/ceBf0IkOElWhOEerNtum37TU7HZnSql eJoq3z1MTWrnNgq8kUgrlNw1v+WS35jWbJzb2NnD9AUlYtDxxxBdF1+cN4ZlJFgUSc40 m8Qb46dk175obwSqEO0nvDjs09MN2xEm42PW/vb3sxey6blttzoyZuMUFIgfwiZetzgW YS3LB/BXsTLEmLFi7MUVNq7Y8ROsHgDVWV+xR2704/ub0NkVa1HeDWpWRvnTexkFPWg2 zTufu0W3Tqfz2tKN5FOz2VBPDv1QWtWNZCd4KsgdXr0I5GMqoE7udOS2K9Zq96gdJViW 4o3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743001092; x=1743605892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t+b94bRjDLqadC2xJjv/RmltkEjQkeN2hO9IYDOH7Pk=; b=K9DBfSDROEl9vVUuaE4rtson1fGkeMXaUaoPPu4yHcFNzSnSMGa8MylCf7i1VuAHgi ayhcL4Qw74ltXVA2IPdMT8yxTSy9ve9yv/41g5orT8Hd0A211Gz4ScLxmrPYcLNQh7xl o/r+zoIQwnXLdYOAFWGOIS9Xmlv+ZgGk3ekPEqgm+5ZFrLfk+ZSMnQzsQSTaNjLHc6vz LBzXtgWzhMb6O1HSip9VKP2sm44QAkN7MSDZLaVcsB/HEAlUaOcHgZioezOlk/VKXvO6 HH3ybJq4khXn7Lcb5ET4AmZkP1wmN/neDf+6GkhTRvHzV5IrDaTYa+jF8+TPC7KnFgdN r2WQ== X-Gm-Message-State: AOJu0YzAeTGHS5G5OWGKwqw4PtbgKDHccUUeF+TQxGgTN0fUQUQ6aYas shpfUC0TdkkNPneDAbxPWKSb2qu+BkHAqs0Dg8tuKcSiqTTLMdyy X-Gm-Gg: ASbGncvHozsWf4j6JsLcZYE7+LT6eJdgqXz+N10AXMAvao6H9+geWQFw2Gk6rmgYqQU KLpN0Gqj1u6iL5utCawMe8utd8aUcx7W/JAdLYENLQKx4ApAu4O+bCFNGXSfMFIlyrRTtuLqMfK a69oBF1Sz5KerCivQefNiDmhgEXs7SJkdE34+iuYsDQQIHIjjhvqRWJcEQ96L54JHQ1PbNtVmKh /ggAf7b7PmozsWXjLTccwEfdDDTF4lzNQL0LdAz8l0DLisr2+3MceWFwmkibbkueYEdx5eH70ED eugVhS3T5U0Zi3HpQBpGIIp3TcL+mK1gztYYJpK7LchGN6PC1nQ2cZYvFb6T49IF+YL8wgRgsNx AUQg1xVdo X-Google-Smtp-Source: AGHT+IEOF/ylGfhuMxvqENQ+yqdkIJC0hgkOQL1C6G6aPP560WWFZhQxTcpSokA0rIxtELKWeMz3fQ== X-Received: by 2002:a05:6402:440a:b0:5e7:b011:6c09 with SMTP id 4fb4d7f45d1cf-5ebcd467fb0mr21907992a12.18.1743001091414; Wed, 26 Mar 2025 07:58:11 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ebccfaeeb1sm9438392a12.35.2025.03.26.07.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Mar 2025 07:58:10 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii , Fabian Brosda Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Wed, 26 Mar 2025 15:58:09 +0100 Message-ID: <2736747.vuYhMxLoTh@fedora> In-Reply-To: <87msdb8sfb.fsf@gmx.de> References: <871pvfkyjc.fsf@gmx.de> <2191042.9o76ZdvQCi@fedora> <87msdb8sfb.fsf@gmx.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart4942451.OV4Wx5bFTl" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.0 (-) This is a multi-part message in MIME format. --nextPart4942451.OV4Wx5bFTl Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Thank you Fabian.=20 This new patch also fixes this problem in my tests. Can you please try it i= n=20 your use cases? There would be some other things to fix as well, but maybe it would be bett= er=20 to do it in emacs 31. What do you think Eli? Vincenzo In data domenica 23 marzo 2025 20:20:56 Ora standard dell=E2=80=99Europa ce= ntrale,=20 =46abian Brosda ha scritto: > Hi Vincenzo, >=20 > all right, thanks for taking care of it. Just in case you don't already > know and maybe interesting, if the indentation should in fact be exactly > the same as in js-mode, I noticed, that your arrow function example is > indented differently. >=20 > In js-mode: >=20 > const Geek =3D (a, b) =3D> > { > return (a + " " + b); > } >=20 >=20 > In js-ts-mode: >=20 > const Geek =3D (a, b) =3D> > { > return (a + " " + b); > } >=20 > js-indent-level is set to 4 in both cases. Looks like js-mode in general > aligns the part of a variable declaration, with the start of the > variable if you add a line break somewhere. >=20 > Fabian >=20 > Vincenzo Pupillo writes: > > Ciao Fabian, thank you. > > In fact, there are other cases where it does not work, and especially t= he > > behavior is different from js-mode. I need to think about this a bit > > more.. > >=20 > > Vincenzo > >=20 > > In data domenica 23 marzo 2025 11:18:02 Ora standard dell=E2=80=99Europ= a centrale, > >=20 > > Fabian Brosda ha scritto: > >> Hi, > >> thanks for the explanation and the patch. The result from the patch is > >> a GNU-style indentation, where only the braces for functions are not > >> indented, while braces for other blocks (if/else, loops, arrow > >> functions) are indented. > >>=20 > >> What I would like to have is Allman style indentation, where the braces > >> for blocks like if/else indent the same as for functions. This also > >> seems the default behavior in the old js-mode. In this case I think it > >> would be correct to not indent the brace for the arrow function. For > >> reference, I found an issue in eslint regarding this indentation: > >>=20 > >> https://github.com/eslint/eslint/issues/8493 > >>=20 > >> Would it be possible to also support the later? > >>=20 > >> Fabian > >>=20 > >> Vincenzo Pupillo writes: > >> > Ciao, > >> > a rule like this: > >> > ((node-is "statement_block") parent-bol 0) > >> >=20 > >> > works for function but brakes the indentation of expressione like th= is: > >> > const Geek =3D (a, b) =3D> > >> >=20 > >> > { > >> > =09 > >> > return (a + " " + b); > >> > =09 > >> > } > >> >=20 > >> > In the attached patch, I have added a new rule specifically for this > >> > case. > >> >=20 > >> > Vincenzo > >> >=20 > >> > In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99Euro= pa > >> > centrale, > >> > Eli> > >> >=20 > >> > Zaretskii ha scritto: > >> >> Ping! Juri and Vincenzo, please chime in. > >> >>=20 > >> >> > Cc: 76704@debbugs.gnu.org > >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 > >> >> > From: Eli Zaretskii > >> >> >=20 > >> >> > > Date: Sun, 02 Mar 2025 20:44:39 +0100 > >> >> > > From: Fabian Brosda via "Bug reports for GNU Emacs, > >> >> > >=20 > >> >> > > the Swiss army knife of text editors" > >> >> > >=20 > >> >> > > Hi, > >> >> > >=20 > >> >> > > when using js-ts-mode instead of js-mode, braces, which are put= on > >> >> > > a > >> >> > > separate line are indented one level too much. Here is a simple > >> >> > > example > >> >> > > of how the indentation looks like, after using indent-region on > >> >> > > the > >> >> > > whole function: > >> >> > >=20 > >> >> > > ``` > >> >> > > function test(x) > >> >> > >=20 > >> >> > > { > >> >> > > =20 > >> >> > > if(x) > >> >> > > =20 > >> >> > > { > >> >> > > =20 > >> >> > > return a; > >> >> > > =20 > >> >> > > } > >> >> > > =20 > >> >> > > else > >> >> > > =20 > >> >> > > { > >> >> > > =20 > >> >> > > return b; > >> >> > > =20 > >> >> > > } > >> >> > > =20 > >> >> > > } > >> >> > >=20 > >> >> > > ``` > >> >> > >=20 > >> >> > > The used tree-sitter grammar is downloaded from > >> >> > > https://github.com/tree-sitter/tree-sitter-javascript. > >> >> > >=20 > >> >> > > Having braces on a separate line is probably not the most common > >> >> > > for > >> >> > > javascript, but using indent-region in the js-mode, does yield = the > >> >> > > expected result. The js.el file does already contain a comment > >> >> > > mentioning braces in js--treesit-indent-rules. But even based = on > >> >> > > the > >> >> > > git history it is not clear to me, what exactly is meant: > >> >> > >=20 > >> >> > > ``` > >> >> > >=20 > >> >> > > ;; "{" on the newline. > >> >> > > ((node-is "statement_block") parent-bol js-indent-level) > >> >> > >=20 > >> >> > > ``` > >> >> > >=20 > >> >> > > Link: > >> >> > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progmode= s/j > >> >> > > s.e > >> >> > > l# > >> >> > > L3457 > >> >> > >=20 > >> >> > > If I replace 'js-indent-level' with '0' in this line, the > >> >> > > indentation > >> >> > > would > >> >> > > be correct, but this might have unwanted side-effects I > >> >> > > overlooked. > >> >> > >=20 > >> >> > > My current emacs version: > >> >> > >=20 > >> >> > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version > >> >> > > 3.24.48, > >> >> > > cairo version 1.18.2) > >> >> > >=20 > >> >> > > Thanks for looking into this. > >> >> >=20 > >> >> > Juri and Vincenzo, any comments? > >> >=20 > >> > From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 20= 01 > >> > From: Vincenzo Pupillo > >> > Date: Sat, 22 Mar 2025 23:43:52 +0100 > >> > Subject: [PATCH] Fix indentation of "{" when on a new line of a > >> > function > >> >=20 > >> > declaration. > >> >=20 > >> > * lisp/progmodes/js.el > >> > (js--treesit-indent-rules): New rule for the indentation of "{" when > >> > of a new line of a function declaration. (bug#76704) > >> > --- > >> >=20 > >> > lisp/progmodes/js.el | 5 ++++- > >> > 1 file changed, 4 insertions(+), 1 deletion(-) > >> >=20 > >> > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > >> > index 3e789218fde..6943ffc2d28 100644 > >> > --- a/lisp/progmodes/js.el > >> > +++ b/lisp/progmodes/js.el > >> > @@ -3464,7 +3464,10 @@ js--treesit-indent-rules > >> >=20 > >> > ((parent-is "ternary_expression") parent-bol js-indent-level) > >> > ((parent-is "member_expression") parent-bol js-indent-level) > >> > ((node-is ,switch-case) parent-bol 0) > >> >=20 > >> > - ;; "{" on the newline. > >> > + ;; "{" on the newline for functions. > >> > + ((query "(function_declaration body: (statement_block \"{\") > >> > @indent)") + parent-bol 0) > >> > + ;; "{" on the newline in other cases. > >> >=20 > >> > ((node-is "statement_block") parent-bol js-indent-level) > >> > ((parent-is "named_imports") parent-bol js-indent-level) > >> > ((parent-is "statement_block") parent-bol js-indent-level) --nextPart4942451.OV4Wx5bFTl Content-Disposition: attachment; filename="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" >From 2d715869962c3720c80ec3009adade5dd3c4c8b1 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 22 Mar 2025 23:43:52 +0100 Subject: [PATCH] Fix indentation of "{" when on a new line of a function declaration. * lisp/progmodes/js.el (js--treesit-indent-rules): Fix rule for the indentation of "{" when of a new line of a function declaration. (bug#76704) Fix other related rules. --- lisp/progmodes/js.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 3e789218fde..802d74103df 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3454,7 +3454,7 @@ js--treesit-indent-rules (let ((switch-case (rx "switch_" (or "case" "default")))) `((javascript ((parent-is "program") parent-bol 0) - ((node-is "}") parent-bol 0) + ((node-is "}") standalone-parent 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) @@ -3465,9 +3465,9 @@ js--treesit-indent-rules ((parent-is "member_expression") parent-bol js-indent-level) ((node-is ,switch-case) parent-bol 0) ;; "{" on the newline. - ((node-is "statement_block") parent-bol js-indent-level) + ((node-is "statement_block") parent-bol 0) ((parent-is "named_imports") parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) + ((parent-is "statement_block") standalone-parent js-indent-level) ((parent-is "variable_declarator") parent-bol js-indent-level) ((parent-is "arguments") parent-bol js-indent-level) ((parent-is "array") parent-bol js-indent-level) @@ -3477,12 +3477,11 @@ js--treesit-indent-rules ((parent-is "object_pattern") parent-bol js-indent-level) ((parent-is "object") parent-bol js-indent-level) ((parent-is "pair") parent-bol js-indent-level) - ((parent-is "arrow_function") parent-bol js-indent-level) + ((parent-is "arrow_function") grand-parent 0) ((parent-is "parenthesized_expression") parent-bol js-indent-level) ((parent-is "binary_expression") parent-bol js-indent-level) ((parent-is "class_body") parent-bol js-indent-level) ((parent-is ,switch-case) parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) ((match "while" "do_statement") parent-bol 0) ((match "else" "if_statement") parent-bol 0) ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement") -- 2.49.0 --nextPart4942451.OV4Wx5bFTl-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 27 14:59:47 2025 Received: (at 76704) by debbugs.gnu.org; 27 Mar 2025 18:59:47 +0000 Received: from localhost ([127.0.0.1]:51362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1txsSA-0002DU-77 for submit@debbugs.gnu.org; Thu, 27 Mar 2025 14:59:47 -0400 Received: from mout.gmx.net ([212.227.15.19]:33037) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1txsS6-0002DG-HO for 76704@debbugs.gnu.org; Thu, 27 Mar 2025 14:59:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1743101976; x=1743706776; i=f.brosda@gmx.de; bh=eFW7R6Itw/11J4YR0waDE66DfCocvL1AYgH8bTxPo/I=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=O2tVSlI6jJqfPz3LWM4QvZ9WyLF2DiPY/4IMpyboupDsQRR9gJeqFMgMQdEuRqbs kA5XLFJFzi/6Zg8YAn9v4Dl/pssgPqtNpOd4+qIgp7l4t2Rin6wUEGXD34Icu60gS eC2bZSP0Cq6l6AI45EtHgOvCSONBMTrOnkr2VuJPlsbCdOGkMMO+QhYnSEwI9SCNS sYBbPcfbyBDncIgoFRj4RxBVc97ucypg06+ltgCy4AP17nnb9ukbts3YBNUKUeHkk T0TNDj1uCTdLj8IEr2xIN/3RR89w4VXG0S9FGvnoJbqcLkQ8cyzeYy0tBUGRWjrUz f5hOEgBBfPageOJ3yQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([84.136.34.218]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MVN6j-1tWhEV0QOl-00XfxC; Thu, 27 Mar 2025 19:59:36 +0100 From: Fabian Brosda To: Vincenzo Pupillo , juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode In-Reply-To: <2736747.vuYhMxLoTh@fedora> References: <871pvfkyjc.fsf@gmx.de> <2191042.9o76ZdvQCi@fedora> <87msdb8sfb.fsf@gmx.de> <2736747.vuYhMxLoTh@fedora> Date: Thu, 27 Mar 2025 19:59:33 +0100 Message-ID: <87bjtms3je.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:nVz2Xwahdt8ORKMYaDfO+L/EgTBO35XTRw4I9N4OcnWN4i3lmdw 2llm55rRm1+d0HC0GhPaEzR4BeYfpbslorpyKt5nnfanrLHDUlakCOrq9lAOhFSTngIOYuU atG3X2ORHXmSkcIdUoRwvDfxTmQbqjzdZDHtPMmfXq02k2XmY4YEi2qkDQrv7atE4eQfoYG +zvCJcOQ8ST7cU6temfgg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:PVhGXMcRHQM=;LHlwQr9GvlLlTrt9q1UhVd4cW4D UfJyd3361qqkch0Vyj5R5PZ2vPi0eGRbtt4eZ4UTmadAHNUHXcaO7YoDFcVHvb2Lp0BYpliwI W1/GgqY8ClDi0ugumLS0C3cd71tn8D1OVPW9Lx5smPouPudjxUK4zg3rcevsvZpm4ZGFc01LP s1zgGJBEUSil0veasUVzAuqVcvTfY3w9JVES9TN1/rgPffgAWWY3jcLVD21AcLd/42M965Tjc ATDDD/aWY6N/ZHuGA9JSFAC7n5l7pol0TRcgpvE6lUZnqoau+v34Es3qdMrUr7qjbMxo7UFmq KlqEquh8onCb5NScB1ieTRhgCh+c8rkiOnu+HjM/NfuuhoqS7JXTVEIJ6wMQ1Jv+2IRklY6jj chiIXYqUTEUs9z/5VJbjJIOH/mL735gh9x01pfMl1ZgzKdCpWZfSMpY7ZP+jfh/bIsa9OpMNU jI/3CssnRCQwD8x7W7nxFFynb9GqkpW9FpbOj2i1ocGkoiMDzbUJ8KnKM893gzs6KUSjQO8/F HeYEDbAOA8LFm7EnKA18/eWjpj0pV217fMba+ygat+QvpZIp2zJn1LuSMmpat8JJvF9H0u+Su bIENkDvy4CLtseRzsxvfvBsw+XVxK2CrPKAR9SVv9NuECrX6LTtGLlcDO42tXEd465hQaGzmO qLbJ/+Hk6Meri/yd5GGj70B1FgcuCN+v79GjYrqQ2Ln+dnoz+GsR9MR8+ROcpsXYAyeMkxHjN lkTI4iM+cQ6HUory90ezb2Q2ETgkaUL6Z/DRt4Js2phyF6cZITyoK+Q0XdHql/z98Mum8Dvfk m4xz8G48RFg89vvACj9dxWZrJwbadNtQFpFMLSPYkUiNJmrNdbQ3xLFwkAZyWgRsBG2/fmO+A t7arUDGRRHx0/UH7dwOVnGd92VT2YkQYeWjURp4A0tXdq/XPQ6qC+TcwjXnXRtj2ZdNZSYhPE 64k0Qr6H3wdKuwOuTIRtJSrftsbUiYBdCBhULc2xiGi1W5GtYq+ZzzUjTrg+PrqdvCkbnKbzP WOIA1DWzUcHxJUCigKQg+nDUVnu8bgmke/lYGFTwQw5sWz4hbyEbXZ1iyu3Mk1bC9BM5F6pS7 6rAV70aSJ3XhoSrvpMkvDMXlWHkMP6o1lpH0rANuW5aVAEnsWFk5EnAfL2s32YD9DqcVKn7UR mTQi/no+p1/N1XIZMI1Qta33bKf5xB8NzaW2T3rnoAfbI0/x9z6/neMqWTKT0+A0/NFQVoNw4 dUkDK6O3d/EV1m2xIGDaADK2MpXA4gtMvNUMjdSrN0vQWV0DRAnf7QWb9oU9rXBehY8UfcKYx mURAnsA7l5RxJPgYlne0QOthN7NSpgHFrrAm0JryuU6HVeN5HNi+ZcVKOlSFPEDIyoKMkW1CU +XLGWnJ/mJncErOg4aN5DN++DHgKtc7Y16BaJU3+YPnIAqgpV70VuAX7AYKuCSyKN573QOmeZ 4/8RWuVW2G2Qm6flhZ+yr4xl40g7LedNLtucUIQAsVv/dU4oet7Q2Dnl+SUdck99FIAhhaA== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.7 (-) Hi Vincenzo, great that there is already an updated patch. I did test it and it looks good for functions, conditionals, loops. Regarding arrow functions (or variable declarations in general), the result is different, then with js-mode, but personally I think the result looks more consistent in js-ts-mode. There is one exception though. switch-case statements with the brace on a separate line inside a function break js-ts-mode. But it is not really a regression, it looks even worse without the patch :D I tried to add an attachment, with a few examples, but the mail delivery was rejected. Therefore putting only the switch-case example inline into the mail: js-mode: function switch_test(a) { switch (a) { case 1: x; break; case 2: y; break; default: z; break; } switch (a) { case 1: x; break; case 2: y; break; default: z; break; } } js-ts-mode: function switch_test(a) { switch (a) { case 1: x; break; case 2: y; break; default: z; break; } switch (a) { case 1: x; break; case 2: y; break; default: z; break; } } Hope this works now. If you want more examples, I could put them in a github gist, but the rest is not always exactly the same in both modes, but imo fine either way. Fabian Vincenzo Pupillo writes: > Thank you Fabian.=20 > This new patch also fixes this problem in my tests. Can you please try it= in=20 > your use cases? > There would be some other things to fix as well, but maybe it would be be= tter=20 > to do it in emacs 31. What do you think Eli? > > Vincenzo > > In data domenica 23 marzo 2025 20:20:56 Ora standard dell=E2=80=99Europa = centrale,=20 > Fabian Brosda ha scritto: >> Hi Vincenzo, >>=20 >> all right, thanks for taking care of it. Just in case you don't already >> know and maybe interesting, if the indentation should in fact be exactly >> the same as in js-mode, I noticed, that your arrow function example is >> indented differently. >>=20 >> In js-mode: >>=20 >> const Geek =3D (a, b) =3D> >> { >> return (a + " " + b); >> } >>=20 >>=20 >> In js-ts-mode: >>=20 >> const Geek =3D (a, b) =3D> >> { >> return (a + " " + b); >> } >>=20 >> js-indent-level is set to 4 in both cases. Looks like js-mode in general >> aligns the part of a variable declaration, with the start of the >> variable if you add a line break somewhere. >>=20 >> Fabian >>=20 >> Vincenzo Pupillo writes: >> > Ciao Fabian, thank you. >> > In fact, there are other cases where it does not work, and especially = the >> > behavior is different from js-mode. I need to think about this a bit >> > more.. >> >=20 >> > Vincenzo >> >=20 >> > In data domenica 23 marzo 2025 11:18:02 Ora standard dell=E2=80=99Euro= pa centrale, >> >=20 >> > Fabian Brosda ha scritto: >> >> Hi, >> >> thanks for the explanation and the patch. The result from the patch = is >> >> a GNU-style indentation, where only the braces for functions are not >> >> indented, while braces for other blocks (if/else, loops, arrow >> >> functions) are indented. >> >>=20 >> >> What I would like to have is Allman style indentation, where the brac= es >> >> for blocks like if/else indent the same as for functions. This also >> >> seems the default behavior in the old js-mode. In this case I think = it >> >> would be correct to not indent the brace for the arrow function. For >> >> reference, I found an issue in eslint regarding this indentation: >> >>=20 >> >> https://github.com/eslint/eslint/issues/8493 >> >>=20 >> >> Would it be possible to also support the later? >> >>=20 >> >> Fabian >> >>=20 >> >> Vincenzo Pupillo writes: >> >> > Ciao, >> >> > a rule like this: >> >> > ((node-is "statement_block") parent-bol 0) >> >> >=20 >> >> > works for function but brakes the indentation of expressione like t= his: >> >> > const Geek =3D (a, b) =3D> >> >> >=20 >> >> > { >> >> >=20=09 >> >> > return (a + " " + b); >> >> >=20=09 >> >> > } >> >> >=20 >> >> > In the attached patch, I have added a new rule specifically for this >> >> > case. >> >> >=20 >> >> > Vincenzo >> >> >=20 >> >> > In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99Eur= opa >> >> > centrale, >> >> > Eli> >> >> >=20 >> >> > Zaretskii ha scritto: >> >> >> Ping! Juri and Vincenzo, please chime in. >> >> >>=20 >> >> >> > Cc: 76704@debbugs.gnu.org >> >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 >> >> >> > From: Eli Zaretskii >> >> >> >=20 >> >> >> > > Date: Sun, 02 Mar 2025 20:44:39 +0100 >> >> >> > > From: Fabian Brosda via "Bug reports for GNU Emacs, >> >> >> > >=20 >> >> >> > > the Swiss army knife of text editors" >> >> >> > >=20 >> >> >> > > Hi, >> >> >> > >=20 >> >> >> > > when using js-ts-mode instead of js-mode, braces, which are pu= t on >> >> >> > > a >> >> >> > > separate line are indented one level too much. Here is a simp= le >> >> >> > > example >> >> >> > > of how the indentation looks like, after using indent-region on >> >> >> > > the >> >> >> > > whole function: >> >> >> > >=20 >> >> >> > > ``` >> >> >> > > function test(x) >> >> >> > >=20 >> >> >> > > { >> >> >> > >=20=20=20=20=20 >> >> >> > > if(x) >> >> >> > >=20=09=20=20=20=20 >> >> >> > > { >> >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> >> > > return a; >> >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> >> > > } >> >> >> > >=20=09=20=20=20=20 >> >> >> > > else >> >> >> > >=20=09=20=20=20=20 >> >> >> > > { >> >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> >> > > return b; >> >> >> > >=20=09=20=20=20=20=20=20=20=20 >> >> >> > > } >> >> >> > >=20=20=20=20=20 >> >> >> > > } >> >> >> > >=20 >> >> >> > > ``` >> >> >> > >=20 >> >> >> > > The used tree-sitter grammar is downloaded from >> >> >> > > https://github.com/tree-sitter/tree-sitter-javascript. >> >> >> > >=20 >> >> >> > > Having braces on a separate line is probably not the most comm= on >> >> >> > > for >> >> >> > > javascript, but using indent-region in the js-mode, does yield= the >> >> >> > > expected result. The js.el file does already contain a comment >> >> >> > > mentioning braces in js--treesit-indent-rules. But even based= on >> >> >> > > the >> >> >> > > git history it is not clear to me, what exactly is meant: >> >> >> > >=20 >> >> >> > > ``` >> >> >> > >=20 >> >> >> > > ;; "{" on the newline. >> >> >> > > ((node-is "statement_block") parent-bol js-indent-level) >> >> >> > >=20 >> >> >> > > ``` >> >> >> > >=20 >> >> >> > > Link: >> >> >> > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progmod= es/j >> >> >> > > s.e >> >> >> > > l# >> >> >> > > L3457 >> >> >> > >=20 >> >> >> > > If I replace 'js-indent-level' with '0' in this line, the >> >> >> > > indentation >> >> >> > > would >> >> >> > > be correct, but this might have unwanted side-effects I >> >> >> > > overlooked. >> >> >> > >=20 >> >> >> > > My current emacs version: >> >> >> > >=20 >> >> >> > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version >> >> >> > > 3.24.48, >> >> >> > > cairo version 1.18.2) >> >> >> > >=20 >> >> >> > > Thanks for looking into this. >> >> >> >=20 >> >> >> > Juri and Vincenzo, any comments? >> >> >=20 >> >> > From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 2= 001 >> >> > From: Vincenzo Pupillo >> >> > Date: Sat, 22 Mar 2025 23:43:52 +0100 >> >> > Subject: [PATCH] Fix indentation of "{" when on a new line of a >> >> > function >> >> >=20 >> >> > declaration. >> >> >=20 >> >> > * lisp/progmodes/js.el >> >> > (js--treesit-indent-rules): New rule for the indentation of "{" when >> >> > of a new line of a function declaration. (bug#76704) >> >> > --- >> >> >=20 >> >> > lisp/progmodes/js.el | 5 ++++- >> >> > 1 file changed, 4 insertions(+), 1 deletion(-) >> >> >=20 >> >> > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el >> >> > index 3e789218fde..6943ffc2d28 100644 >> >> > --- a/lisp/progmodes/js.el >> >> > +++ b/lisp/progmodes/js.el >> >> > @@ -3464,7 +3464,10 @@ js--treesit-indent-rules >> >> >=20 >> >> > ((parent-is "ternary_expression") parent-bol js-indent-leve= l) >> >> > ((parent-is "member_expression") parent-bol js-indent-level) >> >> > ((node-is ,switch-case) parent-bol 0) >> >> >=20 >> >> > - ;; "{" on the newline. >> >> > + ;; "{" on the newline for functions. >> >> > + ((query "(function_declaration body: (statement_block \"{\") >> >> > @indent)") + parent-bol 0) >> >> > + ;; "{" on the newline in other cases. >> >> >=20 >> >> > ((node-is "statement_block") parent-bol js-indent-level) >> >> > ((parent-is "named_imports") parent-bol js-indent-level) >> >> > ((parent-is "statement_block") parent-bol js-indent-level) > > From 2d715869962c3720c80ec3009adade5dd3c4c8b1 Mon Sep 17 00:00:00 2001 > From: Vincenzo Pupillo > Date: Sat, 22 Mar 2025 23:43:52 +0100 > Subject: [PATCH] Fix indentation of "{" when on a new line of a function > declaration. > > * lisp/progmodes/js.el > (js--treesit-indent-rules): Fix rule for the indentation of "{" when > of a new line of a function declaration. (bug#76704) > Fix other related rules. > --- > lisp/progmodes/js.el | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > index 3e789218fde..802d74103df 100644 > --- a/lisp/progmodes/js.el > +++ b/lisp/progmodes/js.el > @@ -3454,7 +3454,7 @@ js--treesit-indent-rules > (let ((switch-case (rx "switch_" (or "case" "default")))) > `((javascript > ((parent-is "program") parent-bol 0) > - ((node-is "}") parent-bol 0) > + ((node-is "}") standalone-parent 0) > ((node-is ")") parent-bol 0) > ((node-is "]") parent-bol 0) > ((node-is ">") parent-bol 0) > @@ -3465,9 +3465,9 @@ js--treesit-indent-rules > ((parent-is "member_expression") parent-bol js-indent-level) > ((node-is ,switch-case) parent-bol 0) > ;; "{" on the newline. > - ((node-is "statement_block") parent-bol js-indent-level) > + ((node-is "statement_block") parent-bol 0) > ((parent-is "named_imports") parent-bol js-indent-level) > - ((parent-is "statement_block") parent-bol js-indent-level) > + ((parent-is "statement_block") standalone-parent js-indent-level) > ((parent-is "variable_declarator") parent-bol js-indent-level) > ((parent-is "arguments") parent-bol js-indent-level) > ((parent-is "array") parent-bol js-indent-level) > @@ -3477,12 +3477,11 @@ js--treesit-indent-rules > ((parent-is "object_pattern") parent-bol js-indent-level) > ((parent-is "object") parent-bol js-indent-level) > ((parent-is "pair") parent-bol js-indent-level) > - ((parent-is "arrow_function") parent-bol js-indent-level) > + ((parent-is "arrow_function") grand-parent 0) > ((parent-is "parenthesized_expression") parent-bol js-indent-leve= l) > ((parent-is "binary_expression") parent-bol js-indent-level) > ((parent-is "class_body") parent-bol js-indent-level) > ((parent-is ,switch-case) parent-bol js-indent-level) > - ((parent-is "statement_block") parent-bol js-indent-level) > ((match "while" "do_statement") parent-bol 0) > ((match "else" "if_statement") parent-bol 0) > ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "= _statement") > --=20 > 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 28 05:53:14 2025 Received: (at 76704) by debbugs.gnu.org; 28 Mar 2025 09:53:14 +0000 Received: from localhost ([127.0.0.1]:52921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ty6On-0000Vd-2F for submit@debbugs.gnu.org; Fri, 28 Mar 2025 05:53:14 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:56565) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ty6Ok-0000VO-BC for 76704@debbugs.gnu.org; Fri, 28 Mar 2025 05:53:11 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43ce70f9afbso19553585e9.0 for <76704@debbugs.gnu.org>; Fri, 28 Mar 2025 02:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743155584; x=1743760384; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lqi/tYgbvJ0Rdy53YQoj1N98JnBJudWz9hjsuYPltBM=; b=e7FvgHaIRlzIWdH28p+TshLdt0Lkq+8a9LcthaBoMoqcwE54YWGfNyc1DAXmAKiqcU 3dtbERwQHreK1Jzeh/Zi4OsWGeCkQ53e/fAtXiUe6PQtVrzwOJc/WF22mL0YygMvJ/AL QjwmiUA+1uQxhJIazmdihrZ4wzRU56U4e2uJ0bL4CQqL7gAW55om9b3PDlrSkM55zQHG petOCyhSs7qi0Z6zJtVbB4+m7gBS5rVCg1vmplcYLUGiFD7ji15MaAA5dn6Yo8gNPIyl kJ0rahXLEI3YXUNFk5Mc3Zt+AiXGw3cQZZQ1HON7dahPpIK5IabulCEBwl2/Bsq6ZETl acgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743155584; x=1743760384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lqi/tYgbvJ0Rdy53YQoj1N98JnBJudWz9hjsuYPltBM=; b=RFzIH1jwTpL9eDBAEwRK/3lD3Acxx1AkcVQOpG2xIDsVdcQ3Pl3SVvf2KvQ1L99mQa QSfdgs/O/3Igmij4hB0ZVUkt2Ol28RN6f3Rsj0ZOK5Ypt2g2M4dVDVPMlL7Y1RWJuWv2 kICb0TTCmW2uy+xopV2JmFCulXVkFTDueo9TV4+dKYE8lNfRXVKfd/6iJpLe6PM3fJEQ ewXJJ0qfsrnO/TJrPyMlSNXtW7FaCPF+EC/wQBFiMplk0WZrDGsI9YodPTL3nycPNZaB onQ+zhDYyOrsWKpF5STMpeoslhuxTKVH6L3tX4XLYMH6RJlYUNdtzvlY5Bzy1bauZLeS zuWA== X-Gm-Message-State: AOJu0YwmWsK+WXPoFxq7oyBjheJ4GlBDHE0kxMzWcqjhkdoLzCRW0egR Urq+3/wVIaMxqL4/VPqwDIvnW2hlI/6CrlXXZTafKLQ4DpygvCiI X-Gm-Gg: ASbGncukq+NawsewAmiUjoRpXqdB9I+z9mOijx1Xlc4w0+XJD3DQgHFBg9ZgNfJf7P3 eFiI21uq7s/mHbW8K53r6s+5GZ+1MusAUroPnbIfrcWC4zuqgFxFeRuhvrncD3Zg8fb7x8ukJQe Z1Ee610DSeJd7N+t6C/MC59i2jmNJx+yZsQw28dzTw4Stv+9Ge/6LqW2dmiVZPGtGmq1AM7iewn cReJ2iU+zyVDFDSqw6uOGKerzv1Tj1bGNcz2Ns0RrFOiuFZo9l4beMIXOXiEjsUnfEeyzR3WZL9 YmmsSJ7qm+zNCXsHxvqM7OWwZP0woLN3tMvsSA1Z9oyzi9cABvU1GT/J935YNsAPKcisP2byv02 QmRabV9cL X-Google-Smtp-Source: AGHT+IFKiHbYpYxBM8nVbcoNF7RFZKX/HEzWaajWgyhn9ilNkfFk0w/EVRM0yw65F65tUhaXK2eiKw== X-Received: by 2002:a05:600c:1ca9:b0:43c:fdbe:43be with SMTP id 5b1f17b1804b1-43d850936d7mr63840715e9.27.1743155583890; Fri, 28 Mar 2025 02:53:03 -0700 (PDT) Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d8314b409sm66250105e9.34.2025.03.28.02.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 02:53:02 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii , Fabian Brosda Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Fri, 28 Mar 2025 10:53:01 +0100 Message-ID: <2895659.vuYhMxLoTh@3-191.divsi.unimi.it> In-Reply-To: <87bjtms3je.fsf@gmx.de> References: <871pvfkyjc.fsf@gmx.de> <2736747.vuYhMxLoTh@fedora> <87bjtms3je.fsf@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.0 (-) Ciao Fabian, In data gioved=C3=AC 27 marzo 2025 19:59:33 Ora standard dell=E2=80=99Europ= a centrale,=20 =46abian Brosda ha scritto: > Hi Vincenzo, >=20 > great that there is already an updated patch. I did test it and it looks > good for functions, conditionals, loops. Regarding arrow functions (or > variable declarations in general), the result is different, then with > js-mode, but personally I think the result looks more consistent in > js-ts-mode. Could you please show me this difference? >=20 > There is one exception though. switch-case statements with the brace on > a separate line inside a function break js-ts-mode. But it is not really > a regression, it looks even worse without the patch :D >=20 > I tried to add an attachment, with a few examples, but the mail delivery > was rejected. Therefore putting only the switch-case example inline > into the mail: >=20 > js-mode: >=20 > function switch_test(a) > { > switch (a) { > case 1: > x; > break; > case 2: > y; > break; > default: > z; > break; > } >=20 > switch (a) > { > case 1: > x; > break; > case 2: > y; > break; > default: > z; > break; > } > } >=20 >=20 > js-ts-mode: >=20 > function switch_test(a) > { > switch (a) { > case 1: > x; > break; > case 2: > y; > break; > default: > z; > break; > } >=20 > switch (a) > { > case 1: > x; > break; > case 2: > y; > break; > default: > z; > break; > } > } >=20 > Hope this works now. If you want more examples, I could put them in a > github gist, but the rest is not always exactly the same in both modes, > but imo fine either way. Thanks Fabian, more complex examples would be very helpful. I used the Reac= t=20 sources and found more problems. Vincenzo >=20 > Fabian >=20 > Vincenzo Pupillo writes: > > Thank you Fabian. > > This new patch also fixes this problem in my tests. Can you please try = it > > in your use cases? > > There would be some other things to fix as well, but maybe it would be > > better to do it in emacs 31. What do you think Eli? > >=20 > > Vincenzo > >=20 > > In data domenica 23 marzo 2025 20:20:56 Ora standard dell=E2=80=99Europ= a centrale, > >=20 > > Fabian Brosda ha scritto: > >> Hi Vincenzo, > >>=20 > >> all right, thanks for taking care of it. Just in case you don't alrea= dy > >> know and maybe interesting, if the indentation should in fact be exact= ly > >> the same as in js-mode, I noticed, that your arrow function example is > >> indented differently. > >>=20 > >> In js-mode: > >>=20 > >> const Geek =3D (a, b) =3D> > >>=20 > >> { > >> =20 > >> return (a + " " + b); > >> =20 > >> } > >>=20 > >> In js-ts-mode: > >>=20 > >> const Geek =3D (a, b) =3D> > >>=20 > >> { > >> =20 > >> return (a + " " + b); > >> =20 > >> } > >>=20 > >> js-indent-level is set to 4 in both cases. Looks like js-mode in gener= al > >> aligns the part of a variable declaration, with the start of the > >> variable if you add a line break somewhere. > >>=20 > >> Fabian > >>=20 > >> Vincenzo Pupillo writes: > >> > Ciao Fabian, thank you. > >> > In fact, there are other cases where it does not work, and especially > >> > the > >> > behavior is different from js-mode. I need to think about this a bit > >> > more.. > >> >=20 > >> > Vincenzo > >> >=20 > >> > In data domenica 23 marzo 2025 11:18:02 Ora standard dell=E2=80=99Eu= ropa > >> > centrale, > >> >=20 > >> > Fabian Brosda ha scritto: > >> >> Hi, > >> >> thanks for the explanation and the patch. The result from the patch > >> >> is > >> >> a GNU-style indentation, where only the braces for functions are not > >> >> indented, while braces for other blocks (if/else, loops, arrow > >> >> functions) are indented. > >> >>=20 > >> >> What I would like to have is Allman style indentation, where the > >> >> braces > >> >> for blocks like if/else indent the same as for functions. This also > >> >> seems the default behavior in the old js-mode. In this case I think > >> >> it > >> >> would be correct to not indent the brace for the arrow function. F= or > >> >> reference, I found an issue in eslint regarding this indentation: > >> >>=20 > >> >> https://github.com/eslint/eslint/issues/8493 > >> >>=20 > >> >> Would it be possible to also support the later? > >> >>=20 > >> >> Fabian > >> >>=20 > >> >> Vincenzo Pupillo writes: > >> >> > Ciao, > >> >> > a rule like this: > >> >> > ((node-is "statement_block") parent-bol 0) > >> >> >=20 > >> >> > works for function but brakes the indentation of expressione like > >> >> > this: > >> >> > const Geek =3D (a, b) =3D> > >> >> >=20 > >> >> > { > >> >> > =09 > >> >> > return (a + " " + b); > >> >> > =09 > >> >> > } > >> >> >=20 > >> >> > In the attached patch, I have added a new rule specifically for t= his > >> >> > case. > >> >> >=20 > >> >> > Vincenzo > >> >> >=20 > >> >> > In data sabato 22 marzo 2025 13:24:16 Ora standard dell=E2=80=99E= uropa > >> >> > centrale, > >> >> > Eli> > >> >> >=20 > >> >> > Zaretskii ha scritto: > >> >> >> Ping! Juri and Vincenzo, please chime in. > >> >> >>=20 > >> >> >> > Cc: 76704@debbugs.gnu.org > >> >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 > >> >> >> > From: Eli Zaretskii > >> >> >> >=20 > >> >> >> > > Date: Sun, 02 Mar 2025 20:44:39 +0100 > >> >> >> > > From: Fabian Brosda via "Bug reports for GNU Emacs, > >> >> >> > >=20 > >> >> >> > > the Swiss army knife of text editors" > >> >> >> > >=20 > >> >> >> > > Hi, > >> >> >> > >=20 > >> >> >> > > when using js-ts-mode instead of js-mode, braces, which are = put > >> >> >> > > on > >> >> >> > > a > >> >> >> > > separate line are indented one level too much. Here is a > >> >> >> > > simple > >> >> >> > > example > >> >> >> > > of how the indentation looks like, after using indent-region= on > >> >> >> > > the > >> >> >> > > whole function: > >> >> >> > >=20 > >> >> >> > > ``` > >> >> >> > > function test(x) > >> >> >> > >=20 > >> >> >> > > { > >> >> >> > > =20 > >> >> >> > > if(x) > >> >> >> > > =20 > >> >> >> > > { > >> >> >> > > =20 > >> >> >> > > return a; > >> >> >> > > =20 > >> >> >> > > } > >> >> >> > > =20 > >> >> >> > > else > >> >> >> > > =20 > >> >> >> > > { > >> >> >> > > =20 > >> >> >> > > return b; > >> >> >> > > =20 > >> >> >> > > } > >> >> >> > > =20 > >> >> >> > > } > >> >> >> > >=20 > >> >> >> > > ``` > >> >> >> > >=20 > >> >> >> > > The used tree-sitter grammar is downloaded from > >> >> >> > > https://github.com/tree-sitter/tree-sitter-javascript. > >> >> >> > >=20 > >> >> >> > > Having braces on a separate line is probably not the most > >> >> >> > > common > >> >> >> > > for > >> >> >> > > javascript, but using indent-region in the js-mode, does yie= ld > >> >> >> > > the > >> >> >> > > expected result. The js.el file does already contain a comm= ent > >> >> >> > > mentioning braces in js--treesit-indent-rules. But even bas= ed > >> >> >> > > on > >> >> >> > > the > >> >> >> > > git history it is not clear to me, what exactly is meant: > >> >> >> > >=20 > >> >> >> > > ``` > >> >> >> > >=20 > >> >> >> > > ;; "{" on the newline. > >> >> >> > > ((node-is "statement_block") parent-bol js-indent-lev= el) > >> >> >> > >=20 > >> >> >> > > ``` > >> >> >> > >=20 > >> >> >> > > Link: > >> >> >> > > https://github.com/emacs-mirror/emacs/blob/master/lisp/progm= ode > >> >> >> > > s/j > >> >> >> > > s.e > >> >> >> > > l# > >> >> >> > > L3457 > >> >> >> > >=20 > >> >> >> > > If I replace 'js-indent-level' with '0' in this line, the > >> >> >> > > indentation > >> >> >> > > would > >> >> >> > > be correct, but this might have unwanted side-effects I > >> >> >> > > overlooked. > >> >> >> > >=20 > >> >> >> > > My current emacs version: > >> >> >> > >=20 > >> >> >> > > GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version > >> >> >> > > 3.24.48, > >> >> >> > > cairo version 1.18.2) > >> >> >> > >=20 > >> >> >> > > Thanks for looking into this. > >> >> >> >=20 > >> >> >> > Juri and Vincenzo, any comments? > >> >> >=20 > >> >> > From 56f0bfe99b0c4cda1e36686e48c58d0d017bda21 Mon Sep 17 00:00:00 > >> >> > 2001 > >> >> > From: Vincenzo Pupillo > >> >> > Date: Sat, 22 Mar 2025 23:43:52 +0100 > >> >> > Subject: [PATCH] Fix indentation of "{" when on a new line of a > >> >> > function > >> >> >=20 > >> >> > declaration. > >> >> >=20 > >> >> > * lisp/progmodes/js.el > >> >> > (js--treesit-indent-rules): New rule for the indentation of "{" w= hen > >> >> > of a new line of a function declaration. (bug#76704) > >> >> > --- > >> >> >=20 > >> >> > lisp/progmodes/js.el | 5 ++++- > >> >> > 1 file changed, 4 insertions(+), 1 deletion(-) > >> >> >=20 > >> >> > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > >> >> > index 3e789218fde..6943ffc2d28 100644 > >> >> > --- a/lisp/progmodes/js.el > >> >> > +++ b/lisp/progmodes/js.el > >> >> > @@ -3464,7 +3464,10 @@ js--treesit-indent-rules > >> >> >=20 > >> >> > ((parent-is "ternary_expression") parent-bol > >> >> > js-indent-level) > >> >> > ((parent-is "member_expression") parent-bol js-indent-lev= el) > >> >> > ((node-is ,switch-case) parent-bol 0) > >> >> >=20 > >> >> > - ;; "{" on the newline. > >> >> > + ;; "{" on the newline for functions. > >> >> > + ((query "(function_declaration body: (statement_block \"{= \") > >> >> > @indent)") + parent-bol 0) > >> >> > + ;; "{" on the newline in other cases. > >> >> >=20 > >> >> > ((node-is "statement_block") parent-bol js-indent-level) > >> >> > ((parent-is "named_imports") parent-bol js-indent-level) > >> >> > ((parent-is "statement_block") parent-bol js-indent-level) > >=20 > > From 2d715869962c3720c80ec3009adade5dd3c4c8b1 Mon Sep 17 00:00:00 2001 > > From: Vincenzo Pupillo > > Date: Sat, 22 Mar 2025 23:43:52 +0100 > > Subject: [PATCH] Fix indentation of "{" when on a new line of a function > >=20 > > declaration. > >=20 > > * lisp/progmodes/js.el > > (js--treesit-indent-rules): Fix rule for the indentation of "{" when > > of a new line of a function declaration. (bug#76704) > > Fix other related rules. > > --- > >=20 > > lisp/progmodes/js.el | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > >=20 > > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > > index 3e789218fde..802d74103df 100644 > > --- a/lisp/progmodes/js.el > > +++ b/lisp/progmodes/js.el > > @@ -3454,7 +3454,7 @@ js--treesit-indent-rules > >=20 > > (let ((switch-case (rx "switch_" (or "case" "default")))) > > =20 > > `((javascript > > =20 > > ((parent-is "program") parent-bol 0) > >=20 > > - ((node-is "}") parent-bol 0) > > + ((node-is "}") standalone-parent 0) > >=20 > > ((node-is ")") parent-bol 0) > > ((node-is "]") parent-bol 0) > > ((node-is ">") parent-bol 0) > >=20 > > @@ -3465,9 +3465,9 @@ js--treesit-indent-rules > >=20 > > ((parent-is "member_expression") parent-bol js-indent-level) > > ((node-is ,switch-case) parent-bol 0) > > ;; "{" on the newline. > >=20 > > - ((node-is "statement_block") parent-bol js-indent-level) > > + ((node-is "statement_block") parent-bol 0) > >=20 > > ((parent-is "named_imports") parent-bol js-indent-level) > >=20 > > - ((parent-is "statement_block") parent-bol js-indent-level) > > + ((parent-is "statement_block") standalone-parent js-indent-leve= l) > >=20 > > ((parent-is "variable_declarator") parent-bol js-indent-level) > > ((parent-is "arguments") parent-bol js-indent-level) > > ((parent-is "array") parent-bol js-indent-level) > >=20 > > @@ -3477,12 +3477,11 @@ js--treesit-indent-rules > >=20 > > ((parent-is "object_pattern") parent-bol js-indent-level) > > ((parent-is "object") parent-bol js-indent-level) > > ((parent-is "pair") parent-bol js-indent-level) > >=20 > > - ((parent-is "arrow_function") parent-bol js-indent-level) > > + ((parent-is "arrow_function") grand-parent 0) > >=20 > > ((parent-is "parenthesized_expression") parent-bol > > js-indent-level) > > ((parent-is "binary_expression") parent-bol js-indent-level) > > ((parent-is "class_body") parent-bol js-indent-level) > > ((parent-is ,switch-case) parent-bol js-indent-level) > >=20 > > - ((parent-is "statement_block") parent-bol js-indent-level) > >=20 > > ((match "while" "do_statement") parent-bol 0) > > ((match "else" "if_statement") parent-bol 0) > > ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") > > "_statement")>=20 > > -- > > 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 28 06:54:00 2025 Received: (at 76704) by debbugs.gnu.org; 28 Mar 2025 10:54:00 +0000 Received: from localhost ([127.0.0.1]:53023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ty7Lb-0003UB-MG for submit@debbugs.gnu.org; Fri, 28 Mar 2025 06:54:00 -0400 Received: from mout.gmx.net ([212.227.15.15]:53557) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ty7LY-0003Tu-Sf for 76704@debbugs.gnu.org; Fri, 28 Mar 2025 06:53:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1743159230; x=1743764030; i=f.brosda@gmx.de; bh=EWrtJK7JxGXZX2Z9UoFWHVG/V/oltnytZIhQVs5nmao=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=e7i5qykYUNIP4EwuBO8FPWIuE+PbuyECATasY0oT3BPCosCoOQLxn3Eg5pJwadBl YhmW8tEerR9rCCUu28dOBe9PLsHqUHrP/7c+7NHUf0y5EzkZEzXjbhGeWMryqcXHY QFjb51BiaWuvpooHGlIGQNywILjOVYurC5L2Y2BxYzLU1UlvX8FF6C8J/D/wLyXpe yJ/BYSXA3nPSdvnH0+IumxGBdnEtiX3//KDk4cZywGZhJQ/MeMS+S6cRRX+PxkZ6t hHAofjNokaK+BbRNtX0nkmUB72hLJrFHD1RUrPyekR7NsoSY1sIBvnMECyAz5dHcc 4j+bvoUsoizrlIK9Nw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([84.136.33.100]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N79yQ-1t41bO17SW-0107vM; Fri, 28 Mar 2025 11:53:50 +0100 From: Fabian Brosda To: Vincenzo Pupillo , juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode In-Reply-To: <2895659.vuYhMxLoTh@3-191.divsi.unimi.it> References: <871pvfkyjc.fsf@gmx.de> <2736747.vuYhMxLoTh@fedora> <87bjtms3je.fsf@gmx.de> <2895659.vuYhMxLoTh@3-191.divsi.unimi.it> Date: Fri, 28 Mar 2025 11:53:49 +0100 Message-ID: <87r02hjuiq.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:fCcqloj5Q/8Mya1ElrWlhfRuJPcsskizUg/fy/Al78BhMcitM9v p0WSPyIrRMw9N9iUdKlB2zDQDRtMD122r7/SvAQrSFTnivRCtZ44//5KtZDEisTPb/XTQhm E9TdKeKsMdTGwDc1uy2gypJ2/6AY66vXaKekAypYrms9/C4WXaKaO5Y4281cIbK5zDydwaY +a7nneF8ssrz9LdVfx+Qg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:mBIZdCR6JW0=;QG83HywaDnGwyHl7DI22VShsCgF gfnU6WshXAzlHnULqLIbHFE8Yy9CiQbM/5+vkVFn3eUB9By0MAMUWhrv44LckSzLzjK516hOr t/efHvwZtUevZartmGyaWPPhSGxh36AFqhoP3SqSuQOBFdaJMLHVrud0kx5VgiOvhy9Mwcsr8 fKPTTvpuGWGM8vLyRf9289RywzXN7o5uPGNBBf0idvlArbg/YLEMOVdRTQFPBBonbOElOLgyH 8fFIlMl9K5iNpTF4mWmVM7IQDjExCmump0oCV5uc0nIGoGv/hQjDm400/oraGOt75z8zqyXCs RuiAx2w+97Ol/2vQjiNYQ7psp1O/qRWQPY4elfztZ2nEzd/zOdf8Hb/xduQ9pNjJVhg0n7voq Z4wL7Kvub+XTRXrYd865ZeeKifx5FLa7xVps60Pr8WK6EtrVZi0giVF18/CUXmX29ZVqBkQ+1 kQDMlAgK+Z+gwihgeckB/MiaXbGqOuwGdebWr3M27b2ECujBMOk0JhyMqqKZVExLeo97EfaMa pM++QtRFAmIyOWmEwAu5DxQC5ALHfOXhL475qDXQICZA+bD2Rr9sX1HE1cUes2iM1u1XOBpPB QOeDoXbxhoNEDS9UM3WCtvqAe49vT1gJASsL57/63VtDPwohVL4owCegK/rhN2kDJnJyq54ml Xpytfz9LVutlv/mZRKB1ppAZyhwFGoXtTsOwnCQvfS5NqkBv0YT6Z/Ksje3ND3O9AuY4bbOs4 kwNp+cvoSG5LVRLYdJKHlyNCiz+R7YWvdcqFL57kX5OS9TtR6/EWjSbTOOaZFMW2Y43Esbh7N TniDggS8INWv4t7jjyJ3r1Nnu3FvqVQjiGmhw3AbQU/bOY8N+bJX9Ue6pcLo6lf983j5P1rad VMYqRfTUw295aRMmAbAX5JQcNPhmDZsxA9oHRaSWoIJ/bZTcxjn/l8w4sNSD4sJWd1nIbLRIJ yftyuYOnhhhljMm+7Q3aXq78g5U4DyjgEn6GIFjODXlBcxOGiOowpYeWjGJuAm7JnO5X0l4wb YYLuw+UZVI8aX6nGDrvdu5YCIKYwl4ZxnqCr8W2q5fxknK/qgrtGMtAAAWEijXy3WBhr4ag8+ 9jKJqMJyqSqraai3DEqHXaL5kN4NW6YGk7EPZ4Xca0wdl/9DOzKylUAijVI0Qs5UkUuSHuTSK FfWmpiVaqtjCguZU3hSpZ5PvAzNe2yn/wT9QBP0p2cEWY9F3SKBJURJ6eIfdPB7TII265O4cd 4R42mqYNse4YbQamyUmpMGl7+wNlW7d3M8DEeWowDSa1IfbZi8SKBfXL/OWnFcglCNJZQqGHM 7YLVEfj0/47CtTCAOcHZcIUgcuiPyDUVhgWsSYN6fLFp84GxfDnNfpF2nDCjp03k/IqVUvBKt doIFGVJCxemttgNoEMnwmdsEzI0vqfQeUohbVBQp+gRH81Owl9wZyeTdTrGmvqF0C1AyKqhFw cPmzIdAO+KBSAl+X7w+ZL5x5/ICqXzVP3AlRXSb6fK9fQcmH1Nud0VlX12HUlkMl17tngGg== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.7 (-) Hi Vincenzo, >> great that there is already an updated patch. I did test it and it looks >> good for functions, conditionals, loops. Regarding arrow functions (or >> variable declarations in general), the result is different, then with >> js-mode, but personally I think the result looks more consistent in >> js-ts-mode. > Could you please show me this difference? The examples are not really complex, just a few maybe a bit unusual cases I could think of. You can find the gist containing the js-mode and js-ts-mode (including your latest patch) version and a diff here: https://gist.github.com/fbrosda/11870561bb009be87b719d5b9a7aa625 A short summary: - Declaring a variable and assigning an arrow function, the braces are not indented in js-ts-mode, but indented to the start of the variable in js-mode (also compare the difference between let and const) - Similar cases, when having a line break in a variable declaration. js-ts-mode uses the fixed indentation js-indent-level, while js-mode indents to the start of the variable name. Observe the difference between const and let. I personally prefer the js-ts-mode, so that const and let, if you mix the two. But at least in my code, this is normally used very rarely, so both versions are fine. - switch-cases have a few differences. For switch with the { on a separate line, it is imo wrong in js-mode to indent the case statements, as the blocks inside the case are not further indented. Switches inside a function break in js-ts-mode, as they have a nega Hope this helps. Fabian From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 01 17:04:27 2025 Received: (at 76704) by debbugs.gnu.org; 1 Apr 2025 21:04:27 +0000 Received: from localhost ([127.0.0.1]:51719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzimY-0001rb-2B for submit@debbugs.gnu.org; Tue, 01 Apr 2025 17:04:27 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:50198) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tzimU-0001qT-Pb for 76704@debbugs.gnu.org; Tue, 01 Apr 2025 17:04:24 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-ac3b12e8518so1159319366b.0 for <76704@debbugs.gnu.org>; Tue, 01 Apr 2025 14:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743541456; x=1744146256; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RUxzgv8ZflsQ5wCIdZbaCfK7RIOivMGtheUq0z4xuwk=; b=iv64FmD4ve/KYKLGAgid2GBzclNlGrvYaejHR5K0GMqQaS8n7ZMF5xssGFzgoTz/Hf PJZyPQfF5KBN1qjrrmDxjhfRwNj1CS+9L5SocWAsfyaRMZBTKhAFsSAyNhe758LBxe98 bMYidCJ74x8uJJNurBHRMJ+oekHi17HExpZskOLeTmMD28aQtgOikqWFqcaJivsaZV4g EP1g78FfmAq8jNZlorJEvdMem1dw3ANKIE4TSggYwV7Svi+ZbDzyXYqgYCxcE3tp38YE i8GdFBwIFXFARq77v0lKVSpwUdBzOrVjNINILtQlwxin3ehhr4GI7xdQtDwt1XIsza1F oMgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743541456; x=1744146256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RUxzgv8ZflsQ5wCIdZbaCfK7RIOivMGtheUq0z4xuwk=; b=NYS5IFUYqHRiZh/y66T6nepUfrR96U5lWeBgh1qblSMvDQIThwQBCfhP7iXszbvPAX t8p+Z6jjsY5egn8BqZXfLd4luq/exIW5jT1CCphtShIjREBXLxCy52EpVUMvfu4KWu0+ +QDFueTKqFl43d78EoetDyInU8a/+mBGZRmlLjtBHSIQG71nUQjfO5bLDY4akiqBrxgl U8EV/nBFxH2nM0Ilu6cJCnT0Q4YJ8OC/rVzseSrZHMHREXQo1qGS3nZv9aTi+1gQtBI7 1D2/ENN3dgjg36y8OfVR7gq8V4DmZWIpYA77M7m6+MRpCRwBf/o6UACMaEwGSX1Vo63O a8uw== X-Gm-Message-State: AOJu0YwFuu67Dg0Aj1NePBv/SAsz2EPoKWKIynpdWYMFdHPT46xCfmPE TxAhrTCzEShH+s55PCq2RQ9PqbMwqoIJ2rM13Cujcy+EFguE7Nyy X-Gm-Gg: ASbGnctt40jlk3HpdHcqzhVHn9VBrOUahThhFNxSww+TkLtK5aZjLDMjUZqDrOvMJBd PifKlUycGk5x7cfJGE3j21BvLITcpbubiqMHelT3nnnI9Lfe5eJheWcRHQMw8D6LNPj7e+zUVFi gVJpOjTN5KrS9FIjyYwYi3eCYPEXMAzxYnhVEyh/1fJG4r9syaObmZfSuOO4Yl4YSbK7l1yWA3O O2E9x+f4U8yZD2jTCCZj7KOg6LF038yniwRA1VoDBYKe5CgkcZ+gS1t+skOAX2l5z/X2me/asGk ROj+FXpHDr0hQqY40dIQNjL9+b7b4ES6IkNmI9XU3mj2Hw2cR8N0/4d/ZZPD1lWjIE3WpEsPMCj ZwNkvcLjMGsHmwd7h+/0= X-Google-Smtp-Source: AGHT+IFImRDPhumEVhUhtytqqoUqyLJJWM2NObmJs/Rdyuq2f2LdUq0ZrIHesHGQnivDP4nsWuWrXw== X-Received: by 2002:a17:907:9693:b0:abf:19ac:771 with SMTP id a640c23a62f3a-ac738976007mr1408154066b.2.1743541456243; Tue, 01 Apr 2025 14:04:16 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac71966df75sm809728466b.124.2025.04.01.14.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 14:04:15 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii , Fabian Brosda Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Tue, 01 Apr 2025 23:04:14 +0200 Message-ID: <22112873.4csPzL39Zc@fedora> In-Reply-To: <87r02hjuiq.fsf@gmx.de> References: <871pvfkyjc.fsf@gmx.de> <2895659.vuYhMxLoTh@3-191.divsi.unimi.it> <87r02hjuiq.fsf@gmx.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2001764.7Z3S40VBb9" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.0 (-) This is a multi-part message in MIME format. --nextPart2001764.7Z3S40VBb9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ciao Fabian,=20 this updated patch fix all yours example and others corner case of arrow=20 function, chained member expression.=20 =46or switch body indentation now possible to use js-switch-indent-offset a= s in=20 js-mode. js-chain-indent can be used to achieve the same behavior as js-mod= e=20 for that chained member expression. Can you please try it again? Vincenzo In data venerd=C3=AC 28 marzo 2025 11:53:49 Ora legale dell=E2=80=99Europa = centrale, Fabian=20 Brosda ha scritto: > Hi Vincenzo, >=20 > >> great that there is already an updated patch. I did test it and it loo= ks > >> good for functions, conditionals, loops. Regarding arrow functions (or > >> variable declarations in general), the result is different, then with > >> js-mode, but personally I think the result looks more consistent in > >> js-ts-mode. > >=20 > > Could you please show me this difference? >=20 > The examples are not really complex, just a few maybe a bit unusual > cases I could think of. You can find the gist containing the js-mode > and js-ts-mode (including your latest patch) version and a diff here: >=20 > https://gist.github.com/fbrosda/11870561bb009be87b719d5b9a7aa625 >=20 > A short summary: >=20 > - Declaring a variable and assigning an arrow function, the braces are > not indented in js-ts-mode, but indented to the start of the variable > in js-mode (also compare the difference between let and const) > - Similar cases, when having a line break in a variable declaration. > js-ts-mode uses the fixed indentation js-indent-level, while js-mode > indents to the start of the variable name. Observe the difference > between const and let. I personally prefer the js-ts-mode, so that > const and let, if you mix the two. But at least in my code, this is > normally used very rarely, so both versions are fine. > - switch-cases have a few differences. For switch with the { on a > separate line, it is imo wrong in js-mode to indent the case > statements, as the blocks inside the case are not further indented. > Switches inside a function break in js-ts-mode, as they have a nega >=20 >=20 > Hope this helps. >=20 > Fabian --nextPart2001764.7Z3S40VBb9 Content-Disposition: attachment; filename="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="utf-8"; name="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" >From faaf48e4f9b76c6450c687f0047a6b8c1f3db010 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 22 Mar 2025 23:43:52 +0100 Subject: [PATCH] Fix indentation of "{" when on a new line of a function declaration. * lisp/progmodes/js.el (js--treesit-switch-body-helper): New anchor helper function for the switch_body. (js--treesit-member-chained-expression-helper): New anchor helper function for chained calls in member_expression. (js--treesit-arrow-function-helper): New anchor helper function for arrow_function. (js--treesit-indent-rules): Fix rule for the indentation of "{" when of a new line of a function declaration. (bug#76704) Fix the indentation of the parent of arrow_function, member_expression, and switch_body. --- lisp/progmodes/js.el | 88 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 3e789218fde..8db02cb8399 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3450,11 +3450,74 @@ js-jsx--treesit-indent-compatibility-bb1f97b `(((match "<" "jsx_text") parent 0) ((parent-is "jsx_text") parent js-indent-level))))) +(defun js--treesit-switch-body-helper (_node parent _bol &rest _args) + "Anchor helper for the switch body.. +If \"{\" is on a newline return the PARENT bol plus an offset, +otherwise return the usual `parent-bol' value. If `js-switch-indent-offset' > 0 +this is the offset, otherwise is `js-indent-level'." + (save-excursion + (goto-char (treesit-node-start parent)) + (back-to-indentation) + (if (not (eq ?{ (char-after))) + (point) + ;; offset relative to "{" + (let ((offset + (if (= js-switch-indent-offset 0) + js-indent-level + js-switch-indent-offset)) + (pos + ;; position relative to the "statement_block" + (treesit-node-start + (treesit-node-parent + parent)))) + (+ pos offset))))) + +(defun js--treesit-member-chained-expression-helper (_node parent _bol &rest _args) + "Anchor helper for member chained expressions. +Returns a position relative to PARENT context and the value of +`js-chain-indent'. +See `js-chain-indent' and `js--chained-expression-p'." + (let ((parent-start (treesit-node-start parent))) + (if (not js-chain-indent) + (if-let* ((ancestor-node + (treesit-parent-until + parent + "variable_declarator"))) + (treesit-node-start ancestor-node) + (save-excursion + (goto-char parent-start) + (back-to-indentation) + (if (eq parent-start (point)) + (+ parent-start js-indent-level) + parent-start))) + (save-excursion + (goto-char parent-start) + (let ((pos (search-forward "." (pos-eol) t 1))) + (if (and pos (> pos 0)) + (- pos 1) + parent-start)))))) + +(defun js--treesit-arrow-function-helper (node parent bol &rest args) + "Anchor helper for arrow_function, return a position based on context. +If and arrow function has a variable_declarator ancestor, returns the +same value of `grand-parent' otherwise return `parent-bol' plus +`js-indent-level'. +PARENT is NODE's parent, BOL is the beginning of non-whitespace +characters of the current line." + (if-let* ((ancestor-node + (treesit-parent-until + parent + "variable_declarator"))) + (apply (alist-get 'grand-parent treesit-simple-indent-presets) + node parent bol args) + (+ (apply (alist-get 'parent-bol treesit-simple-indent-presets) + node parent bol args) + js-indent-level))) + (defvar js--treesit-indent-rules - (let ((switch-case (rx "switch_" (or "case" "default")))) `((javascript ((parent-is "program") parent-bol 0) - ((node-is "}") parent-bol 0) + ((node-is "}") standalone-parent 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) @@ -3462,13 +3525,10 @@ js--treesit-indent-rules c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) ((parent-is "ternary_expression") parent-bol js-indent-level) - ((parent-is "member_expression") parent-bol js-indent-level) - ((node-is ,switch-case) parent-bol 0) - ;; "{" on the newline. - ((node-is "statement_block") parent-bol js-indent-level) + ((parent-is "member_expression") js--treesit-member-chained-expression-helper 0) ((parent-is "named_imports") parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) - ((parent-is "variable_declarator") parent-bol js-indent-level) + ((parent-is "statement_block") standalone-parent js-indent-level) + ((parent-is "variable_declarator") parent 0) ((parent-is "arguments") parent-bol js-indent-level) ((parent-is "array") parent-bol js-indent-level) ((parent-is "formal_parameters") parent-bol js-indent-level) @@ -3477,12 +3537,16 @@ js--treesit-indent-rules ((parent-is "object_pattern") parent-bol js-indent-level) ((parent-is "object") parent-bol js-indent-level) ((parent-is "pair") parent-bol js-indent-level) - ((parent-is "arrow_function") parent-bol js-indent-level) + ((parent-is "arrow_function") js--treesit-arrow-function-helper 0) ((parent-is "parenthesized_expression") parent-bol js-indent-level) ((parent-is "binary_expression") parent-bol js-indent-level) + ((parent-is "assignment_expression") parent-bol js-indent-level) ((parent-is "class_body") parent-bol js-indent-level) - ((parent-is ,switch-case) parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) + ;; "{" on the newline, should stay here. + ((node-is "statement_block") parent-bol 0) + ((parent-is "switch_statement") parent-bol 0) + ((parent-is "switch_body") js--treesit-switch-body-helper 0) + ((parent-is ,(rx "switch_" (or "case" "default"))) parent-bol js-indent-level) ((match "while" "do_statement") parent-bol 0) ((match "else" "if_statement") parent-bol 0) ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement") @@ -3500,7 +3564,7 @@ js--treesit-indent-rules ((match "/" "jsx_self_closing_element") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level) ;; FIXME(Theo): This no-node catch-all should be removed. When is it needed? - (no-node parent-bol 0))))) + (no-node parent-bol 0)))) (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" -- 2.49.0 --nextPart2001764.7Z3S40VBb9-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 04:51:26 2025 Received: (at 76704) by debbugs.gnu.org; 2 Apr 2025 08:51:26 +0000 Received: from localhost ([127.0.0.1]:54674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tztok-00088B-2F for submit@debbugs.gnu.org; Wed, 02 Apr 2025 04:51:26 -0400 Received: from mout.gmx.net ([212.227.17.21]:48271) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tztoh-00087B-E2 for 76704@debbugs.gnu.org; Wed, 02 Apr 2025 04:51:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1743583867; x=1744188667; i=f.brosda@gmx.de; bh=t1X//cnfTT/w3vjRJqhffYWAYlbZ5f0o/26ckVq9pcA=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=apIxfRYdRASKhavwz1dtNmnd32ZOgoBtJ2wQRg0OI0N9Pu3QOxieDDSygds4kTJC 6T5pxuVj7pkyVlo1jP/0oCnKqZ3EqgsFOqZD8HpzKZinlKme8yjU4bgMWyjJVbrWm G9IoHR9uxJgpb8sVx/M/AE3Hc6pqQ7UyqOQefa/J/E6PHF8C5RPAd91RvSQ+MGn17 cqWXawdYQ5ojitcHYOx0MA5FFMxyZ3jxNTdEzWqNHWXr5koq9hsowo+IA7xfFSdWt CoIayDVMNiiLke5RPpHvIYZtvzM4wfF1hDzFSlcZh7KvIVK1J7q/TvfY9S6EqLhW8 rIuXIPUpquToKGjwqA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([84.156.66.105]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MMobU-1th8TW309k-00IxTw; Wed, 02 Apr 2025 10:51:06 +0200 From: Fabian Brosda To: Vincenzo Pupillo , juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode In-Reply-To: <22112873.4csPzL39Zc@fedora> References: <871pvfkyjc.fsf@gmx.de> <2895659.vuYhMxLoTh@3-191.divsi.unimi.it> <87r02hjuiq.fsf@gmx.de> <22112873.4csPzL39Zc@fedora> Date: Wed, 02 Apr 2025 10:51:05 +0200 Message-ID: <87ldsjvtdy.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:iYMLHuuFbtKTBDrM/Pc4YsCp/vW5Nt65KvudUAhGSaT2/azSTUf XRbppc0k7uKnahq5dLy3LyxP1eGHrZ7hHyMre6CXorDVRqhx1h7HcKjubMfcl0/ovjLMKjo SppGMj9/95Y8Yg0pId3if+XA+x+ZmMXwnVP7weUT7xkM8xHN7sMHcjdkLrHOBeHY4kf5dGS IPaQTAHZjT16EH0v3COKA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:FaXgYL1+YvI=;WONhfGHqRhWjCYn6g6dFlfCdwiL 9amk1i0R/htBUqBj2KyqwDU4O6JG10ggOcRqoLovK9ZFs7ARwoBpr6+C9tB0WZqrw46svwRnJ OVf/Y8yvGhKY2F9x6IUgZ72UtLO5SpACOwS1TDmPeOXEaeSCfQwxbG8b0x8/C9AzYZO0iETfu dOFQHR5ZoVU+sU85NCig2vQraRP9WJTt5eaD0G1ETQAUTl9yeHmIF3FMqyZehEps9TSIuRbMu bOt/9EN9I4gqvs/djAuUozFYcTu4ooIiNSajbmZUsaWM66V4ke6DmEPf7KlGxFQaWPEpWMVBl H1u8+yqWl8Wyz+GP7qwpeJF15ZbzRo5Gk7yxv14tfoDiW9OBehOSDPjGLbGmaHBoGnaRMGQRe r2fuDhx/3YMgdTpWleNdNcJ/pkXDqb3i355uGJPx3jAjQID8iDBhfleqv4OGZylvUDJsBjGDP m0al7ZvUUufolsB4GWVlCVkqn5y85pi9aKmph/dgZYwZ3FOXiXiEZ2Ho8X/R2XYZtlwyBOy+I 2Wd2AwJ1D7VA/tqZA9e7rKKFZH77z6CIXclNNDJAwT334YotgwFg4CTk1sswTe4SEuezxVhBT wYK5NZJ4UCQjPpnKkbdtus1ZhceoeSIbdiTthzn4x3gQM3bDmF+yjOWAUszY5EtZP7BQKR0Jh 9WtXlRNLY7GUnrzCekigj0gllRSdyiGdWeNwYCQIeSLcxrK4auAG+l+jqZWjPg4rwkEGJlAam dYXwxUNA0ySPJcgCXEO7SmBmeI25zXcL/aNG4USE9L+hfhreprpND7En7xaTKBZXp+AZO8LgG T2+siAN/O11zNcr199Dj5X2uun0vRTnTTjnEZXCjrptq0nD7uWPMZLvqTZtY2QyFfLssswK6k 0x0jKAgzn1KI4waccPJzcgdO3e1qMwbehwduu7BS45ymJ+1DXMbgkg9zYT6/qyx4GnzF4gHUl 0JvVuc9QBEJGIRdVqZw8qjF8k54iT6E+Jvpw8dfbQDAQ2+uNAKer6qWZElOm9aV3tGqUIEJX1 yviSiUztdJNqzgiLDRxizJ+qdEthktS4vzPt9mG5vwFyoexV9ZfR5HpVJYOLAaHMerGdmPv5O kQmfljktU1dcmyrY6OgtiEvblrXn5NctYFjsu1ZVNy4Gqeunxa7rzzqHESLa8x4m0dihSFkvv W4IrYjzb3OLjDpThWSnNnqSSU3d+wYeBmAFOhi6wVQjahDVKtazird6pId847Gj+q5tt9bv7M 1a82udCUmq0FN6QJrgwzcSeVB4WLeTrH9gcGAOncnFf45S8GZKHToOPkft7njyLvJS0cQzm9K IIazVEJoGO/UVL+kTTS9Pc5yNFP/bDG+FFXFOzY3KBXleDJQjJRBeymCKgRtlb0+/ZEpH7dLc vOiq8HmYI5AtKPjrUjHF0VyQgEhkDfhaX+QtNiGO5iJ39vtq2Qh0sbVjPsnMq95Ddhux0gIYR WX/8BAsR/ruRhRQYaL/dDuixlXkQ= Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.7 (-) Hi Vincenzo, > For switch body indentation now possible to use js-switch-indent-offset = as in > js-mode. Testing this, the results are different in js-mode and js-ts-mode. js-mod= e applies the offset only if the brace is on the same line, while js-ts-mode applies it only, if the brace is on a separate line. I updated the gist, and used js-switch-indent-offset =3D 2, to distinguish it from the regular indentation. > Can you please try it again? I also tested in a couple of projects and found one difference when using ternary operators and putting the whole expression in parenthesis. I also added it to the gist. Note, that only the combination of parenthesis and ternary operator is different, the other two cases are the same. But otherwise I could not find any more differences and the original case with braces on separate lines also works very well :-) Fabian From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 17:17:23 2025 Received: (at 76704) by debbugs.gnu.org; 2 Apr 2025 21:17:23 +0000 Received: from localhost ([127.0.0.1]:59777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u05Sc-0003iL-Mm for submit@debbugs.gnu.org; Wed, 02 Apr 2025 17:17:23 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:42082) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u05SZ-0003i6-HR for 76704@debbugs.gnu.org; Wed, 02 Apr 2025 17:17:20 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-ac2aeada833so51104566b.0 for <76704@debbugs.gnu.org>; Wed, 02 Apr 2025 14:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743628633; x=1744233433; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LTRAvYXrzUVJz3w7J8rkICl0hXD6C2+oO4VPMffyFJY=; b=MTkTBNa+Hzv72Dz4IDfJisbz7lZuqxHpLRyKfY4nU3SfSk+oDv5sJa8A4qpc64l7M+ IBFTaomUazQDmg1cRL/QF2bDibt7EjLAj+9gzbY8btqyPdxIIUId5iPSixFDE1nu7rDA pPYZsIuQILvlr/XspOhk62GUOigE9CQ4RB7I9CbR/ISH0IrpL9hlNjrhcYRx6/N2c/gS mdT++SghvP1tSIDmR2/KOZBI5aKLIp3XPhp9gETQEeCw+GKDpd4Hxd8qnNooVerX10j9 DoUUUjaq8CQX62MRxkuK4rtWzlJa/gTEewi3i/BC8aU+GRWTsrnVQGvEt4INYls0D8yk P42A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743628633; x=1744233433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LTRAvYXrzUVJz3w7J8rkICl0hXD6C2+oO4VPMffyFJY=; b=ljgRHzXIoyF/9fFVzIhpcgIaDO1gIvKwRiFiahR45y4zeplI99XEWmdguv41+wWFre cZMK5WeEDv/WMgvvux/1W4mx6IG9Ce2OKJJHSbKZWJm/rBQEbF7tlGEBjFaoJndnscbr R6xJYBwSiEI2YKLM1GF2AMEJQ1q4wSH0BTuDVXJ+HfVJ4sVDrUpRTt072UhESRSKfHhC kLuQAhEjEWj5ieUdN6BObpqL/lu9YIVkDICVsNhePJdjnskYjZ7l+/nMGRtr0j0pJcYS sgnxAGbwEDOiF6wCPHX8vl9dlRZn6iaSCIjGBgMQwkecegw60952mESLmufmam+fGrmf BKAA== X-Gm-Message-State: AOJu0YzmpPCnztKri4L42/Rezl0/NgNG+DvtMB6mJi+TmA302J7v7apg wSfz+oVL4I4VIhPKjflfj9a3/o/TfpmI2eeN+QIWCEnFJLgeD7sK X-Gm-Gg: ASbGncuv2/Qx4UBGxqD9pAvlljLuD3U7kRZKgqNQn/mXwq7qhZkApLe1hoyCKmFH5DI oZphLqVBNBCaw2+Ukq4rejEEtqxEadxd7rJFT+S7AJHfn4nyg9hNKyWpeMdgY2qp0D/dN74E3OU jo8tFbVyNgAYekpFu1GEseQoNSAb7eQLAnekiMORxIJQfFQwPiLWHff6SXBEHZ6sRYOwS/a5VTH laEK4qGhec5wrJ7jhsjHPNFDiEdmLztryzBsvGt/VnlnKgsdUH+SyoB62MG//yC0gP//YwpqDmK T89at4L99qQJct1J50isTingJfdv2LHOyBK/FCkMrhysGDNpAuwB3AmQ+GNBF2i0XcgtxKOTJY4 862Pn9gWkpj0WVCV93do= X-Google-Smtp-Source: AGHT+IEqdj9kfBgdSw+tfSdagX313iGLlz34uNVJX0K3rnGpAAVmBSU2GsHh6581OKV7NcK6on2RLA== X-Received: by 2002:a17:907:7b9d:b0:ac7:3441:79aa with SMTP id a640c23a62f3a-ac7b6c57deamr111573766b.13.1743628632419; Wed, 02 Apr 2025 14:17:12 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac71961f9cfsm954602266b.122.2025.04.02.14.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 14:17:11 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii , Fabian Brosda Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Wed, 02 Apr 2025 23:17:10 +0200 Message-ID: <2302847.vFx2qVVIhK@fedora> In-Reply-To: <87ldsjvtdy.fsf@gmx.de> References: <871pvfkyjc.fsf@gmx.de> <22112873.4csPzL39Zc@fedora> <87ldsjvtdy.fsf@gmx.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2736033.lGaqSPkdTl" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.0 (-) This is a multi-part message in MIME format. --nextPart2736033.lGaqSPkdTl Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ciao Fabian, I've fixed these two things (I hope!). The new patch is attached. Vincenzo In data mercoled=C3=AC 2 aprile 2025 10:51:05 Ora legale dell=E2=80=99Europ= a centrale,=20 =46abian Brosda ha scritto: > Hi Vincenzo, >=20 > > For switch body indentation now possible to use js-switch-indent-offset= as > > in js-mode. >=20 > Testing this, the results are different in js-mode and js-ts-mode. js-mo= de > applies the offset only if the brace is on the same line, while > js-ts-mode applies it only, if the brace is on a separate line. I > updated the gist, and used js-switch-indent-offset =3D 2, to distinguish > it from the regular indentation. >=20 > > Can you please try it again? >=20 > I also tested in a couple of projects and found one difference when > using ternary operators and putting the whole expression in parenthesis. > I also added it to the gist. Note, that only the combination of > parenthesis and ternary operator is different, the other two cases are > the same. >=20 > But otherwise I could not find any more differences and the original > case with braces on separate lines also works very well :-) >=20 > Fabian --nextPart2736033.lGaqSPkdTl Content-Disposition: attachment; filename="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" >From 62ea80c26a47a5da6fe3d96f797e637656830dd2 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 22 Mar 2025 23:43:52 +0100 Subject: [PATCH] Fix indentation of "{" when on a new line of a function declaration. * lisp/progmodes/js.el (js--treesit-switch-body-helper): New anchor helper function for the switch_body. (js--treesit-member-chained-expression-helper): New anchor helper function for chained calls in member_expression. (js--treesit-arrow-function-helper): New anchor helper function for arrow_function. (js--treesit-indent-rules): Fix rule for the indentation of "{" when of a new line of a function declaration. (bug#76704) Fix the indentation of the parent of arrow_function, member_expression, , switch_body, ternary_expression and sequence_expression. --- lisp/progmodes/js.el | 89 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 3e789218fde..d63621bf170 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3450,25 +3450,86 @@ js-jsx--treesit-indent-compatibility-bb1f97b `(((match "<" "jsx_text") parent 0) ((parent-is "jsx_text") parent js-indent-level))))) +(defun js--treesit-switch-body-helper (_node parent _bol &rest _args) + "Anchor helper for the switch body.. +If \"{\" is on a newline return the PARENT bol plus an offset, +otherwise return the usual `parent-bol' value. If `js-switch-indent-offset' > 0 +this is the offset, otherwise is `js-indent-level'." + (save-excursion + (goto-char (treesit-node-start parent)) + (back-to-indentation) + (if (not (eq ?{ (char-after))) + (+ (point) js-switch-indent-offset) + (let ((offset ; offset relative to "{" + (if (= js-switch-indent-offset 0) + js-indent-level + js-switch-indent-offset)) + (pos ; position relative to the "statement_block" + (treesit-node-start + (treesit-node-parent + parent)))) + (+ pos offset))))) + +(defun js--treesit-member-chained-expression-helper (_node parent _bol &rest _args) + "Anchor helper for member chained expressions. +Returns a position relative to PARENT context and the value of +`js-chain-indent'. +See `js-chain-indent' and `js--chained-expression-p'." + (let ((parent-start (treesit-node-start parent))) + (if (not js-chain-indent) + (if-let* ((ancestor-node + (treesit-parent-until + parent + "variable_declarator"))) + (treesit-node-start ancestor-node) + (save-excursion + (goto-char parent-start) + (back-to-indentation) + (if (eq parent-start (point)) + (+ parent-start js-indent-level) + parent-start))) + (save-excursion + (goto-char parent-start) + (let ((pos (search-forward "." (pos-eol) t 1))) + (if (and pos (> pos 0)) + (- pos 1) + parent-start)))))) + +(defun js--treesit-arrow-function-helper (node parent bol &rest args) + "Anchor helper for arrow_function, return a position based on context. +If and arrow function has a variable_declarator ancestor, returns the +same value of `grand-parent' otherwise return `parent-bol' plus +`js-indent-level'. +PARENT is NODE's parent, BOL is the beginning of non-whitespace +characters of the current line." + (if-let* ((ancestor-node + (treesit-parent-until + parent + "variable_declarator"))) + (apply (alist-get 'grand-parent treesit-simple-indent-presets) + node parent bol args) + (+ (apply (alist-get 'parent-bol treesit-simple-indent-presets) + node parent bol args) + js-indent-level))) + (defvar js--treesit-indent-rules - (let ((switch-case (rx "switch_" (or "case" "default")))) `((javascript ((parent-is "program") parent-bol 0) - ((node-is "}") parent-bol 0) + ((node-is "}") standalone-parent 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) ((and (parent-is "comment") c-ts-common-looking-at-star) c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) + ((n-p-gp "identifier" "ternary_expression" "parenthesized_expression") + parent 0) ((parent-is "ternary_expression") parent-bol js-indent-level) - ((parent-is "member_expression") parent-bol js-indent-level) - ((node-is ,switch-case) parent-bol 0) - ;; "{" on the newline. - ((node-is "statement_block") parent-bol js-indent-level) + ((parent-is "sequence_expression") parent 0) + ((parent-is "member_expression") js--treesit-member-chained-expression-helper 0) ((parent-is "named_imports") parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) - ((parent-is "variable_declarator") parent-bol js-indent-level) + ((parent-is "statement_block") standalone-parent js-indent-level) + ((parent-is "variable_declarator") parent 0) ((parent-is "arguments") parent-bol js-indent-level) ((parent-is "array") parent-bol js-indent-level) ((parent-is "formal_parameters") parent-bol js-indent-level) @@ -3477,12 +3538,16 @@ js--treesit-indent-rules ((parent-is "object_pattern") parent-bol js-indent-level) ((parent-is "object") parent-bol js-indent-level) ((parent-is "pair") parent-bol js-indent-level) - ((parent-is "arrow_function") parent-bol js-indent-level) + ((parent-is "arrow_function") js--treesit-arrow-function-helper 0) ((parent-is "parenthesized_expression") parent-bol js-indent-level) ((parent-is "binary_expression") parent-bol js-indent-level) + ((parent-is "assignment_expression") parent-bol js-indent-level) ((parent-is "class_body") parent-bol js-indent-level) - ((parent-is ,switch-case) parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) + ;; "{" on the newline, should stay here. + ((node-is "statement_block") parent-bol 0) + ((parent-is "switch_statement") parent-bol 0) + ((parent-is "switch_body") js--treesit-switch-body-helper 0) + ((parent-is ,(rx "switch_" (or "case" "default"))) parent-bol js-indent-level) ((match "while" "do_statement") parent-bol 0) ((match "else" "if_statement") parent-bol 0) ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement") @@ -3500,7 +3565,7 @@ js--treesit-indent-rules ((match "/" "jsx_self_closing_element") parent 0) ((parent-is "jsx_self_closing_element") parent js-indent-level) ;; FIXME(Theo): This no-node catch-all should be removed. When is it needed? - (no-node parent-bol 0))))) + (no-node parent-bol 0)))) (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" -- 2.49.0 --nextPart2736033.lGaqSPkdTl-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 03:33:53 2025 Received: (at 76704) by debbugs.gnu.org; 7 Apr 2025 07:33:53 +0000 Received: from localhost ([127.0.0.1]:52126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1gzQ-0003Az-OK for submit@debbugs.gnu.org; Mon, 07 Apr 2025 03:33:53 -0400 Received: from mout.gmx.net ([212.227.17.21]:36209) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u1gzN-0003AD-38 for 76704@debbugs.gnu.org; Mon, 07 Apr 2025 03:33:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1744011213; x=1744616013; i=f.brosda@gmx.de; bh=mexqGxajUEUISNpLA5q0X/tBqYUKZmiI4pS4o1D53S4=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=VAyIqXcZ+WO70Q9oHgAe/E7GbMBexZzz69flFcuQnxAFmtM8dCMUr+v2dCI113WC LJYJJbolGrcYGTR8eQ7HTlxsecy55cpzS1wNvbaz7IYjYdjzxgy9jT+UHAWoBprtZ tn1SBNa6+q6HVg5MN2+R/PyozrWq+KMGXcQYzu5ZKW+9rfWhzRZmpN+IYPKVgw4ze vnjayp8622vKf4oBLXZp+ftpy5Yzi1tNilwOBlr6Ceja26IcUNyobZARIlZcIx2xA X9w4lCps09bCd7NPYtCrMlmI6h5QlgAYLtGu/s2jv9krKW1Diw1n3MWKzndM4yNan 0tFdub4Xed9apUdMrg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost ([93.195.180.76]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdebB-1tSM6H3RHF-00brL0; Mon, 07 Apr 2025 09:33:33 +0200 From: Fabian Brosda To: Vincenzo Pupillo , juri@linkov.net, Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode In-Reply-To: <2302847.vFx2qVVIhK@fedora> References: <871pvfkyjc.fsf@gmx.de> <22112873.4csPzL39Zc@fedora> <87ldsjvtdy.fsf@gmx.de> <2302847.vFx2qVVIhK@fedora> Date: Mon, 07 Apr 2025 09:33:26 +0200 Message-ID: <87cydofmt5.fsf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:NXeX7FBVxlcs5mjkRsWiIAg+q9IvMKUSs9JkDhZZK5FsXgrR7Z2 k/VSbOHk40zuPf8HJOO9EHo5xaBUcdZOPJ+7en5O8jFH27TA8niKQMvN7b1cPlsp3YKq7sm kITgFEJinQOH6y14xRVjE7Cvsu1dIsh+X76LEV43ovX3KJx9y73Rcwn0pHTECJwSSXz4ajv hf58JSiiRzuXkJUB9HUew== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Ih/5s78cGB4=;hQdyOZngK6b5QG8K1XJBEB9+1XJ /U6g+NUIjgbEhpRs6/fIYmCydOrdS1QP6SMJiXzlJa+szh5UKW+zDXpeV7WG6UI77LjsJcUcb 7tq1UIQboLegLl+lMjOphHQN/dvthrhy0GzKRzy9PGqe7lREp5hvMZO8UL9MAA7ARJlsavI0I lPQBvPTFzzT9UZI3geuiPzydYY0+xGEbQsHDcYyWaq1qbABiafSQvamqeiHf0q4NkPngv8//h xEf7fTgpcma3KF5w3aGM9cQJiH2LDQdmJ060hfa1oEirhEDGM3/vEAirkuO+fC6JpfMfljpjt ef3eMGytqJr3c3u2AjIjphnUFJjU7DnkO0w3vv1ZXvV9f9/KtNql8kE7u3wYvEuietbEu4o8w hyxiWELiYrCxlR/Qd6IMGL8RyvYC4rOsy0q7IhMFnICZy9ebJKUy93Mqzj5OyDkS6+FT6G2xY WGyJW851czuJfAj9LjRO8iYt6MSAf+3OXjzG7aDrZ0MFpSidtV7LemnbV8irwfhVcvIRP0koa ujaru8RqK0atavQPpSBdr9Jm5ufpkRrnVYlx4CU/wo7V3Bm80vyT+DdwBqC5mlqqOfvmMf1lt kgZzUHZTXXh8zC9ZF7GHzHRHR17vSrxjuUnHPLxyiQhonEIU4IMj03DEktR/R1ZPkW3nvYM+C CxbYiE/PzL8JTlQLRYz4GL5SupbSzPKLdYg7aHLLJzxBf6oj23RHLJme7XjTfVM39NbVDbb+r xKjWxNxodLhmPwCIT/eY3i3xML50q1WumEntgYJgYx30dltQtdEbtqFURn8vgiIYDRhzmbR+a ZZWQkiLTwwYVCcLdU/waws0/Ko5/Vsyk1+kWkxTIoIcNMHLRneWTKNG4pnnYRDz/+NurkjY1z rIFgLLSkFtjrTlEQ5MbhDwSeG7oD3rrqHjE361kZ74czccwhrWEO1Lt/EEA3+Aq9Pm+gmU2e1 3HTNRdOXauxiYK3ETe4392u69Xl8yZhSZPcI/rUNwxJdx4m7Y2z5oB3ozIa20/eGItyDXz/5f Xqh1wXeu7ZccbOT1zKI+q3jPGYCjD/iYMe1JMlmoR23KS4icW5YofxFP9Oq2k0L/33+vG0OZH CjOy3Vgqwt8d4K83boycYqlG9neyZI4ExkJw78nBKp1Ow1PPi6Sq9a2KGaWDIOTMdKjETji03 Jw+oZVQmswPxSsalrKrguuXx8zG2PsawX6oBU2LKWgmhNudO7gCnqyFMmYltlj2Qyqvurgx6Q kCKrt4J3kc35Dlrtw6EMtoW6Bh4LvEyninbFYao45hsmQW2ADF7Og2wfJZvgP+uuU7wiWuVR6 9jIcJ0aMlKJhmPI8eYmwPv6OPud+ja3+wAMjq6S0RsbF83hpF4a2vvE3d4Z7Iw7V7/0brhO2M qDM226iSjsc5E8urm7EYThtRrlUAWcP/SEcsfF5PohxfnThJUhBzIFj1ynHaye5ExefeTxJf+ Jg7vcag== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.7 (-) Hi Vincenzo, thanks for the new patch. The results look very good and I couldn't find any example, which gives unexpected indentation in js-ts-mode now. Regarding the use of js-switch-indent-offset for js-mode, the results are still different, depending on the brace being on the same line or not. Should I open a separate bug report for this? Again thanks for your time and the prompt updates. Fabian From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 05:39:37 2025 Received: (at 76704) by debbugs.gnu.org; 7 Apr 2025 09:39:37 +0000 Received: from localhost ([127.0.0.1]:52752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1ix6-0001Wp-Qd for submit@debbugs.gnu.org; Mon, 07 Apr 2025 05:39:37 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:61547) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u1ix3-0001WK-AF for 76704@debbugs.gnu.org; Mon, 07 Apr 2025 05:39:33 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3914aba1ce4so3360099f8f.2 for <76704@debbugs.gnu.org>; Mon, 07 Apr 2025 02:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744018767; x=1744623567; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R2LJqvq7TIPlwHi7P/lpcoJlw7isNmQ5QR8m6YmKKm8=; b=B4dzq62juR+BnSYp0N6GaaxlQBw9J33eu3cY3BVJJC5OC84QjgifXuhjOFzlZcJoaL LJZWGTQ1XVbXKsIoxJL7Fq9DqeQywoeKZy+TIok2nSI+G/merf+yINLjMuzZYUx/R5iV 03AdxaiHuC/c14q3wdNxFCnagVI7j8D121q4hc4Lx495uopWo2CIdastvG8KERERIKP2 k2xarAObs3a1F1KL7QKwm2/6CktNlMWZAcXKRjPX777f7hU/s5EDn4I+TL5bjVBTgMlM wJwDNYr1H+l7IAZhB+kzgQcOhdBU11GlYNcfxYSLW72hqa/VBQcEtKwQq9osgNE4Mwpv lK9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744018767; x=1744623567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R2LJqvq7TIPlwHi7P/lpcoJlw7isNmQ5QR8m6YmKKm8=; b=LouQr8P4nSmcL8WL8bK7BxO/pdUetZ58OJu0Brvmq1AN65h11R76PgEGsNqIKsx7Ke rhL6NZIevkJcIgONaTU7H6m98SEAjsYb45yWAx3nS3gO5WKvMkdUQzv8JRWysguA34qk HEKvu1HJKKickH8rrj64S2rgODZnEYsaPBE+y61yVuxq+YWmoiSTyMsCLM0rxW5QRS1S FQEvQWXc/LtP41xSKJnTUFM/detX5catXE70kmLdj2R+ai/m2ySDBYTDNvK+NL6xCoR4 C1w6DnA0xaaEkqAJmOzdeGEjfykJ1UTk8TDZWz0ZJtK65Zq/8E1K7sasbON6KDc6re+G 1zkg== X-Gm-Message-State: AOJu0Yyx+IByV6GcQid9PMZ9dcfiG2QFBntMdj/IEySl25EwWi5lAlvH 3AKyjaQ9UDLLirmGxx4fr04b7bLYyqR1fyOupniEnJJSPxkUz9Al X-Gm-Gg: ASbGncu+pv4iDp8t3aUMyu2QroruD3ZrLB9zm1xv0yw/P0pt8KulGUJI4PIOBezNan0 JY05CebKqHWzwTLlv2E9iGDkCH4PJpRmyowyDj7Brz1zo3zvWPFzhTDP/jjERgeOgtRRzTaH4PI 2dJJyNbfs+FbUX7zchFzwDEGGDohqdRVOcyykPYly5i6ok8eWTmbjb3KbUeM2KpWij7S0PYHaNF cxxCZeHFHFBeIzt1Mwu4QxsGJwrQrhYfZXOPrik0lgLBoauf+tdIyCMc1zNlsrF0NiloCiOdjFV Ly/v0eZWW1smwxaHUfjer105tzH4kkWzPvtseHkm6+cuWd9rsAO4q5Q++QDXZOUYhEeRcObNEQ= = X-Google-Smtp-Source: AGHT+IFP9h63KxztWfW5q+u2XyCXQzlQYMFL+u6Mx1BS8Yt+Fwf7dFAu96zfgu9spmOS19uwonxaPA== X-Received: by 2002:a05:6000:1a87:b0:398:fd9b:b935 with SMTP id ffacd0b85a97d-39d1475794amr9945673f8f.53.1744018766738; Mon, 07 Apr 2025 02:39:26 -0700 (PDT) Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c301a7225sm11442759f8f.26.2025.04.07.02.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 02:39:26 -0700 (PDT) From: Vincenzo Pupillo To: juri@linkov.net, Eli Zaretskii , Fabian Brosda , Daniel Colascione Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Mon, 07 Apr 2025 11:39:25 +0200 Message-ID: <26872875.1r3eYUQgxm@3-191.divsi.unimi.it> In-Reply-To: <87cydofmt5.fsf@gmx.de> References: <871pvfkyjc.fsf@gmx.de> <2302847.vFx2qVVIhK@fedora> <87cydofmt5.fsf@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: 76704@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: -1.0 (-) Ciao Fabian, In data luned=C3=AC 7 aprile 2025 09:33:26 Ora legale dell=E2=80=99Europa c= entrale, Fabian=20 Brosda ha scritto: > Hi Vincenzo, >=20 > thanks for the new patch. The results look very good and I couldn't > find any example, which gives unexpected indentation in js-ts-mode now. >=20 > Regarding the use of js-switch-indent-offset for js-mode, the results > are still different, depending on the brace being on the same line or > not. Should I open a separate bug report for this? whith js-switch-indent-offset =3D 2 and js-indent-offset =3D 4, with js-mod= e the=20 result is: function switch_test(a) { switch (a) { case 1: x; break; case 2: y; break; default: z; break; } switch (a) { case 1: x; break; case 2: y; break; default: z; break; } } js-ts-mode the result is: function switch_test(a) { switch (a) { case 1: x; break; case 2: y; break; default: z; break; } switch (a) { case 1: x; break; case 2: y; break; default: z; break; } } =46or me the js-ts mode is correct, but I am not an expert.=20 @Daniel WDYT? Vincenzo >=20 > Again thanks for your time and the prompt updates. >=20 > Fabian From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 19 09:40:43 2025 Received: (at 76704) by debbugs.gnu.org; 19 Apr 2025 13:40:43 +0000 Received: from localhost ([127.0.0.1]:60261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u68R1-0004DY-23 for submit@debbugs.gnu.org; Sat, 19 Apr 2025 09:40:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34330) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u68Qz-0004D2-96 for 76704@debbugs.gnu.org; Sat, 19 Apr 2025 09:40:41 -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 1u68Qt-0000Gl-DJ; Sat, 19 Apr 2025 09:40:35 -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=NSrWgNhkpZWYhUT9PZM+nlnNx5KXz6FsIjypxV9Vy+c=; b=Ch7a8jwVAklU lAXjgQEPbE8rD0Pf8KDUykMRE3KAj7hO1UvgFRbkgIg9dV6aOmfUjPLBoGW3YrkcqJWW6HwUyoKPN cHvMrqXU0KbmWgqOj0oNwh1gTwAcStyrVmDdoNijCbkmXT9OhtcdXP7PEjT9myQ4pnB7tbqk5X++m uFRikPaw17vp1xPWd3AqiN6hfDXfoAz2KLhPsQB9DhP9ZjWlaXPdLgTVE+FxAEwOmBjuIcB4idZC+ RSKN7egcpZO95jWAwwPw1KpArZBMyVcKFOu703Yzvbc5+DwFqM6y0P/ZyjsytLkMneqXWUPgetv8W eQ5fy0PlkjvqQ2FC50Oibg==; Date: Sat, 19 Apr 2025 16:40:31 +0300 Message-Id: <86ikn08e28.fsf@gnu.org> From: Eli Zaretskii To: Vincenzo Pupillo In-Reply-To: <2302847.vFx2qVVIhK@fedora> (message from Vincenzo Pupillo on Wed, 02 Apr 2025 23:17:10 +0200) Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode References: <871pvfkyjc.fsf@gmx.de> <22112873.4csPzL39Zc@fedora> <87ldsjvtdy.fsf@gmx.de> <2302847.vFx2qVVIhK@fedora> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76704 Cc: f.brosda@gmx.de, 76704@debbugs.gnu.org, juri@linkov.net 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: Vincenzo Pupillo > Cc: 76704@debbugs.gnu.org > Date: Wed, 02 Apr 2025 23:17:10 +0200 > > Ciao Fabian, I've fixed these two things (I hope!). > > The new patch is attached. I wanted to install this, but it no longer applies cleanly. Could you please rebase on the current master and resubmit? From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 19 17:09:51 2025 Received: (at 76704) by debbugs.gnu.org; 19 Apr 2025 21:09:51 +0000 Received: from localhost ([127.0.0.1]:38818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u6FRc-0000BN-8T for submit@debbugs.gnu.org; Sat, 19 Apr 2025 17:09:51 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:61491) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u6FRV-00009I-29 for 76704@debbugs.gnu.org; Sat, 19 Apr 2025 17:09:45 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3914aba1ce4so2020568f8f.2 for <76704@debbugs.gnu.org>; Sat, 19 Apr 2025 14:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745096975; x=1745701775; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DA6jtLipx8XQ9Q7e09lo4cBgmNFFxDSIUXQ+4sXPPxM=; b=YHfG1jUi/HQLmQwFKg65UjW/jsy1NbBb/JKjAFDkYWFJ2kjFM8P+P4qls5baLCkIih 8vErvETAUtCKC++2SCZuRQlQIcz2DtsPbTeYCFji/vVLjMsBCFUSvCTmS0bPIv0DrIYJ F84jEG98jvdB6TYAr02tk41WofKELIxNHqHYTZkRR5qA9Hn8/BA1H7HJRRMmDV6vJ88w ErjA2fEb++5VUIc/qIh+3f+RVQo9he+xcjrHSXeQl6SPkt8ENDzll69OPCp+7MhOtVnj FQIYp5V8ncRtcwO32yGu2ks5JXVq0VcNnQ4xY1/hUyYgskcpcbS17FoBtPkFXuX4MKQv 7bCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745096975; x=1745701775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DA6jtLipx8XQ9Q7e09lo4cBgmNFFxDSIUXQ+4sXPPxM=; b=jDSA1i7hVsK8nFLJnj+MvnYHQ/jzSEht2s7YxMFnr9w9KHt9A/oho/UBz0Xw+CZTSA 5KGnNG+aCUNyniUGldTmGf4KzvpN9NX0Hj8pKER0MV74wPkeEfXGPkwl73afqSlDXnjY Fiu0NkEioPSE935vaUGLWqAAY9UdFWfeC8OyWhDduNT1F4UWK2ad0TfqUEsbE5OdXjAN 72oEzlKfcjP2VbxP0IATplclf/NXMQInpmgfT8eG4KAOL05pqf0LhKyaIE0avDtp3pEe lSVMxmysVkreuuH658t8+ColcJzxjM2fBaZlWHhnZRmBQb3EYLCbTme4I86mvtvaMevz V0Mw== X-Forwarded-Encrypted: i=1; AJvYcCWqFhqyxMX8BUAOb9Sqb8JUpGsqvjewLuhiKhCogE71gsy6W6s2RcX32MTouarrIm7UNhM5hQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzRsMd6jgAjvexsNLKekyn2R1emDgGUo2H09QjWmTz/5ko4Uwme hH6Z2P1W0N+tpWUTOPsq1taOrqbBKAJIZ1KJoWMjC9LrdLMz3aDi X-Gm-Gg: ASbGnct9XoygcbrGxOO/hqL5N1VIoLfJpUHsTJWXrcsdwkTdEacYI3QD0KqY/oTHe/R apJ8WzK1vnBbJVeJacJUnsvh08RN2RZBG3ekmNs0USc71CRW2fIJmL5HPNThW0jOEUyYyG8pE1c 0FqnIDDcaajO42XPfzibaHspQJl6ROJzo4eE6idanxH6phl3xZ1qXqJXMODGPpzXZQrSFD7hVcQ o9R4HFR/krVG4tRvmLwfvZPkUF60b3Q4LJiMmHRy3Nw4N+E12nE+9F0X+D46Q+NPYt9tlkL9/Rk andAHBOMXn2d6A+wIGk3BEaP95gwF5IFS8hZh6j/Iu5yJVt+XCYeKRszuNX53CXpJ9oAh/sWapp HTJq9 X-Google-Smtp-Source: AGHT+IH5HddffjwwqY9JulYkq4b/KPB6raQEm7GIRmTdwCXDPhBRFTDTjDRD3fU6VOiVrAzgBTFDZg== X-Received: by 2002:a5d:6d88:0:b0:39c:2669:d7f4 with SMTP id ffacd0b85a97d-39efbad7d40mr5171614f8f.43.1745096974534; Sat, 19 Apr 2025 14:09:34 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39efa4a4f21sm7004662f8f.91.2025.04.19.14.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Apr 2025 14:09:33 -0700 (PDT) From: Vincenzo Pupillo To: Eli Zaretskii Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode Date: Sat, 19 Apr 2025 23:09:32 +0200 Message-ID: <2740840.vuYhMxLoTh@fedora> In-Reply-To: <86ikn08e28.fsf@gnu.org> References: <871pvfkyjc.fsf@gmx.de> <2302847.vFx2qVVIhK@fedora> <86ikn08e28.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart4949196.OV4Wx5bFTl" Content-Transfer-Encoding: 7Bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76704 Cc: f.brosda@gmx.de, 76704@debbugs.gnu.org, juri@linkov.net 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 (-) This is a multi-part message in MIME format. --nextPart4949196.OV4Wx5bFTl Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ciao Eli, In data sabato 19 aprile 2025 15:40:31 Ora legale dell=E2=80=99Europa centr= ale, Eli=20 Zaretskii ha scritto: > > From: Vincenzo Pupillo > > Cc: 76704@debbugs.gnu.org > > Date: Wed, 02 Apr 2025 23:17:10 +0200 > >=20 > > Ciao Fabian, I've fixed these two things (I hope!). > >=20 > > The new patch is attached. >=20 > I wanted to install this, but it no longer applies cleanly. Could you > please rebase on the current master and resubmit? Done, the attached patch is rebased against the master. Thanks. Vincenzo --nextPart4949196.OV4Wx5bFTl Content-Disposition: attachment; filename="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch" >From a6ade9f29f476898d3e993987d8d8c536e2fe60c Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 19 Apr 2025 22:58:39 +0200 Subject: [PATCH] Fix indentation of "{" when on a new line of a function declaration. * lisp/progmodes/js.el (js--treesit-switch-body-helper): New anchor helper function for the switch_body. (js--treesit-member-chained-expression-helper): New anchor helper function for chained calls in member_expression. (js--treesit-arrow-function-helper): New anchor helper function for arrow_function. (js--treesit-indent-rules): Fix rule for the indentation of "{" when of a new line of a function declaration. (bug#76704) Fix the indentation of the parent of arrow_function, member_expression, , switch_body, ternary_expression and sequence_expression. --- lisp/progmodes/js.el | 89 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 243329de7ae..aa0d35efab8 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3449,25 +3449,86 @@ js-jsx--treesit-indent-compatibility-bb1f97b `(((match "<" "jsx_text") parent 0) ((parent-is "jsx_text") parent js-indent-level))))) +(defun js--treesit-switch-body-helper (_node parent _bol &rest _args) + "Anchor helper for the switch body.. +If \"{\" is on a newline return the PARENT bol plus an offset, +otherwise return the usual `parent-bol' value. If `js-switch-indent-offset' > 0 +this is the offset, otherwise is `js-indent-level'." + (save-excursion + (goto-char (treesit-node-start parent)) + (back-to-indentation) + (if (not (eq ?{ (char-after))) + (+ (point) js-switch-indent-offset) + (let ((offset ; offset relative to "{" + (if (= js-switch-indent-offset 0) + js-indent-level + js-switch-indent-offset)) + (pos ; position relative to the "statement_block" + (treesit-node-start + (treesit-node-parent + parent)))) + (+ pos offset))))) + +(defun js--treesit-member-chained-expression-helper (_node parent _bol &rest _args) + "Anchor helper for member chained expressions. +Returns a position relative to PARENT context and the value of +`js-chain-indent'. +See `js-chain-indent' and `js--chained-expression-p'." + (let ((parent-start (treesit-node-start parent))) + (if (not js-chain-indent) + (if-let* ((ancestor-node + (treesit-parent-until + parent + "variable_declarator"))) + (treesit-node-start ancestor-node) + (save-excursion + (goto-char parent-start) + (back-to-indentation) + (if (eq parent-start (point)) + (+ parent-start js-indent-level) + parent-start))) + (save-excursion + (goto-char parent-start) + (let ((pos (search-forward "." (pos-eol) t 1))) + (if (and pos (> pos 0)) + (- pos 1) + parent-start)))))) + +(defun js--treesit-arrow-function-helper (node parent bol &rest args) + "Anchor helper for arrow_function, return a position based on context. +If and arrow function has a variable_declarator ancestor, returns the +same value of `grand-parent' otherwise return `parent-bol' plus +`js-indent-level'. +PARENT is NODE's parent, BOL is the beginning of non-whitespace +characters of the current line." + (if-let* ((ancestor-node + (treesit-parent-until + parent + "variable_declarator"))) + (apply (alist-get 'grand-parent treesit-simple-indent-presets) + node parent bol args) + (+ (apply (alist-get 'parent-bol treesit-simple-indent-presets) + node parent bol args) + js-indent-level))) + (defvar js--treesit-indent-rules - (let ((switch-case (rx "switch_" (or "case" "default")))) `((javascript ((parent-is "program") parent-bol 0) - ((node-is "}") parent-bol 0) + ((node-is "}") standalone-parent 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) ((and (parent-is "comment") c-ts-common-looking-at-star) c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) + ((n-p-gp "identifier" "ternary_expression" "parenthesized_expression") + parent 0) ((parent-is "ternary_expression") parent-bol js-indent-level) - ((parent-is "member_expression") parent-bol js-indent-level) - ((node-is ,switch-case) parent-bol 0) - ;; "{" on the newline. - ((node-is "statement_block") parent-bol js-indent-level) + ((parent-is "sequence_expression") parent 0) + ((parent-is "member_expression") js--treesit-member-chained-expression-helper 0) ((parent-is "named_imports") parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) - ((parent-is "variable_declarator") parent-bol js-indent-level) + ((parent-is "statement_block") standalone-parent js-indent-level) + ((parent-is "variable_declarator") parent 0) ((parent-is "arguments") parent-bol js-indent-level) ((parent-is "array") parent-bol js-indent-level) ((parent-is "formal_parameters") parent-bol js-indent-level) @@ -3476,12 +3537,16 @@ js--treesit-indent-rules ((parent-is "object_pattern") parent-bol js-indent-level) ((parent-is "object") parent-bol js-indent-level) ((parent-is "pair") parent-bol js-indent-level) - ((parent-is "arrow_function") parent-bol js-indent-level) + ((parent-is "arrow_function") js--treesit-arrow-function-helper 0) ((parent-is "parenthesized_expression") parent-bol js-indent-level) ((parent-is "binary_expression") parent-bol js-indent-level) + ((parent-is "assignment_expression") parent-bol js-indent-level) ((parent-is "class_body") parent-bol js-indent-level) - ((parent-is ,switch-case) parent-bol js-indent-level) - ((parent-is "statement_block") parent-bol js-indent-level) + ;; "{" on the newline, should stay here. + ((node-is "statement_block") parent-bol 0) + ((parent-is "switch_statement") parent-bol 0) + ((parent-is "switch_body") js--treesit-switch-body-helper 0) + ((parent-is ,(rx "switch_" (or "case" "default"))) parent-bol js-indent-level) ((match "while" "do_statement") parent-bol 0) ((match "else" "if_statement") parent-bol 0) ((parent-is ,(rx (or (seq (or "if" "for" "for_in" "while" "do") "_statement") @@ -3502,7 +3567,7 @@ js--treesit-indent-rules (no-node parent-bol 0)) (jsdoc ((and (parent-is "document") c-ts-common-looking-at-star) - c-ts-common-comment-start-after-first-star -1))))) + c-ts-common-comment-start-after-first-star -1)))) (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" -- 2.49.0 --nextPart4949196.OV4Wx5bFTl-- From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 20 02:16:19 2025 Received: (at 76704-done) by debbugs.gnu.org; 20 Apr 2025 06:16:19 +0000 Received: from localhost ([127.0.0.1]:43725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u6NyV-0001IJ-Cg for submit@debbugs.gnu.org; Sun, 20 Apr 2025 02:16:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52482) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u6NyS-0001HC-Dc for 76704-done@debbugs.gnu.org; Sun, 20 Apr 2025 02:16:17 -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 1u6NyM-0007hf-6j; Sun, 20 Apr 2025 02:16:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=QZ/31MoDxRxb6o2hCiJI0mEllz3kVjTcVjveH1QPNqw=; b=bH71+9gVF/7s16tR/mI8 qacuQONTl6ikKDzAwRbOdaMuFBoJ0DK9GNcsbTr3tiogmS+JgFwi/s4g+jgr7d/wfLsjPCaLwEYwr pvzgi/bZAI963rn+IENUfcY8elh7WxAsrJSoDF9VlvPD4W/UGbmtDf/DgX58nS88IC25eFdpKyDM6 sYY9vVjmbo2c45XVAdytvsEUHxFdo7N/oCAedn4RqqHUQtC1VE0Sr9TP0iofVAalnIocP/4+kKQ9L nUVaup+r1wpUP4kCp8YuXqLiUU6A8jlbmvimnUZ5EvOHoFwQeJ77zGKBLg0RdYBuPxtkYsyL1dPLJ Bh3JYnO8FBwMUw==; Date: Sun, 20 Apr 2025 09:16:02 +0300 Message-Id: <86jz7f73z1.fsf@gnu.org> From: Eli Zaretskii To: Vincenzo Pupillo In-Reply-To: <2740840.vuYhMxLoTh@fedora> (message from Vincenzo Pupillo on Sat, 19 Apr 2025 23:09:32 +0200) Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode References: <871pvfkyjc.fsf@gmx.de> <2302847.vFx2qVVIhK@fedora> <86ikn08e28.fsf@gnu.org> <2740840.vuYhMxLoTh@fedora> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76704-done Cc: f.brosda@gmx.de, 76704-done@debbugs.gnu.org, juri@linkov.net 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: Vincenzo Pupillo > Cc: juri@linkov.net, f.brosda@gmx.de, 76704@debbugs.gnu.org > Date: Sat, 19 Apr 2025 23:09:32 +0200 > > Ciao Eli, > > In data sabato 19 aprile 2025 15:40:31 Ora legale dell’Europa centrale, Eli > Zaretskii ha scritto: > > > From: Vincenzo Pupillo > > > Cc: 76704@debbugs.gnu.org > > > Date: Wed, 02 Apr 2025 23:17:10 +0200 > > > > > > Ciao Fabian, I've fixed these two things (I hope!). > > > > > > The new patch is attached. > > > > I wanted to install this, but it no longer applies cleanly. Could you > > please rebase on the current master and resubmit? > Done, the attached patch is rebased against the master. Thanks, installed on master, and closing the bug. From unknown Sat Aug 16 11:12:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 18 May 2025 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator