aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/edlin_expand.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-01-20 07:12:57 +0000
committerErlang/OTP <[email protected]>2010-01-20 07:12:57 +0000
commitfcff652f0fc9d19157e6f72f2c864533bf0c0d28 (patch)
treef667a33ba496f9d3220a21a86934b5d8a827f96d /lib/stdlib/src/edlin_expand.erl
parent9bf84f381797df7411335fed11ee83886b09514f (diff)
parent1c3a6c89c4f8d25dc0a3f71f4967ad80729cdbfe (diff)
downloadotp-fcff652f0fc9d19157e6f72f2c864533bf0c0d28.tar.gz
otp-fcff652f0fc9d19157e6f72f2c864533bf0c0d28.tar.bz2
otp-fcff652f0fc9d19157e6f72f2c864533bf0c0d28.zip
Merge branch 'uw/shell-tab-completion' into ccase/r13b04_dev
* uw/shell-tab-completion: Shell tab completion now works for quoted module and function names OTP-8383 Shell tab completion now works for quoted module and function names. (Thanks to Ulf Wiger.)
Diffstat (limited to 'lib/stdlib/src/edlin_expand.erl')
-rw-r--r--lib/stdlib/src/edlin_expand.erl49
1 files changed, 32 insertions, 17 deletions
diff --git a/lib/stdlib/src/edlin_expand.erl b/lib/stdlib/src/edlin_expand.erl
index 7ed76a6b09..516c0aa30b 100644
--- a/lib/stdlib/src/edlin_expand.erl
+++ b/lib/stdlib/src/edlin_expand.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2005-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2005-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(edlin_expand).
@@ -46,23 +46,38 @@ expand_module_name(Prefix) ->
match(Prefix, code:all_loaded(), ":").
expand_function_name(ModStr, FuncPrefix) ->
- Mod = list_to_atom(ModStr),
- case erlang:module_loaded(Mod) of
- true ->
- L = Mod:module_info(),
- case lists:keyfind(exports, 1, L) of
- {_, Exports} ->
- match(FuncPrefix, Exports, "(");
- _ ->
- {no, [], []}
- end;
- false ->
+ case to_atom(ModStr) of
+ {ok, Mod} ->
+ case erlang:module_loaded(Mod) of
+ true ->
+ L = Mod:module_info(),
+ case lists:keyfind(exports, 1, L) of
+ {_, Exports} ->
+ match(FuncPrefix, Exports, "(");
+ _ ->
+ {no, [], []}
+ end;
+ false ->
+ {no, [], []}
+ end;
+ error ->
{no, [], []}
end.
+%% if it's a quoted atom, atom_to_list/1 will do the wrong thing.
+to_atom(Str) ->
+ case erl_scan:string(Str) of
+ {ok, [{atom,_,A}], _} ->
+ {ok, A};
+ _ ->
+ error
+ end.
+
match(Prefix, Alts, Extra) ->
Len = length(Prefix),
- Matches = [{S, A} || {H, A} <- Alts, prefix(Prefix, S=atom_to_list(H))],
+ Matches = lists:sort(
+ [{S, A} || {H, A} <- Alts,
+ prefix(Prefix, S=hd(io_lib:fwrite("~w",[H])))]),
case longest_common_head([N || {N, _} <- Matches]) of
{partial, []} ->
{no, [], Matches}; % format_matches(Matches)};