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?

  • 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 at 8: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 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 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.