When curly braces ({, }) are embedded inside multiline strings, Emacs erlang-mode will indent the multiline string's contents as if it were Erlang code. No modifications should be done to the insides of the multiline string.
Example code before (erlang-indent-current-buffer):
{code:erlang}
-module(teletype_new_account).
-export([a/0
]).
-define(TEMPLATE_TEXT, <<"
{% if A %}
A
{% endif %}
{% if B %}
B
{% endif %}
C
">>).
a() ->
?TEMPLATE_TEXT.
{code}
Same code after (erlang-indent-current-buffer):
{code:erlang}
-module(teletype_new_account).
-export([a/0
]).
-define(TEMPLATE_TEXT, <<"
{% if A %}
A
{% endif %}
{% if B %}
B
{% endif %}
C
">>).
a() ->
?TEMPLATE_TEXT.
{code}
Note the braced clauses indented inside the multiline string.
Note how a/0's clause is also wrongly indented.
Workaround: split the multiline string into multiple one-line strings, the compiler will concatenate them.
Minified test cases: https://github.com/fenollp/erlang-formatter/pull/4/files
Formatting code used: https://github.com/fenollp/erlang-formatter/blob/master/fmt.el
Original reporter:
fenollp
Affected version:OTP-19.0.2
Component:tools
Migrated from: https://bugs.erlang.org/browse/ERL-210