zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: make _deb_packages handle -J
@ 1999-12-27  3:05 Clint Adams
  1999-12-27 21:21 ` Tanaka Akira
  0 siblings, 1 reply; 2+ messages in thread
From: Clint Adams @ 1999-12-27  3:05 UTC (permalink / raw)
  To: zsh-workers

At some point _dpkg started passing '-J -default-' to _deb_packages,
and _deb_packages didn't like it.  Since this is intended as a temporary
solution, the option is not being passed along to compadd.

The result is that _apt and _dpkg will both work with _deb_packages.

Index: Completion/Debian/_deb_packages
===================================================================
RCS file: /cvs/zsh/zsh/Completion/Debian/_deb_packages,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 _deb_packages
--- Completion/Debian/_deb_packages	1999/11/15 12:01:48	1.1.1.3
+++ Completion/Debian/_deb_packages	1999/12/27 02:52:55
@@ -1,6 +1,15 @@
 #autoload
 
+local opt caopts
+
 # Usage: _deb_packages installed|uninstalled|avail
+while getopts "J:" opt; do
+  case "$opt" in
+     J) caopts="-J $OPTARG"
+        shift 2			# presume that -J -default- are the first args
+        ;;
+  esac
+done
 
 if (( ! $+_deb_cache_dpkg_get_selections )); then
   _deb_cache_dpkg_get_selections=(


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: make _deb_packages handle -J
  1999-12-27  3:05 PATCH: make _deb_packages handle -J Clint Adams
@ 1999-12-27 21:21 ` Tanaka Akira
  0 siblings, 0 replies; 2+ messages in thread
From: Tanaka Akira @ 1999-12-27 21:21 UTC (permalink / raw)
  To: zsh-workers

In article <19991226220500.A842@dman.com>,
  Clint Adams <schizo@debian.org> writes:

> At some point _dpkg started passing '-J -default-' to _deb_packages,
> and _deb_packages didn't like it.  Since this is intended as a temporary
> solution, the option is not being passed along to compadd.

It's because there is no space between colon and _deb_packages in _dpkg.

> The result is that _apt and _dpkg will both work with _deb_packages.

I modified _deb_packages to take expl arguments at first and a command
at last.

Index: Completion/Debian/_apt
===================================================================
RCS file: /projects/zsh/zsh/Completion/Debian/_apt,v
retrieving revision 1.1.1.16
diff -u -r1.1.1.16 _apt
--- Completion/Debian/_apt	1999/12/10 14:47:58	1.1.1.16
+++ Completion/Debian/_apt	1999/12/27 21:03:24
@@ -375,14 +375,14 @@
     -- \
     /$'update\0'/ \| \
     /$'upgrade\0'/ \| \
-    /$'install\0'/ /$'[^\0]#\0'/ :'_deb_packages uninstalled "$expl_packages[@]" || _deb_packages installed "$expl_packages[@]" ' \# \| \
-    /$'remove\0'/ /$'[^\0]#\0'/ :'_deb_packages installed "$expl_packages[@]"' \# \| \
+    /$'install\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" uninstalled || _deb_packages "$expl_packages[@]" installed' \# \| \
+    /$'remove\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" installed' \# \| \
     /$'dist-upgrade\0'/ \| \
     /$'dselect-upgrade\0'/ \| \
     /$'clean\0'/ \| \
     /$'autoclean\0'/ \| \
     /$'check\0'/ \| \
-    /$'source\0'/ /$'[^\0]#\0'/ :'_deb_packages avail "$expl_packages[@]"' \# \| \
+    /$'source\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" avail' \# \| \
     /$'help\0/' \| \
     /"[]"/	:'_tags actions && compadd "$expl_action[@]" update upgrade install remove dist-upgrade dselect-upgrade clean autoclean check source help'
 
@@ -413,14 +413,14 @@
     /$'help\0'/ \| \
     /$'add\0'/ /$'[^\0]#\0'/ :'_files' \# \| \
     /$'gencaches\0'/ \| \
-    /$'showpkg\0'/ /$'[^\0]#\0'/ :'_deb_packages avail "$expl_packages[@]"' \# \| \
+    /$'showpkg\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" avail' \# \| \
     /$'stats\0'=$status[4]/ \| \
     /$'dump\0'/ \| \
     /$'dumpavail\0'/ \| \
     /$'unmet\0'/ \| \
     /$'check\0'/ \| \
     /$'search\0'/ \| \
-    /$'show\0'/ /$'[^\0]#\0'/ :'_deb_packages avail "$expl_packages[@]"' \# \| \
+    /$'show\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" avail' \# \| \
     /$'depends\0'/ \| \
     /"[]"/ :'_tags actions && compadd "$expl_action[@]" help add gencaches showpkg stats dump dumpavail unmet check search show depends'
 
Index: Completion/Debian/_deb_packages
===================================================================
RCS file: /projects/zsh/zsh/Completion/Debian/_deb_packages,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 _deb_packages
--- Completion/Debian/_deb_packages	1999/12/27 06:19:34	1.1.1.4
+++ Completion/Debian/_deb_packages	1999/12/27 21:03:24
@@ -1,37 +1,49 @@
 #autoload
 
-local opt caopts
+# Usage: _deb_packages expl... avail|installed|uninstalled
 
-# Usage: _deb_packages installed|uninstalled|avail
-while getopts "J:" opt; do
-  case "$opt" in
-     J) caopts="-J $OPTARG"
-        shift 2			# presume that -J -default- are the first args
-        ;;
-  esac
-done
-
-if (( ! $+_deb_cache_dpkg_get_selections )); then
-  _deb_cache_dpkg_get_selections=(
-    ${(f)"$(dpkg --get-selections)"}
-  )
-  _deb_cache_avail=(
-    ${(f)"$(apt-cache dumpavail | awk '/^Package:/ { print $2 }')"}
-  )
-  _deb_cache_installed=(
-    ${${_deb_cache_dpkg_get_selections:#*deinstall}%%	*}
-  )
-  _deb_cache_uninstalled=(
-    ${_deb_cache_avail:#${(j:|:)~${_deb_cache_installed:q}}}
-  )
-fi
-
-local command="$1" expl
-shift
-
-_wanted packages expl packages &&
-    case "$command" in
-    installed) compadd "$@" - $_deb_cache_installed;;
-    uninstalled) compadd "$@" - $_deb_cache_uninstalled;;
-    avail) compadd "$@" - $_deb_cache_avail;;
-    esac
+_deb_packages_updage_avail () {
+  if (( ! $+_deb_packages_cache_uninstalled )); then
+    _deb_packages_cache_avail=(
+      ${(f)"$(apt-cache dumpavail | awk '/^Package:/ { print $2 }')"}
+    )
+  fi
+  cachevar=_deb_packages_cache_avail
+}
+
+_deb_packages_updage_installed () {
+  if (( ! $+_deb_packages_cache_installed )); then
+    _deb_packages_cache_installed=(
+      ${${${(f)"$(dpkg --get-selections)"}:#*deinstall}%%	*}
+    )
+  fi
+  cachevar=_deb_packages_cache_installed
+}
+
+_deb_packages_updage_uninstalled () {
+  _deb_packages_updage_avail
+  _deb_packages_updage_installed
+  if (( ! $+_deb_packages_cache_uninstalled )); then
+    _deb_packages_cache_uninstalled=(
+      ${_deb_packages_cache_avail:#${(j:|:)~${_deb_packages_cache_installed:q}}}
+    )
+  fi
+  cachevar=_deb_packages_cache_uninstalled
+}
+
+_deb_packages () {
+  local command="$argv[$#]" expl cachevar
+
+  [[ "$command" = (installed|uninstalled|avail) ]] || {
+    _message "_deb_packages:unknown command: $command"
+    return
+  }
+
+  expl=("${(@)argv[1,-2]}")
+
+  _deb_packages_updage_$command
+
+  _tags packages && compadd "$expl[@]" - "${(e):-"\${(@)$cachevar}"}"
+}
+
+_deb_packages "$@"
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-12-27 21:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-27  3:05 PATCH: make _deb_packages handle -J Clint Adams
1999-12-27 21:21 ` Tanaka Akira

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