Skip to content

Instantly share code, notes, and snippets.

@dszoboszlay
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dszoboszlay/bf60b674dadc49c7d999 to your computer and use it in GitHub Desktop.
Save dszoboszlay/bf60b674dadc49c7d999 to your computer and use it in GitHub Desktop.
Erlang indentation issues with try blocks and comma-first coding style
%%% -*- mode: erlang; erlang-indent-level: 2 -*-
-module(foo).
-compile([export_all]).
-record(comma_first, { x
, y :: integer() % good indentation
, z % bad indentation (caused by type spec)
}).
try_blocks() ->
try ok,
ok % bad indentation
after
ok
end,
try ok of
X -> X % bad indentation: erlang-indent-level is 2!
after
ok
end,
try ok of
Y -> % bad indentation
Y % looks terrible
after
ok
end.
list_comprehensions() ->
[ok
|| X <- [ 1
, 2
, 3] % comma-first indentation works here
, X > 2 % but not here
].
@jamesaimonetti
Copy link

I'd also add comma first lists of binaries. The element following a binary is indented 4 spaces in Emacs for me.

after_binaries() ->
    [<<"foo">>
         ,bar
     ,baz
    ].

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