From 1d77e36c393be4fa8d836104b6ff2d6bdcfad134 Mon Sep 17 00:00:00 2001 From: Paul Ackersviller Date: Sun, 25 Nov 2007 00:23:37 +0000 Subject: Merge from HEAD of workers/2378{0,1,2,3}. --- Completion/Debian/Command/_dput | 18 +++++++++++++++ Completion/Zsh/Command/_command | 12 ++++++++++ Completion/Zsh/Command/_hash | 41 +++++++++++++++++++++++++++++++++ Completion/Zsh/Command/_which | 39 ++++++++++++++++++++++++++++++++ Completion/Zsh/Context/_equal | 4 +--- Completion/Zsh/Type/_command_names | 46 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 Completion/Zsh/Command/_command create mode 100644 Completion/Zsh/Command/_hash create mode 100644 Completion/Zsh/Command/_which create mode 100644 Completion/Zsh/Type/_command_names (limited to 'Completion') diff --git a/Completion/Debian/Command/_dput b/Completion/Debian/Command/_dput index 664b9b231..01aac15e0 100644 --- a/Completion/Debian/Command/_dput +++ b/Completion/Debian/Command/_dput @@ -1,14 +1,32 @@ #compdef dput +_dput() { _arguments \ '(-c --config)'{-c,--config}'[specify config file]:config file:_files' \ '(-d --debug)'{-d,--debug}'[debug mode]' \ '(-D --dinstall)'{-D,--dinstall}'[run dinstall after upload]' \ + '(-e --delayed)'{-E,--delayed}'number of days in delayed queue:(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)' \ '(-f --force)'{-f,--force}'[force upload of already uploaded package]' \ + '(-H --host-list)'{-H,--host-list}'[display host list]' \ '(-l --lintian)'{-l,--lintian}'[run lintian before upload]' \ '(-o --check-only)'{-o,--check-only}'[check the package, do not upload]' \ '(-p --print)'{-p,--print}'[print configuration]' \ '(-s --simulate)'{-s,--simulate}'[simulate an upload only]' \ '(-u --unchecked)'{-u,--unchecked}'[do not check GPG signature on the changes file]' \ '(-v --version)'{-v,--version}'[show version information]' \ + '1::host:_dput_hosts' \ '*:changes file:_files -g "*.changes(-.)"' +} + +_dput_hosts() { + local expl + + if ( [[ ${+_dput_cfhosts} -eq 0 ]] || _cache_invalid dputhosts ) && ! _retrieve_cache dputhosts; then + _dput_cfhosts=(${${(M)${(f)"$(dput -H)"}:#*=>*}/ =>*/}) + _store_cache dputhosts _dput_cfhosts + fi + + _wanted dputhosts expl 'target host' compadd -a _dput_cfhosts +} + +_dput "$@" diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command new file mode 100644 index 000000000..72d7b6e99 --- /dev/null +++ b/Completion/Zsh/Command/_command @@ -0,0 +1,12 @@ +#compdef command + +local ret + +if [[ CURRENT -ge 3 ]]; then + compset -n 2 + _normal && ret=0 +else + _path_commands "$@" && ret=0 +fi + +return ret diff --git a/Completion/Zsh/Command/_hash b/Completion/Zsh/Command/_hash new file mode 100644 index 000000000..d4bb59d28 --- /dev/null +++ b/Completion/Zsh/Command/_hash @@ -0,0 +1,41 @@ +#compdef hash rehash + +local state line expl common_args curcontext="$curcontext" ret=1 +typeset -A opt_args + +common_args=( \ + '-d[use named directory hash table]' \ + '(-r -m -v)-f[rebuild hash table]' ) + +case ${service} in + hash) + _arguments -C -s -S \ + '(-f -m -v)-r[empty hash table]' \ + '(-f -r)-m[treat arguments as patterns]' \ + '(-f -r -m)-v[list entries as they are added]' \ + '(-f -r -v)-L[list in the form of calls to hash]' \ + "${common_args[@]}" \ + '(-d -f -r -m -v -L)*:hash:->hashval' && ret=0 + ;; + rehash) + _arguments -C -s ${common_args[@]} && return 0 + ;; +esac + +if [[ $state = hashval ]]; then + if (( $+opt_args[-d] )); then + if compset -P 1 '*='; then + _wanted -C value files expl directories _path_files -/ && ret=0 + else + _wanted -C name named-directories expl 'named directory' \ + compadd -q -S '=' -k nameddirs && ret=0 + fi + elif compset -P 1 '*='; then + _wanted -C value values expl 'executable file' _files -g '*(-*)' && ret=0 + else + curcontext="${curcontext%:*}:name" + _path_commands -q -S '=' && ret=0 + fi +fi + +return ret diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which new file mode 100644 index 000000000..07ede39fd --- /dev/null +++ b/Completion/Zsh/Command/_which @@ -0,0 +1,39 @@ +#compdef which whence where type + +local farg aarg cargs args state line curcontext="$curcontext" ret=1 + +cargs=( \ + '(-v -c)-w[print command type]' \ + '-p[always do a path search]' \ + '-m[treat the arguments as patterns]' \ + '-s[print symlink free path as well]' \ + '*:commands:->command' ) +farg='-f[output contents of functions]' +aarg='-a[print all occurrences in path]' + +case ${service} in + whence) + _arguments -C -s -A "-*" -S \ + '(-c -w)-v[verbose output]' \ + '(-v -w)-c[csh-like output]' \ + "${cargs[@]}" "$farg" "$aarg" && ret=0 + ;; + where) _arguments -C -s -A "-*" -S "${cargs[@]}" && ret=0;; + which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" && ret=0;; + type) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$farg" && ret=0;; +esac + +if [[ "$state" = command ]]; then + + args=( "$@" ) + + _alternative -O args \ + 'commands:external command:_path_commands' \ + 'builtins:builtin command:compadd -k builtins' \ + 'functions:shell function:compadd -k functions' \ + 'aliases:alias:compadd -k aliases' \ + 'reserved-words:reserved word:compadd -k reswords' && ret=0 + +fi + +return ret diff --git a/Completion/Zsh/Context/_equal b/Completion/Zsh/Context/_equal index a1577d62c..58a415d56 100644 --- a/Completion/Zsh/Context/_equal +++ b/Completion/Zsh/Context/_equal @@ -1,5 +1,3 @@ #compdef -equal- -local expl - -_wanted commands expl command compadd -k commands +_path_commands diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names new file mode 100644 index 000000000..f57d05226 --- /dev/null +++ b/Completion/Zsh/Type/_command_names @@ -0,0 +1,46 @@ +#autoload + +# The option `-e' if given as the first argument says that we should +# complete only external commands and executable files. This and a +# `-' as the first argument is then removed from the arguments. + +local args defs + +zstyle -t ":completion:${curcontext}:commands" rehash && rehash + +defs=( + 'commands:external command:_path_commands' +) + +[[ -n "$path[(r).]" || $PREFIX = */* ]] && + defs=( "$defs[@]" + 'executables:executable file or directory:_path_files -/g \*\(-\*\)' + ) + +if [[ "$1" = -e ]]; then + shift +else + [[ "$1" = - ]] && shift + + defs=( "$defs[@]" + 'builtins:builtin command:compadd -k builtins' + 'functions:shell function:compadd -k functions' + 'aliases:alias:compadd -k aliases' + 'suffix-aliases:suffix alias:_suffix_alias_files' + 'reserved-words:reserved word:compadd -k reswords' + 'jobs:: _jobs -t' + 'parameters:: _parameters -g "^*readonly*" -qS= -r "\n\t\- =["' + ) +fi + +args=( "$@" ) + +local -a cmdpath +if zstyle -a ":completion:${curcontext}" command-path cmdpath && + [[ $#cmdpath -gt 0 ]] +then + local -a +h path + local -A +h commands + path=( $cmdpath ) +fi +_alternative -O args "$defs[@]" -- cgit 1.4.1