Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation expectation on existing code #93

Open
PierreR opened this issue Jan 16, 2015 · 4 comments
Open

Indentation expectation on existing code #93

PierreR opened this issue Jan 16, 2015 · 4 comments

Comments

@PierreR
Copy link

PierreR commented Jan 16, 2015

I have some existing code formated as such:

        buildDir </> "lint.fail" %> \out -> do
            alwaysRerun
            pps <- getDirectoryFiles "modules" ["//*.pp"]
            let rs = [buildDir </> pp -<.> "txt" | pp <- pps, not $ isBlackLintModule pp]
            need rs

If I place the cursor after the o of do, I am not able to go above the a of alwaysReturn. By default it goes below the u of out.

I am using haskell-simple-indent and try to switch to hi2 but without success.

Is there a way to get the behavior I expect ?

Thanks for your help.

@chrisdone
Copy link
Member

The reason it does that is because it's indenting to the lambda's start column + the \ + haskell-indent-spaces which I presume is set to 2 on your setup right now. Indentation is always the parent's start column + something by default.

Try setting shm-lambda-indent-style to leftmost-parent. That'll make it go to the column of the outermost parent that starts on the same line as the lambda, and then it will add haskell-indent-spaces.

@chrisdone
Copy link
Member

I just noticed in let declarations this goes too far up, pushed a change that stops at declarations. I recommend pulling it.

@PierreR
Copy link
Author

PierreR commented Jan 16, 2015

Thanks !

There is still a case where it does not seem to work right:

main = do
  shakeArgsWith shakeOptions{shakeFiles=buildDir} extraflags $ \flags targets -> return $ Just $ do
    if ...

So here it insist to go below the r of return instead of above the i of if.

@PierreR
Copy link
Author

PierreR commented Jan 16, 2015

As another example I have a hard time to find a way to write the following with structured-haskell-mode enabled :

pyth_cps x y = \k ->
    square_cps x $ \x_square ->
    square_cps y $ \y_square ->
    add_cps x_square y_square k

The behavior is actually quite erratic.

After \x_square -> it goes correctly below s. Unfortunately when I reach \y_square -> it insists on going below y. Then again as I said, trying it multiple times it seems impredictable (which is the worse experience ever identation wise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants