From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.bugs Subject: bug#40760: 27.0.50; An indentation problem with const and chaining in js-mode Date: Mon, 21 Mar 2022 07:26:00 +0100 Message-ID: <87czifq0sn.fsf@mbork.pl> References: <87r1wf99id.fsf@mbork.pl> <87fsnkoosu.fsf@gnus.org> <87ilsgvo2q.fsf@mbork.pl> <0f3dfed4-f61a-87f9-6325-ca9d80e7077e@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30581"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.1.0; emacs 29.0.50 Cc: Lars Ingebrigtsen , 40760@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 21 07:28:03 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nWBWN-0007mG-9H for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Mar 2022 07:28:03 +0100 Original-Received: from localhost ([::1]:58484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWBWM-00041u-0U for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Mar 2022 02:28:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWBVQ-00041k-KC for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2022 02:27:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nWBVO-0008Lg-W9 for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2022 02:27:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nWBVO-0004Un-D3 for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2022 02:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marcin Borkowski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Mar 2022 06:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40760 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 40760-submit@debbugs.gnu.org id=B40760.164784397817226 (code B ref 40760); Mon, 21 Mar 2022 06:27:02 +0000 Original-Received: (at 40760) by debbugs.gnu.org; 21 Mar 2022 06:26:18 +0000 Original-Received: from localhost ([127.0.0.1]:35650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nWBUf-0004Tm-Vl for submit@debbugs.gnu.org; Mon, 21 Mar 2022 02:26:18 -0400 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:39676) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nWBUb-0004TX-9y for 40760@debbugs.gnu.org; Mon, 21 Mar 2022 02:26:16 -0400 Original-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 Original-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) Original-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) In-reply-to: <0f3dfed4-f61a-87f9-6325-ca9d80e7077e@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:228648 Archived-At: On 2022-03-18, at 02:12, Dmitry Gutov wrote: > On 14.03.2022 12:13, Marcin Borkowski wrote: >> On 2022-03-14, at 10:40, Lars Ingebrigtsen wrote: >> >>> Marcin Borkowski 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 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