Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: use of _arguments for hash
- X-seq: zsh-workers 11347
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxxxxxx>
- Subject: PATCH: use of _arguments for hash
- Date: Fri, 12 May 2000 14:10:59 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
This adds _arguments based completion for the hash (and rehash)
builtins. Why does rehash accept the -v option when as far as I can
tell, it can never do anything? Would it be useful to add a -L option
to hash similar to alias -L?
I'm getting one problem with this completion: when I type hash -r<tab>,
it is completed to 'hash -d '. I would expect it to complete to
'hash -rd '. I also get 'no more arguments' duplicated after
'hash -d -v<tab>'.
I've also added the + options in _vars_eq for typeset now that the bug
with them is fixed (thanks Sven).
Oliver
Index: Completion/Builtins/_hash
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_hash,v
retrieving revision 1.3
diff -u -r1.3 _hash
--- _hash 2000/05/02 08:23:31 1.3
+++ _hash 2000/05/12 13:05:53
@@ -1,16 +1,37 @@
-#compdef hash
+#compdef hash rehash
-local expl
+local state line expl common_args curcontext="$curcontext"
+typeset -A opt_args
-if [[ "$words[2]" = -*d* ]]; then
- if compset -P 1 '*='; then
- _wanted -C -d-value files expl directories _path_files -/
+common_args=( \
+ '-d[use named directory hash table]' \
+ '(-r -m -v)-f[rebuild hash table]' )
+
+case ${words[1]} in
+ hash)
+ _arguments -C -s \
+ '(-f -m -v)-r[empty hash table]' \
+ '(-f -r)-m[treat arguments as patterns]' \
+ '(-f -r -m)-v[list entires as they are added]' \
+ "${common_args[@]}" \
+ '(-d -f -r -m -v)*:hash:->hashval' && return 0
+ ;;
+ rehash)
+ _arguments -C -s ${common_args[@]} && return 0
+ ;;
+esac
+
+if [[ $state = hashval ]]; then
+ if (( $+opt_args[-d] )); then
+ if compset -P 1 '*='; then
+ _wanted -C value files expl directories _path_files -/
+ else
+ _wanted -C name named-directories expl 'named directory' \
+ compadd -q -S '=' - "${(@k)nameddirs}"
+ fi
+ elif compset -P 1 '*='; then
+ _wanted -C value values expl 'executable file' _files -g '*(-*)'
else
- _wanted -C -d named-directories expl 'named directory' \
- compadd -q -S '=' - "${(@k)nameddirs}"
+ _wanted -C name commands expl command compadd -q -S '=' - "${(@k)commands}"
fi
-elif compset -P 1 '*='; then
- _wanted -C value values expl 'executable file' _files -g '*(-*)'
-else
- _wanted -C name commands expl command compadd -q -S '=' - "${(@k)commands}"
fi
Index: Completion/Builtins/_vars_eq
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_vars_eq,v
retrieving revision 1.4
diff -u -r1.4 _vars_eq
--- _vars_eq 2000/05/09 16:53:34 1.4
+++ _vars_eq 2000/05/12 13:05:53
@@ -17,19 +17,19 @@
Z '(-A -E -F -f -i)-Z+[right justify and fill with leading zeros]:width' \
a '(-A -E -F -T -f -i)-a[specify that arguments refer to arrays]' \
f '(-A -E -F -L -R -T -Z -a -g -h -i -l -r -x)-f[specify that arguments refer to functions]' \
- g '(-T -f)-g[do not restrict parameter to local scope]' \
- h '(-T -f)-h[hide parameter]' \
- i '(-A -E -F -T -f)-i[represent internally as an integer]' \
+ g '(-T -f)-+g[do not restrict parameter to local scope]' \
+ h '(-T -f)-+h[hide parameter]' \
+ i '(-A -E -F -T -f)-+i[represent internally as an integer]' \
l '(-T -f)-l[convert the value to lowercase]' \
m '(-A -E -F -T -i)-m[treat arguments as patterns]' \
- r '(-f)-r[mark parameters as readonly]' \
- t '(-T)-t[tag parameters and turn on execution tracing for functions]' \
- tf '(-T)-t[turn on execution tracing for functions]' \
- tp '(-T)-t[tag parameters]' \
+ r '(-f)-+r[mark parameters as readonly]' \
+ t '(-T)-+t[tag parameters and turn on execution tracing for functions]' \
+ tf '(-T)-+t[turn on execution tracing for functions]' \
+ tp '(-T)-+t[tag parameters]' \
u '-u[convert the value to uppercase or mark function for autoloading]' \
uf '-u[mark function for autoloadling]' \
up '-u[convert the value to uppercase]' \
- x '(-f)-x[export parameter]' )
+ x '(-f)-+x[export parameter]' )
use="AEFLRTUZafghilmrtux"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author