From e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Tue, 26 Oct 1999 15:36:10 +0000 Subject: manual/8424 --- Completion/Core/_approximate | 25 ++----------------------- Completion/Core/_main_complete | 11 +++-------- Completion/Core/_normal | 6 +----- Completion/Core/_options | 3 ++- Completion/Core/_parameters | 8 +------- Completion/Core/_path_files | 32 +------------------------------- Completion/Core/compinit | 4 ++++ 7 files changed, 14 insertions(+), 75 deletions(-) (limited to 'Completion/Core') diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate index 57b327e64..235e324f7 100644 --- a/Completion/Core/_approximate +++ b/Completion/Core/_approximate @@ -70,22 +70,6 @@ compadd() { fi } -compgen() { - [[ "$*" != *-([a-zA-Z/]#|)U* && - "${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return - - if [[ "$PREFIX" = \~*/* ]]; then - PREFIX="${PREFIX%%/*}/(#a${_comp_correct})${PREFIX#*/}" - else - PREFIX="(#a${_comp_correct})$PREFIX" - fi - if [[ -n "$_correct_prompt" ]]; then - builtin compgen "$@" -X "$_correct_prompt" -J _correct - else - builtin compgen "$@" -J _correct - fi -} - # Now initialise our counter. We also set `compstate[matcher]' # to `-1'. This allows completion functions to use the simple # `[[ compstate[matcher] -gt 1 ]] && return' to avoid being @@ -99,11 +83,6 @@ compstate[matcher]=-1 _correct_prompt="${cfgps//\\%e/1}" -# We also need to set `extendedglob' and make the completion -# code behave as if globcomplete were set. - -setopt extendedglob - [[ -z "$compstate[pattern_match]" ]] && compstate[pattern_match]='*' while [[ _comp_correct -le comax ]]; do @@ -135,7 +114,7 @@ while [[ _comp_correct -le comax ]]; do compstate[force_list]=list fi compstate[matcher]="$compstate[total_matchers]" - unfunction compadd compgen + unfunction compadd return 0 fi @@ -147,6 +126,6 @@ while [[ _comp_correct -le comax ]]; do done compstate[matcher]="$compstate[total_matchers]" -unfunction compadd compgen +unfunction compadd return 1 diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index 304a97828..72233a59b 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -9,13 +9,8 @@ # # local _set_options _unset_options # -# if zmodload -e parameter; then -# _set_options=(${(k)options[(R)on]}) -# _unset_options=(${(k)options[(R)off]}) -# else -# _set_options=("${(@f)$({ unsetopt kshoptionprint; setopt } 2>/dev/null)}") -# _unset_options=("${(@f)$({ unsetopt kshoptionprint; unsetopt } 2>/dev/null)}") -# fi +# _set_options=(${(k)options[(R)on]}) +# _unset_options=(${(k)options[(R)off]}) # # This is needed because completion functions may set options locally # which makes the output of setopt and unsetopt reflect a different @@ -26,7 +21,7 @@ local comp post ret=1 _compskip typeset -U _lastdescr -setopt localoptions nullglob rcexpandparam +setopt localoptions nullglob rcexpandparam extendedglob unsetopt markdirs globsubst shwordsplit nounset ksharrays # Special completion contexts after `~' and `='. diff --git a/Completion/Core/_normal b/Completion/Core/_normal index 085c738d2..79efaeb97 100644 --- a/Completion/Core/_normal +++ b/Completion/Core/_normal @@ -27,11 +27,7 @@ elif [[ "$command" == */* ]]; then cmd2="${command:t}" else cmd1="$command" - if zmodload -e parameter; then - cmd2="$commands[$command]" - else - cmd2=$(whence -p - $command) - fi + cmd2="$commands[$command]" fi # See if there are any matching pattern completions. diff --git a/Completion/Core/_options b/Completion/Core/_options index 356cd70db..0232db857 100644 --- a/Completion/Core/_options +++ b/Completion/Core/_options @@ -5,4 +5,5 @@ local expl _description expl 'zsh option' -compgen "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -o +compadd "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - \ + "${(@k)options}" diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters index 34a8c3e9b..fdb786231 100644 --- a/Completion/Core/_parameters +++ b/Completion/Core/_parameters @@ -3,17 +3,11 @@ # This should be used to complete parameter names if you need some of the # extra options of compadd. It completes only non-local parameters. -setopt localoptions extendedglob - local pars expl _description expl parameter -if zmodload -e parameter; then - pars=( ${(k)parameters[(R)^*local*]} ) -else - pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } ) -fi +pars=( ${(k)parameters[(R)^*local*]} ) compadd "$expl[@]" "$@" - $pars diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 9d44180c8..cbec82c8a 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -10,7 +10,7 @@ local nm=$compstate[nmatches] menu match matcher typeset -U prepaths exppaths -setopt localoptions nullglob rcexpandparam extendedglob +setopt localoptions nullglob rcexpandparam unsetopt markdirs globsubst shwordsplit nounset local sopt='-' gopt='' opt @@ -110,36 +110,6 @@ orig="${PREFIX}${SUFFIX}" ( $#compstate[pattern_match] -ne 0 && "${orig#\~}" != "${${orig#\~}:q}" ) ]] && menu=yes -# We will first try normal completion called with `compgen', but only if we -# weren't given a `-F', `-r', or `-R' option or we are in the string. - -if [[ -z "$suf" && $#ignore -eq 0 && $#remsfx -eq 0 && - -z "$_comp_correct" ]]; then - # First build an array containing the `-W' option, if there is any and we - # want to use it. We don't want to use it if the string from the command line - # is a absolute path or relative to the current directory. - - if [[ -z "$prepaths[1]" || "$pre[1]" = [~/] || "$pre" = (.|..)/* ]]; then - tmp1=() - else - tmp1=(-W "( $prepaths )") - fi - - # Now call compgen. - - if [[ -z "$gopt" ]]; then - compgen "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \ - "$tmp1[@]" "$matcher[@]" $sopt - else - compgen "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \ - "$tmp1[@]" "$matcher[@]" $sopt -g "$pats" - fi - - # If this generated any matches, we don't want to do in-path completion. - - [[ compstate[nmatches] -eq nm ]] || return 0 -fi - # If given no `-F' option, we want to use `fignore'. (( $#ignore )) || ignore=(-F fignore) diff --git a/Completion/Core/compinit b/Completion/Core/compinit index ca9240f92..b3472ca0e 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -78,6 +78,10 @@ while [[ $# -gt 0 && $1 = -[dDf] ]]; do fi done +# We need the parameter modules. + +zmodload -i parameter zleparameter + # The associative array containing the definitions for the commands. # Definitions for patterns will be stored in the normal arrays `_patcomps' # and `_postpatcomps'. -- cgit 1.4.1