* [PATCH] Unify apt releases handling for apt and aptitude completion.
@ 2013-09-22 10:48 Daniel Schaal
0 siblings, 0 replies; only message in thread
From: Daniel Schaal @ 2013-09-22 10:48 UTC (permalink / raw)
To: zsh-workers; +Cc: Daniel Schaal
The aptitude completion was slightly broken, as it didn't
consider /etc/apt/sources.list.d/*, so just use the same
completion for apt and aptitude.
---
Completion/Debian/Command/_apt | 35 ---------------------------------
Completion/Debian/Command/_aptitude | 13 +-----------
Completion/Debian/Type/_apt_releases | 38 ++++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 47 deletions(-)
create mode 100644 Completion/Debian/Type/_apt_releases
diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt
index b51b2fc..d656303 100644
--- a/Completion/Debian/Command/_apt
+++ b/Completion/Debian/Command/_apt
@@ -551,39 +551,4 @@ _apt-config () {
_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 policy)"}:#*release*}#*a=}%%,*}:#now}
- )
- typeset -U _apt_releases
- _store_cache APT_releases _apt_releases
- fi
-}
-
-_apt_releases () {
- local 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 () {
- local -a oldp
-
- oldp=( "$1"(mw+1) )
- (( $#oldp )) && return 0
-
- [[ /var/cache/apt/pkgcache.bin -nt "$1" ||
- /var/lib/dpkg/available -nt "$1" ]]
-}
-
_apt "$@"
diff --git a/Completion/Debian/Command/_aptitude b/Completion/Debian/Command/_aptitude
index 2c462e4..ae89ad2 100644
--- a/Completion/Debian/Command/_aptitude
+++ b/Completion/Debian/Command/_aptitude
@@ -2,17 +2,6 @@
local curcontext="$curcontext" state line cmds ret=1
-function _aptitude_release() {
- #{{{
- local expl releases
- releases=(
-${${(M)${(f)"$(</etc/apt/sources.list)"}\
-:#[ $'\t']#deb(|-src)*}/(#b)[ $'\t']#[^ $'\t']##[ $'\t']##[^ $'\t']##[ $'\t']##([^ $'\t']##)*/$match[1]}
- )
- _wanted list expl release compadd ${expl} - ${(u)releases}
- #}}}
-}
-
# Helper function for -F / --display-format
function _aptitude_format_strings() {
_values -s , 'format string' \
@@ -65,7 +54,7 @@ _arguments -C \
'(--without-suggests)--with-suggests[install suggested packages when installing new packages]' \
'(-r --with-recommends)'{-r,--without-recommends}'[ignore recommended packages when installing new packages]' \
'(--with-suggests)--without-suggests[ignore suggested packages when installing new packages]' \
- '(-t --target-release)'{-t,--target-release}'[set the release from which packages should be installed]:release:_aptitude_release' \
+ '(-t --target-release)'{-t,--target-release}'[set the release from which packages should be installed]:release:_apt_releases' \
'(-q --quiet)'{-q=,--quiet=}'[less Output]:level' \
'--schedule-only[schedule operations to be performed in the future]' \
'--purge-unused[purge unused packages instead of removing]' \
diff --git a/Completion/Debian/Type/_apt_releases b/Completion/Debian/Type/_apt_releases
new file mode 100644
index 0000000..26bc40b
--- /dev/null
+++ b/Completion/Debian/Type/_apt_releases
@@ -0,0 +1,38 @@
+#autoload
+
+_apt_releases_update () {
+ if ( [[ ${+_apt_releases} -eq 0 ]] ||
+ _cache_invalid APT_releases ) && ! _retrieve_cache APT_releases;
+ then
+ _apt_releases=(
+${${${${(M)${(f)"$(apt-cache policy)"}:#*release*}#*a=}%%,*}:#now}
+ )
+ typeset -U _apt_releases
+ _store_cache APT_releases _apt_releases
+ fi
+}
+
+_apt_releases () {
+ local 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 () {
+ local -a oldp
+
+ oldp=( "$1"(mw+1) )
+ (( $#oldp )) && return 0
+
+ [[ /var/cache/apt/pkgcache.bin -nt "$1" ||
+ /var/lib/dpkg/available -nt "$1" ]]
+}
+
+_apt_releases "@"
--
1.8.4.rc3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-09-22 11:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-22 10:48 [PATCH] Unify apt releases handling for apt and aptitude completion Daniel Schaal
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).