Skip to content

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

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

Open
jwiegley opened this issue Sep 5, 2012 · 7 comments
Open

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

jwiegley opened this issue Sep 5, 2012 · 7 comments

Comments

@jwiegley
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

jwiegley commented Sep 7, 2012

Isn't haskell-indent really old?

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

return $ foo
<1>
       <2>
         <3>

@jwiegley
Copy link
Contributor Author

jwiegley commented Sep 7, 2012

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

@chrisdone
Copy link
Member

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

@hvr
Copy link
Member

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
Copy link
Contributor

gracjan commented Dec 5, 2015

Any progress here?

@geraldus
Copy link
Contributor

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
    baz
    quux
foo
  bar baz quux
foo
  bar
  baz
  quux

bur other people may prefer different ways.

And in this case likely we have exact one indentation step

-- (5)
return $
   1

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

-- (6)
return
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
Projects
None yet
Development

No branches or pull requests

6 participants