GNU bug report logs -
#20915
25.0.50; [js-mode] electric annoyances
Previous Next
Full log
Message #38 received at 20915 <at> debbugs.gnu.org (full text, mbox):
Hi,
Stefan Monnier <monnier <at> iro.umontreal.ca> 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
This bug report was last modified 10 years and 44 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.