about summary refs log tree commit diff
path: root/Completion/User
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User')
-rw-r--r--Completion/User/_archie8
-rw-r--r--Completion/User/_flex2
-rw-r--r--Completion/User/_gcc4
-rw-r--r--Completion/User/_gprof6
-rw-r--r--Completion/User/_groups2
-rw-r--r--Completion/User/_gs10
-rw-r--r--Completion/User/_hosts2
-rw-r--r--Completion/User/_lynx2
-rw-r--r--Completion/User/_mount29
-rw-r--r--Completion/User/_mutt23
-rw-r--r--Completion/User/_netscape71
-rw-r--r--Completion/User/_nslookup14
-rw-r--r--Completion/User/_pbm4
-rw-r--r--Completion/User/_ports2
-rw-r--r--Completion/User/_rlogin19
-rw-r--r--Completion/User/_socket17
-rw-r--r--Completion/User/_ssh115
-rw-r--r--Completion/User/_telnet18
-rw-r--r--Completion/User/_tiff4
-rw-r--r--Completion/User/_urls19
-rw-r--r--Completion/User/_user_at_host10
-rw-r--r--Completion/User/_users2
-rw-r--r--Completion/User/_users_on2
-rw-r--r--Completion/User/_wget2
-rw-r--r--Completion/User/_whois23
-rw-r--r--Completion/User/_yp33
26 files changed, 292 insertions, 151 deletions
diff --git a/Completion/User/_archie b/Completion/User/_archie
index 1e0eb71be..640fbc4ed 100644
--- a/Completion/User/_archie
+++ b/Completion/User/_archie
@@ -1,6 +1,6 @@
 #compdef archie
 
-local state line
+local context state line expl
 typeset -A opt_args
 
 _arguments -s \
@@ -25,6 +25,10 @@ _arguments -s \
 case "$state" in
 serverhost)
   : ${(A)archie_servers:=${(M)$(archie -L):#archie.*}}
-  compadd $archie_servers
+
+  _tags "${context}:server" hosts || return 1
+
+  _description expl 'archie servers'
+  compadd "$expl[@]" -  $archie_servers
   ;;
 esac
diff --git a/Completion/User/_flex b/Completion/User/_flex
index ef998c3cf..5d5d55f7a 100644
--- a/Completion/User/_flex
+++ b/Completion/User/_flex
@@ -1,6 +1,6 @@
 #compdef flex
 
-local state line ret=1
+local context state line ret=1
 typeset -A opt_args
 
 _arguments -s \
diff --git a/Completion/User/_gcc b/Completion/User/_gcc
index 2fa29df8c..88f70ad52 100644
--- a/Completion/User/_gcc
+++ b/Completion/User/_gcc
@@ -1,6 +1,6 @@
 #compdef gcc
 
-local state line ret=1 expl args
+local context state line ret=1 expl args
 typeset -A opt_args
 
 args=()
@@ -273,6 +273,8 @@ dump)
     'p[annotate assembler output]' && ret=0
   ;;
 library)
+  _tags "${context}" libraries || return 1
+
   _description expl library
   compadd "$expl[@]" - ${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(:t:fr:s/lib//) && ret=0
   ;;
diff --git a/Completion/User/_gprof b/Completion/User/_gprof
index 211a7a15f..cbc362331 100644
--- a/Completion/User/_gprof
+++ b/Completion/User/_gprof
@@ -1,6 +1,6 @@
 #compdef gprof
 
-local state line ret=1
+local context state line ret=1
 typeset -A opt_args
 
 _arguments -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \
@@ -17,6 +17,8 @@ _arguments -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \
 if [[ -n "$state" ]]; then
   local cmd pair expl
 
+  _tags "${context}" functions || return 1
+
   [[ "$state" = pair ]] && pair=yes
 
   if [[ $#line -gt 1 ]]; then
@@ -46,7 +48,7 @@ if [[ -n "$state" ]]; then
     else
       _description expl function
     fi
-    compadd -M 'r:|_=* r:|=*' - "$_gprof_funcs[@]" && ret=0
+    compadd "$expl[@]" -M 'r:|_=* r:|=*' - "$_gprof_funcs[@]" && ret=0
   else
     return 1
   fi
diff --git a/Completion/User/_groups b/Completion/User/_groups
index b867634c0..bc955a8d2 100644
--- a/Completion/User/_groups
+++ b/Completion/User/_groups
@@ -2,6 +2,8 @@
 
 local expl
 
+_tags any groups || return 1
+
 if (( ! $+groups )); then
   if whence -p ypcat > /dev/null; then
     : ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use NIS
diff --git a/Completion/User/_gs b/Completion/User/_gs
index 55dc4f8f7..0c9c11e10 100644
--- a/Completion/User/_gs
+++ b/Completion/User/_gs
@@ -8,7 +8,7 @@ if compset -N --; then
     return 1
   fi
 else
-  local state line ret=1
+  local context state line ret=1
   typeset -A opt_args
 
   _x_arguments \
@@ -25,6 +25,8 @@ else
     if [[ "$PREFIX" = *\=* ]]; then
       _message 'systemdict definition value'
     else
+      _tags "$context" names || return 1
+
       _description expl 'systemdict definition name'
       compadd "$expl[@]" -M 'm:{a-z}={A-Z}' - \
               DISKFONTS NOCACHE NOBIND NODISPLAY NOPAUSE PLATFONTS SAFER \
@@ -35,10 +37,14 @@ else
     if compset -P '*\='; then
       case "$IPREFIX" in
       *DEVICE\=)
+        _tags "$context" devices || return 1
+
         _description expl 'ghostscript device'
         compadd "$expl[@]" - "${(@)${=${$(gs -h)##* devices:}%%Search path:*}:#}" && ret=0
         ;;
       *OutputFile\=)
+        _tags "$context" files || return 1
+
         _description expl 'output file'
         _files && ret=0
         ;;
@@ -47,6 +53,8 @@ else
         return 1
       esac
     else
+      _tags "$context" names || return 1
+
       _description expl 'systemdict name'
       compadd "$expl[@]" -S\= -M 'm:{a-z}={A-Z}' - DEVICE OutputFile && ret=0
     fi
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index 00150f9b7..d577c83ab 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -2,6 +2,8 @@
 
 local expl
 
+_tags any hosts || return 1
+
 : ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
 
 _description expl host
diff --git a/Completion/User/_lynx b/Completion/User/_lynx
index eaf5a6603..8399c4735 100644
--- a/Completion/User/_lynx
+++ b/Completion/User/_lynx
@@ -1,6 +1,6 @@
 #compdef lynx
 
-local state line
+local context state line
 typeset -A opt_args
 
 _arguments \
diff --git a/Completion/User/_mount b/Completion/User/_mount
index 579f24381..39e31ee35 100644
--- a/Completion/User/_mount
+++ b/Completion/User/_mount
@@ -5,7 +5,7 @@
 # arguments for the `mount' command for different operating systems
 # are below these table.
 
-local state line ret=1 args fss deffs=iso9660 descr tmp
+local context state line ret=1 args fss deffs=iso9660 descr tmp
 typeset -A opt_args
 
 if (( ! $+_fs_any )); then
@@ -228,11 +228,15 @@ fi
 
 case "$state" in
 fstype)
+  _tags "$context" types || return 1
+
   compset -P '*,'
   _description expl 'file system type'
   compadd "$expl[@]" -qS, -M 'L:|no=' - "$fss[@]" && ret=0
   ;;
 fsopt)
+  _tags "$context" options || return 1
+
   eval 'tmp=(' '"$_fs_'${(s:,:)^${opt_args[-t]:-${deffs}}}'[@]"' ')'
   tmp=( "$_fs_any[@]" "${(@)tmp:#}" )
   _values -s , 'file system options' "$tmp[@]" && ret=0
@@ -241,25 +245,24 @@ devordir)
   if (( $+opt_args[-a] )); then
     _message "no device or directory with option \`-a'"
   else
-    _description expl device
-    compadd "$expl[@]" /dev/* && ret=0
-    if (( ! $+opt_args[-t] )); then
-      _description expl 'mount point'
-      _files "$expl[@]" -/ && ret=0
-    fi
+    _alternative "$context" \
+        'devices:device:compadd /dev/\*' \
+	'directories:mount point:_files -/' && ret=0
   fi
   ;;
 udevordir)
   if (( $+opt_args[-a] )); then
     _message "no device or directory with option \`-a'"
   else
+    local dev_tmp mp_tmp
+
     tmp=( "${(@f)$(< /etc/mtab)}" )
-    _description expl device
-    compadd "$expl[@]" - "${(@)${(@)tmp%% *}:#none}" && ret=0
-    if (( ! $+opt_args[-t] )); then
-      _description expl 'mount point'
-      compadd "$expl[@]" - "${(@)${(@)tmp#* }%% *}"
-    fi
+    dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
+    mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
+
+    _alternative "$context" \
+        'devices:device:compadd - $dev_tmp[@]' \
+	'directories:mount point:compadd - $mp_tmp[@]' && ret=0
   fi
   ;;
 esac
diff --git a/Completion/User/_mutt b/Completion/User/_mutt
index 1339c32b0..16b1b0c6d 100644
--- a/Completion/User/_mutt
+++ b/Completion/User/_mutt
@@ -1,6 +1,6 @@
 #compdef mutt
 
-local state line muttrc="~/.muttrc" ret=1
+local context state line muttrc="~/.muttrc" ret=1
 
  _arguments \
  '::recipient:->userhost' \
@@ -25,15 +25,16 @@ local state line muttrc="~/.muttrc" ret=1
  '-Z+:open first mailbox with new mail:' && ret=0
 
 if [[ "$state" = userhost ]]; then
-      if compset -P '*@'; then
-        _description expl 'remote host name'
-        _hosts "$expl[@]" -q -S,
-        return
-      else
-          _description expl 'login name'
-          _users "$expl[@]" -q -S@ && ret=0
-        fi
-      fi
+  _tags "$context" hosts || return 1
 
-return ret
+  if compset -P '*@'; then
+    _description expl 'remote host name'
+    _hosts "$expl[@]" -q -S, && return 0
+  else
+    _description expl 'login name'
+    _users "$expl[@]" -q -S@ && return 0
+   fi
+ fi
 fi
+
+return ret
diff --git a/Completion/User/_netscape b/Completion/User/_netscape
index 11f583dd5..3caaad05e 100644
--- a/Completion/User/_netscape
+++ b/Completion/User/_netscape
@@ -1,6 +1,6 @@
 #compdef netscape
 
-local state line
+local context state line ret=1
 typeset -A opt_args
 
 _x_arguments \
@@ -22,56 +22,75 @@ _x_arguments \
   -{,no-}{,irix-}session-management \
   -{done-save,ignore}-geometry-prefs \
   -{component-bar,composer,edit,messenger,mail,discussions,news} \
-  '*:location:->urls'
+  '*:location:->urls' && ret=0
+
+[[ "$state" = "urls" ]] &&
+  _tags "$context" files && _files "$@" && return 0
 
-[ "$state" = "urls" ] && _files "$@" && return
 
 # Handle netscape remote commands
-if [ "$state" = "remote" ]; then  
+if [[ "$state" = "remote" ]]; then  
   local -a remote_commands
   remote_commands=(openURL openFile saveAs mailto addBookmark)
 
   [[ $compstate[quoting] = (double|single) ]] && compset -q
   compset -P '*\('
   case $IPREFIX in
-    openURL*|addBookmark* ) state=urls;;
-    openFile* ) _files -W ~;;
-    saveAs* ) 
+    openURL*|addBookmark*) state=urls;;
+    openFile*) _files -W ~;;
+    saveAs*) 
       if compset -P "*,"; then
-        compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript
+        if _tags "$context" types; then
+          _description expl 'data type'
+          compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript &&
+              ret=0
+        fi
       else
-        _path_files -W ~
+        _tags "$context" files && _path_files -W ~ && ret=0
       fi
     ;;
-    mailto* )
+    mailto*)
       compset -P "*,"
       if compset -P '*@'; then
-        _description expl 'remote host name'
-        _hosts "$expl[@]" -q -S,
+        if _tags "$context" hosts; then
+          _description expl 'remote host name'
+          _hosts "$expl[@]" -q -S, && ret=0
+        fi
       else
-        _description expl 'login name'
-        _users "$expl[@]" -q -S@
+        if _tags "$context" users; then
+          _description expl 'login name'
+          _users "$expl[@]" -q -S@ && ret=0
+        fi
       fi
     ;;
-    * )
-      if [ "$QIPREFIX" ]; then
-        compadd -q -S '(' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands
-      else
-	compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands
+    *)
+      if _tags "$context" commands; then
+        if [[ "$QIPREFIX" ]]; then
+          compadd -q -S '(' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands && ret=0
+        else
+	  compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands && ret=0
+	fi
       fi
     ;;
   esac
 fi
 
-if [ "$state" = "urls" ]; then
+if [[ "$state" = "urls" ]]; then
   # Complete netscape urls
   if [[ -prefix about: ]]; then
-    compset -P about:
-    compadd authors blank cache document fonts global hype image-cache \
-        license logo memory-cache mozilla plugins
+    if _tags "$context" values; then
+      _description expl 'about what'
+      compset -P about:
+      compadd authors blank cache document fonts global hype image-cache \
+          license logo memory-cache mozilla plugins && ret=0
+    fi
   else
-    _description expl 'URL prefix'
-    compadd "$expl[@]" -S '' about: mocha: javascript:
-    _urls "$@"
+    if _tags "$context" prefixes; then
+      _description expl 'URL prefix'
+      compadd "$expl[@]" -S '' about: mocha: javascript:
+      _urls "$@" && ret=0
+    fi
   fi
 fi
+
+return ret
diff --git a/Completion/User/_nslookup b/Completion/User/_nslookup
index 7bf97a8ad..f3e290505 100644
--- a/Completion/User/_nslookup
+++ b/Completion/User/_nslookup
@@ -19,7 +19,7 @@
 # other characters than lower case letters, we try to call the function
 # `_nslookup_host'.
 
-local state expl ret=1 setopts
+local context state expl ret=1 setopts
 
 setopts=(
   'all[print current values]' \
@@ -52,6 +52,8 @@ if [[ -n "$compcontext" ]]; then
 
     funcall ret _nslookup_command && return ret
 
+    _tags any commands || return 1
+
     _description expl 'command'
     compadd "$expl[@]" - server lserver root finger ls view help set && ret=0
     _hosts && ret=0
@@ -60,6 +62,8 @@ if [[ -n "$compcontext" ]]; then
 
     funcall ret _nslookup_redirect && return ret
 
+    _tags redirection files || return 1
+
     if [[ "$words[1]" != (finger|ls) ]]; then
       _message "redirection not allowed for command \`$words[1]'"
       return 1
@@ -84,6 +88,8 @@ if [[ -n "$compcontext" ]]; then
 
   case "$words[1]" in
   (|l)server)
+    _tags argument hosts || return 1
+
     _description expl 'new default server'
     _hosts "$expl[@]"
     return
@@ -106,6 +112,8 @@ if [[ -n "$compcontext" ]]; then
     return
     ;;
   view)
+    _tags argument files || return 1
+
     _description expl 'view file'
     _files "$expl[@]"
     return
@@ -118,6 +126,8 @@ if [[ -n "$compcontext" ]]; then
     [[ -z "$state" ]] && return ret
     ;;
   *)
+    _tags argument hosts || return 1
+
     _description expl 'server'
     _hosts "$expl[@]"
     return
@@ -141,6 +151,8 @@ fi
 # This is completion after `srchlist' for both types.
 
 if [[ -n "$state" ]]; then
+  _tags "$context" hosts || return 1
+
   if compset -P '*/'; then
     _description expl 'search list entry'
   else
diff --git a/Completion/User/_pbm b/Completion/User/_pbm
index 77af9b23b..c697ebaa6 100644
--- a/Completion/User/_pbm
+++ b/Completion/User/_pbm
@@ -21,7 +21,7 @@ if [[ $# -ne 0 || $+_in_pbm -ne 0 ]]; then
     _description expl 'picture file'
     set -- "$expl[@]"
   fi
-  _path_files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
+  _files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
   return
 fi
 
@@ -775,5 +775,5 @@ zeisstopnm)
 
 *) 
   _description expl 'picture file'
-  _path_files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
+  _files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
 esac
diff --git a/Completion/User/_ports b/Completion/User/_ports
index 950212832..9012dfd5e 100644
--- a/Completion/User/_ports
+++ b/Completion/User/_ports
@@ -2,6 +2,8 @@
 
 local expl
 
+_tags any ports || return 1
+
 : ${(A)ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ 	]*}}
 
 _description expl port
diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin
index aa66b8f01..898f10870 100644
--- a/Completion/User/_rlogin
+++ b/Completion/User/_rlogin
@@ -20,7 +20,7 @@ _rlogin () {
       ':remote host name:_rlogin_hosts'
     ;;
   rsh|remsh)
-    local state line ret=1
+    local context state line ret=1
     typeset -A opt_args
 
     _arguments -s \
@@ -48,13 +48,18 @@ _rlogin () {
 
     if [[ -n "$state" ]]; then
       if compset -P '*:'; then
+        _tags "$context" files || return 1
+
 	_files && ret=0
       elif compset -P '*@'; then
+        _tags "$context" hosts || return 1
+
 	_rlogin_hosts -S: -q && ret=0
       else
-	_files && ret=0
-	_rlogin_all_hosts -S: -q && ret=0
-	_rlogin_users -S@ -q && ret=0
+        _alternative "$context" \
+	    'files:: _files' \
+	    'hosts:: _rlogin_all_hosts -qS:' \
+	    'users:: _rlogin_users -qS@' && ret=0
       fi
     fi
     return ret
@@ -63,10 +68,12 @@ _rlogin () {
 }
 
 _rlogin_users () {
-  _combination accounts_users_hosts users "$@"
+  _tags any users && _combination accounts_users_hosts users "$@"
 }
 
 _rlogin_hosts () {
+  _tags any hosts || return 1
+
   if [[ "$IPREFIX" == *@ ]]; then
     _combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@"
   else
@@ -76,6 +83,8 @@ _rlogin_hosts () {
 }
 
 _rlogin_all_hosts () {
+  _tags any hosts || return 1
+
   _combination accounts_users_hosts hosts "$@"
 }
 
diff --git a/Completion/User/_socket b/Completion/User/_socket
index e43c14c24..ad9232af9 100644
--- a/Completion/User/_socket
+++ b/Completion/User/_socket
@@ -5,13 +5,14 @@
 #  socket_hosts_ports
 #    The array that contains paris `host:port'.
 
-local state line expl
+local context state line expl
 typeset -A opt_args
 
-if [[ $CURRENT -eq 2 && (
-  -z "$compconfig[option_prefix]" ||
-  "$compconfig[option_prefix]" = *\!${words[1]}* ||
-  "$PREFIX" = -* ) ]]; then
+if _tags any options &&
+   [[ $CURRENT -eq 2 && (
+      -z "$compconfig[option_prefix]" ||
+      "$compconfig[option_prefix]" = *\!${words[1]}* ||
+      "$PREFIX" = -* ) ]]; then
   _description expl option
   compadd -M 'r:|[_-]=* r:|=*' "$expl[@]" - -version
 fi
@@ -42,9 +43,13 @@ command)
 
 arg1)
   if (( $+opt_args[-s] )); then
+    _tags "$context" ports || return 1
+
     _description expl 'port to listen'
     _ports "$expl[@]"
   else
+    _tags "$context" hosts || return 1
+
     _description expl 'host'
     _combination socket_hosts_ports hosts "$expl[@]"
   fi
@@ -52,6 +57,8 @@ arg1)
 
 arg2)
   if (( ! $+opt_args[-s] )); then
+    _tags "$context" ports || return 1
+
     _description expl 'port to connect'
     _combination socket_hosts_ports hosts="${line[2]:q}" ports "$expl[@]"
   fi
diff --git a/Completion/User/_ssh b/Completion/User/_ssh
index 952b99193..2c71b49a0 100644
--- a/Completion/User/_ssh
+++ b/Completion/User/_ssh
@@ -1,7 +1,7 @@
 #compdef ssh slogin scp ssh-add ssh-agent ssh-keygen
 
 _ssh () {
-  local state lstate line ret=1 expl args
+  local context state lstate line ret=1 expl args tmp
   typeset -A opt_args
 
   local accounts_users_hosts
@@ -58,23 +58,31 @@ _ssh () {
         if compset -P '*[= ]'; then
           case "$IPREFIX" in
           *(#i)(batchmode|compression|fallbacktorsh|forward(agent|x11)|keepalive|passwordauthentication|rhosts(|rsa)authentication|rsaauthentication|usersh|kerberos(authetication|tgtparsing)|usepriviledgedport)*)
-            compadd yes no && ret=0
+	    _tags "$context" values && compadd yes no && ret=0
             ;;
           *(#i)cipher*)
-            _description expl 'encryption cipher'
-            compadd "$expl[@]" idea des 3des blowfish arcfour tss none && ret=0
+	    if _tags "$context" values; then
+              _description expl 'encryption cipher'
+              compadd "$expl[@]" idea des 3des blowfish arcfour tss none && ret=0
+	    fi
             ;;
           *(#i)globalknownhostsfile*)
-            _description expl 'global file with known hosts'
-            _files "$expl[@]" && ret=0
+	    if _tags "$context" files; then
+              _description expl 'global file with known hosts'
+              _files "$expl[@]" && ret=0
+	    fi
             ;;
           *(#i)hostname*)
-            _description expl 'real host name to log into'
-            _ssh_hosts "$expl[@]" && ret=0
+	    if _tags "$context" hosts; then
+              _description expl 'real host name to log into'
+              _ssh_hosts "$expl[@]" && ret=0
+	    fi
             ;;
           *(#i)identityfile*)
-            _description expl 'SSH identity file'
-            _files "$expl[@]" && ret=0
+	    if _tags "$context" files; then
+              _description expl 'SSH identity file'
+              _files "$expl[@]" && ret=0
+	    fi
             ;;
           *(#i)(local|remote)forward*)
             state=forward
@@ -86,36 +94,44 @@ _ssh () {
             _normal && ret=0
             ;;
           *(#i)stricthostkeychecking*)
-            compadd yes no ask
+            _tags "$context" values && compadd yes no ask
             ;;
           *(#i)userknownhostsfile*)
-            _description expl 'user file with known hosts'
-            _files "$expl[@]" && ret=0
+	    if _tags "$context" files; then
+              _description expl 'user file with known hosts'
+              _files "$expl[@]" && ret=0
+	    fi
             ;;
           *(#i)user*)
-            _description expl 'user to log in as'
-            _ssh_users "$expl[@]" && ret=0
+	    if _tags "$context" files; then
+              _description expl 'user to log in as'
+              _ssh_users "$expl[@]" && ret=0
+	    fi
             ;;
           *(#i)xauthlocation*)
-            _description expl 'xauth program'
-            _files "$expl[@]" -g '*(*)' && ret=0
+	    if _tags "$context" files; then
+              _description expl 'xauth program'
+              _files "$expl[@]" -g '*(*)' && ret=0
+	    fi
             ;;
           esac
         else
-          _description expl 'configure file option'
-          compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '=' - \
-              BatchMode ClearAllForwardings Cipher Compression \
-              CompressionLevel Host ConnectionAttempts EscapeChar \
-              FallBackToRsh ForwardAgent ForwardX11 \
-              GlobalKnownHostsFile HostName IdentityFile KeepAlive \
-              KerberosAuthentication KerberosTgtPassing LocalForward \
-              NumberOfPasswordPrompts PasswordAuthentication Port \
-              ProxyCommand RemoteForward RhostsAuthentication \
-              RhostsRSAAuthentication RSAAuthentication \
-              StrictHostKeyChecking TISAuthentication \
-              UsePriviledgedPort User UserKnownHostsFile UseRsh \
-              XAuthLocation \
-            && ret=0
+          if _tags "$context" values; then
+            _description expl 'configure file option'
+            compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '=' - \
+                BatchMode ClearAllForwardings Cipher Compression \
+                CompressionLevel Host ConnectionAttempts EscapeChar \
+                FallBackToRsh ForwardAgent ForwardX11 \
+                GlobalKnownHostsFile HostName IdentityFile KeepAlive \
+                KerberosAuthentication KerberosTgtPassing LocalForward \
+                NumberOfPasswordPrompts PasswordAuthentication Port \
+                ProxyCommand RemoteForward RhostsAuthentication \
+                RhostsRSAAuthentication RSAAuthentication \
+                StrictHostKeyChecking TISAuthentication \
+                UsePriviledgedPort User UserKnownHostsFile UseRsh \
+                XAuthLocation \
+              && ret=0
+	  fi
         fi
         ;;
       forward)
@@ -123,7 +139,7 @@ _ssh () {
           if compset -P '*:'; then
             _message 'port number'
           else
-            _ssh_hosts -S: -q
+	    _tags "$context" hosts && _ssh_hosts -S: -q
           fi
         else
           _message 'listen-port number'
@@ -138,15 +154,19 @@ _ssh () {
         ;;
       userhost)
         if compset -P '*@'; then
-          _description expl 'remote host name'
-          _ssh_hosts "$expl[@]" && ret=0
+	  if _tags "$context" hosts; then
+            _description expl 'remote host name'
+            _ssh_hosts "$expl[@]" && ret=0
+	  fi
         else
-          _description expl 'remote host name'
-          _ssh_hosts "$expl[@]" && ret=0
-          if (( ! $+opt_args[-l] )); then
-            _description expl 'login name'
-            _ssh_users "$expl[@]" -S@ -q && ret=0
-          fi
+          if (( $+opt_args[-l] )); then
+	    tmp=()
+	  else
+	    tmp=( 'users:login name:_ssh_users -qS@' )
+	  fi
+	  _alternative "$context" \
+	      'hosts:remote host name:_ssh_hosts' \
+	      "$tmp[@]" && ret=0
         fi
         ;;
       esac
@@ -178,13 +198,14 @@ _ssh () {
       return
     elif [[ -n "$state" ]]; then
       if compset -P '*:'; then
-        _files && ret=0
+        _tags "$context" files && _files && ret=0
       elif compset -P '*@'; then
-        _ssh_hosts -S: && ret=0
+        _tags "$context" hosts && _ssh_hosts -S: && ret=0
       else
-        _files && ret=0
-        _ssh_hosts -S: && ret=0
-        _ssh_users -S@ && ret=0
+        _alternative "$context" \
+	    'files:: _files' \
+	    'hosts:: _ssh_hosts -S:' \
+	    'users:: _ssh_users -S@' && ret=0
       fi
     fi
     return ret
@@ -222,10 +243,12 @@ _ssh () {
 }
 
 _ssh_users () {
-  _combination accounts_users_hosts users "$@"
+  _tags any users && _combination accounts_users_hosts users "$@"
 }
 
 _ssh_hosts () {
+  _tags any hosts || return 1
+
   if [[ "$IPREFIX" == *@ ]]; then
     _combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@"
   else
diff --git a/Completion/User/_telnet b/Completion/User/_telnet
index b1c628d11..04c9fe69f 100644
--- a/Completion/User/_telnet
+++ b/Completion/User/_telnet
@@ -5,9 +5,9 @@
 #  telnet_hosts_ports_users
 #    The array that contains 3-tuples `host:port:user'.
 
-local state line expl
+local context state line expl
 typeset -A opt_args
-
+set -x
 if (( ! $+_telnet_short )); then
   local k help="$(telnet -\? < /dev/null 2>&1)"
   local -A optionmap
@@ -52,13 +52,11 @@ if (( ! $+_telnet_short )); then
   done
 fi
 
-[[ $#_telnet_long != 0 && (
-     -z "$compconfig[option_prefix]" ||
-     "$compconfig[option_prefix]" = *\!${words[1]}* ||
-     "$PREFIX" = [-+]* ) ]] && {
+if _tags any options && (( $#_telnet_long )) &&
+   { ! _style options prefix-needed yes || [[ "$PREFIX" = [-+]* ]] } ; then
   _description expl 'option'
   _describe -o option _telnet_long "$expl[@]"
-}
+fi
 
 _arguments -s \
   "$_telnet_short[@]" \
@@ -67,6 +65,8 @@ _arguments -s \
 
 case "$state" in
 hosts)
+  _tags "$context" hosts || return 1
+
   _description expl 'host'
   _combination telnet_hosts_ports_users \
     ${opt_args[-l]:+users=${opt_args[-l]:q}} \
@@ -74,6 +74,8 @@ hosts)
   ;;
 
 ports)
+  _tags "$context" ports || return 1
+
   _description expl 'port'
   _combination telnet_hosts_ports_users \
     ${opt_args[-l]:+users=${opt_args[-l]:q}} \
@@ -82,6 +84,8 @@ ports)
   ;;
 
 users)
+  _tags "$context" users || return 1
+
   _description expl 'user'
   _combination telnet_hosts_ports_users \
     ${line[2]:+hosts="${line[2]:q}"} \
diff --git a/Completion/User/_tiff b/Completion/User/_tiff
index e02ce6455..e3a023c24 100644
--- a/Completion/User/_tiff
+++ b/Completion/User/_tiff
@@ -19,7 +19,7 @@ fi
 
 local _in_tiff=yes
 
-local state line ret=1
+local context state line ret=1
 typeset -A opt_args
 
 case "$words[1]" in
@@ -194,6 +194,8 @@ if [[ -n "$state" ]]; then
       ;;
     esac
   else
+    _tags "$context" values || return 1
+
     _description expl 'compression scheme'
     compadd "$expl[@]" - none g4 packbits && ret=0
     compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0
diff --git a/Completion/User/_urls b/Completion/User/_urls
index 21d3deaa6..8c0c6f8d8 100644
--- a/Completion/User/_urls
+++ b/Completion/User/_urls
@@ -45,12 +45,13 @@ local localhttp_userdir="${${(@s.:.)compconfig[urls_localhttp]}[3]}"
 
 if [[ "$1" = -f ]]; then
   shift
-  _files "$@" && return
+  _tags argument:-f files && _files "$@" && return
 fi
 
 ipre="$IPREFIX"
 
-if ! compset -P '(#b)([-+.a-z0-9]#):'; then
+if ! compset -P '(#b)([-+.a-z0-9]#):' &&
+   _tags argument prefixes; then
   _description expl 'URL prefix'
   [[ -d $urls_path/bookmark ]] &&
     compadd "$@" "$expl[@]" -S '' bookmark: && ret=0
@@ -62,12 +63,14 @@ scheme="$match[1]"
 case "$scheme" in
   http|ftp|gopher)
     if ! compset -P //; then
-      compadd "$@" -S '' //
+      _tags "$scheme" slashes && compadd "$@" -S '' //
       return
     fi
   ;;
   file)
     if ! compset -P //; then
+      _tags file files || return 1
+
       if [[ -prefix / ]]; then
 	_path_files "$@" -S '' -g '*(^/)' && ret=0
 	_path_files "$@" -S/ -r '/' -/ && ret=0
@@ -81,8 +84,12 @@ case "$scheme" in
   bookmark)
     if [[ -f "$urls_path/$scheme/$PREFIX$SUFFIX" &&
 	  -s "$urls_path/$scheme/$PREFIX$SUFFIX" ]]; then
+      _tags bookmark caches || return 1
+
       compadd "$@" -QU -- "$ipre$(<"$urls_path/$scheme/$PREFIX$SUFFIX")" && ret=0
     else
+      _tags bookmark files || return 1
+
       _description expl 'bookmark'
       _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && ret=0
       _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0
@@ -92,7 +99,8 @@ case "$scheme" in
 esac
 
 # Complete hosts
-if ! compset -P '(#b)([^/]#)/'; then
+if ! compset -P '(#b)([^/]#)/' &&
+   _tags argument hosts; then
   uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t))
   (( $#uhosts )) || _hosts -S/ && ret=0
   [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
@@ -103,6 +111,9 @@ fi
 host="$match[1]"
 
 # Complete part after hostname
+
+_tags local files || return 1
+
 if [[ "$localhttp_servername" = "$host" ]]; then
   if compset -P \~; then
     if ! compset -P '(#b)([^/]#)/'; then
diff --git a/Completion/User/_user_at_host b/Completion/User/_user_at_host
index 6006ef63b..c33a024d9 100644
--- a/Completion/User/_user_at_host
+++ b/Completion/User/_user_at_host
@@ -1,15 +1,17 @@
 #autoload
 
-local expl nm="$compstate[nmatches]"
-
 if [[ -prefix 1 *@ ]]; then
+
+  _tags any:user-at hosts || return 1
+
   local user=${PREFIX/@}
+
   compset -P 1 '*@'
   _description expl "hostnames for $user"
   _combination accounts_users_hosts users="$user" hosts "$expl[@]" "$@"
 else
+  _tags any users || return 1
+
   _description expl "usernames"
   _combination accounts_users_hosts users -S@ -q "$expl[@]" "$@"
 fi
-
-[[ nm -ne compstate[nmatches] ]]
diff --git a/Completion/User/_users b/Completion/User/_users
index 6d0b1ce2f..9f2751c11 100644
--- a/Completion/User/_users
+++ b/Completion/User/_users
@@ -5,6 +5,8 @@
 
 local expl
 
+_tags any users || return 1
+
 _description expl user
 
 [[ "${(t)users}" = *array* ]] &&
diff --git a/Completion/User/_users_on b/Completion/User/_users_on
index 7a1ecd864..221ebb0fd 100644
--- a/Completion/User/_users_on
+++ b/Completion/User/_users_on
@@ -2,6 +2,8 @@
 
 local expl
 
+_tags any users || return 1
+
 if which users >/dev/null; then
   _description expl 'users logged on'
   compadd "$@" "$expl[@]" - $(users) && return 0
diff --git a/Completion/User/_wget b/Completion/User/_wget
index c9b671194..3a15d3867 100644
--- a/Completion/User/_wget
+++ b/Completion/User/_wget
@@ -1,6 +1,6 @@
 #compdef wget
 
-local state line
+local context state line
 typeset -A opt_args
 
 local tmp1 tmp2
diff --git a/Completion/User/_whois b/Completion/User/_whois
index 2043cbd4e..1e0f7707c 100644
--- a/Completion/User/_whois
+++ b/Completion/User/_whois
@@ -112,7 +112,7 @@ _whois_setup () {
 }
 
 _whois_single () {
-  local state line expl
+  local context state line expl
   typeset -A opt_args
   local tmp host
 
@@ -189,19 +189,25 @@ _whois_fwhois () {
 }
 
 _whois_hosts () {
-  compadd "$@" \
-    -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \
-    - ${_whois_servers%:?} || _hosts "$@"
+  _tags any hosts &&
+    compadd "$@" \
+      -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \
+      - ${_whois_servers%:?} || _hosts "$@"
 }
 
 _whois_ports () {
-  compadd "$@" - whois || _ports "$@"
+  _tags any ports && compadd "$@" - whois || _ports "$@"
 }
 
 (( $+functions[_whois:whois.internic.net] )) ||
 _whois:whois.internic.net () {
   if (( CURRENT == 1 )); then
-    compadd HELP DOMAIN HOST
+    local expl
+
+    _tags any string || return 1
+
+    _description expl string
+    compadd "$expl[@]" HELP DOMAIN HOST
   else
     _message 'string'
   fi
@@ -210,6 +216,11 @@ _whois:whois.internic.net () {
 (( $+functions[_whois:whois.nic.ad.jp] )) ||
 _whois:whois.nic.ad.jp () {
   if (( CURRENT == 1 )); then
+    local expl
+
+    _tags any string || return 1
+
+    _description expl string
     compadd HELP DOM NET HOST PERSON CONN COM
   else
     _message 'string'
diff --git a/Completion/User/_yp b/Completion/User/_yp
index e06f42a29..d0876f6dd 100644
--- a/Completion/User/_yp
+++ b/Completion/User/_yp
@@ -1,6 +1,6 @@
 #compdef ypcat ypmatch yppasswd ypwhich ypset ypserv ypbind yppush yppoll ypxfr domainname
 
-local line state ret=1
+local context line state ret=1
 typeset -A opt_args
 
 if (( ! $+_yp_cache_maps )); then
@@ -87,20 +87,31 @@ esac
 if [[ "$state" = map* ]]; then
   local expl
 
-  _description expl 'map name'
-
-  # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'.
-
-  compadd "$expl[@]" -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \
-          "$_yp_cache_maps[@]" && ret=0
   if [[ $+opt_args[-t] -eq 0 && "$state" != maponly ]]; then
-    _description expl 'nicknames'
-    compadd "$expl[@]" - "$_yp_cache_nicks[@]" && ret=0
+    _tags "$context" maps nicknames
+  else
+    _tags "$context" maps
   fi
+
+  while _tags; do
+    if _requested maps; then
+      # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'.
+
+      _description expl 'map name'
+      compadd "$expl[@]" -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \
+              "$_yp_cache_maps[@]" && ret=0
+    fi
+    if _requested nicknames; then
+      _description expl 'nicknames'
+      compadd "$expl[@]" - "$_yp_cache_nicks[@]" && ret=0
+    fi
+  done
 elif [[ "$state" = servers ]]; then
   if compset -P '*,'; then
-    _description expl 'server'
-    _hosts -qS, && ret=0
+    if _tags "$context" hosts; then
+      _description expl 'server'
+      _hosts -qS, && ret=0
+    fi
   else
     _message 'domain name'
   fi