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

funs are formatted incorrectly #1044

Open
brigadier opened this issue Sep 12, 2024 · 3 comments
Open

funs are formatted incorrectly #1044

brigadier opened this issue Sep 12, 2024 · 3 comments

Comments

@brigadier
Copy link

this is how they are formatted now:

1

This is how I think is the correct way to format a fun:

2

btw, the rest of operators are formatted correctly :

3
@ignatov
Copy link
Owner

ignatov commented Sep 29, 2024

Hi!

Am I right that you're trying to do the following

foo() ->
  fun(A, B) ->
    lists:seq(1, 2)
  end,
ok.

@kvakvs
Copy link
Collaborator

kvakvs commented Sep 29, 2024

@ignatov as usually a standalone fun expression makes no sense, you usually have them in an assignment or a function call. So the fun will not begin at the start of the line, like so:

foo() ->
  X = fun(A, B) ->
    lists:seq(1, 2)
  end.
% or
bar() ->
  quux(fun(X) -> 
    hello 
  end).

And this would do wrong indents. Acceptable indentation would be either: a) single indent from the expression start, and then closing end lined up with the expression start. Or b) use fun as starting column offset, line end up to it (i think this is the current behaviour), and line up function contents between them indented (this is not happening now, at least not consistent with the end)

@brigadier
Copy link
Author

brigadier commented Sep 30, 2024

Hi!

Am I right that you're trying to do the following

As kvakvs said above funs are usually used in assignments, as parameters of function calls and very rarely standalone (only when you mean to return the fun as the result), so I think funs should be treated (and they are!) just like any other block construction such as case, if and begin - their content should be aligned relative to their opening word. Funs are not a special case, they are really the same as if, case etc

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

3 participants