Subject: Re: bug#20915: 25.0.50; [js-mode] electric annoyances

From: Stefan Monnier <[email-masked]>
Date: Sun, 28 Jun 2015 21:12:15 -0400

> Electric layout doesn't always quite work to my liking in js-mode.
>
> Start with Emacs -q and try the following example.
>
>       x.map(function(d) {return f(x);});
>
> When electric layout mode is on this is typed as
>
>      x.map(function(d){
>          return f(d);
>      };

I can't think of any way Emacs could guess that you want to keep this as
a single line.  Any idea?

> Typing the *third line*, I get something like (with electric indent and
> electric layout):
>
> plot.scale.y = d3.scale.ordinal()
>                        .domain(bar.ybins)
>     .rangeRoundBands([plot.height, 0
> 		     ], 0.1);

electric-indent-mode presumes indentation works correctly.  In this
case, I think we clearly have an indentation bug (can someone imagine
a sane programmer who'd want the above indentation?), so the thing to do
is to fix the indentation code.

> I don't know if it is even possible for electric indent mode to somehow
> guess that things are indented to an unknown style....

I can't imagine how.  You can tell Emacs, tho, by disabling
electric-indent-(local-)mode.

        Stefan