From 35b2633ad941966f5fca07b625a594a5b68c0fdb Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 15 Nov 1999 12:01:46 +0000 Subject: manual/8639 --- Completion/Core/_complete | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'Completion/Core/_complete') diff --git a/Completion/Core/_complete b/Completion/Core/_complete index f351c7349..235265326 100644 --- a/Completion/Core/_complete +++ b/Completion/Core/_complete @@ -2,16 +2,21 @@ # Generate all possible completions. Note that this is not intended as # a normal completion function, but as one possible value for the -# compconfig[completer] parameter. +# completer style. -local comp name _tag_context="$_tag_context" +local comp name curcontext="$curcontext" oldcontext -[[ "$compstate[context]" != command || CURRENT -eq 1 ]] && - _tag_context="-${compstate[context]:s/_/-/}-" +# Probably set initial context. + +[[ -z "$curcontext" ]] && curcontext=':complete' + +oldcontext="$curcontext" # If we have a user-supplied context name, use only that. if [[ -n "$compcontext" ]]; then + curcontext="${curcontext}:$compcontext" + comp="$_comps[$compcontext]" [[ -z "$comp" ]] || "$comp" @@ -22,6 +27,7 @@ fi comp="$_comps[-first-]" if [[ ! -z "$comp" ]]; then + curcontext="${curcontext}:-first-" "$comp" if [[ "$_compskip" = all ]]; then _compskip='' @@ -34,12 +40,17 @@ fi # For arguments and command names we use the `_normal' function. if [[ "$compstate[context]" = command ]]; then + curcontext="$oldcontext" _normal -s else # Let's see if we have a special completion definition for the other # possible contexts. - comp="$_comps[$_tag_context]" + local cname="-${compstate[context]:s/_/-/}-" + + curcontext="${oldcontext}:$cname" + + comp="$_comps[$cname]" # If not, we use default completion, if any. -- cgit 1.4.1