From dfb4ec804a099b539c91e5643090d8183885e71c Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Tue, 3 Dec 2013 12:55:38 +0000 Subject: Shell: expand 0-arity functions all the way to closing parenthesis `erl` has tab completion for modules' exported functions but expands only up to the opening paren. This commit closes that opening paren in case the function is of arity zero and there is no other function with the same name. It browses the lists of matches (a 2nd time) for Arity, on complete match and then decides what to append. --- lib/stdlib/src/edlin_expand.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/stdlib/src/edlin_expand.erl') diff --git a/lib/stdlib/src/edlin_expand.erl b/lib/stdlib/src/edlin_expand.erl index 516c0aa30b..0033010dce 100644 --- a/lib/stdlib/src/edlin_expand.erl +++ b/lib/stdlib/src/edlin_expand.erl @@ -89,7 +89,13 @@ match(Prefix, Alts, Extra) -> {yes, Remain, []} end; {complete, Str} -> - {yes, nthtail(Len, Str) ++ Extra, []}; + {_, Arity} = lists:keyfind(Str, 1, Matches), + case {Arity, Extra} of + {0, "("} -> + {yes, nthtail(Len, Str) ++ "()", []}; + _ -> + {yes, nthtail(Len, Str) ++ Extra, []} + end; no -> {no, [], []} end. -- cgit v1.2.3