开发者

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.

How to get js-mode to properly indent continued (compound?) var declarations?

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 to get js-mode to properly indent continued (compound?) var declarations?

How can I get the proper indentation and font-locking?


A forked version of js2-mode does exactly what you want.

How to get js-mode to properly indent continued (compound?) var declarations?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜