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

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

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


From: Rasmus
Subject: bug#20915: 25.0.50; [js-mode] electric annoyances
Date: Mon, 29 Jun 2015 03:26:07 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Hi,

Stefan Monnier <address@hidden> writes:

>> 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?

I don't know if this is possible.  Perhaps via js2 since it knows more
about semantics.

What about differentiating between functions saved to a var or an object
slot:

    var foo = function(a,b){...};
    baz.f = function(a,b){...};

Versus functions that are not saved.

    [1,2,3].map(function(d){...});

Is that identifiable and desirable?

I'm expect Dmitry has a better understanding of this issue.

>> 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.

And you would not consider the lonely "]" an stylistic annoyance?  That, I
guess, is the work of electric layout.

>> 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.

Of course.  I can also remove some of the most unpleasant characters in
electric-indent-chars...

Rasmus

-- 
C is for Cookie





reply via email to

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