Closed dmitriid closed 11 years ago
erlang-mode for Emacs (part of Erlang distribution) have already support for it (will be published with next Erlang release)
https://github.com/erlang/otp/commit/8bfff9e0f80868ad7edc08dfda6c51a2b00966e6
@dmitriid +1 from my side to this feature request.
@dmitriid @andrzejsliwa I've just pushed an experimental formatter with comma first setting, please see my gist.
Also Erlang.comma.first.zip is available for installation.
@ignatov Awesome! Will try it as soon as I can!
@ignatov I check your gist, and its looks like there is problem: only lists should be formatted this way, not a tuples... formating should be also repeatable only if there is already comma in previous line, this means if somebody already format something as one line, this should not change in reformat, this should respect existing format (please look on @dmitriid algorithm). I will check tomorrow how this is working exactly in emacs case and I will review @dmitriid aglorithm.
@dmitriid @andrzejsliwa Please try the 325 build. How it works you can see in https://github.com/ignatov/intellij-erlang/commit/28624020e2052c9396325262b135ab5eb82e5f75#diff-3 and https://github.com/ignatov/intellij-erlang/commit/28624020e2052c9396325262b135ab5eb82e5f75#diff-2.
@ignatov: I check 325... but is not working for me, are you sure that this is part of 325?
before:
test() ->
Bar = [X || X <- [ 1
, 2
, a
, 3
, 4
, b
, 5
, 6], is_integer(X), X > 3].
after:
test() ->
Bar = [X || X <- [1, 2, a, 3, 4, b, 5, 6], is_integer(X), X > 3].
@andrzejsliwa Code style > Wrapping and braces > Comma first style is on?
@ignatov ok :) now formatting seems to working, but what about proper indenting in writing time?
actual:
test() ->
Bar = [X || X <- [ 1 [Enter]
, 1
expected:
test() ->
Bar = [X || X <- [ 1 [Enter]
, 1
@andrzejsliwa Alignment > Blocks also should be checked in.
@ignatov I have everything checked in.
@andrzejsliwa Got it, it's another issues about auto indentation.
@ignatov working ok. thx
Quite a few projects (or at least me :) use comma-first style. See, for example, http://www.scribd.com/doc/101504510/Erlang-Programming-Style-Guide. Currently, IDEA and Erlang plugin don't support it.
See related http://youtrack.jetbrains.com/issue/IDEA-112365
The fix for comma-first in Erlang could be:
Sorry I have no pull request for this :(