Skip to content

Indenting differences compared to erlang-mode #32

@ghost

Description

Since vim-erlang is designed to follow erlang-mode indenting style (see #31 (comment)), I did a quick test of some of the rebar code.

rebar_port_compiler:os_env/0:

erlang.el:

os_env() ->
    ReOpts = [{return, list}, {parts, 2}, unicode],
    Os = [list_to_tuple(re:split(S, "=", ReOpts)) ||
             S <- lists:filter(fun discard_deps_vars/1, os:getenv())],
    %% Drop variables without a name (win32)
    [T1 || {K, _V} = T1 <- Os, K =/= []].

vim-erlang:

os_env() ->
    ReOpts = [{return, list}, {parts, 2}, unicode],
    Os = [list_to_tuple(re:split(S, "=", ReOpts)) ||
          S <- lists:filter(fun discard_deps_vars/1, os:getenv())],
    %% Drop variables without a name (win32)
    [T1 || {K, _V} = T1 <- Os, K =/= []].

diff after vim-erlang indent:

diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 906bcb0..b8c50c6 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -524,7 +524,7 @@ erts_dir() ->
 os_env() ->
     ReOpts = [{return, list}, {parts, 2}, unicode],
     Os = [list_to_tuple(re:split(S, "=", ReOpts)) ||
-             S <- lists:filter(fun discard_deps_vars/1, os:getenv())],
+          S <- lists:filter(fun discard_deps_vars/1, os:getenv())],
     %% Drop variables without a name (win32)
     [T1 || {K, _V} = T1 <- Os, K =/= []].

rebar:set_log_level/3:

erlang.el:

set_log_level(Config, Options) ->
    {IsVerbose, Level} =
        case proplists:get_bool(quiet, Options) of
            true ->
                {false, rebar_log:error_level()};
            false ->
                DefaultLevel = rebar_log:default_level(),
                case proplists:get_all_values(verbose, Options) of
                    [] ->
                        {false, DefaultLevel};
                    Verbosities ->
                        {true, DefaultLevel + lists:last(Verbosities)}
                end
        end,

    case IsVerbose of
        true ->
            Config1 = rebar_config:set_xconf(Config, is_verbose, true),
            rebar_config:set_global(Config1, verbose, Level);
        false ->
            rebar_config:set_global(Config, verbose, Level)
    end.

vim-erlang:

set_log_level(Config, Options) ->
    {IsVerbose, Level} =
    case proplists:get_bool(quiet, Options) of
        true ->
            {false, rebar_log:error_level()};
        false ->
            DefaultLevel = rebar_log:default_level(),
            case proplists:get_all_values(verbose, Options) of
                [] ->
                    {false, DefaultLevel};
                Verbosities ->
                    {true, DefaultLevel + lists:last(Verbosities)}
            end
    end,

    case IsVerbose of
        true ->
            Config1 = rebar_config:set_xconf(Config, is_verbose, true),
            rebar_config:set_global(Config1, verbose, Level);
        false ->
            rebar_config:set_global(Config, verbose, Level)
    end.

diff after vim-erlang indent:

diff --git a/src/rebar.erl b/src/rebar.erl
index 2fceb19..86588cc 100644
--- a/src/rebar.erl
+++ b/src/rebar.erl
@@ -341,18 +341,18 @@ save_options(Config, {Options, NonOptArgs}) ->
 %%
 set_log_level(Config, Options) ->
     {IsVerbose, Level} =
-        case proplists:get_bool(quiet, Options) of
-            true ->
-                {false, rebar_log:error_level()};
-            false ->
-                DefaultLevel = rebar_log:default_level(),
-                case proplists:get_all_values(verbose, Options) of
-                    [] ->
-                        {false, DefaultLevel};
-                    Verbosities ->
-                        {true, DefaultLevel + lists:last(Verbosities)}
-                end
-        end,
+    case proplists:get_bool(quiet, Options) of
+        true ->
+            {false, rebar_log:error_level()};
+        false ->
+            DefaultLevel = rebar_log:default_level(),
+            case proplists:get_all_values(verbose, Options) of
+                [] ->
+                    {false, DefaultLevel};
+                Verbosities ->
+                    {true, DefaultLevel + lists:last(Verbosities)}
+            end
+    end,

     case IsVerbose of
         true ->

rebar:is_command*:

erlang.el:

is_command_name_candidate(Command, Candidate) ->
    lists:prefix(Command, Candidate)
        orelse is_command_name_sub_word_candidate(Command, Candidate).

is_command_name_sub_word_candidate(Command, Candidate) ->
    %% Allow for parts of commands to be abbreviated, i.e. create-app
    %% can be shortened to "create-a", "c-a" or "c-app" (but not
    %% "create-" since that would be ambiguous).
    ReOpts = [{return, list}],
    CommandSubWords = re:split(Command, "-", ReOpts),
    CandidateSubWords = re:split(Candidate, "-", ReOpts),
    is_command_name_sub_word_candidate_aux(CommandSubWords, CandidateSubWords).

is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs],
                                       [CandSW | CandSWs]) ->
    lists:prefix(CmdSW, CandSW) andalso
        is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs);
is_command_name_sub_word_candidate_aux([], []) ->
    true;
is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) ->
    false.

vim-erlang:

is_command_name_candidate(Command, Candidate) ->
    lists:prefix(Command, Candidate)
    orelse is_command_name_sub_word_candidate(Command, Candidate).

is_command_name_sub_word_candidate(Command, Candidate) ->
    %% Allow for parts of commands to be abbreviated, i.e. create-app
    %% can be shortened to "create-a", "c-a" or "c-app" (but not
    %% "create-" since that would be ambiguous).
    ReOpts = [{return, list}],
    CommandSubWords = re:split(Command, "-", ReOpts),
    CandidateSubWords = re:split(Candidate, "-", ReOpts),
    is_command_name_sub_word_candidate_aux(CommandSubWords, CandidateSubWords).

is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs],
                                       [CandSW | CandSWs]) ->
    lists:prefix(CmdSW, CandSW) andalso
    is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs);
is_command_name_sub_word_candidate_aux([], []) ->
    true;
is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) ->
    false.

diff after vim-erlang indent:

diff --git a/src/rebar.erl b/src/rebar.erl
index 86588cc..905902f 100644
--- a/src/rebar.erl
+++ b/src/rebar.erl
@@ -610,7 +610,7 @@ get_command_name_candidates(Command) ->

 is_command_name_candidate(Command, Candidate) ->
     lists:prefix(Command, Candidate)
-        orelse is_command_name_sub_word_candidate(Command, Candidate).
+    orelse is_command_name_sub_word_candidate(Command, Candidate).

 is_command_name_sub_word_candidate(Command, Candidate) ->
     %% Allow for parts of commands to be abbreviated, i.e. create-app
@@ -624,7 +624,7 @@ is_command_name_sub_word_candidate(Command, Candidate) ->
 is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs],
                                        [CandSW | CandSWs]) ->
     lists:prefix(CmdSW, CandSW) andalso
-        is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs);
+    is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs);
 is_command_name_sub_word_candidate_aux([], []) ->
     true;
 is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) ->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions