0

I'm working within a small team writing Erlang. I'm the only developer using Emacs. The Erlang code the rest of the team outputs is indented using multiples of 4 spaces. For example:

store_data_somewhere(Data) ->
    StandardProplist = fun(Arg1, Arg2) ->
        Parameters = [
            {param1, Arg1},
            {param2, Arg2}
            ],
        {ok, Parameters}
    end,
    PreparedStatement = storage:prepare(
        Data,
        StandardProplist
        ),
    db:transaction(PreparedStatement).

Currently erlang-mode would format as follows:

store_data_somewhere(Data) ->
    StandardProplist = fun(Arg1, Arg2) ->
                               Parameters = [
                                             {param1, Arg1},
                                             {param2, Arg2}
                                            ],
                               {ok, Parameters}
                       end,
    PreparedStatement = storage:prepare(
                          Data,
                          StandardProplist
                         ),
    db:transaction(PreparedStatement).

Is there any way I can coerce my emacs so that it follows the same rules as my colleagues' editors and conforms to the company style-guide?

Phill Oldham
  • 227
  • 1
  • 9
  • Unfortunately, the Erlang mode doesn't support too much customisation. Interestingly, Emacs indentation is considered the "standard one" in many projects. It sounds silly and doesn't answer the question, but maybe it would be better to convince the rest of the team to adhere to standards. – tkowal Mar 28 '19 at 08:04
  • It looks like you are using 4 spaces, but not for everything. `erlang-mode` has more than one setting controlling indentation. Take a look at the (customize) variables defined [here](https://github.com/erlang/otp/blob/2367dc1397063f78cc49eafa8e95e7e3493979d1/lib/tools/emacs/erlang.el#L470) and make sure they're set according to your needs. If `erlang-mode` can't indent how you like, you might want to look into using an external linter and hooking that in to your file save command for Erlang files. – nega Mar 28 '19 at 19:51

0 Answers0