zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _deb_packages: New completion for source packages.
@ 2016-05-04 20:54 Daniel Shahaf
  0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2016-05-04 20:54 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Debian/Type/_deb_packages | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/Completion/Debian/Type/_deb_packages b/Completion/Debian/Type/_deb_packages
index 74b1518..d82515c 100644
--- a/Completion/Debian/Type/_deb_packages
+++ b/Completion/Debian/Type/_deb_packages
@@ -1,6 +1,6 @@
 #autoload
 
-# Usage: _deb_packages expl... avail|installed|uninstalled
+# Usage: _deb_packages expl...  (installed|deinstalled|xinstalled|held|uninstalled|avail|available|source)
 
 _deb_packages_update_avail () {
   if ( [[ ${+_deb_packages_cache_avail} -eq 0 ]] ||
@@ -80,6 +80,21 @@ _deb_packages_update_uninstalled () {
   cachevar=_deb_packages_cache_uninstalled
 }
 
+_deb_packages_update_source () {
+  if ( [[ ${+_deb_packages_cache_source} -eq 0 ]] ||
+      _cache_invalid DEBS_source ) && ! _retrieve_cache DEBS_source;
+  then
+    _deb_packages_cache_source=(
+      # requires apt >= 1.1.8
+      # if dpkg --compare-versions "$(dpkg-query --show --showformat '${Version}\n' apt)" '>=' '1.1.8' ; then ...; else ...; fi
+      ${(f)"$(/usr/lib/apt/apt-helper cat-file $(apt-get indextargets --format '$(FILENAME)' 'Created-By: Sources' 2>/dev/null) 2>/dev/null | sed -ne 's/^Package: //p' | uniq)"}
+    )
+
+    _store_cache DEBS_source _deb_packages_cache_source
+  fi
+  cachevar=_deb_packages_cache_source
+}
+
 _deb_packages () {
   local command="$argv[$#]" expl cachevar pkgset update_policy
 
@@ -88,14 +103,14 @@ _deb_packages () {
     zstyle ":completion:*:*:$service:*" cache-policy _debs_caching_policy
   fi
 
-  [[ "$command" = (installed|deinstalled|xinstalled|held|uninstalled|avail|available) ]] || {
+  [[ "$command" = (installed|deinstalled|xinstalled|held|uninstalled|avail|available|source) ]] || {
     _message "unknown command: $command"
     return
   }
 
   zstyle -s ":completion:${curcontext}:" packageset pkgset
 
-  [[ "$pkgset" = (installed|deinstalled|xinstalled|held|uninstalled|avail|available) ]] || {
+  [[ "$pkgset" = (installed|deinstalled|xinstalled|held|uninstalled|avail|available|source) ]] || {
     pkgset="$command"
   }
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-04 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-04 20:54 [PATCH] _deb_packages: New completion for source packages Daniel Shahaf

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).