From d139ae56432a82a3dbe11f4be89ba7d886f2c177 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 22 Sep 1999 12:35:20 +0000 Subject: zsh-3.1.6-pws-5 --- Completion/Base/.distfiles | 7 ++--- Completion/Builtins/.distfiles | 4 +-- Completion/Builtins/_compdef | 22 +++++++++++++++ Completion/Core/_multi_parts | 62 ++++++++++++++++++++++++++++-------------- Completion/Core/_path_files | 35 ++++++++++++++++++------ Completion/Core/_sep_parts | 6 +++- Completion/Linux/_rpm | 4 +-- Completion/User/.distfiles | 13 +++++---- Completion/User/_dirs | 3 ++ Completion/User/_hosts | 3 -- Completion/User/_mailboxes | 7 ++--- Completion/User/_man | 6 ++-- Completion/X/.distfiles | 7 +++-- 13 files changed, 121 insertions(+), 58 deletions(-) create mode 100644 Completion/Builtins/_compdef create mode 100644 Completion/User/_dirs (limited to 'Completion') diff --git a/Completion/Base/.distfiles b/Completion/Base/.distfiles index 1c2c49fa2..14bab9676 100644 --- a/Completion/Base/.distfiles +++ b/Completion/Base/.distfiles @@ -1,7 +1,6 @@ DISTFILES_SRC=' .distfiles - _arguments _brace_parameter _command_names - _condition _default _equal _first - _math _parameter _precommand _redirect _regex_arguments _subscript - _tilde _values _vars + _arg_compile _arguments _brace_parameter _command_names _condition + _default _describe _equal _first _math _parameter _precommand _redirect + _regex_arguments _subscript _tilde _values _vars ' diff --git a/Completion/Builtins/.distfiles b/Completion/Builtins/.distfiles index e0d0f3e99..633dc2d01 100644 --- a/Completion/Builtins/.distfiles +++ b/Completion/Builtins/.distfiles @@ -1,7 +1,7 @@ DISTFILES_SRC=' .distfiles _aliases _arrays _autoload _bg_jobs _bindkey _builtin _cd _command - _dirs _disable _echotc _enable _fc _functions _hash _jobs _kill + _compdef _disable _echotc _enable _fc _functions _hash _jobs _kill _limits _sched _set _setopt _source _stat _trap _unhash _unsetopt - _vars_eq _wait _which _zftp _zle _zmodload + _vars_eq _wait _which _zftp _zle _zmodload ' diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef new file mode 100644 index 000000000..1df5758b3 --- /dev/null +++ b/Completion/Builtins/_compdef @@ -0,0 +1,22 @@ +#compdef compdef + +local func base=2 + +while [[ $words[base] = -* ]]; do + case $words[base] in + -d) delete=yes ;; + -p) type=pattern ;; + -k) type=key ;; + esac + (( base++ )) +done + +if [ "$delete" ]; then + compadd ${(k)_comps} +else + if [[ CURRENT -eq base ]]; then + for func in ${^~fpath:/.}/_(|*[^~])(N:t); compadd -P_ - ${func#_} + else + compgen -c + fi +fi diff --git a/Completion/Core/_multi_parts b/Completion/Core/_multi_parts index d51130391..30a68d312 100644 --- a/Completion/Core/_multi_parts +++ b/Completion/Core/_multi_parts @@ -7,7 +7,7 @@ # The parts of words from the array that are separated by the # separator character are then completed independently. -local sep matches pref npref i tmp1 group expl menu pre suf +local sep matches pref npref i tmp1 group expl menu pre suf opre osuf cpre typeset -U tmp2 # Get the options. @@ -40,6 +40,8 @@ fi pre="$PREFIX" suf="$SUFFIX" +opre="$PREFIX" +osuf="$SUFFIX" orig="$PREFIX$SUFFIX" # Special handling for menucompletion? @@ -100,14 +102,17 @@ while true; do matches=( "${(@M)matches:#${tmp1[1]}*}" ) tmp2=( "${(@M)matches:#${tmp1[1]}${sep}*}" ) + PREFIX="${cpre}${pre}" + SUFFIX="$suf" + if (( $#tmp2 )); then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" -qS "$sep" - "$tmp1[1]" + compadd "$group[@]" "$expl[@]" -p "$pref" -qS "$sep" \ + -M "r:|${sep}=* r:|=*" - "$tmp1[1]" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" - "$tmp1[1]" + compadd "$group[@]" "$expl[@]" -p "$pref" \ + -M "r:|${sep}=* r:|=*" - "$tmp1[1]" fi - return 1 + return 0 fi elif (( $#tmp1 )); then @@ -118,6 +123,14 @@ while true; do SUFFIX="$suf" compadd -O matches -M "r:|${sep}=* r:|=*" - "$matches[@]" + if [[ "$pre" = *${sep}* ]]; then + PREFIX="${cpre}${pre%%${sep}*}" + SUFFIX="${sep}${pre#*${sep}}${suf}" + else + PREFIX="${cpre}${pre}" + SUFFIX="$suf" + fi + if [[ -n "$menu" ]]; then # With menucompletion we just add matches for the matching # components with the prefix we collected and the rest from the @@ -125,11 +138,12 @@ while true; do tmp2="$pre$suf" if [[ "$tmp2" = *${sep}* ]]; then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" -s "${sep}${tmp2#*${sep}}" - "$tmp1[@]" + compadd "$group[@]" "$expl[@]" \ + -p "$pref" -s "${sep}${tmp2#*${sep}}" \ + -M "r:|${sep}=* r:|=*" - "$tmp1[@]" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" - "$tmp1[@]" + compadd "$group[@]" "$expl[@]" -p "$pref"\ + -M "r:|${sep}=* r:|=*" - "$tmp1[@]" fi else # With normal completion we add all matches one-by-one with @@ -138,11 +152,12 @@ while true; do for i in "${(@M)matches:#(${(j:|:)~tmp1})*}"; do if [[ "$i" = *${sep}* ]]; then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' -p "$pref" -s "${i#*${sep}}" - "${i%%${sep}*}${sep}" + compadd "$group[@]" "$expl[@]" -S '' \ + -p "$pref" -s "${i#*${sep}}" \ + -M "r:|${sep}=* r:|=*" - "${i%%${sep}*}${sep}" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' -p "$pref" - "$i" + compadd "$group[@]" "$expl[@]" -S '' -p "$pref" \ + -M "r:|${sep}=* r:|=*" - "$i" fi done fi @@ -154,12 +169,15 @@ while true; do [[ "$orig" = "$pref$pre$suf" ]] && return 1 + PREFIX="${cpre}${pre}" + SUFFIX="$suf" + if [[ -n "$suf" ]]; then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -s "$suf" - "$pref$pre" + compadd "$group[@]" "$expl[@]" -s "$suf" \ + -M "r:|${sep}=* r:|=*" - "$pref$pre" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' - "$pref$pre$suf" + compadd "$group[@]" "$expl[@]" -S '' \ + -M "r:|${sep}=* r:|=*" - "$pref$pre" fi return 0 fi @@ -175,8 +193,10 @@ while true; do # Now we set `pre' and `suf' to their new values. if [[ "$pre" = *${sep}* ]]; then + cpre="${cpre}${pre%%${sep}*}${sep}" pre="${pre#*${sep}}" elif [[ "$suf" = *${sep}* ]]; then + cpre="${cpre}${pre}${suf%%${sep}*}${sep}" pre="${suf#*${sep}}" suf="" else @@ -184,9 +204,11 @@ while true; do # unambiguous prefix and that differs from the original string, # we insert it. + PREFIX="${opre}${osuf}" + SUFFIX="" + [[ -n "$pref" && "$orig" != "$pref" ]] && - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' - "$pref" + compadd "$group[@]" "$expl[@]" -S '' -M "r:|${sep}=* r:|=*" - "$pref" return fi diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index b017d78e5..b4b6fff97 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -24,7 +24,7 @@ # menucompletion. local linepath realpath donepath prepath testpath exppath -local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf +local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf opre osuf cpre local pats haspats=no ignore group expl addpfx addsfx remsfx local nm=$compstate[nmatches] menu @@ -118,6 +118,8 @@ fi pre="$PREFIX" suf="$SUFFIX" +opre="$PREFIX" +osuf="$SUFFIX" orig="${PREFIX}${SUFFIX}" [[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" || @@ -291,6 +293,8 @@ for prepath in "$prepaths[@]"; do if [[ "$haspats" = no && -z "$tpre$tsuf" && "$pre" = */ && -z "$suf" ]]; then + PREFIX="${opre}${osuf}" + SUFFIX="" compadd -nQS '' - "$linepath$donepath$orig" tmp4=- fi @@ -349,19 +353,27 @@ for prepath in "$prepaths[@]"; do # collected as the suffixes to make the completion code expand # it as far as possible. + if [[ "$tmp3" = */* ]]; then + PREFIX="${linepath}${cpre}${tmp3%%/*}" + SUFFIX="/${tmp3#*/}" + else + PREFIX="${linepath}${cpre}${tmp3}" + SUFFIX="" + fi + if [[ -n $menu ]]; then [[ -n "$compconfig[path_cursor]" ]] && compstate[to_end]='' if [[ "$tmp3" = */* ]]; then compadd -QUf -p "$linepath${testpath:q}" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ ++ "$group[@]" "$expl[@]" \ - "${(@)${(@)tmp1%%/*}:q}" else compadd -QUf -p "$linepath${testpath:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${(@)tmp1:q}" fi else @@ -370,14 +382,14 @@ for prepath in "$prepaths[@]"; do compadd -QUf -p "$linepath${testpath:q}" -s "/${${i#*/}:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${${i%%/*}:q}" done else compadd -QUf -p "$linepath${testpath:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${(@)tmp1:q}" fi fi @@ -399,14 +411,17 @@ for prepath in "$prepaths[@]"; do testpath="${testpath}${tmp1[1]%%/*}/" tmp1=( "${(@)tmp1#*/}" ) + cpre="${cpre}${tmp3%%/*}/" tmp3="${tmp3#*/}" done - if [[ -z "$tmp4" ]]; then - compadd -QUf -p "$linepath${testpath:q}" \ + if [[ -z "$tmp4" ]]; then + PREFIX="${opre}${osuf}" + SUFFIX="" + compadd -QUf -p "$linepath${testpath:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${(@)tmp1:q}" fi done @@ -419,7 +434,9 @@ exppaths=( "${(@)exppaths:#$orig}" ) if [[ -n "$compconfig[path_expand]" && $#exppaths -gt 0 && nm -eq compstate[nmatches] ]]; then - compadd -QU -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + PREFIX="${opre}${osuf}" + SUFFIX="" + compadd -Q -S '' "$group[@]" "$expl[@]" \ -M 'r:|/=* r:|=*' -p "$linepath" - "$exppaths[@]" fi diff --git a/Completion/Core/_sep_parts b/Completion/Core/_sep_parts index 6f2595120..0a8cae28f 100644 --- a/Completion/Core/_sep_parts +++ b/Completion/Core/_sep_parts @@ -18,7 +18,7 @@ # `-X explanation' options. local str arr sep test testarr tmparr prefix suffixes matchers autosuffix -local matchflags opt group expl nm=$compstate[nmatches] +local matchflags opt group expl nm=$compstate[nmatches] opre osuf # Get the options. @@ -34,6 +34,8 @@ shift OPTIND-1 # Get the string from the line. +opre="$PREFIX" +osuf="$SUFFIX" str="$PREFIX$SUFFIX" SUFFIX="" prefix="" @@ -144,6 +146,8 @@ done # Add the matches for each of the suffixes. +PREFIX="$pre" +SUFFIX="$suf" for i in "$suffixes[@]"; do compadd -U "$group[@]" "$expl[@]" "$matchers[@]" "$autosuffix[@]" \ -i "$IPREFIX" -I "$ISUFFIX" -p "$prefix" -s "$i" - "$testarr[@]" diff --git a/Completion/Linux/_rpm b/Completion/Linux/_rpm index 4a54eddfa..5f6843267 100644 --- a/Completion/Linux/_rpm +++ b/Completion/Linux/_rpm @@ -148,7 +148,7 @@ while [[ -n "$state" ]]; do '*:RPM package:->package' && ret=0 ;; build_b) - tmp=( '*:spec file:_path_files -/ -g \*.spec' ) + tmp=( '*:spec file:_files -g \*.spec' ) ;& build_t) (( $#tmp )) || tmp=( '*:tar file:_files -g \*.\(\#i\)tar\(.\*\|\)' ) @@ -195,7 +195,7 @@ while [[ -n "$state" ]]; do _hosts -S/ && ret=0 else _description expl 'RPM package file' - _path_files "$expl[@]" -/ -g '*.(#i)rpm' && ret=0 + _files "$expl[@]" -g '*.(#i)rpm' && ret=0 _description expl 'ftp URL prefix' compadd "$expl[@]" ftp:// fi diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles index b17ca6488..579d947f0 100644 --- a/Completion/User/.distfiles +++ b/Completion/User/.distfiles @@ -1,9 +1,10 @@ DISTFILES_SRC=' .distfiles - _a2ps _bison _bunzip2 _bzip2 _chown _compress _configure _cvs _dd - _dir_list _dvi _find _flex _gdb _gprof _groups _gs _gunzip _gv _gzip - _hosts _ispell _lynx _make _man _man.old _mh _mount _nslookup _patch - _pbm _pdf _perl_basepods _perl_builtin_funcs _perl_modules _perldoc _ps - _pspdf _rcs _rlogin _sh _socket _ssh _strip _stty _su _tar _tar_archive - _telnet _tex _tiff _uncompress _urls _use_lo _users _xargs _yodl _yp + _a2ps _bison _bunzip2 _bzip2 _chown _combination _compress _configure + _cvs _dd _dir_list _dirs _dvi _find _flex _gcc _gdb _gprof _groups _gs + _gunzip _gv _gzip _hosts _ispell _lynx _mailboxes _make _man _mh _mount + _mutt _nslookup _patch _pbm _pdf _perl_basepods _perl_builtin_funcs + _perl_modules _perldoc _ports _ps _pspdf _rcs _rlogin _sh _socket _ssh + _strip _stty _su _tar _tar_archive _telnet _tex _tiff _uncompress _urls + _use_lo _users _webbrowser _wget _xargs _yodl _yp ' diff --git a/Completion/User/_dirs b/Completion/User/_dirs new file mode 100644 index 000000000..04c4b75d9 --- /dev/null +++ b/Completion/User/_dirs @@ -0,0 +1,3 @@ +#compdef rmdir df du dircmp + +_files -/ diff --git a/Completion/User/_hosts b/Completion/User/_hosts index bbc1e88b2..9f5a39cca 100644 --- a/Completion/User/_hosts +++ b/Completion/User/_hosts @@ -4,8 +4,5 @@ local expl : ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$( $muttboxes) -[[ -n "$mailpath" ]] && - _mailbox_cache=($_mailbox_cache ${mailpath//\?*/}) - _mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes) fi diff --git a/Completion/User/_man b/Completion/User/_man index ffdac91cd..88d2118c0 100644 --- a/Completion/User/_man +++ b/Completion/User/_man @@ -14,11 +14,11 @@ if [[ -n $_comp_correct ]]; then approx="(#a${_comp_correct})" fi -# `sman' is the SGML manual directory for Solaris 7. - -[ "$manpath" ] || manpath=$(manpath 2>/dev/null) || \ +(( $#manpath )) || manpath=$(manpath 2>/dev/null) || manpath=( /usr/man(-/N) /(opt|usr)/(dt|share|X11R6|local)/(cat|)man(-/N) ) +# `sman' is the SGML manual directory for Solaris 7. + if [[ $words[2] = (<->*|ln) ]]; then rep=( $manpath/(sman|man|cat)${words[2]}/${~approx}$PREFIX${~star}$SUFFIX.<->*(N:t) ) diff --git a/Completion/X/.distfiles b/Completion/X/.distfiles index 10cebc77c..0865ed4ec 100644 --- a/Completion/X/.distfiles +++ b/Completion/X/.distfiles @@ -1,6 +1,7 @@ DISTFILES_SRC=' .distfiles - _x_borderwidth _x_color _x_cursor _x_display _x_font _x_geometry - _x_locale _x_name _x_arguments _x_resource _x_selection_timeout - _x_title _xdvi _xfig _xsetroot _xt_arguments _xt_session_id _xterm _xv + _x_arguments _x_borderwidth _x_color _x_cursor _x_display _x_extension + _x_font _x_geometry _x_locale _x_name _x_resource _x_selection_timeout + _x_title _x_window _xdvi _xfig _xt_arguments _xt_session_id _xterm + _xutils _xv ' -- cgit 1.4.1