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

Previous Next

Package: emacs;

Reported by: Marcin Borkowski <mbork <at> mbork.pl>

Date: Wed, 22 Apr 2020 09:06:01 UTC

Severity: normal

Found in version 27.0.50

Full log


Message #16 received at 40760 <at> debbugs.gnu.org (full text, mbox):

From: Marcin Borkowski <mbork <at> mbork.pl>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 40760 <at> debbugs.gnu.org, mbork <at> mbork.pl
Subject: Re: bug#40760: 27.0.50; An indentation problem with const and
 chaining in js-mode
Date: Mon, 14 Mar 2022 11:13:49 +0100
On 2022-03-14, at 10:40, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Marcin Borkowski <mbork <at> mbork.pl> 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 <at> mbork.pl> 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




This bug report was last modified 3 years and 67 days ago.

Previous Next


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