diff -Nau zsh-completion-20040730/_gentoolkit /usr/share/zsh/site-functions/_gentoolkit --- zsh-completion-20040730/_gentoolkit 2005-01-07 02:09:18.432700856 -0800 +++ /usr/share/zsh/site-functions/_gentoolkit 2005-01-07 02:09:48.074194664 -0800 @@ -12,18 +12,13 @@ _tags overlay && { compadd "$@" ${(kv)=overlay} } } -#moved out of equery -_equery_val(){ - _values "equery actions" \ - 'files[list files owned by pkg]' \ - 'list[list all packages matching pattern]' \ - 'belongs[list all packages owning file]' \ - 'uses[display USE flags for package]' \ - 'which[print full path to ebuild for package]' \ - 'depgraph[display a dependency tree for package]' \ - 'check[check files against recorded md5sums and timestamps]' \ - 'size[print size of files contained in package]' - } +_packages(){ + if compset -P '(\\|)(>=|<=|<|>|=)' ; then + _gentoo_packages ${*/(#m)(installed|available)/${MATCH}_versions} + else + _gentoo_packages $* + fi + } case $service in @@ -65,82 +60,118 @@ "(- :)"{--help,-h}"[show help]" \ "(--info -i --query-deps -q --slot -s)1:package:_gentoo_packages installed_versions" ;; - -equery) - local prev="$words[CURRENT-1]" prev2="$words[CURRENT-2]" - if (( CURRENT == 2 ));then - _equery_val - _arguments \ - $common_args && return 0 - elif (( CURRENT > 2 ));then - - case "$prev" in - files|--timestamp|--md5sum|--type) - _arguments -s \ +equery) + # Based off of X/_xauth. + local state context line expl ret=1 + local tmp cmd start_args common_args + + start_args=( + {'(--nocolor)-C','(-C)--nocolor'}'[turns off colors]' + {'(--quiet)-q','(-q)--quiet'}'[minimal output]' + {'(--help)-h','(-h)--help'}'[show help]' + ) + + common_args=( + '(-i --installed -I --exclude-installed)'{-i,--installed}'[search installed packages]' + '(-I --exclude-installed -i --installed)'{-I,--exclude-installed}'[do not search installed packages]' + '(-p --portage)'{-p,--portage-tree}'[also search in portage tree]' + '(-o --overlay-tree)'{-o,--overlay-tree}'[also search in overlay tree]' + ) + + + _arguments -s $start_args \ + '*::command:->command' && ret=0 + + while [[ -n "$state" ]]; do + tmp="$state" + state= + case "$tmp" in + command) + if (( CURRENT == 1 )); then + state=subcommands + else + cmd="$words[1]" + curcontext="${curcontext%:*:*}:equery-${cmd}:" + case "$cmd" in + belongs|b) + _arguments \ + '(-c --category)'{-c,--category}'[only search in specified category]:category:_gentoo_packages category' \ + '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ + '(-f --full-regex)'{-f,--full-regex}'[supplied query is a full regex]:pattern:' \ + '*:file:_files' && ret=0 + ;; + check|k) + _arguments \ + ':portage:_packages installed' && ret=0 + ;; + depends|d) + _arguments \ + '(-a --all-packages)'{-a,--all-packages}'[search in all available packages (slow)]:all packages:->packages' \ + '(-d --direct -D --indirect)'{-d,--direct}'[search direct dependencies only (default)]' \ + '(-d --direct -D --indirect)'{-D,--indirect}'[search indirect dependencies (VERY slow)]' \ + '*:package:_packages installed' && ret=0 + ;; + depgraph|g) + _arguments \ + '(-U --no-useflags)'{-U,--no-useflags}'[do not show USE flags]' \ + '(-l --linear)'{-l,--linear}'[do not use fancy formatting]' \ + ':package:_packages installed' && ret=0 + ;; + files|f) + _arguments \ '--timestamp[append timestamp]' \ '--md5sum[append md5sum]' \ '--type[prepend file type]' \ - '*:installed pkgname:_gentoo_packages installed_versions' && return 0 + '--filter=[filter output]:filter(s):_values -s , '' dir obj sym dev fifo path conf cmd doc man info' \ + ':installed pkgname:_packages installed' && ret=0 ;; - belongs|--earlyout) - _arguments -s \ - '(-c --category)'{-c,--category}'[only search in specified category]' \ - '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ - '*:file:_files' && return 0 + hasuse|h) + _arguments \ + $common_args \ + ':useflag:_gentoo_packages useflag' && ret=0 + ;; + list|l) + _arguments \ + $common_args \ + ': :_guard "^--*" pattern' && ret=0 + ;; + size|s) + _arguments \ + '(-b --bytes)'{-b,--bytes}'[report size in bytes]' \ + ':package:_packages installed' && ret=0 + ;; + which|w) + _arguments \ + ':portage:_packages available' && ret=0 ;; - --category|-c) - _arguments -s \ - '*:category:_gentoo_packages category' && return 0 - ;; - list|--installed|-i|--exclude-installed|-I|-p|--portage-tree|-o|--overlay-tree) - _arguments -s \ - '(-i --installed -I --exclude-installed)'{-i,--installed}'[search installed packages]' \ - '(-I --exclude-installed -i --installed)'{-I,--exclude-installed}'[do not search installed packages]' \ - '(-p --portage)'{-p,--portage-tree}'[also search in portage tree]' \ - '(-o --overlay-tree)'{-o,--overlay-tree}'[also search in overlay tree]' \ - '*:package:_gentoo_packages installed_versions' && return 0 - ;; - uses|which) - _arguments \ - '*:package:_gentoo_packages installed_versions' \ - && return 0 - ;; - depgraph|-U|--no-useflags|-l|--linear) - _arguments -s \ - '(-U --no-useflags)'{-U,--no-useflags}'[do not show USE flags]' \ - '(-l --linear)'{-l,--linear}'[do not use fancy formatting]' \ - '*:package:_gentoo_packages installed_versions' \ - && return 0 - ;; - size|-b|--bytes) - _arguments -s \ - '(-b --bytes)'{-b,--bytes}'[report size in bytes]' \ - '*:package:_gentoo_packages installed_versions' \ - && return 0 - ;; - check) - _arguments -s \ - '*:package:_gentoo_packages installed_versions' \ - && return 0 - ;; - --nocolor|-C|--quiet|-q) - _equery_val + uses|u) _arguments \ - $common_args && return 0 + {--all,-a}'[include non-installed packages]' \ + ":portage:_packages installed" && ret=0 + ;; + *) + _message 'command not found' + ;; + esac + fi ;; - esac - - [[ $prev2 == (--category|-c) ]] && - _arguments '(-c --category)'{-c,--category}'[only search in specified category]' \ - '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ - '*:file:_files' && return 0 - - fi - common_args=( - {'(--nocolor)-C','(-C)--nocolor'}'[turns off colors]' - {'(--quiet)-q','(-q)--quiet'}'[minimal output]' - {'(--help)-h','(-h)--help'}'[show help]' - ) - ;; + subcommands) + tmp=( + {belongs,b}'[list all packages owning file(s)]' + {check,k}'[check MD5sums and timestamps of package]' + {depends,d}'[list all packages depending on specified package]' + {depgraph,g}'[display a dependency tree for package]' + {files,f}'[list files owned by package]' + {hasuse,h}'[list all packages with specified useflag]' + {list,l}'[list all packages matching pattern]' + {size,s}'[print size of files contained in package]' + {uses,u}'[display USE flags for package]' + {which,w}'[print full path to ebuild for package]' + ) + _values 'equery command' $tmp && ret=0 + ;; + esac + done +;; esac diff -Nau zsh-completion-20040730/_gentoo_packages /usr/share/zsh/site-functions/_gentoo_packages --- zsh-completion-20040730/_gentoo_packages 2005-01-07 02:09:18.432700856 -0800 +++ /usr/share/zsh/site-functions/_gentoo_packages 2005-01-07 02:09:48.074194664 -0800 @@ -5,8 +5,21 @@ #Description: # functions for gentoo packages # inspired by _deb_packages -#Usage: _gentoo_packages installed|available|installed_versions|available_versions|binary|category +#Usage: _gentoo_packages installed|available|installed_versions|available_versions|binary|category|useflag +# Completion function to show useflags. +_gentoo_packages_update_useflag(){ + local flags PORTDIR + var=PORTDIR + [[ -z ${(P)var} && -r /etc/make.conf ]] && + local $var="`. /etc/make.conf 2>/dev/null; echo ${(P)var}`" + [[ -z ${(P)var} && -r /etc/make.globals ]] && + local $var="`. /etc/make.globals 2>/dev/null; echo ${(P)var}`" + + flags=( ${${(M)${(f)"$(<$PORTDIR/profiles/use.desc)"}:#* - *}%% - *} + ${${${(M)${(f)"$(<$PORTDIR/profiles/use.local.desc)"}#* - *}%% - *}#*:} ) + compadd $flags +} _gentoo_packages_update_category(){ local var trees category @@ -112,11 +125,11 @@ if [[ -z "$update_policy" ]]; then zstyle ":completion:*:*:$service:*" cache-policy _gentoo_cache_policy fi - [[ "$command" == (installed(_versions|)|available(_versions|)|binary|category) ]] || { + [[ "$command" == (installed(_versions|)|available(_versions|)|binary|category|useflag) ]] || { _message "unknown command: $command" return } - [[ "$pkgset" == (installed(_versions|)|available(_versions|)|binary|category) ]] || { + [[ "$pkgset" == (installed(_versions|)|available(_versions|)|binary|category|useflag) ]] || { pkgset="$command" } expl=("${(@)argv[1,-2]}")