bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40760: 27.0.50; An indentation problem with const and chaining in js


From: Dmitry Gutov
Subject: bug#40760: 27.0.50; An indentation problem with const and chaining in js-mode
Date: Wed, 23 Mar 2022 02:46:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]