GNU bug report logs - #40760
27.0.50; An indentation problem with const and chaining in js-mode

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

Package: emacs; Reported by: Marcin Borkowski <mbork@HIDDEN>; dated Wed, 22 Apr 2020 09:06:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 40760) by debbugs.gnu.org; 23 Mar 2022 00:46:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 22 20:46:56 2022
Received: from localhost ([127.0.0.1]:42156 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nWp9M-00022y-12
	for submit <at> debbugs.gnu.org; Tue, 22 Mar 2022 20:46:56 -0400
Received: from mail-ej1-f54.google.com ([209.85.218.54]:46684)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1nWp9J-00022k-O5
 for 40760 <at> debbugs.gnu.org; Tue, 22 Mar 2022 20:46:54 -0400
Received: by mail-ej1-f54.google.com with SMTP id qx21so39572759ejb.13
 for <40760 <at> debbugs.gnu.org>; Tue, 22 Mar 2022 17:46:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=sender:message-id:date:mime-version:user-agent:subject
 :content-language:to:cc:references:from:in-reply-to
 :content-transfer-encoding;
 bh=izDMR3u3cnKsDtYRxxHhEIQbiVp1uk9gNkngyVkq6XU=;
 b=dDJTWZWB4CzLXb/7OOjBQNW3POR1eSs7Aog4MqrxLixO1KkYb3ZT2svroJJtMwAVnz
 xZm7Q2yZ9pLIcTZRWLysJyPGnLes+DLYVXrSvJT+nQs+VeK6K7moe1JwYztvKo7m6sZj
 ZbbnHvyLNkUoGsodI3rfgauMGyJhJg6sPj/ZTzC7ZWIt0pTwG17Pw6FCCG9Eao7Z6tML
 EXKEqi4d0lff0qE68bsb5X3fjAGunbjemSrK2Go601ZqACNaXDfKnxhWsp3Fwhl6Pnfq
 FdGTjVTSwAWwArwRY5+BiNeojkVr9iSe//lMstlzYzy9gXba2uI+eOtbFM3TnSjuvzmj
 XSxg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:sender:message-id:date:mime-version:user-agent
 :subject:content-language:to:cc:references:from:in-reply-to
 :content-transfer-encoding;
 bh=izDMR3u3cnKsDtYRxxHhEIQbiVp1uk9gNkngyVkq6XU=;
 b=VQV6H7XT414eQshIpHhpzhK6BWXYl3mlkq4G9R1QE/qByxoJ9SR83+D3/ofJX5a/lk
 H7tJYMPo6VbY9dImf2UwZ2qFKWzaIq8RpHnJFqRtv9LK5IueGQlrTbDQTUYuk1W41rTL
 IaPct35dweWmPn55wwWrM+zypP9VD/NXFIzO3YpjaPpNAV/xdrfYn/Rsz9oDQ8mZE3ZW
 qFs3Xv2FxYiUBhAuM2T++XOmGbnwTvRbnK5lfwr2bt9R1dW5HePyXKXnlstyoNTHGXyl
 fLKhbLo5ziO3Sgl8nRz/qIb4RfW+c/chSViY+N0HcM+SuneZ9l9FFPLvG/494POvQi5r
 wxCg==
X-Gm-Message-State: AOAM532GbVnzKuqfJiJEq6KKk7EGAc6zu2Jue9HfLMyqzbtt8bAqTzfc
 ePAJ3pGSPZ6pOOdLMGjHb14=
X-Google-Smtp-Source: ABdhPJyRldbPXpKpFy4BDpjDeYaFZl1wjUPgEboxIsptufg4R73mPMmMndDSqwaQDCLuFKdeBtL4NQ==
X-Received: by 2002:a17:906:99c2:b0:6df:8834:4f4c with SMTP id
 s2-20020a17090699c200b006df88344f4cmr28470116ejn.496.1647996407661; 
 Tue, 22 Mar 2022 17:46:47 -0700 (PDT)
Received: from [192.168.236.48] ([173.237.64.48])
 by smtp.googlemail.com with ESMTPSA id
 g21-20020a056402115500b00413c824e422sm10368800edw.72.2022.03.22.17.46.46
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 22 Mar 2022 17:46:47 -0700 (PDT)
Message-ID: <77d4627a-8e73-ce5c-c027-01813cbedbb9@HIDDEN>
Date: Wed, 23 Mar 2022 02:46:45 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Subject: Re: bug#40760: 27.0.50; An indentation problem with const and
 chaining in js-mode
Content-Language: en-US
To: Marcin Borkowski <mbork@HIDDEN>
References: <87r1wf99id.fsf@HIDDEN> <87fsnkoosu.fsf@HIDDEN>
 <87ilsgvo2q.fsf@HIDDEN> <0f3dfed4-f61a-87f9-6325-ca9d80e7077e@HIDDEN>
 <87czifq0sn.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <87czifq0sn.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 40760
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, 40760 <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: -0.5 (/)

On 21.03.2022 08:26, Marcin Borkowski wrote:

> Interesting - I thought using spaces for indentation is a no-no nowadays
> (at least in JS, Lisp is another thing, for obvious reasons).  But I may
> be mistaken, and I don't think tabs are inherently better - though we do
> use them in our company.

There are a bunch of odd styles in use in JS. For example, comma-first 
indentation, where you don't put commas at the end of a line, and 
instead add newline and indentation before them.

But space-based indentation still seems prevalent.

Anyway...

>> This indentation feature was ported from js2-mode at some point, where
>> it is guarded by the (on by default) user option
>> js2-pretty-multiline-declarations. The option itself was lost in
>> transition.
>>
>> See js2-old-indent.el for more info.
> 
> Very interesting.  FWIW, I almost never have many variables in a single
> let/const - I prefer to write
> 
> let a = 1;
> let b = 2;
> const c = 3;
> const d = 4;
> 
> (and this also is a style I learned where I work).

At some point support for multi-var combined declarations was requested 
for, that's when I added that var.

So, the code is out there, it shouldn't be hard to adapt to js-mode, if 
you have the time.




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

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


Received: (at 40760) by debbugs.gnu.org; 21 Mar 2022 06:26:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 21 02:26:18 2022
Received: from localhost ([127.0.0.1]:35650 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nWBUf-0004Tm-Vl
	for submit <at> debbugs.gnu.org; Mon, 21 Mar 2022 02:26:18 -0400
Received: from mail.mojserwer.eu ([195.110.48.8]:39676)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mbork@HIDDEN>) id 1nWBUb-0004TX-9y
 for 40760 <at> debbugs.gnu.org; Mon, 21 Mar 2022 02:26:16 -0400
Received: from localhost (localhost [127.0.0.1])
 by mail.mojserwer.eu (Postfix) with ESMTP id 4041EE6ECE;
 Mon, 21 Mar 2022 07:26:08 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu
Received: from mail.mojserwer.eu ([127.0.0.1])
 by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 5cfjaGJMvKkF; Mon, 21 Mar 2022 07:26:03 +0100 (CET)
Received: from localhost (178235147176.dynamic-3-poz-k-0-1-0.vectranet.pl
 [178.235.147.176])
 by mail.mojserwer.eu (Postfix) with ESMTPSA id 9700DE626D;
 Mon, 21 Mar 2022 07:26:03 +0100 (CET)
References: <87r1wf99id.fsf@HIDDEN> <87fsnkoosu.fsf@HIDDEN>
 <87ilsgvo2q.fsf@HIDDEN> <0f3dfed4-f61a-87f9-6325-ca9d80e7077e@HIDDEN>
User-agent: mu4e 1.1.0; emacs 29.0.50
From: Marcin Borkowski <mbork@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#40760: 27.0.50; An indentation problem with const and
 chaining in js-mode
In-reply-to: <0f3dfed4-f61a-87f9-6325-ca9d80e7077e@HIDDEN>
Date: Mon, 21 Mar 2022 07:26:00 +0100
Message-ID: <87czifq0sn.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 40760
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, 40760 <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 (-)


On 2022-03-18, at 02:12, Dmitry Gutov <dgutov@HIDDEN> wrote:

> On 14.03.2022 12:13, Marcin Borkowski wrote:
>> On 2022-03-14, at 10:40, Lars Ingebrigtsen <larsi@HIDDEN> wrote:
>> 
>>> Marcin Borkowski <mbork@HIDDEN> writes:
>>>
>>>> When declaring a const variable which is assigned a value of a long,
>>>> chained expression, the default indentation is wrong (compared to a let
>>>> declaration):
>>>>
>>>> let a = /regex/
>>>>      .test('regex hello');
>>>>
>>>> const a = /regex/
>>>>        .test('regex hello');
>>>
>>> I think this is the intended indentation?  That is, they indent to where
>>> the "a" is.
>> Well, in a tab-only indentation style (used by many people, me
>> included)
>> this is _very_ wrong, e.g. because it results in Emacs using both tabs
>> and spaces here.
>
> I'm fairly certain it's not a very popular style, but we should try to
> cater to it as well, of course.

Interesting - I thought using spaces for indentation is a no-no nowadays
(at least in JS, Lisp is another thing, for obvious reasons).  But I may
be mistaken, and I don't think tabs are inherently better - though we do
use them in our company.

>
>>> Marcin Borkowski <mbork@HIDDEN> writes:
>>>
>>>> This is the temporary solution I employed:
>>>>
>>>> (setq js--declaration-keyword-re "\\<\\(let\\|var\\)\\>")
>>>>
>>>> I would suggest turning this variable into a user option.
>>>
>>> This isn't just used for indentation, so altering this const will lead
>>> to other breakages (and so it shouldn't be customiseable, either).
>> Grep apparently disagrees - I found 5 occurrences of
>> `js--declaration-keyword-re' in Emacs sources, and all of them seem to
>> be related to indentation.  So, I don't see any danger here.  (Anyway,
>> I changed it in my init.el; we'll see how that works.)
>
> I think it would be better to add a more semantically-named user option.

Definitely, the name 

>
> This indentation feature was ported from js2-mode at some point, where
> it is guarded by the (on by default) user option
> js2-pretty-multiline-declarations. The option itself was lost in
> transition.
>
> See js2-old-indent.el for more info.

Very interesting.  FWIW, I almost never have many variables in a single
let/const - I prefer to write

let a = 1;
let b = 2;
const c = 3;
const d = 4;

(and this also is a style I learned where I work).

Best,


-- 
Marcin Borkowski
http://mbork.pl




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

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


Received: (at 40760) by debbugs.gnu.org; 18 Mar 2022 01:12:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 17 21:12:15 2022
Received: from localhost ([127.0.0.1]:55741 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nV1A6-0003XH-KG
	for submit <at> debbugs.gnu.org; Thu, 17 Mar 2022 21:12:15 -0400
Received: from mail-wr1-f43.google.com ([209.85.221.43]:37616)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1nV1A0-0003Wx-UO
 for 40760 <at> debbugs.gnu.org; Thu, 17 Mar 2022 21:12:12 -0400
Received: by mail-wr1-f43.google.com with SMTP id u16so8753730wru.4
 for <40760 <at> debbugs.gnu.org>; Thu, 17 Mar 2022 18:12:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=sender:message-id:date:mime-version:user-agent:subject
 :content-language:to:cc:references:from:in-reply-to
 :content-transfer-encoding;
 bh=7xc5tC618XhUUtvQ3Z1PAzBSmAgl3QHMxMG5VJ8m47Y=;
 b=FMdOLMNVwa4icNdsnph/HwdjdPdOAj3xrfQONvHhSCMip54LMTnyF8QCVNHvDrs8LN
 CcOexhAAwV8uOEv8CSCV7KGmZ/2FziCUoDUDUZCZDnebqIA4cBS3X5ow6umJ5Gri+W3K
 vC5HIjuluQrnvcY1Zl7U+gJ62ctFdoE9BWM2V0tbz102wZnm3TD/sSRc+DltivCOP2BN
 gohLdu+HNUPzDi7I3Kklh9XMvl9jjosJrRt/xl7CsZhVSNslp118Dkx5gA2EqYq8SXoG
 xXTThbX+VBFFtkicE1RjMEzt9AwZ4/TfN0BOYNW68I6V6AzFQ5Zobu00QOoFd/GVMtIC
 X7YA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:sender:message-id:date:mime-version:user-agent
 :subject:content-language:to:cc:references:from:in-reply-to
 :content-transfer-encoding;
 bh=7xc5tC618XhUUtvQ3Z1PAzBSmAgl3QHMxMG5VJ8m47Y=;
 b=4EJvpbifyGNXuent2BP8Mjd30cF/AybDJ46p/38QklBrTgjkVZ6Ub33l5o3utiCasO
 f+V9gSnek16dUj7PSbsHBWL7bDORJ510Z/ateg8+mymxMasraNUOHMXeDlqjpPOTYXE6
 5JIiHpgtMtP1+MUDD1q+UvBlLnrtOFWZ+1N3Lzo0MutIdcpNjxrq668+9SDsA0+wHqhD
 gff2UNjrvFgyRRZgRWLXIoGT9Y9B0vqe5XuHMUEvi6yyh0J3fPML/Xe4RZs4pE245HKw
 LZoKfqOR/+GTHEfLpBItTSXKW37RsIlyJPzTdKw9pWMxFqz7FXt7nBD0UY6BGlokRnIG
 nuBQ==
X-Gm-Message-State: AOAM533QsP3ObbMfg/Ovx3Oi/BCMKCNZRtAwXXzagCPcLzbshkHDTcyu
 BwC4XWdCmv8IDwCWtTcYsFo=
X-Google-Smtp-Source: ABdhPJw4wD8/vGtqzUAXd/EKy10np6OLJEeXvarnrqfXuA6K+V0yrnBMRk6r9dD6QydXkbr6aA/qMQ==
X-Received: by 2002:a5d:6d8a:0:b0:203:6efe:7960 with SMTP id
 l10-20020a5d6d8a000000b002036efe7960mr6073449wrs.291.1647565923065; 
 Thu, 17 Mar 2022 18:12:03 -0700 (PDT)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 bg42-20020a05600c3caa00b00380deeaae72sm7288962wmb.1.2022.03.17.18.12.02
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 17 Mar 2022 18:12:02 -0700 (PDT)
Message-ID: <0f3dfed4-f61a-87f9-6325-ca9d80e7077e@HIDDEN>
Date: Fri, 18 Mar 2022 03:12:01 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Subject: Re: bug#40760: 27.0.50; An indentation problem with const and
 chaining in js-mode
Content-Language: en-US
To: Marcin Borkowski <mbork@HIDDEN>, Lars Ingebrigtsen <larsi@HIDDEN>
References: <87r1wf99id.fsf@HIDDEN> <87fsnkoosu.fsf@HIDDEN>
 <87ilsgvo2q.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <87ilsgvo2q.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 40760
Cc: 40760 <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: -0.5 (/)

On 14.03.2022 12:13, Marcin Borkowski wrote:
> 
> On 2022-03-14, at 10:40, Lars Ingebrigtsen <larsi@HIDDEN> wrote:
> 
>> Marcin Borkowski <mbork@HIDDEN> writes:
>>
>>> When declaring a const variable which is assigned a value of a long,
>>> chained expression, the default indentation is wrong (compared to a let
>>> declaration):
>>>
>>> let a = /regex/
>>>      .test('regex hello');
>>>
>>> const a = /regex/
>>>        .test('regex hello');
>>
>> I think this is the intended indentation?  That is, they indent to where
>> the "a" is.
> 
> Well, in a tab-only indentation style (used by many people, me included)
> this is _very_ wrong, e.g. because it results in Emacs using both tabs
> and spaces here.

I'm fairly certain it's not a very popular style, but we should try to 
cater to it as well, of course.

>> Marcin Borkowski <mbork@HIDDEN> writes:
>>
>>> This is the temporary solution I employed:
>>>
>>> (setq js--declaration-keyword-re "\\<\\(let\\|var\\)\\>")
>>>
>>> I would suggest turning this variable into a user option.
>>
>> This isn't just used for indentation, so altering this const will lead
>> to other breakages (and so it shouldn't be customiseable, either).
> 
> Grep apparently disagrees - I found 5 occurrences of
> `js--declaration-keyword-re' in Emacs sources, and all of them seem to
> be related to indentation.  So, I don't see any danger here.  (Anyway,
> I changed it in my init.el; we'll see how that works.)

I think it would be better to add a more semantically-named user option.

This indentation feature was ported from js2-mode at some point, where 
it is guarded by the (on by default) user option 
js2-pretty-multiline-declarations. The option itself was lost in transition.

See js2-old-indent.el for more info.




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

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


Received: (at 40760) by debbugs.gnu.org; 14 Mar 2022 10:14:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 14 06:14:00 2022
Received: from localhost ([127.0.0.1]:44145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nThiC-0007tJ-L8
	for submit <at> debbugs.gnu.org; Mon, 14 Mar 2022 06:14:00 -0400
Received: from mail.mojserwer.eu ([195.110.48.8]:46420)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mbork@HIDDEN>) id 1nThi8-0007t8-Mg
 for 40760 <at> debbugs.gnu.org; Mon, 14 Mar 2022 06:13:59 -0400
Received: from localhost (localhost [127.0.0.1])
 by mail.mojserwer.eu (Postfix) with ESMTP id 02A42E70B0;
 Mon, 14 Mar 2022 11:13:53 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu
Received: from mail.mojserwer.eu ([127.0.0.1])
 by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id RJUmxLCpvmNr; Mon, 14 Mar 2022 11:13:49 +0100 (CET)
Received: from localhost (83.8.166.110.ipv4.supernova.orange.pl [83.8.166.110])
 by mail.mojserwer.eu (Postfix) with ESMTPSA id 924E0E653B;
 Mon, 14 Mar 2022 11:13:49 +0100 (CET)
References: <87r1wf99id.fsf@HIDDEN> <87fsnkoosu.fsf@HIDDEN>
User-agent: mu4e 1.1.0; emacs 29.0.50
From: Marcin Borkowski <mbork@HIDDEN>
To: Lars Ingebrigtsen <larsi@HIDDEN>
Subject: Re: bug#40760: 27.0.50; An indentation problem with const and
 chaining in js-mode
In-reply-to: <87fsnkoosu.fsf@HIDDEN>
Date: Mon, 14 Mar 2022 11:13:49 +0100
Message-ID: <87ilsgvo2q.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 40760
Cc: 40760 <at> debbugs.gnu.org, mbork@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


On 2022-03-14, at 10:40, Lars Ingebrigtsen <larsi@HIDDEN> wrote:

> Marcin Borkowski <mbork@HIDDEN> writes:
>
>> When declaring a const variable which is assigned a value of a long,
>> chained expression, the default indentation is wrong (compared to a let
>> declaration):
>>
>> let a = /regex/
>>     .test('regex hello');
>>
>> const a = /regex/
>>       .test('regex hello');
>
> I think this is the intended indentation?  That is, they indent to where
> the "a" is.

Well, in a tab-only indentation style (used by many people, me included)
this is _very_ wrong, e.g. because it results in Emacs using both tabs
and spaces here.

> Marcin Borkowski <mbork@HIDDEN> writes:
>
>> This is the temporary solution I employed:
>>
>> (setq js--declaration-keyword-re "\\<\\(let\\|var\\)\\>")
>>
>> I would suggest turning this variable into a user option.
>
> This isn't just used for indentation, so altering this const will lead
> to other breakages (and so it shouldn't be customiseable, either).

Grep apparently disagrees - I found 5 occurrences of
`js--declaration-keyword-re' in Emacs sources, and all of them seem to
be related to indentation.  So, I don't see any danger here.  (Anyway,
I changed it in my init.el; we'll see how that works.)

Best,

-- 
Marcin Borkowski
http://mbork.pl




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#40760; Package emacs. Full text available.
Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 40760) by debbugs.gnu.org; 14 Mar 2022 09:40:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 14 05:40:16 2022
Received: from localhost ([127.0.0.1]:44117 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nThBX-0002dC-Ph
	for submit <at> debbugs.gnu.org; Mon, 14 Mar 2022 05:40:16 -0400
Received: from quimby.gnus.org ([95.216.78.240]:40520)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1nThBW-0002cq-FQ
 for 40760 <at> debbugs.gnu.org; Mon, 14 Mar 2022 05:40:15 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=07iUfqViHjnbHbwfXcxJzYWjeRAeO06UjvM7UKGxUkE=; b=P2KfnryzZhwN/vc1izdXhBRVIq
 cejZvw4Zx9/QtdSxlv0lFW+0OGkzXrYzghjz90D5v+Du6jOsB6xMoj0F2zzqaCXa8paKRuzJdAMyy
 tU2U6G/NORh3IN3PH1DMPqgEPulz6xd1r+aYYQJdG5dcw2DUywGG+ojA/hzH5aSxHYas=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1nThBL-0004ua-T3; Mon, 14 Mar 2022 10:40:06 +0100
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Marcin Borkowski <mbork@HIDDEN>
Subject: Re: bug#40760: 27.0.50; An indentation problem with const and
 chaining in js-mode
References: <87r1wf99id.fsf@HIDDEN>
X-Now-Playing: Thomas Dolby's _Blinded by Science_: "Flying North"
Date: Mon, 14 Mar 2022 10:40:01 +0100
In-Reply-To: <87r1wf99id.fsf@HIDDEN> (Marcin Borkowski's message of "Wed, 22
 Apr 2020 11:05:08 +0200")
Message-ID: <87fsnkoosu.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Marcin Borkowski <mbork@HIDDEN> writes: > When declaring
 a const variable which is assigned a value of a long, > chained expression,
 the default indentation is wrong (compared to a let > declaration): > > let
 a = /regex/ > .test('regex hell [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 40760
Cc: 40760 <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 (---)

Marcin Borkowski <mbork@HIDDEN> writes:

> When declaring a const variable which is assigned a value of a long,
> chained expression, the default indentation is wrong (compared to a let
> declaration):
>
> let a = /regex/
>     .test('regex hello');
>
> const a = /regex/
>       .test('regex hello');

I think this is the intended indentation?  That is, they indent to where
the "a" is.

Marcin Borkowski <mbork@HIDDEN> writes:

> This is the temporary solution I employed:
>
> (setq js--declaration-keyword-re "\\<\\(let\\|var\\)\\>")
>
> I would suggest turning this variable into a user option.

This isn't just used for indentation, so altering this const will lead
to other breakages (and so it shouldn't be customiseable, either).

It looks to me like everything here is working as intended (but you're
free to prefer other indentation methods if you want, of course), but I
don't think there's much to do on the Emacs side here.  Anybody else
got an opinion? 

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




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

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


Received: (at submit) by debbugs.gnu.org; 14 Mar 2022 05:11:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 14 01:11:01 2022
Received: from localhost ([127.0.0.1]:43791 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nTcyz-0001v3-8I
	for submit <at> debbugs.gnu.org; Mon, 14 Mar 2022 01:11:01 -0400
Received: from lists.gnu.org ([209.51.188.17]:46876)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mbork@HIDDEN>) id 1nTcyy-0001uV-Kf
 for submit <at> debbugs.gnu.org; Mon, 14 Mar 2022 01:11:00 -0400
Received: from eggs.gnu.org ([209.51.188.92]:53402)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mbork@HIDDEN>) id 1nTcyy-0006VX-9g
 for bug-gnu-emacs@HIDDEN; Mon, 14 Mar 2022 01:11:00 -0400
Received: from mail.mojserwer.eu ([195.110.48.8]:45366)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mbork@HIDDEN>) id 1nTcyw-0008Sf-Bj
 for bug-gnu-emacs@HIDDEN; Mon, 14 Mar 2022 01:11:00 -0400
Received: from localhost (localhost [127.0.0.1])
 by mail.mojserwer.eu (Postfix) with ESMTP id BA13CE70B0
 for <bug-gnu-emacs@HIDDEN>; Mon, 14 Mar 2022 06:10:51 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu
Received: from mail.mojserwer.eu ([127.0.0.1])
 by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id BRslJ6vP8Yqe; Mon, 14 Mar 2022 06:10:48 +0100 (CET)
Received: from localhost (178235147010.dynamic-3-poz-k-0-1-0.vectranet.pl
 [178.235.147.10])
 by mail.mojserwer.eu (Postfix) with ESMTPSA id 6C374E653B;
 Mon, 14 Mar 2022 06:10:48 +0100 (CET)
References: <87r1wf99id.fsf@HIDDEN>
User-agent: mu4e 1.1.0; emacs 29.0.50
From: Marcin Borkowski <mbork@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Re: 27.0.50; An indentation problem with const and chaining in js-mode
In-reply-to: <87r1wf99id.fsf@HIDDEN>
Date: Mon, 14 Mar 2022 06:10:44 +0100
Message-ID: <87mthtunjf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=195.110.48.8; envelope-from=mbork@HIDDEN;
 helo=mail.mojserwer.eu
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: mbork@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


On 2020-04-22, at 11:05, Marcin Borkowski <mbork@HIDDEN> wrote:

> When declaring a const variable which is assigned a value of a long,
> chained expression, the default indentation is wrong (compared to a let
> declaration):
>
> let a = /regex/
>     .test('regex hello');
>
> const a = /regex/
>       .test('regex hello');
>
> I would expect (and prefer) this:
>
> let a = /regex/
>     .test('regex hello');
>
> const a = /regex/
>     .test('regex hello');
>     
> (checked on emacs -Q)

This is the temporary solution I employed:

(setq js--declaration-keyword-re "\\<\\(let\\|var\\)\\>")

I would suggest turning this variable into a user option.

Best,

PS. Please CC me in any replies, I am not subscribed to bug-gnu-emacs.

-- 
Marcin Borkowski
http://mbork.pl




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

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


Received: (at submit) by debbugs.gnu.org; 22 Apr 2020 09:05:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 22 05:05:38 2020
Received: from localhost ([127.0.0.1]:51272 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jRBK6-00068G-Hr
	for submit <at> debbugs.gnu.org; Wed, 22 Apr 2020 05:05:38 -0400
Received: from lists.gnu.org ([209.51.188.17]:60826)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mbork@HIDDEN>) id 1jRBK5-000684-HP
 for submit <at> debbugs.gnu.org; Wed, 22 Apr 2020 05:05:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36794)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mbork@HIDDEN>) id 1jRBK5-0001qK-6i
 for bug-gnu-emacs@HIDDEN; Wed, 22 Apr 2020 05:05:37 -0400
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,
 RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,URIBL_BLOCKED
 autolearn=unavailable autolearn_force=no version=3.4.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1)
 (envelope-from <mbork@HIDDEN>) id 1jRBK2-0007nA-2p
 for bug-gnu-emacs@HIDDEN; Wed, 22 Apr 2020 05:05:36 -0400
Received: from mail.mojserwer.eu ([195.110.48.8]:53940)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mbork@HIDDEN>) id 1jRBK1-0007IR-JF
 for bug-gnu-emacs@HIDDEN; Wed, 22 Apr 2020 05:05:33 -0400
Received: from localhost (localhost [127.0.0.1])
 by mail.mojserwer.eu (Postfix) with ESMTP id 09421E6367
 for <bug-gnu-emacs@HIDDEN>; Wed, 22 Apr 2020 11:05:26 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu
Received: from mail.mojserwer.eu ([127.0.0.1])
 by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id VqkxnfyinzSQ for <bug-gnu-emacs@HIDDEN>;
 Wed, 22 Apr 2020 11:05:11 +0200 (CEST)
Received: from localhost (jeden09-dwa27.echostar.pl [213.156.109.227])
 by mail.mojserwer.eu (Postfix) with ESMTPSA id A1841E62CF
 for <bug-gnu-emacs@HIDDEN>; Wed, 22 Apr 2020 11:05:11 +0200 (CEST)
User-agent: mu4e 1.1.0; emacs 27.0.50
From: Marcin Borkowski <mbork@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.0.50; An indentation problem with const and chaining in js-mode
Message-ID: <87r1wf99id.fsf@HIDDEN>
Date: Wed, 22 Apr 2020 11:05:08 +0200
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=195.110.48.8; envelope-from=mbork@HIDDEN;
 helo=mail.mojserwer.eu
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/22 05:05:26
X-ACL-Warn: Detected OS   = Linux 3.11 and newer [fuzzy]
X-Received-From: 195.110.48.8
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

When declaring a const variable which is assigned a value of a long,
chained expression, the default indentation is wrong (compared to a let
declaration):

let a = /regex/
    .test('regex hello');

const a = /regex/
      .test('regex hello');

I would expect (and prefer) this:

let a = /regex/
    .test('regex hello');

const a = /regex/
    .test('regex hello');
    
(checked on emacs -Q)

TIA,
mb



In GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.8)
 of 2019-06-15 built on tars
Repository revision: f6a1647a8be9148b8db76aca601773968af7c343
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Arch Linux

--
Marcin Borkowski
http://mbork.pl




Acknowledgement sent to Marcin Borkowski <mbork@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#40760; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 15 Apr 2022 10:30:02 UTC

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