diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2001-04-02 11:08:54 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2001-04-02 11:08:54 +0000 |
commit | a067f38ad1ef32fd1e3daa1ea6afe7dfdf6621ad (patch) | |
tree | b7c8fb944f9fefc1ee3e09f1ce431d2666383da3 | |
parent | 8f6cfb83af3a6aac0203637f27ac407a1cf8d827 (diff) | |
download | zsh-a067f38ad1ef32fd1e3daa1ea6afe7dfdf6621ad.tar.gz zsh-a067f38ad1ef32fd1e3daa1ea6afe7dfdf6621ad.tar.xz zsh-a067f38ad1ef32fd1e3daa1ea6afe7dfdf6621ad.zip |
moved from Completion/Core/_prefix
-rw-r--r-- | Completion/Base/Completer/_prefix | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Completion/Base/Completer/_prefix b/Completion/Base/Completer/_prefix new file mode 100644 index 000000000..86fad12dc --- /dev/null +++ b/Completion/Base/Completer/_prefix @@ -0,0 +1,53 @@ +#autoload + +# Try to ignore the suffix. A bit like e-o-c-prefix. + +[[ _matcher_num -gt 1 || -z "$SUFFIX" ]] && return 1 + +local comp curcontext="$curcontext" tmp \ + _completer _completer_num \ + _matcher _c_matcher _matchers _matcher_num + +zstyle -a ":completion:${curcontext}:" completer comp || + comp=( "${(@)_completers[1,_completer_num-1][(R)_prefix(|:*),-1]}" ) + +if zstyle -t ":completion:${curcontext}:" add-space; then + ISUFFIX=" $SUFFIX" +else + ISUFFIX="$SUFFIX" +fi +SUFFIX='' + +_completer_num=1 + +for tmp in "$comp[@]"; do + if [[ "$tmp" = *:-* ]]; then + _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}" + tmp="${tmp%:*}" + elif [[ $tmp = *:* ]]; then + _completer="${tmp#*:}" + tmp="${tmp%:*}" + else + _completer="${tmp[2,-1]//_/-}" + fi + curcontext="${curcontext/:[^:]#:/:${_completer}:}" + + zstyle -a ":completion:${curcontext}:" matcher-list _matchers || + _matchers=( '' ) + + _matcher_num=1 + _matcher='' + for _c_matcher in "$_matchers[@]"; do + if [[ "$_c_matcher" == +* ]]; then + _matcher="$_matcher $_c_matcher[2,-1]" + else + _matcher="$_c_matcher" + fi + + [[ "$tmp" != _prefix ]] && "$tmp" && return 0 + (( _matcher_num++ )) + done + (( _completer_num++ )) +done + +return 1 |