Received: (at 76704) by debbugs.gnu.org; 27 Mar 2025 18:59:47 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 14:59:47 2025 Received: from localhost ([127.0.0.1]:51362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1txsSA-0002DU-77 for submit <at> 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 <f.brosda@HIDDEN>) id 1txsS6-0002DG-HO for 76704 <at> 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@HIDDEN; 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 <f.brosda@HIDDEN> To: Vincenzo Pupillo <v.pupillo@HIDDEN>, juri@HIDDEN, Eli Zaretskii <eliz@HIDDEN> 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@HIDDEN> <2191042.9o76ZdvQCi@fedora> <87msdb8sfb.fsf@HIDDEN> <2736747.vuYhMxLoTh@fedora> Date: Thu, 27 Mar 2025 19:59:33 +0100 Message-ID: <87bjtms3je.fsf@HIDDEN> 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 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.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 <v.pupillo@HIDDEN> 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 <v.pupillo@HIDDEN> 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 <v.pupillo@HIDDEN> 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 <at> debbugs.gnu.org >> >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 >> >> >> > From: Eli Zaretskii <eliz@HIDDEN> >> >> >> >=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" <bug-gnu-emacs@HIDDEN> >> >> >> > >=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 <v.pupillo@HIDDEN> >> >> > 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 <v.pupillo@HIDDEN> > 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
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 26 Mar 2025 14:58:23 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 26 10:58:22 2025 Received: from localhost ([127.0.0.1]:43844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1txSD0-0000Kd-1u for submit <at> 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 <v.pupillo@HIDDEN>) id 1txSCw-0000KB-CY for 76704 <at> 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 <at> 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 <v.pupillo@HIDDEN> To: juri@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, Fabian Brosda <f.brosda@HIDDEN> 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@HIDDEN> References: <871pvfkyjc.fsf@HIDDEN> <2191042.9o76ZdvQCi@fedora> <87msdb8sfb.fsf@HIDDEN> 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 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) 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 <v.pupillo@HIDDEN> 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 <v.pupillo@HIDDEN> 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 <at> debbugs.gnu.org > >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 > >> >> > From: Eli Zaretskii <eliz@HIDDEN> > >> >> >=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" <bug-gnu-emacs@HIDDEN> > >> >> > >=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 <v.pupillo@HIDDEN> > >> > 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 <v.pupillo@HIDDEN> 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--
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 23 Mar 2025 19:21:11 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 15:21:11 2025 Received: from localhost ([127.0.0.1]:52706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1twQsg-0000NB-Js for submit <at> 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 <f.brosda@HIDDEN>) id 1twQsa-0000Ly-Q2 for 76704 <at> 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@HIDDEN; 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 <f.brosda@HIDDEN> To: Vincenzo Pupillo <v.pupillo@HIDDEN>, juri@HIDDEN, Eli Zaretskii <eliz@HIDDEN> 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@HIDDEN> <4873433.vXUDI8C0e8@fedora> <87sen4f3tx.fsf@HIDDEN> <2191042.9o76ZdvQCi@fedora> Date: Sun, 23 Mar 2025 20:20:56 +0100 Message-ID: <87msdb8sfb.fsf@HIDDEN> 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 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.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 <v.pupillo@HIDDEN> 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 <v.pupillo@HIDDEN> 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 <at> debbugs.gnu.org >> >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 >> >> > From: Eli Zaretskii <eliz@HIDDEN> >> >> >=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" <bug-gnu-emacs@HIDDEN> >> >> > >=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 <v.pupillo@HIDDEN> >> > 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)
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 23 Mar 2025 18:21:16 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 14:21:16 2025 Received: from localhost ([127.0.0.1]:52587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1twPwi-0002pO-9E for submit <at> 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 <v.pupillo@HIDDEN>) id 1twPwe-0002p8-Sg for 76704 <at> 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 <at> 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 <v.pupillo@HIDDEN> To: juri@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, Fabian Brosda <f.brosda@HIDDEN> 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@HIDDEN> References: <871pvfkyjc.fsf@HIDDEN> <4873433.vXUDI8C0e8@fedora> <87sen4f3tx.fsf@HIDDEN> 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 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) 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 <v.pupillo@HIDDEN> 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 <at> debbugs.gnu.org > >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 > >> > From: Eli Zaretskii <eliz@HIDDEN> > >> >=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" <bug-gnu-emacs@HIDDEN> > >> > >=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 <v.pupillo@HIDDEN> > > 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)
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 23 Mar 2025 10:18:23 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 23 06:18:23 2025 Received: from localhost ([127.0.0.1]:47763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1twIPO-0004mD-DB for submit <at> 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 <f.brosda@HIDDEN>) id 1twIPL-0004kl-4o for 76704 <at> 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@HIDDEN; 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 <f.brosda@HIDDEN> To: Vincenzo Pupillo <v.pupillo@HIDDEN>, juri@HIDDEN, Eli Zaretskii <eliz@HIDDEN> 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@HIDDEN> <861pv6h6bz.fsf@HIDDEN> <86wmchi77z.fsf@HIDDEN> <4873433.vXUDI8C0e8@fedora> Date: Sun, 23 Mar 2025 11:18:02 +0100 Message-ID: <87sen4f3tx.fsf@HIDDEN> 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 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.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 <v.pupillo@HIDDEN> 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 <at> debbugs.gnu.org >> > Date: Sun, 09 Mar 2025 12:00:16 +0200 >> > From: Eli Zaretskii <eliz@HIDDEN> >> >=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" <bug-gnu-emacs@HIDDEN> >> > >=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 <v.pupillo@HIDDEN> > 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
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 22 Mar 2025 22:49:09 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 22 18:49:09 2025 Received: from localhost ([127.0.0.1]:46146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tw7eP-0005by-0F for submit <at> 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 <v.pupillo@HIDDEN>) id 1tw7eL-0005aI-DG for 76704 <at> 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 <at> 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 <v.pupillo@HIDDEN> To: juri@HIDDEN, Eli Zaretskii <eliz@HIDDEN> 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@HIDDEN> References: <871pvfkyjc.fsf@HIDDEN> <861pv6h6bz.fsf@HIDDEN> <86wmchi77z.fsf@HIDDEN> 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@HIDDEN, 76704 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) 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 <at> debbugs.gnu.org > > Date: Sun, 09 Mar 2025 12:00:16 +0200 > > From: Eli Zaretskii <eliz@HIDDEN> > >=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" <bug-gnu-emacs@HIDDEN> > > >=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 <v.pupillo@HIDDEN> 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--
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 22 Mar 2025 12:24:35 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 22 08:24:34 2025 Received: from localhost ([127.0.0.1]:41390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tvxtu-0002Kp-8e for submit <at> 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 <eliz@HIDDEN>) id 1tvxtq-0002KX-QV for 76704 <at> 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 <eliz@HIDDEN>) 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@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: juri@HIDDEN, v.pupillo@HIDDEN In-Reply-To: <861pv6h6bz.fsf@HIDDEN> (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@HIDDEN> <861pv6h6bz.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76704 Cc: f.brosda@HIDDEN, 76704 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Ping! Juri and Vincenzo, please chime in. > Cc: 76704 <at> debbugs.gnu.org > Date: Sun, 09 Mar 2025 12:00:16 +0200 > From: Eli Zaretskii <eliz@HIDDEN> > > > 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" <bug-gnu-emacs@HIDDEN> > > > > 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? > > > >
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Received: (at 76704) by debbugs.gnu.org; 9 Mar 2025 10:00:29 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 09 06:00:29 2025 Received: from localhost ([127.0.0.1]:58440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1trDSO-00065G-Pg for submit <at> 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 <eliz@HIDDEN>) id 1trDSN-000650-7N for 76704 <at> 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 <eliz@HIDDEN>) 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@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Fabian Brosda <f.brosda@HIDDEN>, Juri Linkov <juri@HIDDEN>, Vincenzo Pupillo <v.pupillo@HIDDEN> In-Reply-To: <871pvfkyjc.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN) Subject: Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode References: <871pvfkyjc.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76704 Cc: 76704 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -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" <bug-gnu-emacs@HIDDEN> > > 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?
bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at submit) by debbugs.gnu.org; 3 Mar 2025 04:32:29 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 02 23:32:29 2025 Received: from localhost ([127.0.0.1]:42408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1toxTg-0004kJ-9t for submit <at> 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 <f.brosda@HIDDEN>) id 1topFE-0004Gq-7M for submit <at> 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 <f.brosda@HIDDEN>) id 1topF5-0006aC-Gq for bug-gnu-emacs@HIDDEN; 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 <f.brosda@HIDDEN>) id 1topF2-0002wr-PG for bug-gnu-emacs@HIDDEN; 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@HIDDEN; 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 <bug-gnu-emacs@HIDDEN>; Sun, 02 Mar 2025 20:44:43 +0100 From: Fabian Brosda <f.brosda@HIDDEN> To: bug-gnu-emacs@HIDDEN 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@HIDDEN> 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@HIDDEN; 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 <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) 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
Fabian Brosda <f.brosda@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#76704
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.