zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: use _arguments in _which and _unhash
@ 2000-05-28 17:35 Oliver Kiddle
  2000-05-28 20:52 ` PATCH: _arguments (Re: PATCH: use _arguments in _which and _unhash) Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Kiddle @ 2000-05-28 17:35 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:

> I can reproduce this, but
> 
> } % zpty -w l <tab>
> } _arguments:shift:297: shift count must be <= $#
> 
> I can't reproduce that.

Are you sure? I can reproduce it on different platforms and when
starting with zsh -f. Maybe one of your options avoids it.

Totally unrelated to this, I've changed a couple more of the
completion functions to use _arguments (which and unhash).

Oliver


--- Completion/Builtins/_unhash	Thu Dec 30 18:28:37 1999
+++ Completion/Builtins/_unhash	Sun May 28 16:45:29 2000
@@ -1,14 +1,14 @@
 #compdef unhash
 
-local fl="$words[2]" args
+local expl state line curcontext="$curcontext"
 
-args=()
-[[ "$fl" = -*d* ]] &&
-    args=( 'named-directories:named directory:compadd - ${(@k)nameddirs}' )
-[[ "$fl" = -*a* ]] &&
-    args=( "$args[@]"
-           'aliases:alias:compadd - ${(@k)aliases} ${(@k)galiases} ${(@k)dis-aliases} ${(@k)dis-galiases}' )
-[[ "$fl" != -* ]] &&
-    args=( 'commands:: _command_names -e' )
+_arguments -C -s \
+  '(-a -f *)-d[remove named directories]:*:named directory:->nameddir' \
+  '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \
+  '(-d -a *)-f[remove functions]:*:functions:_functions' \
+  '-m[treat arguments as patterns]' \
+  '*:commands:_command_names -e'  && return 0
 
-_alternative "$args[@]"
+if [[ "$state" = nameddir ]]; then
+  _wanted nameddir expl 'named directory' compadd - ${(@k)nameddirs}
+fi
--- Completion/Builtins/_which.bak	Mon Nov 15 12:01:47 1999
+++ Completion/Builtins/_which	Sun May 28 15:50:57 2000
@@ -1,6 +1,29 @@
 #compdef which whence where type
 
-local args
+local farg aarg cargs args state line curcontext="$curcontext"
+
+cargs=( \
+  '(-v -c)-w[print command type]' \
+  '-p[always do a path search]' \
+  '-m[treat the arguments as patterns]' \
+  '-s[print symlink free path as well]' \
+  '*:commands:->command' )
+farg='-f[output contents of functions]'
+aarg='-a[print all occurences in path]'
+
+case ${words[1]} in
+  whence)
+    _arguments -C -s \
+      '(-c -w)-v[verbose output]' \
+      '(-v -w)-c[csh-like output]' \
+      "${cargs[@]}" "$farg" "$aarg" && return 0
+  ;;
+  where) _arguments -C -s "${cargs[@]}" && return 0;;
+  which) _arguments -C -s "${cargs[@]}" "$aarg" && return 0;;
+  type) _arguments -C -s "${cargs[@]}" "$aarg" "$farg" && return 0;;
+esac
+
+if [[ "$state" = command ]]; then
 
 args=( "$@" )
 
@@ -10,3 +33,5 @@
   'functions:shell function:compadd - ${(k@)functions}' \
   'aliases:alias:compadd - ${(k@)aliases}' \
   'reserved-words:reserved word:compadd - ${(k@)reswords}'
+
+fi



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

end of thread, other threads:[~2000-05-28 20:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-28 17:35 PATCH: use _arguments in _which and _unhash Oliver Kiddle
2000-05-28 20:52 ` PATCH: _arguments (Re: PATCH: use _arguments in _which and _unhash) Bart Schaefer

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