Support indentation to continue a function's argument list #82

jwiegley opened this Issue Sep 5, 2012 · 7 comments


None yet

6 participants

jwiegley commented Sep 5, 2012

When I hit Tab with the cursor at <> below:

return foo

I'd like the cursor to go here:

return foo

And if a $ was present, then:

return $ foo

I tried making the change myself in haskell-indentation.el, but I couldn't understand how the parser works. If you can tell me where to look, I'd be happy to try.

ivan-m commented Sep 7, 2012

Have you tried using haskell-indent instead of -indentation?

I presume your reasoning is for if you want to provide arguments to whatever `foo' is; as such, wouldn't it actually be better for it to be indented more?

jwiegley commented Sep 7, 2012

Isn't haskell-indent really old?

In the return $ foo case, the cursor positions should be:

return $ foo
jwiegley commented Sep 7, 2012

Oh, and a <4> that's one space after "foo", of course, but only if foo had arguments.


It seems that nobody wants to own this issue. Looks like it's not gonna be fixed. Will close in one month.

@jwiegley jwiegley closed this May 20, 2013
hvr commented Jun 29, 2013

I'm reopening this as it's a valid request imho and I have some hope this will be be implemented sooner or later (maybe I'll do it myself when I get to fix other haskell-indentation issues)

@hvr hvr reopened this Jun 29, 2013
@gracjan gracjan removed the blocked label Mar 25, 2015
@gracjan gracjan removed this from the milestone Oct 16, 2015
gracjan commented Dec 5, 2015

Any progress here?


This is still relevant and I'm often annoyed of this. If I'm not mistaken, currently is't hard to understand is function supplied with all arguments or not, so in first case indentation order should be

-- (1)
return foo
1   ?  2

? is optional indentation step according to tab width (offset) value (I'm not familiar with indentation code yet, is it possible to jump to 2 second position after first TAB and include optional position in indentation positions list for further cycles?).

Same here:

-- (2)
return $ foo
1   ?    2

Two following cases a bit complicated

-- (3)
return $ foo bar
1   ?        2

I have no strong opinion what indentation steps should be here:

-- (4)
return $ foo bar baz
_   ?    ?   ?   ?

Personally, I put arguments either on single line or one per line:

foo bar baz quux
foo bar
  bar baz quux

bur other people may prefer different ways.

And in this case likely we have exact one indentation step

-- (5)
return $

Finally, here 2 second step is based on tab width (offset).

-- (6)
1    2

Implementing first two cases seems to be pretty simple:

  • assert that point is on blank line
  • on first TAB find last word on previous line, set second indentation step at same column where it starts
  • on third TAB go back to beginning of the line (this is uncovered in all examples, I suppose we should always provide line beginning step assuming top-level definitions)
  • for further cycles include all optional steps

In case (5) indentation should be at position 1 by default.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment