Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: apt-get -t completion
- X-seq: zsh-workers 13864
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: apt-get -t completion
- Date: Sun, 1 Apr 2001 20:54:41 -0400
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This seems to add support for the new -t apt-get option to _apt.
Index: Completion/Debian/_apt
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_apt,v
retrieving revision 1.12
diff -u -r1.12 _apt
--- Completion/Debian/_apt 2001/03/18 14:45:27 1.12
+++ Completion/Debian/_apt 2001/04/02 00:47:03
@@ -20,6 +20,7 @@
typeset -A canonicalize num_options
local short_hasarg short_bool short_intlevel short_configfile short_arbitem
local long_hasarg long_bool long_intlevel long_configfile long_arbitem
+ local short_release long_release
local comp_hasarg=''
local opt opts type
@@ -32,6 +33,7 @@
intlevel) num_options[$opts]=-1;;
configfile) num_options[$opts]=1;;
arbitem) num_options[$opts]=-1;;
+ release) num_options[$opts]=1;;
*) num_options[$opts]=1
comp_hasarg="${comp_hasarg}$opts) $type;;"$'\n'
type=hasarg;;
@@ -55,6 +57,7 @@
local short_seq false true bool bool_prefix intlevel word word1 nul qnul match
local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt
+ local comp_release
local regex_short regex_long regex_all
regex_all=( \( "$@" \) )
@@ -78,6 +81,7 @@
comp_intlevel=
comp_configfile='_files'
comp_arbitem=
+ comp_release='_apt_releases'
comp_short=\
'{if [[ $PREFIX = -'"$short_seq"' ]]; then
@@ -93,16 +97,16 @@
comp_long=\
'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}"
tmp2=(--${(M)^long_bool:#$~tmp1} --${(M)^long_intlevel:#$~tmp1})
-tmp3=(--${(M)^long_hasarg:#$~tmp1} --${(M)^long_configfile:#$~tmp1} --${(M)^long_arbitem:#$~tmp1})
+tmp3=(--${(M)^long_hasarg:#$~tmp1} --${(M)^long_configfile:#$~tmp1} --${(M)^long_arbitem:#$~tmp1} --${(M)^long_release:#$~tmp1})
_describe -o option tmp2 -- tmp3 -S= -- bool_prefix -S ""'
comp_long_prefix=\
'{tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}"
tmp2=($_ra_left${(M)^long_bool:#$~tmp1} $_ra_left${(M)^long_intlevel:#$~tmp1})
-tmp3=($_ra_left${(M)^long_hasarg:#$~tmp1} $_ra_left${(M)^long_configfile:#$~tmp1} $_ra_left${(M)^long_arbitem:#$~tmp1})
+tmp3=($_ra_left${(M)^long_hasarg:#$~tmp1} $_ra_left${(M)^long_configfile:#$~tmp1} $_ra_left${(M)^long_arbitem:#$~tmp1} $_ra_left${(M)^long_release:#$~tmp1})
tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#-?}#-}}"
tmp2=("$tmp2[@]" $_ra_left${(M)^short_bool:#$~tmp1} $_ra_left${(M)^short_intlevel:#$~tmp1})
-tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1})
+tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1} $_ra_left${(M)^short_release:#$~tmp1})
_describe -o option tmp2 -- tmp3 -S=}'
comp_opt='{{ ! zstyle -T ":completion:${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }}"
@@ -197,6 +201,22 @@
)
fi
+ if (( $#short_release )); then
+ regex_short=("$regex_short[@]"
+ /"$short_seq(${(j:|:)short_release})(=|)"/
+ -'_apt_consume_short ${match[1]%=}'
+ \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":release name:release:$comp_release" \) \|
+ )
+ regex_long_prefix=("$regex_long_prefix[@]"
+ /"(${(j:|:)short_release})$nul"/
+ -'_apt_consume_short ${match[1][-2]}'
+ /"$word"/ ":releases:release name:$comp_release" \|
+ /"(${(j:|:)short_release})="/
+ -'_apt_consume_short ${match[1][-2]}'
+ \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":releases:release name:$comp_release" \) \|
+ )
+ fi
+
if (( $#long_hasarg )); then
regex_long=("$regex_long[@]"
/"(${(j:|:)long_hasarg})$nul"/
@@ -292,6 +312,25 @@
)
fi
+ if (( $#long_release )); then
+ regex_long=("$regex_long[@]"
+ /"(${(j:|:)long_release})$nul"/
+ -'_apt_consume_long ${match[1]%'$qnul'}'
+ /"$word"/ ":releases:release name:$comp_release" \|
+ /"(${(j:|:)long_release})="/
+ -'_apt_consume_long ${match[1]%=}'
+ \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":releases:release name:$comp_release" \) \|
+ )
+ regex_long_prefix=("$regex_long_prefix[@]"
+ /"(${(j:|:)long_release})$nul"/
+ -'_apt_consume_long ${match[1]%'$qnul'}'
+ /"$word"/ ":releases:release name:$comp_release" \|
+ /"(${(j:|:)long_release})="/
+ -'_apt_consume_long ${match[1]%=}'
+ \( /"$word1"/ ":releases:release name:$comp_release" \| /"$nul"/ /"$word"/ ":releases:release name:$comp_release" \) \|
+ )
+ fi
+
regex_all=(
/"$word"/
\( /--/+ \( "$regex_long[@]"
@@ -312,17 +351,20 @@
local short_hasarg short_bool short_intlevel short_configfile short_arbitem
local long_hasarg long_bool long_intlevel long_configfile long_arbitem
+ local short_release long_release
local bool_prefix
short_hasarg=($short_hasarg)
short_bool=($short_bool)
short_intlevel=($short_intlevel)
short_configfile=($short_configfile)
short_arbitem=($short_arbitem)
+ short_release=($short_release)
long_hasarg=($long_hasarg)
long_bool=($long_bool)
long_intlevel=($long_intlevel)
long_configfile=($long_configfile)
long_arbitem=($long_arbitem)
+ long_release=($long_release)
bool_prefix=($bool_prefix)
local current_option tmp1 tmp2 tmp3
@@ -368,6 +410,7 @@
--list-cleanup:bool \
-c,--config-file:configfile \
-o,--option:arbitem \
+ -t:release \
-- \
/$'update\0'/ \| \
/$'upgrade\0'/ \| \
@@ -478,5 +521,40 @@
_apt-config "$@"
}
+
+_apt_releases_update () {
+ if ( [[ ${+_apt_releases} -eq 0 ]] ||
+ _cache_invalid APT_releases ) && ! _retrieve_cache APT_releases;
+ then
+ _apt_releases=(
+${${${${(M)${(f)"$(apt-cache dump)"}:# #Archive:*}# #Archive: #}:#*\(null\)*}/ /}
+ )
+ typeset -U _apt_releases
+ _store_cache APT_releases _apt_releases
+ fi
+}
+
+_apt_releases () {
+ local command="$argv[$#]" update_policy
+
+ zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+ if [[ -z "$update_policy" ]]; then
+ zstyle ":completion:*:*:$service:*" cache-policy _apt_caching_policy
+ fi
+
+ _apt_releases_update
+
+ _tags apt-releases && compadd -a _apt_releases
+}
+
+ _apt_caching_policy () {
+ # rebuild if cache is more than a week old
+ oldp=( "$1"(mw+1) )
+ (( $#oldp )) && return 0
+
+ [[ /var/cache/apt/pkgcache.bin -nt "$1" ||
+ /var/lib/dpkg/available -nt "$1" ]]
+ }
+
_apt "$@"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author