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/_gdb52
-rw-r--r--Completion/User/_getconf37
-rw-r--r--Completion/User/_groups19
-rw-r--r--Completion/User/_lp76
-rw-r--r--Completion/User/_make33
-rw-r--r--Completion/User/_mh67
-rw-r--r--Completion/User/_nedit9
-rw-r--r--Completion/User/_netscape70
-rw-r--r--Completion/User/_tiff37
-rw-r--r--Completion/User/_urls180
-rw-r--r--Completion/User/_users12
-rw-r--r--Completion/User/_users_on8
12 files changed, 414 insertions, 186 deletions
diff --git a/Completion/User/_gdb b/Completion/User/_gdb
index ff54e6a07..55e149bb7 100644
--- a/Completion/User/_gdb
+++ b/Completion/User/_gdb
@@ -1,36 +1,44 @@
 #compdef gdb
 
-# This uses the configuration keys `ps_args' and `ps_listargs'
-# described in the `_wait' function.
+local cur="$words[CURRENT]" prev w list ret=1 expl
 
-local cur="$words[CURRENT]" prev w list ret=1
-
-_long_options -t '*=(CORE|SYM)FILE'	'_files' \
-		 '*=EXECFILE'   	'_files *(*)' \
-		 '*=TTY'		'compadd /dev/tty*' && return 0
+[[ "$PREFIX" = --* ]] &&
+    _arguments -- '*=(CORE|SYM)FILE:core file:_files' \
+		  '*=EXECFILE:executable:_files \*\(-\*\)' \
+		  '*=TTY:terminal device:compadd /dev/tty\*' && return 0
 
 if compset -P '-(cd|directory)='; then
   _files -/
 elif compset -P '-tty='; then
-  compadd - /dev/tty*
+  _wanted devices expl 'terminal device' compadd - /dev/tty*
 elif compset -P '-(exec|se)='; then
-  _files -/g '*(*)'
+  _description files expl executable
+  _files "$expl[@]" -g '*(-*)'
 elif compset -P '-(symbols|core|command)='; then
   _files
-elif compset -P -; then
-  compadd -QS '' - symbols\= exec\= se\= core\= command\= directory\= \
-	           cd\= tty\=
-  compadd - help h s e c x d nx n quiet q batch fullname f b
+elif [[ "$PREFIX" = -* ]]; then
+  if _wanted options; then
+    while _next_label options expl option; do
+      compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \
+                                  -directory\= -cd\= -tty\= && ret=0
+      compadd "$expl[@]"        - -help -h -s -e -c -x -d -nx -n -quiet -q \
+	    		          -batch -fullname -f -b && ret=0
+      (( ret )) || return 0
+    done
+  fi
 else
   prev="$words[CURRENT-1]"
 
   case "$prev" in
-  (-d) _files -/ && return 0 ;;
-  (-e) _files -/g '*(*)' && return 0 ;;
+  (-d)     _files -/ && return 0 ;;
   (-[csx]) _files && return 0 ;;
-  (-b) compadd -V baud 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
-                       9600 19200 38400 57600 115200 230400 && return 0 ;;
+  (-e)     _description files expl executable
+           _files "$expl[@]" -g '*(-*)' && return 0 ;;
+  (-b)     _wanted -V values expl 'baud rate' \
+               compadd 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
+		       9600 19200 38400 57600 115200 230400 && return 0 ;;
   esac
+
   w=( "${(@)words[2,-1]}" )
   while [[ "$w[1]" = -* ]]; do
     [[ "$w[1]" = -[decsxb] ]] && shift 1 w
@@ -38,13 +46,9 @@ else
   done
 
   if [[ $#w -gt 1 ]]; then
-    _files && ret=0
-    list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${w[1]:t}}}
-")
-    compadd -y list - ${${${(M)${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
-
-    return ret
+    _alternative 'files:: _files' "processes:: _pids -m ${w[1]:t}"
   else
-    _files -/g '*(*)'
+    _description files expl executable
+    _files "$expl[@]" -g '*(-*)'
   fi
 fi
diff --git a/Completion/User/_getconf b/Completion/User/_getconf
index 7ce709588..59e9a83bc 100644
--- a/Completion/User/_getconf
+++ b/Completion/User/_getconf
@@ -1,20 +1,19 @@
 #compdef getconf
 
-local expl
+local expl ret=1
 
 if [[ CURRENT -eq 2 ]]; then
   _tags syswideconfig pathconfig standardsconfig
 
   while _tags; do
-    if _requested -V syswideconfig expl 'systemwide configuration variables'
-    then
-      compadd "$expl[@]" -S '' ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX \
+    _requested -V syswideconfig expl 'systemwide configuration variables' \
+      compadd -S '' ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX \
           BC_STRING_MAX CHILD_MAX COLL_WEIGHTS_MAX EXPR_NEST_MAX LINE_MAX \
-	  NGROUPS_MAX OPEN_MAX RE_DUP_MAX STREAM_MAX TZNAME_MAX
-    fi
-    if _requested -V standardsconfig \
-        expl 'system-standards configuration variables'; then
-      compadd "$expl[@]" -S '' _POSIX_CHILD_MAX _POSIX_LINK_MAX \
+	  NGROUPS_MAX OPEN_MAX RE_DUP_MAX STREAM_MAX TZNAME_MAX && ret=0
+
+    _requested -V standardsconfig \
+        expl 'system-standards configuration variables' \
+      compadd -S '' _POSIX_CHILD_MAX _POSIX_LINK_MAX \
           _POSIX_MAX_CANON _POSIX_MAX_INPUT _POSIX_NAME_MAX _POSIX_NGROUPS_MAX \
 	  _POSIX_OPEN_MAX _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX \
 	  _POSIX_STREAM_MAX _POSIX_TZNAME_MAX _POSIX_VERSION \
@@ -22,15 +21,17 @@ if [[ CURRENT -eq 2 ]]; then
 	  POSIX2_BC_STRING_MAX POSIX2_COLL_WEIGHTS_MAX POSIX2_EXPR_NEST_MAX \
 	  POSIX2_LINE_MAX POSIX2_RE_DUP_MAX POSIX2_VERSION POSIX2_C_BIND \
 	  POSIX2_C_DEV POSIX2_FORT_DEV POSIX2_FORT_RUN POSIX2_LOCALEDEF \
-	  POSIX2_SW_DEV _XOPEN_VERSION
-    fi
-    if _requested -V pathconfig expl 'system path configuration variables'
-    then
-      compadd "$expl[@]" -S '' PIPE_BUF _POSIX_CHOWN_RESTRICTED \
-          _POSIX_NO_TRUNC _POSIX_VDISABLE
-      compadd "$expl[@]" -S ' ' LINK_MAX MAX_CANON MAX_INPUT NAME_MAX PATH_MAX \
-          PIPE_BUF
-    fi
+	  POSIX2_SW_DEV _XOPEN_VERSION && ret=0
+
+    _requested pathconfig &&
+        while _next_label -V pathconfig expl 'system path configuration variables'; do
+          compadd "$expl[@]" -S '' PIPE_BUF _POSIX_CHOWN_RESTRICTED \
+                                   _POSIX_NO_TRUNC _POSIX_VDISABLE && ret=0
+          compadd "$expl[@]" -S ' ' LINK_MAX MAX_CANON MAX_INPUT NAME_MAX \
+                                    PATH_MAX PIPE_BUF && ret=0
+          (( ret )) || break
+        done
+    (( ret )) || return 0
   done
 else
   _files -/
diff --git a/Completion/User/_groups b/Completion/User/_groups
index 975189174..27444d26d 100644
--- a/Completion/User/_groups
+++ b/Completion/User/_groups
@@ -1,6 +1,19 @@
 #compdef newgrp
 
-: ${(A)groups:=${${(s: :)$(</etc/group)}%%:*}}
-# : ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use NIS
+local expl groups tmp
 
-compadd $groups
+_wanted groups || return 1
+
+if ! zstyle -a ":completion:${curcontext}:" groups groups; then
+  (( $+_cache_groups )) ||
+      if (( ${+commands[ypcat]} )) &&
+	  tmp=$(_call groups ypcat group.byname); then
+        : ${(A)_cache_groups:=${${(f)tmp}%%:*}} # If you use YP
+      else
+        : ${(A)_cache_groups:=${${(s: :)$(</etc/group)}%%:*}}
+      fi
+
+  groups=( "$_cache_groups[@]" )
+fi
+
+_all_labels groups expl group compadd "$@" - "$groups[@]"
diff --git a/Completion/User/_lp b/Completion/User/_lp
index f37c62a14..cfa2a147c 100644
--- a/Completion/User/_lp
+++ b/Completion/User/_lp
@@ -1,50 +1,98 @@
 #compdef lp lpr lpq lprm
 
-local file expl ret=1 list disp strs shown
+local expl ret=1 printer list disp strs shown
 
 if (( ! $+_lp_cache )); then
+  local file entry names i
+
    file=( /etc/(printcap|printers.conf)(N) )
 
-  if (( $#file )); then
-    _lp_cache=( "${(@)${(@s:|:)${(@)${(@f)$(< $file[1])}:#[    \#]*}%%:*}%%[ 	]*}" )
-  else
-    # Default value. Could probably be improved
+  _lp_cache=()
+  _lp_alias_cache=()
 
-    _lp_cache=( lp0 )
+  if (( $#file )); then
+    while read entry; do
+      if [[ "$entry" = [^[:blank:]\#\*_]*:* ]]; then
+        names=( "${(s:|:)entry%%:*}" )
+        if [[ "$entry" = *:description=* ]]; then
+          disp="${${entry##*:description=}%%:*}"
+        elif [[ $#names -gt 1 && "$names[-1]" = *\ * ]] ;then
+          disp="$names[-1]"
+        else
+          disp=''
+        fi
+        if [[ -n "$disp" ]]; then
+          _lp_cache=( "$_lp_cache[@]" "${names[1]}:${disp}" )
+  	_lp_alias_cache=( "$_lp_alias_cache[@]" "${(@)^names[2,-1]:#*\ *}:${disp}" )
+        else
+          _lp_cache=( "$_lp_cache[@]" "${names[1]}" )
+  	_lp_alias_cache=( "$_lp_alias_cache[@]" "${(@)names[2,-1]:#*\ *}" )
+        fi
+      fi
+    done < $file[1]
   fi
+  (( $#_lp_cache )) || _lp_cache=( 'lp0:Guessed default printer' )
+  (( $#_lp_alias_cache )) || unset _lp_alias_cache
 fi
 
 if compset -P -P || [[ "$words[CURRENT-1]" = -P ]]; then
-  _wanted printers expl printer && compadd "$expl" - "$_lp_cache[@]"
+  if _wanted printers; then
+    if zstyle -T ":completion:${curcontext}:printers" verbose; then
+      zformat -a list ' -- ' "$_lp_cache[@]"
+      disp=(-ld list)
+    else
+      disp=()
+    fi
+    _all_labels printers expl printer \
+        compadd "$disp[@]" - "${(@)_lp_cache%%:*}" && return 0
+
+    (( $+_lp_alias_cache )) || return 1
+
+    if zstyle -T ":completion:${curcontext}:printers" verbose; then
+      zformat -a list ' -- ' "$_lp_alias_cache[@]"
+      disp=(-ld list)
+    else
+      disp=()
+    fi
+    compadd "$expl[@]" "$disp[@]" - "${(@)_lp_alias_cache%%:*}"
+  else
+    return 1
+  fi
 else
   if [[ "$words[1]" = (lpq|lprm) ]]; then
-    list=( "${(@M)${(f@)$(lpq)}:#[0-9]*}" )
+    if [[ "$words" = *-P* ]]; then
+      printer=(-P "${${words##*-P( |)}%% *}")
+    else
+      printer=()
+    fi
+    list=( ${(M)"${(f@)$(_call jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
 
     if (( $#list )); then
       _tags users jobs
 
       while _tags; do
-        if _requested users expl user; then
+        if _requested users; then
           strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
           if [[ -z "$shown" ]] &&
-             zstyle -t ":completion:${curcontext}:users" verbose; then
+             zstyle -T ":completion:${curcontext}:users" verbose; then
             disp=(-ld list)
   	  shown=yes
           else
   	  disp=()
           fi
-          compadd "$expl[@]" "$disp[@]" - "$strs[@]" || _users && ret=0
+	  _all_labels users expl user compadd "$disp[@]" - "$strs[@]" ||
+              _users && ret=0
         fi
-        if _requested jobs expl job; then
+        if _requested jobs; then
           strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
           if [[ -z "$shown" ]] &&
-             zstyle -t ":completion:${curcontext}:jobs" verbose; then
+             zstyle -T ":completion:${curcontext}:jobs" verbose; then
             disp=(-ld list)
   	  shown=yes
           else
   	  disp=()
           fi
-          compadd "$expl[@]" "$disp[@]" - "$strs[@]" && ret=0
+          _all_labels jobs expl job compadd "$disp[@]" - "$strs[@]" && ret=0
         fi
         (( ret )) || return 0
       done
diff --git a/Completion/User/_make b/Completion/User/_make
index d576b0308..741cbb7dc 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -1,3 +1,32 @@
-#defcomp make gmake pmake
+#compdef make gmake pmake
 
-complist -s "\$(awk '/^[a-zA-Z0-9][^/ 	]+:/ {print \$1}' FS=: [mM]akefile)"
+local prev="$words[CURRENT-1]" file expl tmp
+
+if [[ "$prev" = -[CI] ]]; then
+  _files -/
+elif [[ "$prev" = -[foW] ]]; then
+  _files
+else
+  file="$words[(I)-f]"
+  if (( file )); then
+    file="$words[file+1]"
+  elif [[ -e Makefile ]]; then
+    file=Makefile
+  elif [[ -e makefile ]]; then
+    file=makefile
+  else
+    file=''
+  fi
+
+  if [[ -n "$file" ]] && _wanted targets; then
+    tmp=(
+          $(awk '/^[a-zA-Z0-9][^\/ \t]+:/ {print $1}
+ 	      /^\.include  *<bsd\.port\.(subdir\.|pre\.)?mk>/ || /^\.include  *".*mk\/bsd\.pkg\.(subdir\.)?mk"/ {
+ 	        print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum" }' \
+ 	     FS=: $file)
+         )
+    _all_labels targets expl 'make target' compadd "$tmp[@]" && return 0
+  fi
+  compset -P 1 '*='
+  _files
+fi
diff --git a/Completion/User/_mh b/Completion/User/_mh
index 67ce49fd2..c1f397744 100644
--- a/Completion/User/_mh
+++ b/Completion/User/_mh
@@ -1,28 +1,36 @@
-#defcomp folder comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath mhpatch
+#compdef folder folders comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath
 
 # Completion for all possible MH commands.
 # Alter the following two to your own mh directory and the directory
 # where standard mh library files live.  (It works anyway, but this
 # will save a little time.)
+
 local mymhdir=~/Mail
 local mhlib=/usr/lib/mh
 
+local prev="$words[CURRENT-1]" expl
+
 # To be on the safe side, check this exists and if not, get it anyway.
 [[ -d $mymhdir ]] || mymhdir=$(mhpath +)
 
-if [[ -iprefix - ]]; then
+if compset -P 1 -; then
   # get list of options, which MH commands can generate themselves
   # awk is just too icky to use for this, sorry.  send me one if
   # you come up with it.
-  compadd -m $($COMMAND -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
-    $n = $1;
-    $n =~ s/\)//g;
-    print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n";
-  }')
-  return
-elif [[ -iprefix '+' || -iprefix '@' || -current -1 -draftfolder ]]; then
+  if _wanted options; then
+    _all_labels options expl option \
+        compadd - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
+            $n = $1;
+            $n =~ s/\)//g;
+            print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n";
+          }')
+    return
+  fi
+  return 1
+elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then
   # Complete folder names.
   local mhpath
+
   if [[ $IPREFIX != '@' ]]; then
     [[ $IPREFIX = '+' ]] || IPREFIX=+
     mhpath=$mymhdir
@@ -30,13 +38,12 @@ elif [[ -iprefix '+' || -iprefix '@' || -current -1 -draftfolder ]]; then
     mhpath=$(mhpath)
   fi
 
-  # painless, or what?
-  complist -W mhpath -/
-elif [[ -mcurrent -1 -(editor|(whatnow|rmm|show|more)proc) ]]; then
-  complist -c
-elif [[ -current -1 -file ]]; then
-  complist -f
-elif [[ -mcurrent -1 -(form|audit|filter) ]]; then
+  _wanted files expl 'MH folder' _path_files -W mhpath -/
+elif [[ "$prev" = -(editor|(whatnow|rmm|show|more)proc) ]]; then
+  _command_names -e
+elif [[ "$prev" = -file ]]; then
+  _files
+elif [[ "$prev" = -(form|audit|filter) ]]; then
   # Need some MH template file, which may be in our own MH directory
   # or with the standard library.
   local mhfpath
@@ -44,15 +51,16 @@ elif [[ -mcurrent -1 -(form|audit|filter) ]]; then
   [[ -d $mhlib ]] || { mhlib=$(mhparam mhlproc); mhlib=$mhlib:h; }
   mhfpath=($mymhdir $mhlib)
 
-  complist -W mhfpath -g '*(.)'
-elif [[ -mcurrent -1 -(no|)cc ]]; then
-  compadd -m all to cc me
-elif [[ -mcurrent -1 -[rw]cache ]]; then
-  compadd -m public private never ask
+  _wanted files expl 'MH template file' _files -W mhfpath -g '*(.)'
+elif [[ "$prev" = -(no|)cc ]]; then
+  _wanted -C "$prev" values expl 'CC address' compadd all to cc me
+elif [[ "$prev" = -[rw]cache ]]; then
+  _wanted -C "$prev" values expl cache compadd public private never ask
 else
   # Generate sequences.
-  local foldnam folddir f
-  for f in $argv; do
+  local foldnam folddir f ret
+
+  for f in $words; do
     [[ $f = [@+]* ]] && foldnam=$f
   done
   if [[ $foldnam = '+'* ]]; then
@@ -64,7 +72,14 @@ else
     # leaving foldnam empty works here
   fi
 
-  complist -s '$(mark $foldnam | awk -F: '\''{ print $1 }'\'')'
-  compadd -m reply next cur prev first last all unseen
-  complist -W folddir -g '<->'
+  if _wanted sequences; then
+    while _next_label sequences expl sequence; do
+      compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') &&
+        ret=0
+      compadd "$expl[@]" reply next cur prev first last all unseen && ret=0
+      _files "$expl[@]" -W folddir -g '<->' && ret=0
+      (( ret )) || return 0
+    done
+  fi
+  return ret
 fi
diff --git a/Completion/User/_nedit b/Completion/User/_nedit
index 1f030e369..a3fcd9785 100644
--- a/Completion/User/_nedit
+++ b/Completion/User/_nedit
@@ -40,10 +40,11 @@ else
     '(-background)-bg[specify background color]:background color:_x_color' \
     '(-fg)-foreground:foreground color:_x_color' \
     '(-foreground)-fg[specify foreground color]:foreground color:_x_color' \
-    '-import[load additional preferences file]:nedit preferences file:_files' \
+    '*-import[load additional preferences file]:nedit preferences file:_files' \
     "$nedit_common[@]"
 fi
 
-[[ $state = lang ]] && _wanted neditlanguages expl 'language mode' &&
-    compadd "$expl[@]" -  ${(f)"$(sed -n \
-      '/^nedit.languageMode/,/^nedit/ s/.*	\([^:]*\).*/\1/p' < ~/.nedit)"}
+[[ $state = lang ]] &&
+    _wanted neditlanguages expl 'language mode' \
+        compadd -  ${(f)"$(sed -n \
+            '/^nedit.languageMode/,/^nedit/ s/.*	\([^:]*\).*/\1/p' < ~/.nedit)"}
diff --git a/Completion/User/_netscape b/Completion/User/_netscape
index f176083d2..b29c27c6c 100644
--- a/Completion/User/_netscape
+++ b/Completion/User/_netscape
@@ -1,8 +1,9 @@
 #compdef netscape
 
-local state
+local curcontext="$curcontext" state line ret=1
+typeset -A opt_args
 
-_x_arguments \
+_x_arguments -C \
   '-xrm:resource:_x_resource' \
   '-help[show usage message]' \
   '-version[show the version number and build date]' \
@@ -21,55 +22,70 @@ _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" ]] &&
+  _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
+        _wanted types expl 'data type' \
+            compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript &&
+                ret=0
       else
-        _path_files -W ~
+        _files -W ~ && ret=0
       fi
     ;;
-    mailto* )
+    mailto*)
       compset -P "*,"
       if compset -P '*@'; then
-        _description expl 'remote host name'
-        _hosts "$expl[@]" -q -S,
+        _wanted hosts expl 'remote host name' _hosts -q -S, && ret=0
       else
-        _description expl 'login name'
-        _users "$expl[@]" -q -S@
+        _wanted users expl 'login name' _users -q -S@ && ret=0
       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 _wanted commands; then
+        if [[ -z "$QIPREFIX" ]]; then
+	  _all_labels commands expl 'remote commands' \
+  	      compadd  -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' - \
+                      $remote_commands && ret=0
+        else
+	  _all_labels commands expl 'remote commands' \
+              compadd -qS '(' -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 compset -P about: ; then
+    _wanted values expl 'about what' \
+        compadd authors blank cache document fonts global hype image-cache \
+            license logo memory-cache mozilla plugins && ret=0
   else
-    compadd -S '' about: mocha: javascript:
-    _urls "$@"
+    if _wanted prefixes; then
+      while _next_label prefixes expl 'URL prefix'; do
+        compadd "$expl[@]" -S '' about: mocha: javascript: && ret=0
+        _urls "$@" && ret=0
+	(( ret )) || return 0
+      done
+    fi
   fi
 fi
+
+return ret
diff --git a/Completion/User/_tiff b/Completion/User/_tiff
index bbc331442..8fd008f0f 100644
--- a/Completion/User/_tiff
+++ b/Completion/User/_tiff
@@ -10,21 +10,22 @@ fi
 
 if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then
   if (( ! $# )); then
-    _description expl 'picture file'
+    _description files expl 'picture file'
     set -- "$expl[@]"
   fi
-  _path_files "$@" -g "$pat" || _files "$@" -g '*.(#i)tiff'
+  _wanted files expl 'picture file' _path_files "$@" -g "$pat" - ||
+      _files "$@" "$expl[@]" -g '*.(#i)tiff'
   return
 fi
 
 local _in_tiff=yes
 
-local state line ret=1
-typeset -A options
+local curcontext="$curcontext" state line ret=1
+typeset -A opt_args
 
 case "$words[1]" in
 tiff2bw)
-  _arguments \
+  _arguments -C \
     '-c[specify compression scheme]:compression scheme:->compress' \
     '-r[specify rows per strip]:rows per strip:' \
     '-R[specify percentage of red channel]:percentage of red channel:' \
@@ -59,7 +60,7 @@ tiffcmp)
     ':second input TIFF file:_files -g \*.\(\#i\)' && ret=0
   ;;
 tiffcp)
-  _arguments \
+  _arguments -C \
     '-B[write output in bin-endian byte order]' \
     '-c[specify compression scheme]:compression scheme:->compress' \
     '-o[set initial TIFF directory (file offset)]:file offset:' \
@@ -74,7 +75,7 @@ tiffcp)
     '*:input TIFF file:_files -g \*.\(\#i\)' && ret=0
   ;;
 tiffdither)
-  _arguments \
+  _arguments -C \
     '-c[specify compression scheme]:compression scheme:->compress' \
     '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \
     '-r[specify rows per strip]:rows per strip:' \
@@ -102,7 +103,7 @@ tiffinfo)
     '*:input TIFF file:_files -g \*.\(\#i\)' && ret=0
   ;;
 tiffmedian)
-  _arguments \
+  _arguments -C \
     '-r[specify rows per strip]:rows per strip:' \
     '-C[specify number of colormap entries]:number of colormap entries:' \
     '-c[specify compression scheme]:compression scheme:->compress' \
@@ -135,14 +136,14 @@ fax2tiff)
     ':FAX input file:_files -g \*.\(\#i\)\(g\[34\]\|fax\)' && ret=0
   ;;
 gif2tiff)
-  _arguments \
+  _arguments -C \
     '-r[specify rows per strip]:rows per strip:' \
     '-c[specify compression scheme]:compression scheme:->compress' \
     ':input GIF file:_files -g \*.\(\#i\)gif' \
     ':output file:_files -g \*.\(\#i\)tiff' && ret=0
   ;;
 ppm2tiff)
-  _arguments \
+  _arguments -C \
     '-r[specify rows per strip]:rows per strip:' \
     '-c[specify compression scheme]:compression scheme:->compress' \
     '-R[specify resolution]:resolution:' \
@@ -150,14 +151,14 @@ ppm2tiff)
     ':output file:_files -g \*.\(\#i\)tiff' && ret=0
   ;;
 ras2tiff)
-  _arguments \
+  _arguments -C \
     '-r[specify rows per strip]:rows per strip:' \
     '-c[specify compression scheme]:compression scheme:->compress' \
     ':input raster image file:_files -g \*.\(\#i\)ras\(\|t\)' \
     ':output file:_files -g \*.\(\#i\)tiff' && ret=0
   ;;
 pal2rgb)
-  _arguments \
+  _arguments -C \
     '-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \
     '-p[set sample packing]:sample packing:(contig separate)' \
     '-c[specify compression scheme]:compression scheme:->compress' \
@@ -166,7 +167,7 @@ pal2rgb)
     ':output file:_files -g \*.\(\#i\)tiff' && ret=0
   ;;
 *)
-  _description expl 'picture file'
+  _description files expl 'picture file'
   _files "$expl[@]" -g "$pat" && ret=0
 esac
 
@@ -194,9 +195,13 @@ if [[ -n "$state" ]]; then
       ;;
     esac
   else
-    _description expl 'compression scheme'
-    compadd "$expl[@]" - none g4 packbits && ret=0
-    compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0
+    if _wanted values; then
+      while _next_label values expl 'compression scheme'; do
+        compadd "$expl[@]" - none g4 packbits && ret=0
+        compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0
+	(( ret )) || return 0
+      done
+    fi
   fi
 fi
 
diff --git a/Completion/User/_urls b/Completion/User/_urls
index 19f7eea3a..03e8902cb 100644
--- a/Completion/User/_urls
+++ b/Completion/User/_urls
@@ -1,65 +1,155 @@
-#autoload
+#compdef curl
 
 # Usage: _urls [-f]
 # Options:
-#  -f : complete files.
-
-# To complete URLs, you must make a URL database locally such as:
+#  -f : complete files first.
+#
+# Configuration styles used:
+#
+#  path
+#    The path to a directory containing a URL database, such as:
+#
+#      % cd ~/.zsh/urls
+#      % find . -ls
+#      ... drwxr-xr-x ... 512 Sep  3 02:46 .
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http
+#      ... drwxr-xr-x ... 512 Sep  3 02:52 ./http/www.zsh.org
+#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla
+#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers
+#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999
+#      ... -rw-r--r-- ...   0 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999/index.html
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.auc.dk
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.auc.dk/zsh
+#      ... drwxr-xr-x ... 512 Sep  3 02:47 ./bookmark
+#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./bookmark/zsh
+#      ... -rw-r--r-- ...  27 Sep  3 02:47 ./bookmark/zsh/home
+#      ... -rw-r--r-- ...  20 Sep  3 02:48 ./bookmark/zsh/meta
+#      % cat bookmark/zsh/home 
+#      http://sunsite.auc.dk/zsh/
+#      % cat bookmark/zsh/meta
+#      http://www.zsh.org/
 #
-# % cd ~/.zsh/urls
-# % find . -ls
-# ... drwxr-xr-x ... 512 Sep  3 02:46 .
-# ... drwxr-xr-x ... 512 Sep  3 02:48 ./http
-# ... drwxr-xr-x ... 512 Sep  3 02:52 ./http/www.zsh.org
-# ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla
-# ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers
-# ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999
-# ... -rw-r--r-- ...   0 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999/index.html
-# ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.auc.dk
-# ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.auc.dk/zsh
-# ... drwxr-xr-x ... 512 Sep  3 02:47 ./bookmark
-# ... drwxr-xr-x ... 512 Sep  3 02:48 ./bookmark/zsh
-# ... -rw-r--r-- ...  27 Sep  3 02:47 ./bookmark/zsh/home
-# ... -rw-r--r-- ...  20 Sep  3 02:48 ./bookmark/zsh/meta
+#  local
+#    Specify a local web server as an array with three elements:
+#      <hostname> <doc root> <user area>
+#    where hostname is the name of the web server, doc root is the path to
+#    the default web pages for the server and user area is the directory
+#    name used by a user placing web pages within their home area.
+#    E.g.:
+#      zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html
 
-local ipre scheme dirs files
+local ipre scheme host user uhosts ret=1 expl
+local urls_path localhttp
+zstyle -s ":completion:${curcontext}:urls" path urls_path ||
+    urls_path="${ZDOTDIR:-$HOME}/.zsh/urls"
+zstyle -a ":completion:${curcontext}:urls" local localhttp
+local localhttp_servername="$localhttp[1]"
+local localhttp_documentroot="$localhttp[2]"
+local localhttp_userdir="$localhttp[3]"
 
 if [[ "$1" = -f ]]; then
   shift
-  _files "$@" && return
-fi
-
-if [[ -z "$compconfig[_urls_dir]" ]]; then
-  compconfig[_urls_dir]=${ZDOTDIR:-$HOME}/.zsh/urls
+  _wanted -C -f files && _files "$@" && return
 fi
 
 ipre="$IPREFIX"
 
-if [[ -prefix [-+.a-z0-9]#: ]]; then
-  scheme="${PREFIX%%:*}"
-  compset -P "[-+.a-z0-9]#:"
-else
-  compadd -S '' http:// ftp:// bookmark:
-  return
+if ! compset -P '(#b)([-+.a-z0-9]#):' && _wanted -C argument prefixes; then
+  while _next_label prefixes expl 'URL prefix' "$@"; do
+    [[ -d $urls_path/bookmark ]] &&
+      compadd "$expl[@]" -S '' bookmark: && ret=0
+    compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0
+    (( ret )) || return 0
+  done
+  return ret
 fi
+scheme="$match[1]"
 
 case "$scheme" in
-  http) compset -P // || { compadd "$@" -S '' //; return };;
-  ftp) compset -P // || { compadd "$@" -S '' //; return };;
+  http|ftp|gopher)
+    if ! compset -P //; then
+      _wanted -C "$scheme" prefixes expl 'end of prefix' compadd "$@" -S '' //
+      return
+    fi
+  ;;
+  file)
+    if ! compset -P //; then
+      _wanted -C file files || return 1
+
+      while _next_label files expl 'local file' "$@"; do
+        if [[ -prefix / ]]; then
+	  _path_files "$expl[@]" -S '' -g '*(^/)' && ret=0
+	  _path_files "$expl[@]" -S/ -r '/' -/ && ret=0
+        elif [[ -z "$PREFIX" ]]; then
+	  compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0
+        fi
+	(( ret )) || return 0
+      done
+      return ret
+    fi
+  ;;
+  bookmark)
+    if [[ -f "$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" &&
+	  -s "$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" ]]; then
+      _wanted -C bookmark bookmarks expl bookmarks \
+          compadd "$@" -U - \
+              "$ipre$(<"$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0
+    else
+      if _wanted -C bookmark files; then
+        while _next_label files expl 'bookmark'; do
+          _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && 
+              ret=0
+          _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0
+          (( ret )) || return 0
+        done
+      fi
+    fi
+    return ret
+  ;;
 esac
 
-if [[ "$scheme" = bookmark &&
-      -f "$compconfig[_urls_dir]/$scheme/$PREFIX$SUFFIX" &&
-      -s "$compconfig[_urls_dir]/$scheme/$PREFIX$SUFFIX" ]]; then
-  compadd "$@" -QU -- "$ipre$(<"$compconfig[_urls_dir]/$scheme/$PREFIX$SUFFIX")"
-else
-  dirs=($compconfig[_urls_dir]/$scheme/$PREFIX*$SUFFIX(/:t))
-  files=($compconfig[_urls_dir]/$scheme/$PREFIX*$SUFFIX(.:t))
-  compset -P '*/'
-  compadd "$@" -Q -S '/' - $dirs
-  if [[ "$scheme" = bookmark ]]; then
-    compadd "$@" -QS '' - $files
+# Complete hosts
+if ! compset -P '(#b)([^/]#)/' && _wanted hosts; then
+  uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t))
+
+  while _next_label hosts expl host "$@"; do
+    (( $#uhosts )) || _hosts -S/ && ret=0
+    [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
+    compadd "$expl[@]" -S/ - $uhosts && ret=0
+    (( ret )) || return 0
+  done
+  return ret
+fi
+host="$match[1]"
+
+# Complete part after hostname
+
+_wanted -C local files || return 1
+
+if [[ "$localhttp_servername" = "$host" ]]; then
+  if compset -P \~; then
+    if ! compset -P '(#b)([^/]#)/'; then
+      _users -S/
+      return
+    fi
+    user="$match[1]"
+    while _next_label files expl 'local file'; do
+      _path_files "$expl[@]" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0
+      _path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0
+      (( ret )) || return 0
+    done
   else
-    compadd "$@" -Q - $files
+    while _next_label files expl 'local file'; do
+      _path_files "$expl[@]" -W $localhttp_documentroot -g '*(^/)' && ret=0
+      _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0
+      (( ret )) || return 0
+    done
   fi
+else
+  while _next_label files expl 'local file'; do
+    _path_files "$expl[@]" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0
+    _path_files "$expl[@]" -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0
+    (( ret )) || return 0
+  done
 fi
+return $ret
diff --git a/Completion/User/_users b/Completion/User/_users
index fc1e87e52..d04731af9 100644
--- a/Completion/User/_users
+++ b/Completion/User/_users
@@ -1,6 +1,10 @@
-#autoload
+#compdef last passwd groups
 
-local expl
+local expl users
 
-_description expl user
-compgen "$@" "$expl[@]" -u
+_wanted users || return 1
+
+zstyle -a ":completion:${curcontext}:" users users &&
+    _all_labels users expl user compadd "$@" - "$users[@]" && return 0
+
+_all_labels users expl user compadd "$@" - "${(@k)userdirs}"
diff --git a/Completion/User/_users_on b/Completion/User/_users_on
index 920688089..b19cff6e7 100644
--- a/Completion/User/_users_on
+++ b/Completion/User/_users_on
@@ -1,10 +1,12 @@
-#autoload write
+#compdef write
 
 local expl
 
+_wanted users || return 1
+
 if which users >/dev/null; then
-  _description expl users logged on
-  compadd "$@" "$expl[@]" - $(users) && return 0
+  _all_labels users expl 'users logged on' \
+      compadd "$@" - $(_call users users) && return 0
 else
   # Other methods of finding out users logged on should be added here
   return 1