Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: use _arguments in _which and _unhash
- X-seq: zsh-workers 11615
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: use _arguments in _which and _unhash
- Date: Sun, 28 May 2000 18:35:09 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- Sender: opk
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author