Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the proper way of indenting Erlang?
    text
    copied!<p>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</p> <pre><code>handle_info(get_gss_latest_versions, State) -&gt; GetReqIds = fun(Branch) -&gt; GetInfoUri = State#state.gss_uri ++ Branch ++ "/api/getinfo", case ibrowse:send_req(GetInfoUri, [], get, [], [{stream_to, self()}]) of {ibrowse_req_id, ReqId} -&gt; {ReqId, Branch}; {error, Reason} -&gt; </code></pre> <p>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). </p> <p>I had a look at several prominent erlang softwares (like gproc) and most of them seem to use spaces-only indentation mode.</p> <p>So my questions are:</p> <ol> <li>Am I doing it wrong (seems likely to me).</li> <li>If spaces-only is the predominant indentation way, why is erlang-mode not implementing it (or not configured to using it by default)?</li> <li>How can I configure erlang-mode to force spaces-only?</li> <li>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.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload