Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: minor completion things



This does a few minor things:

_perl_basepods was checking with which if basedepods existed before
running basepods. I take it that this was a typo. I've also changed it
(and _perl_modules) to use $+commands[...] instead of which ...
>/dev/null for consistency with other completion functions.

Fixed suffix handling in _user_at_hosts and _chown. Is there a reason
why _user_at_hosts isn't used in _mutt? It could also be used in
_netscape. Should we maybe have a separate function for completing
e-mail addresses which uses things like mutt/mush/pine/netscape address
books.

Finally, _lsdev was missing a local definition. One aspect of the
_arguments documentation which I am not entirely clear on is whether I
need to declare the local curcontext when we are not using a ->state
thing? If so, a number of the other AIX completions will need it adding.
It seems that the vast majority of uses of _arguments use a -C option:
the context is rarely useful in a state so maybe -C should be the
default?

Oliver

Index: Completion/AIX/_lsdev
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/AIX/_lsdev,v
retrieving revision 1.2
diff -u -r1.2 _lsdev
--- Completion/AIX/_lsdev	2000/05/05 13:38:46	1.2
+++ Completion/AIX/_lsdev	2000/05/23 17:57:42
@@ -1,6 +1,6 @@
 #compdef lsdev
 
-local state line expl
+local curcontext="${curcontext}" state line expl
 
 _arguments -C \
   '(-P)-C[list info about device in customized devices object class]' \
Index: Completion/User/_chown
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_chown,v
retrieving revision 1.2
diff -u -r1.2 _chown
--- Completion/User/_chown	2000/04/05 11:28:09	1.2
+++ Completion/User/_chown	2000/05/23 17:57:42
@@ -1,14 +1,18 @@
 #compdef chown chgrp
 
+local suf
+
 if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
   if [[ ${words[1]:t} = chgrp ]] || compset -P '*[:.]'; then
     _groups
   else
     if [[ $OSTYPE = (solaris*|hpux*) ]]; then
-      _users -S ':' -q
+      suf=':'
     else
-      _users -S '.' -q
+      suf='.'
     fi
+    compset -S '.*' && unset suf
+    _users -S "$suf" -q
   fi
 else
   _files
Index: Completion/User/_perl_basepods
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_perl_basepods,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 _perl_basepods
--- Completion/User/_perl_basepods	2000/03/23 04:19:30	1.1.1.4
+++ Completion/User/_perl_basepods	2000/05/23 17:57:42
@@ -11,7 +11,7 @@
 if [[ ${+_perl_basepods} -eq 0 ]]; then
   typeset -agU _perl_basepods
 
-  if which basdepods >/dev/null; then
+  if (( ${+commands[basepods]} )); then
     _perl_basepods=( ${$(basepods):t:r} )
   else
     local podpath
Index: Completion/User/_perl_modules
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_perl_modules,v
retrieving revision 1.3
diff -u -r1.3 _perl_modules
--- Completion/User/_perl_modules	2000/04/27 00:05:53	1.3
+++ Completion/User/_perl_modules	2000/05/23 17:57:42
@@ -22,11 +22,11 @@
 
 if [[ ${+_perl_modules} -eq 0 ]]; then
   if zstyle -t ":completion:${curcontext}:modules" try-to-use-pminst \
-     && which pminst >/dev/null; then
+     && (( ${+commands[pminst]} )); then
     _perl_modules=( $(pminst) )
   else
     local inc libdir new_pms
-    if which perl >/dev/null; then
+    if (( ${+commands[perl]} )); then
       inc=( $( perl -e 'print "@INC"' ) )
     else
       # If perl isn't there, one wonders why the user's trying to
Index: Completion/User/_user_at_host
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_user_at_host,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 _user_at_host
--- Completion/User/_user_at_host	2000/03/23 04:19:31	1.1.1.7
+++ Completion/User/_user_at_host	2000/05/23 17:57:42
@@ -5,7 +5,7 @@
 # with `-t tag'.
 # A `-' or `--' as the first argument is ignored.
 
-local tag=accounts
+local suf tag=accounts
 
 if [[ "$1" = -t?* ]]; then
   tag="${1[3,-1]}"
@@ -25,6 +25,7 @@
   _wanted -C user-at hosts expl "host for $user" \
       _combination -s '[:@]' "${tag}" users-hosts users="$user" hosts "$@" -
 else
+  compset -S '@*' || suf="@"
   _wanted users expl "user" \
-      _combination -s '[:@]' "${tag}" users-hosts users -S@ -q "$@" -
+      _combination -s '[:@]' "${tag}" users-hosts users -S "$suf" -q "$@" -
 fi



Messages sorted by: Reverse Date, Date, Thread, Author