emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
622 stars 162 forks source link

indentation of conditional function definition #337

Open mmaechler opened 8 years ago

mmaechler commented 8 years ago

What I'd want is that the outermost else aligns with its corresponding if .. but it is indented less. This is even more the case if we wrap the two lines tfun <- \\ if(is.function....) into a single line.

## from a robustbase vignette:
{
    ## calculate robustness weights
    lwgts <- Mwgt(lresid, lctrl$tuning.psi, lctrl$psi)
    ## function to calculate robustified leverages
    tfun <-
        if (is.function(attr(estlist$design, 'gen')))
            function(i) {
                if (all(is.na(wi <- lwgts[i,]))) wi
                else .lmrob.hat(lXs[,,i,lcdn[2]],wi)
            }
    else
        function(i) {
            if (all(is.na(wi <- lwgts[i,]))) wi else .lmrob.hat(lX, wi)
        }
}
wmay commented 8 years ago

Does that even run? I can't use else statements on new lines without wrapping the if block in curly brackets. It indents fine for me with the brackets added.

lionel- commented 8 years ago

I'll hopefully fix these issues once and for all when the new parser stuff is finished. I'll try to find some time to work on it before I hand in my thesis, it's long overdue.

vspinu commented 8 years ago

Yes. No hurry. It's a corner case with easy workaround anyways. I just decided to try "assignee" feature on github ;)