How to get js-mode to properly indent continued (compound?) var declarations?
If I use distinct var
statements like
function stretchDiv(){
var wh = $(window).height();
var sz2 = wh - ((paddingTop + paddingBottom) + (mainTop + 2) * 2);
// the scrollbar happens only when the height of the elt is constrained
var sz3 = sz2 - outTop - 2;
$('#out').css({'height': sz3 + 'px'});
}
then JSLint complains, telling me to combine the second and third with the previous.
If I follow that开发者_如何学编程 advice, JSLint is happy, but Emacs' builtin js-mode.el (Emacs v23.2) does not indent the additional var
declarations the way I want. Also, it does not do the font-lock on the additional variables. See:
function stretchDiv(){
var wh = $(window).height(),
sz2 = wh - ((paddingTop + paddingBottom) + (mainTop + 2) * 2),
// the scrollbar happens only when the height of the elt is constrained
sz3 = sz2 - outTop - 2;
$('#out').css({'height': sz3 + 'px'});
}
How can I get the proper indentation and font-locking?
A forked version of js2-mode does exactly what you want.
精彩评论