Till yesterday, I was a happy user of out-of-the-box emacs + erlang-mode. Then my colleague started contributing to the project (using some windows editor), and it seems he is not very happy with the mixed indent mode used by default by erlang-mode. Here is an example. This a part of a function, written using auto-indent on erlang-mode
handle_info(get_gss_latest_versions, State) ->
GetReqIds = fun(Branch) ->
GetInfoUri = State#state.gss_uri ++ Branch ++ "/api/getinfo",
case ibrowse:send_req(GetInfoUri, [], get, [], [{stream_to, self()}]) of
{ibrowse_req_id, ReqId} ->
{ReqId, Branch};
{error, Reason} ->
If you take a closer look, you'll see that line 2 (starting with GetReqIds) is indented with 4 spaces. Line 3 is indented with 3 tabs. Line 5 is indented with 3 tabs + 4 spaces. Line 6 is indented with 4 tabs. As a result, most (dumb) editors (unlike emacs) display lines 5 and 6 (the ones starting with {ibrowse and {ReqId) at the same indentation level. Which looks ugly. (even stackoverflow shows them that way).
I had a look at several prominent erlang softwares (like gproc) and most of them seem to use spaces-only indentation mode.
So my questions are:
- Am I doing it wrong (seems likely to me).
- If spaces-only is the predominant indentation way, why is erlang-mode not implementing it (or not configured to using it by default)?
- How can I configure erlang-mode to force spaces-only?
- What's the "right way" after all? Things like cross-editor compatibility seem to matter, and we can't make all editors as smart as emacs.