Open GoogleCodeExporter opened 8 years ago
I just thought I'd add that this is a frequent annoyance with small page
scripts. If
you're using jQuery you often stick everything into an anonymous function like
this:
$(function () {
// define a couple of functions
function foo(...) {
...
}
// bind functions to events
$(".hello").click(foo);
});
Here js2-mode wants to indent to 6 instead of 4 inside the $();, so it's really
inconsistent with code written with the Karl's Javascript mode.
Original comment by olau%iol...@gtempaccount.com
on 28 Sep 2009 at 2:33
I 3rd this. I stopped using js2-mode because of this since most of the
javascript I
write uses a lot of anonymous functions.
Original comment by lau.laur...@gmail.com
on 28 Oct 2009 at 3:42
This appears to have been fixed in the latest versions (I am using 20090723b).
But
the fix is not complete.
The simple case reported above is fixed:
something(function() {
another():
});
However if there are previous parameters to the function call and they have been
split over more than one line then the behaviour is as reported:
something("foo",
function() {
indentsToHere();
});
Note that putting all the parameters on the same line gives the requested
behaviour:
something("foo", function() {
asDesired();
});
That putting the function on the same line as an earlier parameter (but having
earlier parameters split over lines) give the undesirable indentation:
something("foo",
"bar", function() {
booBoo();
});
And that this is also true if the thing that is split over two lines is an
expression
rather than multiple parameters (like a split string):
something("foo and "
+ "bar", function() {
goesHere();
});
[And this is actually the case I care about. I would like to split Screw.Unit
specs
with long text like so:
it("should allow me to split my very long spec descriptions so that " +
"they are readable and indent like a single block", function() {
expect(indentsToHere()).to(be_true);
});
]
Original comment by ben.butl...@gmail.com
on 9 Nov 2009 at 3:00
people like js2-mode but not quite content with its indentation should
really check this out:
http://mihai.bazon.net/projects/editing-javascript-with-emacs-js2-mode
it not only fixes the problems listed above, but also fix indentation with:
var a,
b = function(){
},
c;
Original comment by darren....@gmail.com
on 11 Oct 2010 at 6:38
Is there any fix available?
Original comment by qwigly...@gmail.com
on 8 Oct 2012 at 6:59
Original issue reported on code.google.com by
aaron...@gmail.com
on 10 Nov 2008 at 2:09