Indenting differences compared to erlang-mode
Opened this issue · 4 comments
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) ->Thanks for the testing. Yeah, this all falls into the "expressions like this" category that I mentioned in my comment you refer to. To be more precise, these are expressions with infix operators (=, orelse, andalso, ||) that are broken into multiple lines without extra parentheses.
Closing due to inactivity.
if you close your eyes, it won't solve the problem. Please consider adjusting the indent, second case is really frequent and annoying in wild life.