Juan571 / js2-mode

Automatically exported from code.google.com/p/js2-mode
0 stars 0 forks source link

Configurable indentation behavior #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm really not looking for another 25K lines of indenting code, but...
Would it be possible to make the tab behavior customizable?  I want to turn
off the indentation cycling on tab.  I'd rather have it be occasionally
wrong than have it move the line around.

I just started using js2-mode, so perhaps I will get used to it in time,
but so far it is driving me a little nutty.

Original issue reported on code.google.com by vthun...@gmail.com on 31 Mar 2008 at 9:28

GoogleCodeExporter commented 8 years ago
I agree, that it would be nice. With javascript-mode I used to do an 
indent-region on whole buffers to fix incorrect 
indentations, this is no longer possible.

An especially frustrating example is when I use the module pattern, which I 
usually format like this:

FooBarBaz = (function () {
    return bax;
})();

By default it indents to:

FooBarBazQux = (function () {
                    return bax;
                })();

Even if I remove the indentation from the last line, it still indents the 
statements inside all the way in, and even worse, it will  
keep indenting this way no matter what the rest of the code looks like, as in 
this example (where | is the caret's position 
after typing "bam;"):

FooBarBazQux = (function () {
    baz;
                    bam;|
})();

And by the way, js2-mode looks like it could develop into something really 
great, keep up the good work!

Original comment by Rae...@gmail.com on 2 Apr 2008 at 5:23

GoogleCodeExporter commented 8 years ago
The particular tab behavior Raevel sees drives me a little batty, too.  Not 
enough to
go back to javascript-mode, mind you, but it'd be nice if this particular 
pattern was
handled differently.

Original comment by mercutio...@gmail.com on 9 Apr 2008 at 9:34

GoogleCodeExporter commented 8 years ago
I agree with turning off the Tab-cycling.  I think that pressing TAB should get 
you
the default indenting and there should be a secondary indent command to cycle 
through
the alternatives.  People could bind that to shift-TAB (or whatever).  There 
could
also be a setting to get back to the present default behavior.  I've found the
indenting to work pretty well.

Raevel: if you get rid of the unnecessary parens then it indents fine:

FooBarBaz = function () {
  return bax;
}();

Original comment by bob.spam...@gmail.com on 12 Apr 2008 at 3:16

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Folks, PLEASE PLEASE PLEASE type M-x customize-group js2-mode.

This behavior is controlled by `js2-bounce-indent-flag'.  Set it to nil and TAB 
will
no longer cycle the indentation.

Original comment by steve.ye...@gmail.com on 14 Apr 2008 at 10:16