about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:25:40 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:25:40 +0000
commit8ceb54fbc2f879e0e80f58c18761bd54db07e5f7 (patch)
treed97bf208b73d5385b174c454e4f41839dc421d25 /Completion
parent6c1fb551ba0973c9a86e1ea479d553d66c6bf6b7 (diff)
downloadzsh-8ceb54fbc2f879e0e80f58c18761bd54db07e5f7.tar.gz
zsh-8ceb54fbc2f879e0e80f58c18761bd54db07e5f7.tar.xz
zsh-8ceb54fbc2f879e0e80f58c18761bd54db07e5f7.zip
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/_brace_parameter2
-rw-r--r--Completion/Base/_command_names2
-rw-r--r--Completion/Base/_condition2
-rw-r--r--Completion/Base/_default2
-rw-r--r--Completion/Base/_equal2
-rw-r--r--Completion/Base/_long_options86
-rw-r--r--Completion/Base/_math4
-rw-r--r--Completion/Base/_parameter2
-rw-r--r--Completion/Base/_precommand2
-rw-r--r--Completion/Base/_redirect2
-rw-r--r--Completion/Base/_subscript2
-rw-r--r--Completion/Base/_tilde2
-rw-r--r--Completion/Base/_vars2
-rw-r--r--Completion/Builtins/_aliases2
-rw-r--r--Completion/Builtins/_arrays2
-rw-r--r--Completion/Builtins/_autoload2
-rw-r--r--Completion/Builtins/_bg_jobs2
-rw-r--r--Completion/Builtins/_bindkey2
-rw-r--r--Completion/Builtins/_builtin2
-rw-r--r--Completion/Builtins/_cd4
-rw-r--r--Completion/Builtins/_command2
-rw-r--r--Completion/Builtins/_dirs2
-rw-r--r--Completion/Builtins/_disable2
-rw-r--r--Completion/Builtins/_echotc2
-rw-r--r--Completion/Builtins/_enable2
-rw-r--r--Completion/Builtins/_fc2
-rw-r--r--Completion/Builtins/_functions2
-rw-r--r--Completion/Builtins/_hash2
-rw-r--r--Completion/Builtins/_jobs2
-rw-r--r--Completion/Builtins/_kill2
-rw-r--r--Completion/Builtins/_limits2
-rw-r--r--Completion/Builtins/_sched2
-rw-r--r--Completion/Builtins/_set2
-rw-r--r--Completion/Builtins/_setopt2
-rw-r--r--Completion/Builtins/_source2
-rw-r--r--Completion/Builtins/_trap2
-rw-r--r--Completion/Builtins/_unhash2
-rw-r--r--Completion/Builtins/_unsetopt2
-rw-r--r--Completion/Builtins/_vars_eq2
-rw-r--r--Completion/Builtins/_wait2
-rw-r--r--Completion/Builtins/_which2
-rw-r--r--Completion/Builtins/_zftp4
-rw-r--r--Completion/Builtins/_zle2
-rw-r--r--Completion/Builtins/_zmodload2
-rw-r--r--Completion/Commands/_correct_filename2
-rw-r--r--Completion/Commands/_correct_word12
-rw-r--r--Completion/Commands/_most_recent_file2
-rw-r--r--Completion/Core/_compalso12
-rw-r--r--Completion/Core/_multi_parts287
-rw-r--r--Completion/Core/_path_files443
-rw-r--r--Completion/Core/_sep_parts78
-rw-r--r--Completion/Core/compinit72
-rw-r--r--Completion/README359
-rw-r--r--Completion/User/_a2ps2
-rw-r--r--Completion/User/_compress2
-rw-r--r--Completion/User/_configure9
-rw-r--r--Completion/User/_dd2
-rw-r--r--Completion/User/_dvi2
-rw-r--r--Completion/User/_find2
-rw-r--r--Completion/User/_gunzip2
-rw-r--r--Completion/User/_gzip2
-rw-r--r--Completion/User/_hosts2
-rw-r--r--Completion/User/_make4
-rw-r--r--Completion/User/_man2
-rw-r--r--Completion/User/_mh2
-rw-r--r--Completion/User/_pdf2
-rw-r--r--Completion/User/_ps2
-rw-r--r--Completion/User/_rcs2
-rw-r--r--Completion/User/_rlogin2
-rw-r--r--Completion/User/_strip2
-rw-r--r--Completion/User/_stty2
-rw-r--r--Completion/User/_tar2
-rw-r--r--Completion/User/_tex2
-rw-r--r--Completion/User/_uncompress2
-rw-r--r--Completion/User/_x_options2
-rw-r--r--Completion/User/_xfig2
76 files changed, 526 insertions, 974 deletions
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
index 3d663a777..d45e317be 100644
--- a/Completion/Base/_brace_parameter
+++ b/Completion/Base/_brace_parameter
@@ -1,4 +1,4 @@
-#defcomp -brace-parameter-
+#compdef -brace-parameter-
 
 if [[ "$SUFFIX" = *\}* ]]; then
   ISUFFIX="${SUFFIX#*\}}$ISUFFIX"
diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names
index f21af674c..8f75f1a77 100644
--- a/Completion/Base/_command_names
+++ b/Completion/Base/_command_names
@@ -1,4 +1,4 @@
-#defcomp -command-
+#compdef -command-
 
 local nm=$compstate[nmatches] ret=1
 
diff --git a/Completion/Base/_condition b/Completion/Base/_condition
index df1bf913e..c617d9d90 100644
--- a/Completion/Base/_condition
+++ b/Completion/Base/_condition
@@ -1,4 +1,4 @@
-#defcomp -condition-
+#compdef -condition-
 
 local prev="$words[CURRENT-1]"
 
diff --git a/Completion/Base/_default b/Completion/Base/_default
index 9ea1a09db..b49ca7115 100644
--- a/Completion/Base/_default
+++ b/Completion/Base/_default
@@ -1,4 +1,4 @@
-#defcomp -default-
+#compdef -default-
 
 # We first try the `compctl's. This is without first (-T) and default (-D)
 # completion. If you want them add `-T' and/or `-D' to this command.
diff --git a/Completion/Base/_equal b/Completion/Base/_equal
index f407014fe..0e2a11e46 100644
--- a/Completion/Base/_equal
+++ b/Completion/Base/_equal
@@ -1,3 +1,3 @@
-#defcomp -equal-
+#compdef -equal-
 
 compgen -am
diff --git a/Completion/Base/_long_options b/Completion/Base/_long_options
index 97b11f2dc..6288fc3a0 100644
--- a/Completion/Base/_long_options
+++ b/Completion/Base/_long_options
@@ -32,12 +32,25 @@
 # for option descriptions containing `=FILE' and paths for option
 # descriptions that contain `=DIR' or `=PATH'. These builtin patterns
 # can be overridden by patterns given as arguments, though.
+# 
+# This function accepts following options:
+#
+# -t   do completion only on words starting with two hyphens
+#
+# -i   list of patterns. Options, matching these patterns, are ignored.
+#      The list may be given as array name or as literal list in braces.
+#      E.g. _long_options -i '(--(enable|disable)-FEATURE*)' will ignore
+#      --enable-FEATURE, that is listed in configure help output
+#
+# -s   list of pattern/replacement pairs. The argument is the same as above.
+#      E.g. configure often lists only --enable but accepts both
+#      --enable and --disable options.
+#      _long_options -s '(#--enable- --disable)' will accept both forms.
 #
 # This function also accepts the `-X', `-J', and `-V' options which
-# are given to `compadd'. Finally, it accepts the option `-t'. If this 
-# is given, completion is only done on words starting with two hyphens.
+# are given to `compadd'. 
 
-local opt expl group test i name action ret=1 tmp suffix
+local opt expl group test i name action ret=1 tmp suffix iopts sopts
 
 setopt extendedglob
 
@@ -46,11 +59,23 @@ setopt extendedglob
 group=()
 expl=()
 if [[ $1 = -*~--* ]]; then
-  while getopts "J:V:X:t" opt; do
+  while getopts "J:V:X:ti:s:" opt; do
     case "$opt" in
       [JV]) group=("-$opt" "$OPTARG");;
       X)    expl=(-X "$OPTARG");;
       t)    test=yes;;
+      i)    if [[ "$OPTARG[1]" = '(' ]]; then
+              iopts=( ${=OPTARG[2,-2]} )
+	    else
+              iopts=( ${(P)${OPTARG}} )
+	    fi
+      ;;
+      s)    if [[ "$OPTARG[1]" = '(' ]]; then
+              sopts=( ${=OPTARG[2,-2]} )
+	    else
+              sopts=( ${(P)${OPTARG}} )
+	    fi
+      ;;
     esac
   done
   shift OPTIND-1
@@ -77,6 +102,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
   (( $+_lo_cache_actions )) && unset "$_lo_cache_names[@]" _lo_cache_actions _lo_cache_names
 
   local opts pattern anum=1 tmpo str
+  typeset -U opts
 
   # Now get the long option names by calling the command with `--help'.
   # The parameter expansion trickery first gets the lines as separate
@@ -87,11 +113,24 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
   # the old array elements with newlines between them. Then we select
   # those elements that start with two hyphens, remove anything up to
   # those hyphens and anything from the space or comma after the
-  # option up to the end. Finally all elements with option strings
-  # that contain uppercase letters are removed.
+  # option up to the end. 
+
+  opts=("--${(@)^${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ 	]#-*}//,/
+}}:#[ 	]#--*}#*--}%%[, ]*}")
 
-  opts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ 	]#-*}//,/
-}}:#[ 	]#--*}#*--}%%[, ]*}:#(*-[A-Z]*|)}")
+  # Now remove all ignored options ...
+
+  while (($#iopts)) ; do
+    opts=( ${opts:#$~iopts[1]} )
+    shift iopts
+  done
+
+  # ... and add "same" options
+
+  while (($#sopts)) ; do
+    opts=( $opts ${opts/$sopts[1]/$sopts[2]} )
+    shift 2 sopts
+  done
 
   # The interpretation of the options is completely table driven. We
   # use the positional parameters we were given and a few standard
@@ -173,7 +212,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then
     # Now filter out any option strings we don't like and stuff them
     # in an array, if there are still some.
 
-    tmp=("${(@)${(@)tmp%%\=*}//[^a-z0-9-]}")
+    tmp=("${(@)${(@)tmp%%\=*}//[^a-zA-Z0-9-]}")
     if (( $#tmp )); then
       _lo_cache_names[anum]="$name"
       _lo_cache_actions[anum]="$action"
@@ -200,20 +239,6 @@ if [[ "$str" = *\=* ]]; then
   osuf="$SUFFIX"
 
   pre="${str%%\=*}"
-  IPREFIX="${IPREFIX}${pre}="
-  PREFIX="${str#*\=}"
-  SUFFIX=""
-
-  # We will check if the arrays contain an option matching what's on
-  # the line. To do this good, we build a pattern.
-
-  [[ -n "$_comp_correct" && $#pre -le _comp_correct ]] && return 1
-
-  pat="${pre}*"
-  patflags=''
-  _match_pattern _long_options pat patflags
-
-  [[ -n "$_comp_correct" ]] && patflags="$patflags(#a$_comp_correct)"
 
   # Then we walk through the array names. For each array we test if it 
   # contains the option string. If so, we `invoke' the action stored
@@ -223,6 +248,9 @@ if [[ "$str" = *\=* ]]; then
   for name in "$_lo_cache_names[@]"; do
     action="$_lo_cache_actions[anum]"
     if (( ${(@)${(@P)name}[(I)$pre]} )); then
+      IPREFIX="${oipre}${pre}="
+      PREFIX="${str#*\=}"
+      SUFFIX=""
       if [[ "$action[1]" = (\[|\() ]]; then
         compadd - ${=action[2,-2]}
       elif (( $#action )); then
@@ -240,7 +268,10 @@ if [[ "$str" = *\=* ]]; then
     # element from `_lo_actions' in `parta'. If we find more than one
     # such option or if we already had one, we set `parto' to `-'.
 
-    tmp=("${(@M)${(@P)name}:#${~pat}}")
+    PREFIX="${str%%\=*}"
+    SUFFIX=""
+    compadd -O tmp -M 'r:|-=* r:|=*' - "${(@P)name}"
+
     if [[ $#tmp -eq 1 ]]; then
       if [[ -z "$parto" ]]; then
         parto="$tmp[1]"
@@ -258,8 +289,9 @@ if [[ "$str" = *\=* ]]; then
   # try to complete the string after the `='.
 
   if [[ -n "$parto" && "$parto" != - ]]; then
-    IPREFIX="${parto}="
-
+    IPREFIX="${oipre}${parto}="
+    PREFIX="${str#*\=}"
+    SUFFIX=""
     if (( $#parta )); then
       if [[ "$parta[1]" = (\[|\() ]]; then
         compadd - ${=parta[2,-2]}
@@ -281,7 +313,7 @@ fi
 
 # The string on the line did not contain a `=', or we couldn't
 # complete the option string since there were more than one matching
-# what's on the line. So we just ad the option string as possible
+# what's on the line. So we just add the option strings as possible
 # matches, giving the string from the `=' on as a suffix.
 
 if [[ "$str" = *\=* ]]; then
diff --git a/Completion/Base/_math b/Completion/Base/_math
index f7f4c360f..90a2c5f7b 100644
--- a/Completion/Base/_math
+++ b/Completion/Base/_math
@@ -1,4 +1,4 @@
-#defcomp -math-
+#compdef -math-
 
 if [[ "$PREFIX" = *[^a-zA-Z0-9_]* ]]; then
   IPREFIX="$IPREFIX${PREFIX%%[a-zA-Z0-9_]#}"
@@ -10,7 +10,7 @@ if [[ "$SUFFIX" = *[^a-zA-Z0-9_]* ]]; then
 fi
 
 compgen -v
-#defcomp -math-
+#compdef -math-
 
 IPREFIX="$IPREFIX${PREFIX%[a-zA-Z0-9_]*}"
 PREFIX="${PREFIX##*[^a-zA-Z0-9_]}"
diff --git a/Completion/Base/_parameter b/Completion/Base/_parameter
index 2bd66ec93..7200ae440 100644
--- a/Completion/Base/_parameter
+++ b/Completion/Base/_parameter
@@ -1,3 +1,3 @@
-#defcomp -parameter-
+#compdef -parameter-
 
 compgen -v
diff --git a/Completion/Base/_precommand b/Completion/Base/_precommand
index c13cd7465..bcda9fc8b 100644
--- a/Completion/Base/_precommand
+++ b/Completion/Base/_precommand
@@ -1,4 +1,4 @@
-#defcomp - nohup nice eval time rusage noglob nocorrect exec
+#compdef - nohup nice eval time rusage noglob nocorrect exec
 
 shift words
 (( CURRENT-- ))
diff --git a/Completion/Base/_redirect b/Completion/Base/_redirect
index 32113ad7c..6e02636da 100644
--- a/Completion/Base/_redirect
+++ b/Completion/Base/_redirect
@@ -1,3 +1,3 @@
-#defcomp -redirect-
+#compdef -redirect-
 
 _files
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript
index e783d04e7..abaabec8c 100644
--- a/Completion/Base/_subscript
+++ b/Completion/Base/_subscript
@@ -1,4 +1,4 @@
-#defcomp -subscript-
+#compdef -subscript-
 
 if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
   compgen -S ']' -k "( ${(kP)${compstate[parameter]}} )"
diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde
index c5ebb66d5..c24c65701 100644
--- a/Completion/Base/_tilde
+++ b/Completion/Base/_tilde
@@ -1,4 +1,4 @@
-#defcomp -tilde-
+#compdef -tilde-
 
 # We use all named directories and user names here. If this is too slow
 # for you or if there are too many of them, you may want to use
diff --git a/Completion/Base/_vars b/Completion/Base/_vars
index 497a9316f..f06562694 100644
--- a/Completion/Base/_vars
+++ b/Completion/Base/_vars
@@ -1,3 +1,3 @@
-#defcomp getopts read unset vared
+#compdef getopts read unset vared
 
 compgen -v
diff --git a/Completion/Builtins/_aliases b/Completion/Builtins/_aliases
index 2ccf18439..94c8a0f7c 100644
--- a/Completion/Builtins/_aliases
+++ b/Completion/Builtins/_aliases
@@ -1,3 +1,3 @@
-#defcomp unalias
+#compdef unalias
 
 compgen -a
diff --git a/Completion/Builtins/_arrays b/Completion/Builtins/_arrays
index 94401f28a..b79bf711c 100644
--- a/Completion/Builtins/_arrays
+++ b/Completion/Builtins/_arrays
@@ -1,3 +1,3 @@
-#defcomp shift
+#compdef shift
 
 compgen -A
diff --git a/Completion/Builtins/_autoload b/Completion/Builtins/_autoload
index d1462e09a..d1c255b73 100644
--- a/Completion/Builtins/_autoload
+++ b/Completion/Builtins/_autoload
@@ -1,3 +1,3 @@
-#defcomp autoload
+#compdef autoload
 
 compgen -s '${^fpath}/*(N:t)'
diff --git a/Completion/Builtins/_bg_jobs b/Completion/Builtins/_bg_jobs
index 4abee070c..ef1cd4d3c 100644
--- a/Completion/Builtins/_bg_jobs
+++ b/Completion/Builtins/_bg_jobs
@@ -1,3 +1,3 @@
-#defcomp bg
+#compdef bg
 
 compgen -z -P '%'
diff --git a/Completion/Builtins/_bindkey b/Completion/Builtins/_bindkey
index 6fca200ba..57b3d8a85 100644
--- a/Completion/Builtins/_bindkey
+++ b/Completion/Builtins/_bindkey
@@ -1,4 +1,4 @@
-#defcomp bindkey
+#compdef bindkey
 
 # Normally, this completes names of zle widgets, whether the builtin ones
 # or ones defined by the user.  Note that a - allows a wildcard before it,
diff --git a/Completion/Builtins/_builtin b/Completion/Builtins/_builtin
index bee67fe8f..0e6d613be 100644
--- a/Completion/Builtins/_builtin
+++ b/Completion/Builtins/_builtin
@@ -1,4 +1,4 @@
-#defcomp builtin
+#compdef builtin
 
 if (( $CURRENT > 2 )); then
   shift words
diff --git a/Completion/Builtins/_cd b/Completion/Builtins/_cd
index a4fd56327..61abd2068 100644
--- a/Completion/Builtins/_cd
+++ b/Completion/Builtins/_cd
@@ -1,4 +1,4 @@
-#defcomp cd pushd
+#compdef cd pushd
 
 # Handling of cd.
 #  - Normally just completes directories.  Uses cdpath if that's set
@@ -55,7 +55,7 @@ elif [[ $words[1] = pu* && $PREFIX = [-+]* ]]; then
   list=(${list%%[ 	]*})
   compgen -y '$lines' -Q -k list && ret=0
   [[ -z $compstate[list] ]] && compstate[list]=list && ret=0
-  [[ -n $compstate[insert] ]] && compstat[insert]=menu && ret=0
+  [[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0
 
   return ret
 elif [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then
diff --git a/Completion/Builtins/_command b/Completion/Builtins/_command
index 4facceb12..6103ee81f 100644
--- a/Completion/Builtins/_command
+++ b/Completion/Builtins/_command
@@ -1,4 +1,4 @@
-#defcomp command
+#compdef command
 
 if [[ CURRENT -ge 3 ]]; then
   compset -n 2
diff --git a/Completion/Builtins/_dirs b/Completion/Builtins/_dirs
index bc426e322..04c4b75d9 100644
--- a/Completion/Builtins/_dirs
+++ b/Completion/Builtins/_dirs
@@ -1,3 +1,3 @@
-#defcomp rmdir df du dircmp
+#compdef rmdir df du dircmp
 
 _files -/
diff --git a/Completion/Builtins/_disable b/Completion/Builtins/_disable
index 27db5c18f..5572fbcf3 100644
--- a/Completion/Builtins/_disable
+++ b/Completion/Builtins/_disable
@@ -1,4 +1,4 @@
-#defcomp disable
+#compdef disable
 
 local prev="$words[CURRENT-1]" ret=1
 
diff --git a/Completion/Builtins/_echotc b/Completion/Builtins/_echotc
index 135cabada..ce282437d 100644
--- a/Completion/Builtins/_echotc
+++ b/Completion/Builtins/_echotc
@@ -1,3 +1,3 @@
-#defcomp echotc
+#compdef echotc
 
 compgen -k '(al dc dl do le up al bl cd ce cl cr dc dl do ho is le ma nd nl se so up)'
diff --git a/Completion/Builtins/_enable b/Completion/Builtins/_enable
index 1baa09ed6..483661efe 100644
--- a/Completion/Builtins/_enable
+++ b/Completion/Builtins/_enable
@@ -1,4 +1,4 @@
-#defcomp enable
+#compdef enable
 
 local prev="$words[CURRENT-1]" ret=1
 
diff --git a/Completion/Builtins/_fc b/Completion/Builtins/_fc
index f8cf4dde8..5b493dc3b 100644
--- a/Completion/Builtins/_fc
+++ b/Completion/Builtins/_fc
@@ -1,4 +1,4 @@
-#defcomp fc
+#compdef fc
 
 local prev="$words[CURRENT-1]"
 
diff --git a/Completion/Builtins/_functions b/Completion/Builtins/_functions
index 7e3174af5..052dfca00 100644
--- a/Completion/Builtins/_functions
+++ b/Completion/Builtins/_functions
@@ -1,3 +1,3 @@
-#defcomp unfunction
+#compdef unfunction
 
 compgen -F
diff --git a/Completion/Builtins/_hash b/Completion/Builtins/_hash
index 4d4ba4244..b03cf7fb9 100644
--- a/Completion/Builtins/_hash
+++ b/Completion/Builtins/_hash
@@ -1,4 +1,4 @@
-#defcomp hash
+#compdef hash
 
 if [[ "$words[2]" = -*d* ]]; then
   if compset -P 1 '*\='; then
diff --git a/Completion/Builtins/_jobs b/Completion/Builtins/_jobs
index 8f6991de0..bce005b4e 100644
--- a/Completion/Builtins/_jobs
+++ b/Completion/Builtins/_jobs
@@ -1,3 +1,3 @@
-#defcomp fg jobs
+#compdef fg jobs
 
 compgen -j -P '%'
diff --git a/Completion/Builtins/_kill b/Completion/Builtins/_kill
index 0b0f5c188..979c87804 100644
--- a/Completion/Builtins/_kill
+++ b/Completion/Builtins/_kill
@@ -1,4 +1,4 @@
-#defcomp kill
+#compdef kill
 
 local list
 
diff --git a/Completion/Builtins/_limits b/Completion/Builtins/_limits
index 8b0b41c71..be5c35593 100644
--- a/Completion/Builtins/_limits
+++ b/Completion/Builtins/_limits
@@ -1,3 +1,3 @@
-#defcomp limit unlimit
+#compdef limit unlimit
 
 compgen -k "(${(j: :)${(f)$(limit)}%% *})"
diff --git a/Completion/Builtins/_sched b/Completion/Builtins/_sched
index 5fba71eac..581438b0e 100644
--- a/Completion/Builtins/_sched
+++ b/Completion/Builtins/_sched
@@ -1,3 +1,3 @@
-#defcomp sched
+#compdef sched
 
 compset -n 3 && _normal
diff --git a/Completion/Builtins/_set b/Completion/Builtins/_set
index 959dac75d..59a38b654 100644
--- a/Completion/Builtins/_set
+++ b/Completion/Builtins/_set
@@ -1,4 +1,4 @@
-#defcomp set
+#compdef set
 
 local prev="$words[CURRENT-1]"
 
diff --git a/Completion/Builtins/_setopt b/Completion/Builtins/_setopt
index e5a6c054f..17ecafb20 100644
--- a/Completion/Builtins/_setopt
+++ b/Completion/Builtins/_setopt
@@ -1,4 +1,4 @@
-#defcomp setopt
+#compdef setopt
 
 # If you first want to complete only unset options, un-comment the lines
 # setting the _unset_options  array and then use:
diff --git a/Completion/Builtins/_source b/Completion/Builtins/_source
index efac4f32b..a232aa458 100644
--- a/Completion/Builtins/_source
+++ b/Completion/Builtins/_source
@@ -1,4 +1,4 @@
-#defcomp source
+#compdef source
 
 if [[ CURRENT -ge 3 ]]; then
   compset -n 2
diff --git a/Completion/Builtins/_trap b/Completion/Builtins/_trap
index 36ab1f1a8..bb0630638 100644
--- a/Completion/Builtins/_trap
+++ b/Completion/Builtins/_trap
@@ -1,4 +1,4 @@
-#defcomp trap
+#compdef trap
 
 if [[ CURRENT -eq 2 ]]; then
   compgen -c
diff --git a/Completion/Builtins/_unhash b/Completion/Builtins/_unhash
index a9050cb49..825c130b2 100644
--- a/Completion/Builtins/_unhash
+++ b/Completion/Builtins/_unhash
@@ -1,4 +1,4 @@
-#defcomp unhash
+#compdef unhash
 
 local fl="$words[2]" ret=1
 
diff --git a/Completion/Builtins/_unsetopt b/Completion/Builtins/_unsetopt
index cdc2ab9f3..d862aa0e1 100644
--- a/Completion/Builtins/_unsetopt
+++ b/Completion/Builtins/_unsetopt
@@ -1,4 +1,4 @@
-#defcomp unsetopt
+#compdef unsetopt
 
 # If you first want to complete only unset options, uncomment the lines
 # setting the _set_options  array and then use:
diff --git a/Completion/Builtins/_vars_eq b/Completion/Builtins/_vars_eq
index 9488cb7f9..892c1f57e 100644
--- a/Completion/Builtins/_vars_eq
+++ b/Completion/Builtins/_vars_eq
@@ -1,3 +1,3 @@
-#defcomp declare export integer local readonly typeset
+#compdef declare export integer local readonly typeset
 
 compgen -v -q -S '='
diff --git a/Completion/Builtins/_wait b/Completion/Builtins/_wait
index 9281a5cc2..0fadc087b 100644
--- a/Completion/Builtins/_wait
+++ b/Completion/Builtins/_wait
@@ -1,4 +1,4 @@
-#defcomp wait
+#compdef wait
 
 local list ret=1
 
diff --git a/Completion/Builtins/_which b/Completion/Builtins/_which
index 9248f9c9f..db5271653 100644
--- a/Completion/Builtins/_which
+++ b/Completion/Builtins/_which
@@ -1,3 +1,3 @@
-#defcomp which whence where type
+#compdef which whence where type
 
 compgen -caF
diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp
index 178d9d9e3..71404fb2b 100644
--- a/Completion/Builtins/_zftp
+++ b/Completion/Builtins/_zftp
@@ -1,4 +1,4 @@
-#defpatcomp zf*
+#compdef -p zf*
 
 # Don't try any more completion after this.
 _compskip=1
@@ -10,7 +10,7 @@ _compskip=1
 local subcom
 
 if [[ $words[1] = zftp ]]; then
-  if [[ $CURRENT -eq 1 ]]; then
+  if [[ $CURRENT -eq 2 ]]; then
     compadd open params user login type ascii binary mode put \
       putat get getat append appendat ls dir local remote mkdir rmdir
     return
diff --git a/Completion/Builtins/_zle b/Completion/Builtins/_zle
index 0a9ad0a9e..f0860c5e3 100644
--- a/Completion/Builtins/_zle
+++ b/Completion/Builtins/_zle
@@ -1,4 +1,4 @@
-#defcomp zle
+#compdef zle
 
 if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then
   compgen -F
diff --git a/Completion/Builtins/_zmodload b/Completion/Builtins/_zmodload
index 9247ba0ce..4b0e91442 100644
--- a/Completion/Builtins/_zmodload
+++ b/Completion/Builtins/_zmodload
@@ -1,4 +1,4 @@
-#defcomp zmodload
+#compdef zmodload
 
 local fl="$words[2]"
 
diff --git a/Completion/Commands/_correct_filename b/Completion/Commands/_correct_filename
index 72bac5f1b..53ed6d113 100644
--- a/Completion/Commands/_correct_filename
+++ b/Completion/Commands/_correct_filename
@@ -1,4 +1,4 @@
-#defkeycomp complete-word \C-xc
+#compdef -k complete-word \C-xc
 
 # Function to correct a filename.  Can be used as a completion widget,
 # or as a function in its own right, in which case it will print the
diff --git a/Completion/Commands/_correct_word b/Completion/Commands/_correct_word
new file mode 100644
index 000000000..db3023860
--- /dev/null
+++ b/Completion/Commands/_correct_word
@@ -0,0 +1,12 @@
+#compdef -k complete-word \C-xc
+
+# Simple completion front-end implementing spelling correction.
+# The maximum number of errors is set quite high, and
+# the numeric prefix can be used to specify a different value.
+
+local oca="$compconfig[correct_accept]"
+compconfig[correct_accept]=6n
+
+_main_complete _correct
+
+compconfig[correct_accept]=$oca
diff --git a/Completion/Commands/_most_recent_file b/Completion/Commands/_most_recent_file
index 5bd737fd2..c571483ca 100644
--- a/Completion/Commands/_most_recent_file
+++ b/Completion/Commands/_most_recent_file
@@ -1,4 +1,4 @@
-#defkeycomp complete-word \C-xm
+#compdef -k complete-word \C-xm
 
 # Complete the most recent file matching the pattern on the line so
 # far: globbing is active, i.e. *.txt will be expanded to the most recent
diff --git a/Completion/Core/_compalso b/Completion/Core/_compalso
index 52fb08f05..61649901e 100644
--- a/Completion/Core/_compalso
+++ b/Completion/Core/_compalso
@@ -1,15 +1,17 @@
 #autoload
 
-# This searches $1 in the array for normal completions and calls the result.
+# This searches $* in the array for normal completions and calls the result.
 # It is used to include completions for another command or special context
 # into the list generated by the calling function.
 # For example the function for `-subscript-' could call this as in
 # `_compalso -math-' to get the completions that would be generated for a
 # mathematical context.
 
-local tmp ret=1
+local i tmp
 
-tmp="$_comps[$1]"
-[[ -z "$tmp" ]] || "$tmp" && ret=0
+for i; do
+  tmp="$_comps[$1]"
+  [[ -z "$tmp" ]] || "$tmp" && return 0
+done
 
-return ret
+return 1
diff --git a/Completion/Core/_multi_parts b/Completion/Core/_multi_parts
index ab9438494..b49c41e22 100644
--- a/Completion/Core/_multi_parts
+++ b/Completion/Core/_multi_parts
@@ -7,15 +7,8 @@
 # The parts of words from the array that are separated by the
 # separator character are then completed independently.
 
-local sep matches patstr orig matchflags pref i tmp1 tmp2 nm
-local group expl menu origflags mflags
-
-_match_test _multi_parts || return 1
-
-# Save the current number of matches to be able to return if we added
-# matches or not.
-
-nm=$compstate[nmatches]
+local sep matches pref npref i tmp1 group expl menu pre suf
+typeset -U tmp2
 
 # Get the options.
 
@@ -41,193 +34,159 @@ else
   matches=( "${(@P)2}" )
 fi
 
-# Now build the pattern from what we have on the line. We also save
-# the original string in `orig'.
+# In `pre' and `suf' we will hold the prefix and the suffix from the
+# line while we walk through them. The original string are used 
+# temporarily for matching.
 
-if [[ $#compstate[pattern_match] -ne 0 ]]; then
-  if [[ "${compstate[pattern_match]-*}" = \** ]]; then
-    str="${PREFIX}*${SUFFIX}*"
-  else
-    str="${PREFIX}${SUFFIX}"
-  fi
-else
-  patstr="${PREFIX:q}*${SUFFIX:q}*"
-fi
-orig="${PREFIX}${SUFFIX}"
+pre="$PREFIX"
+suf="$SUFFIX"
+orig="$PREFIX$SUFFIX"
 
-[[ $compstate[insert] = *menu || -n "$_comp_correct" ||
+# Special handling for menucompletion?
+
+[[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" ||
    ( $#compstate[pattern_match] -ne 0 &&
      "$orig" != "${orig:q}" ) ]] && menu=yes
 
-matchflags=""
-_match_pattern _path_files patstr matchflags
-origflags="$matchflags"
-[[ -n "$_comp_correct" ]] && matchflags="$matchflags(#a$_comp_correct)"
-
-patstr="${${patstr//$sep/*$sep}//\*##/*}"
-
-# First we will skip over those parts of the matches for which we have 
-# exact substrings on the line. In `pref' we will build the
-# unambiguous prefix string.
+# In `pref' we collect the unambiguous prefix path.
 
 pref=''
-while [[ "$orig" = *${sep}* ]] do
 
-  # First build the pattern to use, then collect all strings from
-  # `matches' that match the prefix we have and the exact substring in 
-  # the array `tmp1'.
+# If the string from the line matches at least one of the strings,
+# we use only the matching strings.
 
-  if [[ -n "$_comp_correct" && "${#orig%%${sep}*}" -le _comp_correct ]]; then
-    mflags="$origflags"
-  else
-    mflags="$matchflags"
-  fi
-
-  pat="${${${patstr#*${sep}}%${sep}*}//\*/[^${sep}]#}"
-  tmp1=( "${(@M)matches:#${~mflags}${orig%%${sep}*}${sep}${~pat}}" )
+compadd -O tmp1 -M "r:|${sep}=* r:|=*" - "$matches[@]"
 
-  # If there are no words matching the exact substring, stop.
+(( $#tmp1 )) && matches=( "$tmp1[@]" )
 
-  (( $#tmp1 )) || break
+while true; do
 
-  # Otherwise add the part to the prefix, remove it from the matches
-  # (and also remove all words not matching the string at all), and
-  # set `patstr' and `orig' to the next component.
+  # Get the prefix and suffix for matching.
 
-  tmp1="${orig%%${sep}*}${sep}"
-  pref="$pref$tmp1"
-  matches=("${(@)${(@)${(@M)matches:#${tmp1}*}#$tmp1}:#}")
-  orig="${orig#*${sep}}"
-  patstr="${patstr#*${sep}}"
-done
-
-# Now we get all the words that still match in `tmp1'.
-
-if [[ "$patstr" = *${sep}* ]]; then
-  tmp1="${patstr%${sep}*}${sep}"
-  pat="${tmp1//\*/[^${sep}]#}${patstr##*${sep}}"
-else
-  pat="$patstr"
-fi
-if [[ -n "$_comp_correct" && "${#orig%%${sep}*}" -le _comp_correct ]]; then
-  mflags="$origflags"
-else
-  mflags="$matchflags"
-fi
-tmp1=( "${(@M)matches:#${~mflags}${~pat}}" )
-
-if (( $#tmp1 )); then
-
-  # There are words that are matched, put them into `matches' and then
-  # move all unambiguous components from the beginning into `pref'.
+  if [[ "$pre" = *${sep}* ]]; then
+    PREFIX="${pre%%${sep}*}"
+    SUFFIX=""
+  else
+    PREFIX="${pre}"
+    SUFFIX="${suf%%${sep}*}"
+  fi
 
-  matches=( "$tmp1[@]" )
-  while [[ "$matches[1]" = *${sep}* ]]; do
+  # Check if the component for some of the possible matches is equal
+  # to the string from the line. If there are such strings, we directly
+  # use the stuff from the line. This avoids having `foo' complete to
+  # both `foo' and `foobar'.
 
-    # We just take the first component of the first match and see if
-    # there are other matches with a different prefix (these are
-    # collected in `tmp2'). If there are any, we give up.
+  tmp1=( "${(@M)matches:#${PREFIX}${SUFFIX}${sep}*}" )
 
-    tmp1="${matches[1]%%${sep}*}${sep}"
-    tmp2=( "${(@)matches:#${tmp1}*}" )
-    (( $#tmp2 )) && break
+  if (( $#tmp1 )); then
+    npref="${PREFIX}${SUFFIX}${sep}"
+  else
+    # No exact match, see how many strings match what's on the line.
 
-    # All matches have the same prefix, put it into `pref' and remove
-    # it from the matches.
+    tmp2=( "${(@)matches%%${sep}*}" )
+    compadd -O tmp1 - "$tmp2[@]"
 
-    pref="$pref$tmp1"
-    matches=( "${(@)${(@)matches#$tmp1}:#}" )
+    if [[ $#tmp1 -eq 1 ]]; then
 
-    if [[ "$orig" = *${sep}* ]]; then
-      orig="${orig#*${sep}}"
-    else
-      orig=''
-    fi
-  done
+      # Only one match. If there are still separators from the line
+      # we just accept this component. Otherwise we insert what we 
+      # have collected, probably giving it a separator character
+      # as a suffix.
 
-  # Now we can tell the completion code about the things we
-  # found. Strings that have a separator will be added with a suffix.
-
-  if [[ -z "$orig" && "$PREFIX$SUFFIX" != "$pref$orig" ]]; then
-    compadd -QU  "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" -S '' - \
-            "${pref}${orig}"
-  elif [[ -n "$menu" ]]; then
-    if [[ "$orig" = *${sep}* ]]; then
-      orig="${sep}${orig#*${sep}}"
-    else
-      orig=''
-    fi
-    for i in "$matches[@]" ; do
-      if [[ "$i" = *${sep}* ]]; then
-        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	        -p "$pref" -s "$orig" - "${i%%${sep}*}${sep}"
+      if [[ "$pre$suf" = *${sep}* ]]; then
+        npref="${tmp1[1]}${sep}"
       else
-        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	        -p "$pref" -s "$orig" - "${i%%${sep}*}"
+        matches=( "${(@M)matches:#${tmp1[1]}*}" )
+	tmp2=( "${(@M)matches:#${tmp1[1]}${sep}*}" )
+
+	if (( $#tmp2 )); then
+	  compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	          -p "$pref" -qS "$sep" - "$tmp1[1]"
+        else
+	  compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	          -p "$pref" - "$tmp1[1]"
+        fi
+	return 1
       fi
-    done
-  else
-    for i in "$matches[@]" ; do
-      if [[ "$i" = *${sep}* ]]; then
-        compadd -U -i "$IPREFIX" -I "$ISUFFIX" -p "$pref" -s "${i#*${sep}}" \
-	        "$group[@]" "$expl[@]" -M "r:|${sep:q}=*" - "${i%%${sep}*}${sep}"
+    elif (( $#tmp1 )); then
+
+      # More than one match. First we get all strings that match the
+      # rest from the line.
+
+      PREFIX="$pre"
+      SUFFIX="$suf"
+      compadd -O matches -M "r:|${sep}=* r:|=*" - "$matches[@]"
+
+      if [[ -n "$menu" ]]; then
+        # With menucompletion we just add matches for the matching
+        # components with the prefix we collected and the rest from the
+        # line as a suffix.
+
+        tmp2="$pre$suf"
+        if [[ "$tmp2" = *${sep}* ]]; then
+          compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	          -p "$pref" -s "${sep}${tmp2#*${sep}}" - "$tmp1[@]"
+        else
+          compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	          -p "$pref" - "$tmp1[@]"
+        fi
       else
-        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-                -p "$pref" - "$i"
+        # With normal completion we add all matches one-by-one with
+	# the unmatched part as a suffix. This will insert the longest
+	# unambiguous string for all matching strings.
+
+        for i in "${(@M)matches:#(${(j:|:)~tmp1})*}"; do
+	  if [[ "$i" = *${sep}* ]]; then
+            compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	            -S '' -p "$pref" -s "${i#*${sep}}" - "${i%%${sep}*}${sep}"
+          else
+            compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	            -S '' -p "$pref" - "$i"
+          fi
+        done
       fi
-    done
-  fi
-elif [[ "$patstr" = *${sep}* ]]; then
-
-  # We had no words matching the string from the line. But we want to
-  # be friendly and at least expand the prefix as far as we can. So we 
-  # will loop through the rest of the string from the line and test
-  # the components one by one.
-
-  while [[ "$patstr" = *${sep}* ]]; do
-
-    # First we get all words matching at least this component in
-    # `tmp1'. If there are none, we give up.
-
-    if [[ -n "$_comp_correct" && "${#orig%%${sep}*}" -le _comp_correct ]]; then
-      mflags="$origflags"
+      return 0
     else
-      mflags="$matchflags"
-    fi
-    tmp1=( "${(@M)matches:#${~mflags}${~patstr%%${sep}*}${sep}*}" )
-    (( $#tmp1 )) || break
-
-    # Then we check if there are words that have a different prefix.
+      # We are here if no string matched what's on the line. In this
+      # case we insert the expanded prefix we collected if it differs
+      # from the original string from the line.
 
-    tmp2=( "${(@)tmp1:#${tmp1[1]%%${sep}*}${sep}*}" )
-    if (( $#tmp2 )); then
+      [[ "$orig" = "$pref$pre$suf" ]] && return 1
 
-      # There are words with another prefix, so we have found an
-      # ambiguous component. So we just give all possible prefixes to
-      # the completion code together with our prefix and the rest of
-      # the string from the line as the suffix.
-
-      compadd -U "$group[@]" "$expl[@]" -S '' -i "$IPREFIX" -I "$ISUFFIX" \
-              -p "$pref" -s "${sep}${orig#*${sep}}" - "${(@)matches%%${sep}*}"
+      if [[ -n "$suf" ]]; then
+        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	        -s "$suf" - "$pref$pre"
+      else
+        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	        -S '' - "$pref$pre$suf"
+      fi
       return 0
     fi
+  fi
 
-    # All words have the same prefix, so add it to `pref' again and
-    # try the next component.
+  # We just accepted and/or expanded a component from the line. We
+  # remove it from the matches (using only those that have a least
+  # the skipped string) and ad it the `pref'.
 
-    pref="$pref${tmp1[1]%%${sep}*}${sep}"
-    matches=( "${(@)matches#${tmp1[1]%%${sep}*}${sep}}" )
-    orig="${orig#*${sep}}"
-    patstr="${patstr#*${sep}}"
-  done
+  matches=( "${(@)${(@)${(@M)matches:#${npref}*}#*${sep}}:#}" )
+  pref="$pref$npref"
 
-  # Finally, add the unambiguous prefix and the rest of the string
-  # from the line.
+  # Now we set `pre' and `suf' to their new values.
 
-  compadd -U "$group[@]" "$expl[@]" -S '' -i "$IPREFIX" -I "$ISUFFIX" \
-          -p "$pref" - "$orig"
-fi
+  if [[ "$pre" = *${sep}* ]]; then
+    pre="${pre#*${sep}}"
+  elif [[ "$suf" = *${sep}* ]]; then
+    pre="${suf#*${sep}}"
+    suf=""
+  else
+    # The string from the line is fully handled. If we collected an
+    # unambiguous prefix and that differs from the original string,
+    # we insert it.
 
-# This sets the return value to indicate that we added matches (or not).
+    [[ -n "$pref" && "$orig" != "$pref" ]] &&
+        compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	        -S '' - "$pref"
 
-[[ nm -ne compstate[nmatches] ]]
+    return
+  fi
+done
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 54b04a368..21837ade2 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -7,10 +7,9 @@
 # the last have the same syntax and meaning as for `compgen' or
 # `compadd', respectively. The `-F <ignore>' option may be used to give
 # a list of suffixes either by giving the name of an array or
-# literally by giving them in a string surrounded by
-# parentheses. Files with one of the suffixes thus given are treated
-# like files with one of the suffixes in the `fignore' array in normal
-# completion.
+# literally by giving them in a string surrounded by parentheses. Files
+# with one of the suffixes thus given are treated like files with one
+# of the suffixes in the `fignore' array in normal completion.
 #
 # This function supports one configuration key:
 #
@@ -18,22 +17,13 @@
 #    If this is set to a non-empty string, the partially typed path
 #    from the line will be expanded as far as possible even if trailing
 #    pathname components can not be completed.
-#
-#
-# This function uses the helper functions `_match_test' and `_match_pattern'.
-
-# First see if we should generate matches for the global matcher in use.
-
-_match_test _path_files || return 1
 
-# Yes, so...
+local linepath realpath donepath prepath testpath exppath
+local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf
+local pats ignore group expl addpfx addsfx remsfx
+local nm=$compstate[nmatches] menu
 
-local nm str linepath realpath donepath patstr prepath testpath rest
-local tmp1 collect tmp2 suffixes i ignore matchflags opt group sopt pats gopt
-local addpfx addsfx expl orig ostr nm=$compstate[nmatches] menu remsfx patlast
-local origflags mflags tmp3 tmp4 exppaths
-
-typeset -U prepaths
+typeset -U prepaths exppaths
 
 setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset
@@ -109,35 +99,27 @@ if [[ "$sopt" = - ]]; then
   fi
 fi
 
-# str holds the whole string from the command line with a `*' between
-# the prefix and the suffix. Then we see if we will do menucompletion.
+# We get the prefix and the suffix from the line and save the whole
+# original string. Then we see if we will do menucompletion.
 
-if [[ $#compstate[pattern_match] -ne 0 ]]; then
-  if [[ "${compstate[pattern_match]-*}" = \** ]]; then
-    str="${PREFIX}*${SUFFIX}"
-  else
-    str="${PREFIX}${SUFFIX}"
-  fi
-else
-  str="${PREFIX:q}*${SUFFIX:q}"
-  [[ "$str" = \\\~* ]] && str="$str[2,-1]"
-fi
+pre="$PREFIX"
+suf="$SUFFIX"
 orig="${PREFIX}${SUFFIX}"
 
-[[ $compstate[insert] = *menu || -n "$_comp_correct" ||
+[[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" ||
    ( $#compstate[pattern_match] -ne 0 &&
      "${orig#\~}" != "${${orig#\~}:q}" ) ]] && menu=yes
 
-
 # We will first try normal completion called with `compgen', but only if we
-# weren't given a `-F', `-r', or `-R' option.
+# weren't given a `-F', `-r', or `-R' option or we are in the string.
 
-if [[ $#ignore -eq 0 && $#remsfx -eq 0 && -z "$_comp_correct" ]]; then
+if [[ -z "$suf" && $#ignore -eq 0 && $#remsfx -eq 0 &&
+      -z "$_comp_correct" ]]; then
   # First build an array containing the `-W' option, if there is any and we
   # want to use it. We don't want to use it if the string from the command line
   # is a absolute path or relative to the current directory.
 
-  if [[ -z "$tmp1[1]" || "$str[1]" = [~/] || "$str" = (.|..)/* ]]; then
+  if [[ -z "$prepaths[1]" || "$pre[1]" = [~/] || "$pre" = (.|..)/* ]]; then
     tmp1=()
   else
     tmp1=(-W "( $prepaths )")
@@ -145,7 +127,6 @@ if [[ $#ignore -eq 0 && $#remsfx -eq 0 && -z "$_comp_correct" ]]; then
 
   # Now call compgen.
 
-  nm=$compstate[nmatches]
   if [[ -z "$gopt" ]]; then
     compgen "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" "$tmp1[@]" $sopt
   else
@@ -157,13 +138,13 @@ if [[ $#ignore -eq 0 && $#remsfx -eq 0 && -z "$_comp_correct" ]]; then
   [[ compstate[nmatches] -eq nm ]] || return 0
 fi
 
-# No `-F' option, so we want to use `fignore'.
+# If given no `-F' option, we want to use `fignore'.
 
 (( $#ignore )) || ignore=(-F fignore)
 
 # Now let's have a closer look at the string to complete.
 
-if [[ "$str[1]" = \~ ]]; then
+if [[ "$pre[1]" = \~ ]]; then
   # It begins with `~', so remember anything before the first slash to be able
   # to report it to the completion code. Also get an expanded version of it
   # (in `realpath'), so that we can generate the matches. Then remove that
@@ -171,10 +152,10 @@ if [[ "$str[1]" = \~ ]]; then
   # paths and make sure that the loop below is run only once with an empty
   # prefix path by setting `prepaths'.
   
-  linepath="${str%%/*}/"
+  linepath="${pre%%/*}/"
   eval realpath\=$linepath
   [[ "$realpath" = "$linepath" ]] && return 1
-  str="${str#*/}"
+  pre="${pre#*/}"
   orig="${orig#*/}"
   donepath=''
   prepaths=( '' )
@@ -185,12 +166,12 @@ else
   linepath=''
   realpath=''
 
-  if [[ "$str[1]" = / ]]; then
+  if [[ "$pre[1]" = / ]]; then
     # If it is a absolut path name, we remove the first slash and put it in
     # `donepath' meaning that we treat it as the path that was already handled.
     # Also, we don't use the paths from `-W'.
 
-    str="$str[2,-1]"
+    pre="$pre[2,-1]"
     orig="$orig[2,-1]"
     donepath='/'
     prepaths=( '' )
@@ -198,278 +179,204 @@ else
     # The common case, we just use the string as it is, unless it begins with
     # `./' or `../' in which case we don't use the paths from `-W'.
     
-    [[ "$str" = (.|..)/* ]] && prepaths=( '' )
+    [[ "$pre" = (.|..)/* ]] && prepaths=( '' )
     donepath=''
   fi
 fi
 
-# Now build the glob pattern by calling `_match_pattern'.
-patstr="$str"
-matchflags=""
-_match_pattern _path_files patstr matchflags
-origflags="$matchflags"
-[[ -n "$_comp_correct" ]] && matchflags="$matchflags(#a$_comp_correct)"
-
-# We almost expect the pattern to have changed `..' into `*.*.', `/.' into
-# `/*.', and probably to contain two or more consecutive `*'s. Since these
-# have special meaning for globbing, we remove them. But before that, we
-# add the pattern for matching any characters before a slash.
-
-patstr="$patstr:gs-/-*/-:gs/*.*./../:gs/**/*/:gs-.*/-./-"
-
-# We take the last pathname component from the pattern and store it in
-# `patlast', replacing `*'s in it with patterns that match any character
-# but not slashes. Later we will generate matches using `patstr' with the
-# patterns we were given (like `*.c') appended to it, producing all matching
-# files. These filenames are then compared to `patlast' and all names not
-# matching that will be removed. All this is needed to be able to correctly
-# support `completeinword' as otherwise we would have something like `a*x'
-# from the line (the `*' was inserted above) and appending the `-g' pattern
-# `*.tex' would yield `a*x*.tex' which is not what we want.
-
-if [[ "$patstr" = */* ]]; then
-  if [[ -n "$_comp_correct" && "${#orig##*/}" -le _comp_correct ]]; then
-    patlast="*/${origflags}${${${patstr##*/}//\*/[^/]#}:gs.\[^/]#.\\\*.}"
-  else
-    patlast="*/${matchflags}${${${patstr##*/}//\*/[^/]#}:gs.\[^/]#.\\\*.}"
-  fi
-  patstr="${patstr%/*}/"
-else
-  if [[ -n "$_comp_correct" && "$#orig" -le _comp_correct ]]; then
-    patlast="${origflags}${${patstr//\*/[^/]#}:gs.\[^/]#.\\\*.}"
-  else
-    patlast="${matchflags}${${patstr//\*/[^/]#}:gs.\[^/]#.\\\*.}"
-  fi
-  patstr=""
-fi
-
-# First we skip over all pathname components in `str' which really exist in
-# the file-system, so that `/usr/lib/l<TAB>' doesn't offer you `lib' and
-# `lib5'. Pathname components skipped this way are taken from `orig' and added
-# to `donepath'.
+# Now we generate the matches. First we loop over all prefix paths given
+# with the `-W' option.
 
-while [[ "$orig" = */* ]] do
-  tmp1=( $realpath$donepath${orig%%/*}/${~matchflags}${~patstr#*/}${^~pats} )
-  tmp1=("${(@M)tmp1:#$~patlast}")
-  [[ $#tmp1 -gt 0 && -e "$realpath$donepath${orig%%/*}" ]] || break
-  donepath="$donepath${orig%%/*}/"
-  orig="${orig#*/}"
-  patstr="${patstr#*/}"
-done
+for prepath in "$prepaths[@]"; do
 
-# Finally, generate the matches. First we loop over all the paths from `-W'.
-# Note that in this loop `str' is used as a modifyable version of `patstr'
-# and `testpath' is a modifyable version of `donepath'.
+  # Get local copies of the prefix, suffix, and the prefix path to use
+  # in the following loop, which walks through the pathname components
+  # in the string from the line.
 
-for prepath in "$prepaths[@]"; do
-  str="$patstr"
+  tpre="$pre"
+  tsuf="$suf"
   testpath="$donepath"
-  ostr="$orig"
 
-  [[ -z "$prepath" || "$prepath[-1]" = / ]] || prepath="${prepath}/"
+  tmp1=( "$prepath$realpath$donepath" )
 
-  # The second loop tests the components of the path in `str' to get the
-  # possible matches.
+  while true; do
 
-  while [[ "$str" = */* ]] do
-    # `rest' is the pathname after the first slash that is left. In `tmp1'
-    # we get the globbing matches for the pathname component currently
-    # handled.
+    # Skip over `./' and `../'.
+
+    if [[ "$tpre" = (.|..)/* ]]; then
+      tmp1=( ${^tmp1}${tpre%%/*}/ )
+      tpre="${tpre#*/}"
+      continue
+    fi
 
-    if [[ -n "$_comp_correct" && "${#ostr%%/*}" -le _comp_correct ]]; then
-      mflags="$origflags"
+    # Get the prefix and suffix for matching.
+
+    if [[ "$tpre" = */* ]]; then
+      PREFIX="${tpre%%/*}"
+      SUFFIX=""
     else
-      mflags="$matchflags"
+      PREFIX="${tpre}"
+      SUFFIX="${tsuf%%/*}"
     fi
-    rest="${str#*/}"
-    tmp1="${prepath}${realpath}${testpath}${~mflags}${str%%/*}(-/)"
-    tmp1=( $~tmp1 )
 
-    if [[ $#tmp1 -eq 0 ]]; then
-      # If this didn't produce any matches, we don't need to test this path
-      # any further, so continue with the next `-W' path, if any.
+    # Get the matching files by globbing.
 
-      continue 2
-    elif [[ $#tmp1 -gt 1 ]]; then
-      # If it produced more than one match, we want to remove those which
-      # don't have possible following pathname components matching the 
-      # rest of the string we are completing. (The case with only one
-      # match is handled below.)
-      # In `collect' we will collect those of the produced pathnames that
-      # have a matching possible path-suffix. In `suffixes' we build an
-      # array containing strings build from the rest of the string to 
-      # complete and the glob patterns we were given as arguments.
-
-      collect=()
-      suffixes=( $rest$^pats )
-      suffixes=( "${(@)suffixes:gs.**.*.}" )
-
-      if [[ -n "$_comp_correct" && "${#ostr#*/}" -le _comp_correct ]]; then
-        mflags="$origflags"
-      else
-        mflags="$matchflags"
-      fi
+    if [[ "$tpre$tsuf" = */* ]]; then
+      tmp1=( ${^tmp1}*(D/) )
+    else
+      tmp1=( ${^tmp1}${^~pats} )
+    fi
+
+    if [[ -n "$PREFIX$SUFFIX" ]]; then
+      # See which of them match what's on the line.
 
-      # In the loop the prefixes from the `tmp1' array produced above and
-      # the suffixes we just built are used to produce possible matches
-      # via globbing.
-
-      for i in "$tmp1[@]" ; do
-        tmp2=( ${~i}/${~mflags}${~suffixes} )
-        tmp2=("${(@M)tmp2:#$~patlast}")
-        [[ $#tmp2 -ne 0 ]] && collect=( $collect $i )
-      done
-
-      # If this test showed that none of the matches from the glob in `tmp1'
-      # has a possible sub-path matching what's on the line, we add the
-      # matches found in `tmp1' and otherwise give up and continue with the
-      # next `-W' path.
-
-      if [[ $#collect -eq 0 ]]; then
-        # Before giving, we first try to get the longest expandable path-
-	# prefix, though. The result is stored in `exppaths'
-
-        tmp2=()
-	tmp3="$rest"
-	tmp4="${ostr##*/}"
-	ostr="${ostr%/*}"
-	while [[ "$tmp3" = */* ]]; do
-	  tmp2=( ${^tmp1}/${~mflags}${~tmp3} )
-	  if [[ $#tmp2 -eq 1 ]]; then
-	    exppaths=( "$exppaths[@]" "${tmp2[1]}${tmp4}" )
-	    exppaths=( "${(@)exppaths#${prepath}${realpath}}" )
-	    break;
-          fi
-	  tmp3="${tmp3%/*}"
-	  tmp4="${ostr##*/}/${tmp4}"
-	  ostr="${ostr%/*}"
-        done
+      compadd -O tmp2 "$ignore[@]" - "${(@)tmp1##*/}"
+
+      # If no file matches, save the expanded path and continue with
+      # the outer loop.
+
+      if [[ $#tmp2 -eq 0 ]]; then
+ 	[[ "$tmp1[1]" = */* ]] &&
+	    exppaths=( "$exppaths[@]" ${^tmp1%/*}/${tpre}${tsuf} )
         continue 2
-      elif [[ $#collect -ne 1 ]]; then
-        # If we have more than one possible match, this means that the
-	# pathname component currently handled is ambiguous, so we give
-	# it to the completion code.
-	# First we build the full path prefix in `tmp1'.
+      fi
 
-        tmp1="$prepath$realpath$testpath"
+      # Remove all files that weren't matched.
 
-	# Now produce all matching pathnames in `collect'.
+      if [[ "$tmp1[1]" = */* ]]; then
+        tmp1=( "${(@M)tmp1:#*/(${(j:|:)~${(@)tmp2:q}})}" )
+      else
+        tmp1=( "${(@M)tmp1:#(${(j:|:)~${(@)tmp2:q}})}" )
+      fi
+    elif (( ! $#tmp1 )); then
+      [[ "$tmp1[1]" = */* ]] &&
+          exppaths=( "$exppaths[@]" ${^tmp1%/*}/${tpre}${tsuf} )
+      continue 2
+    fi
 
-        collect=( ${~collect}/${~matchflags}${~suffixes} )
-	collect=("${(@M)collect:#$~patlast}")
+    # Step over to the next component, if any.
 
-	# And then remove the common path prefix from all these matches.
+    if [[ "$tpre" = */* ]]; then
+      tpre="${tpre#*/}"
+    elif [[ "$tsuf" = */* ]]; then
+      tpre="${tsuf#*/}"
+      tsuf=""
+    else
+      break
+    fi
 
-        collect=( ${collect#$tmp1} )
+    # There are more components, so add a slash to the files we are
+    # collecting.
 
-	# Finally, we add all these matches with the common (unexpanded)
-	# pathprefix (the `-p' option), the path-prefix (the `-W' option)
-	# to allow the completion code to test file type, and the path-
-	# suffix (the `-s' option). We also tell the completion code that
-	# these are file names and that `fignore' should be used as usual
-	# (the `-f' and `-F' options).
+    tmp1=( ${^tmp1}/ )
+  done
 
-	if [[ -n "$menu" ]]; then
-          compadd -QU "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \
-                  -i "$IPREFIX" -I "$ISUFFIX" -p "$linepath${testpath:q}" \
-		  -s "/${ostr#*/}" \
-		  -W "$tmp1" -f "$ignore[@]" - "${(@)${(@)collect%%/*}:q}"
-	else
-          for i in $collect; do
-            compadd -QU "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \
-	            -i "$IPREFIX" -I "$ISUFFIX" \
-                    -p "$linepath${testpath:q}" -s "/${${i#*/}:q}" \
-		    -M 'r:|/=*' -W "$tmp1" -f "$ignore[@]" - "${${i%%/*}:q}"
-          done
-	fi
+  # The next loop searches the first ambiguous component.
 
-	# We have just finished handling all the matches from above, so we
-	# can continue with the next `-W' path.
+  tmp3="$pre$suf"
+  tmp1=( "${(@)tmp1#${prepath}${realpath}${testpath}}" )
 
-	continue 2
-      fi
+  while true; do
 
-      # We reach this point if only one of the path prefixes in `tmp1'
-      # has a existing path-suffix matching the string from the line.
-      # In this case we accept this match and continue with the next
-      # path-name component.
+    # First we check if some of the files match the original string
+    # for this component. If there are some we remove all other
+    # names. This avoid having `foo' complete to `foo' and `foobar'.
 
-      tmp1=( "$collect[1]" )
-    elif [[ -n "$_comp_correct" && "$mflags" = "$matchflags" ]]; then
+    if [[ "$tmp3" = */* ]]; then
+      tmp4=( "${(@M)tmp1:#${tmp3%%/*}/*}" )
+      if (( $#tmp4 )); then
+        tmp1=( "$tmp4[@]" )
+      fi
+    fi
 
-      # If we got only one match with auto-correction and if we get none
-      # without correction, stop now.
+    # Next we see if this component is ambiguous.
 
-      tmp2="${prepath}${realpath}${testpath}${~origflags}${str%%/*}(-/)"
-      tmp2=( $~tmp2 )
+    if [[ "$tmp3" = */* ]]; then
+      tmp4=( "${(@)tmp1:#${tmp1[1]%%/*}/*}" )
+    else
+      tmp4=( "${(@)tmp1:#${tmp1[1]}}" )
+    fi
 
-      if [[ $#tmp1 -ne $#tmp2 ]]; then
-        compadd -QU "$addpfx[@]" -S '' "$group[@]" "$expl[@]" \
-                -i "$IPREFIX" -I "$ISUFFIX" \
-                -p "$linepath${testpath:q}" -s "/${ostr#*/}" \
-		- "${${tmp1#${prepath}${realpath}${testpath}}:q}"
-        continue 2
+    if (( $#tmp4 )); then
+
+      # It is. For menucompletion we now add the possible completions
+      # for this component with the unambigous prefix we have built
+      # and the rest of the string from the line as the suffix.
+      # For normal completion we add the rests of the filenames
+      # collected as the suffixes to make the completion code expand
+      # it as far as possible.
+
+      if [[ -n $menu ]]; then
+        if [[ "$tmp3" = */* ]]; then
+	  compadd -Uf -p "$linepath$testpath" -s "/${tmp3#*/}" \
+	          -W "$prepath$realpath$testpath" "$ignore[@]" \
+		  "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
+		  "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+		  - "${(@)tmp1%%/*}"
+	else
+	  compadd -Uf -p "$linepath$testpath" \
+	          -W "$prepath$realpath$testpath" "$ignore[@]" \
+		   "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
+		   "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+		   - "$tmp1[@]"
+	fi
+      else
+        if [[ "$tmp3" = */* ]]; then
+          for i in "$tmp1[@]"; do
+	    compadd -Uf -p "$linepath$testpath" -s "/${i#*/}" \
+		    -W "$prepath$realpath$testpath" "$ignore[@]" \
+		    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \
+		    "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+		    - "${i%%/*}"
+	  done
+        else
+	  compadd -Uf -p "$linepath$testpath" \
+		  -W "$prepath$realpath$testpath" "$ignore[@]" \
+		  "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
+		  "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+		  - "$tmp1[@]"
+        fi
       fi
+      tmp4=-
+      break
     fi
-    # This is also reached if the first globbing produced only one match
-    # in this case we just continue with the next pathname component, too.
 
-    tmp1="$tmp1[1]"
-    testpath="$testpath${tmp1##*/}/"
-    str="$rest"
-    ostr="${ostr#*/}"
-  done
+    # If we have checked all components, we stop now and add the 
+    # strings collected after the loop.
 
-  # We are here if all pathname components except the last one (which is still
-  # not tested) are unambiguous. So we add matches with the full path prefix, 
-  # no path suffix, the `-W' we are currently handling, all the matches we
-  # can produce in this directory, if any.
+    if [[ "$tmp3" != */* ]]; then
+      tmp4=""
+      break
+    fi
 
-  if [[ -n "$_comp_correct" && "${#ostr#*/}" -le _comp_correct ]]; then
-    mflags="$origflags"
-  else
-    mflags="$matchflags"
-  fi
-  tmp1="$prepath$realpath$testpath"
-  suffixes=( $str$^pats )
-  suffixes=( "${(@)suffixes:gs.**.*.}" )
-  tmp2=( ${~tmp1}${~matchflags}${~suffixes} )
-  if [[ "$tmp1" = */* && "$patlast" != \*/* ]]; then
-    tmp2=("${(@M)tmp2:#*${~patlast}}")
-  else
-    tmp2=("${(@M)tmp2:#$~patlast}")
-  fi
-  if [[ $#tmp2 -eq 0 ]]; then
-    # No match, insert the expanded path and add the original tail.
+    # Otherwise we add the unambiguous component to `testpath' and
+    # take it from the filenames.
 
-    [[ "$testpath[-1]" = / ]] && testpath="$testpath[1,-2]"
-    [[ -z "$testpath" && "$linepath[-1]" = / ]] && linepath="$linepath[1,-2]"
-    [[ -n "$ostr" && -n "$linepath$testpath" ]] && ostr="/$ostr"
+    testpath="${testpath}${tmp1[1]%%/*}/"
+    tmp1=( "${(@)tmp1#*/}" )
 
-    # But only if something changed.
-    [[ "${PREFIX}${SUFFIX}" = $linepath$testpath$ostr(|/) ]] && return 1
+    tmp3="${tmp3#*/}"
+  done
 
-    compadd -QU -S '' "$group[@]" "$expl[@]" \
-            -i "$IPREFIX" -I "$ISUFFIX" -f - "$linepath${testpath:q}$ostr"
-  else
-    compadd -QU "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" "$group[@]" "$expl[@]" \
-            -i "$IPREFIX" -I "$ISUFFIX" \
-            -p "$linepath${testpath:q}" -f "$ignore[@]" \
-	    -W "$prepath$realpath$testpath" - "${(@)${(@)tmp2#$tmp1}:q}"
+  if [[ -z "$tmp4" ]]; then
+    compadd -Uf -p "$linepath$testpath" \
+	    -W "$prepath$realpath$testpath" "$ignore[@]" \
+	    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
+	    "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
+	    - "$tmp1[@]"
   fi
 done
 
-# If no matches were found but we have expanded paths which are different
-# from the original string, use them.
+# If we are configured to expand paths as far as possible and we collected
+# expanded paths that are different from the string on the line, we add
+# them as possible matches.
 
 exppaths=( "${(@)exppaths:#$orig}" )
 
 if [[ -n "$compconfig[path_expand]" &&
-      nm -eq compstate[nmatches] && $#exppaths -ne 0 ]]; then
-  compadd -UQ -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" - \
-          "${linepath}${(@)^exppaths}"
+      $#exppaths -ne 0 && nm -eq compstate[nmatches] ]]; then
+  compadd -U -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" - \
+          "${(@)exppaths}"
 fi
 
-# This sets the return value to indicate that we added matches (or not).
-
-[[ nm -ne compstate[nmatches] ]]
+[[ nm -eq compstate[nmatches] ]]
diff --git a/Completion/Core/_sep_parts b/Completion/Core/_sep_parts
index fc927163b..b906a3042 100644
--- a/Completion/Core/_sep_parts
+++ b/Completion/Core/_sep_parts
@@ -9,24 +9,17 @@
 #
 #  _sep_parts '(foo bar)' @ hosts
 #
-# This will make this function complete the strings in the array
-# `friends'. If the string on the line contains a `@', the substring
-# after it will be completed from the array `hosts'. Of course more
-# arrays may be given, each preceded by another separator string.
+# This will make this function complete the strings `foo' and `bar'
+# If the string on the line contains a `@', the substring after it
+# will be completed from the array `hosts'. Of course more arrays
+# may be given, each preceded by another separator string.
 #
 # This function understands the `-J group', `-V group', and
 # `-X explanation' options.
-#
-# This function does part of the matching itself and calls the functions
-# `_match_test' and `_match_pattern' for this.
 
 local str arr sep test testarr tmparr prefix suffixes matchers autosuffix
 local matchflags opt group expl nm=$compstate[nmatches]
 
-# Test if we should use this function for the global matcher in use.
-
-_match_test _sep_parts || return 1
-
 # Get the options.
 
 group=()
@@ -42,7 +35,7 @@ shift OPTIND-1
 # Get the string from the line.
 
 str="$PREFIX$SUFFIX"
-[[ $#compstate[pattern_match] -ne 0 ]] || str="$str:q"
+SUFFIX=""
 prefix=""
 
 # Walk through the arguments to find the longest unambiguous prefix.
@@ -56,61 +49,49 @@ while [[ $# -gt 1 ]]; do
     tmparr=( ${=arr[2,-2]} )
     arr=tmparr
   fi
-  # Is the separator on the line?
-  [[ "$str" != *${sep}* ]] && break
 
-  # Build a pattern matching the possible matches and get all these
-  # matches in an array.
+  # Is the separator on the line?
 
-  test="${str%%${sep}*}"
-  [[ -n "$_comp_correct" && $#test -le _comp_correct ]] && return 1
+  [[ "$str" != *${sep}* ]] && break
 
-  matchflags=""
-  _match_pattern _sep_parts test matchflags
-  [[ -n "$_comp_correct" ]] && matchflags="$matchflags(#a$_comp_correct)"
+  # Get the matching array elements.
 
-  test="${matchflags}${test}"
-  testarr=( "${(@M)${(@P)arr}:#${~test}*}" )
-  testarr=( "${(@)testarr:#}" )
+  PREFIX="${str%%${sep}*}"
+  compadd -O testarr - "${(@P)arr}"
 
   # If there are no matches we give up. If there is more than one
   # match, this is the part we will complete.
+
   (( $#testarr )) || return 1
   [[ $#testarr -gt 1 ]] && break
 
   # Only one match, add it to the prefix and skip over it in `str',
   # continuing with the next array and separator.
+
   prefix="${prefix}${testarr[1]}${sep}"
   str="${str#*${sep}}"
   shift 2
 done
 
 # Get the array to work upon.
+
 arr="$1"
 if [[ "$arr[1]" == '(' ]]; then
   tmparr=( ${=arr[2,-2]} )
   arr=tmparr
 fi
+
 if [[ $# -le 1 || "$str" != *${2}* ]]; then
   # No more separators, build the matches.
 
-  test="$str"
-  [[ -n "$_comp_correct" && $#test -le _comp_correct ]] && return 1
-
-  matchflags=""
-  _match_pattern _sep_parts test matchflags
-  [[ -n "$_comp_correct" ]] && matchflags="$matchflags(#a$_comp_correct)"
-
-  [[ "${compstate[pattern_match]-*}" != \** ]] && test="$test:gs/*//"
-
-  test="${matchflags}${test}"
-  testarr=( "${(@M)${(@P)arr}:#${~test}*}" )
-  testarr=( "${(@)testarr:#}" )
+  PREFIX="$str"
+  compadd -O testarr - "${(@P)arr}"
 fi
 
 [[ $#testarr -eq 0 || ${#testarr[1]} -eq 0 ]] && return 1
 
 # Now we build the suffixes to give to the completion code.
+
 shift
 matchers=()
 suffixes=("")
@@ -118,26 +99,18 @@ autosuffix=()
 
 while [[ $# -gt 0 && "$str" == *${1}* ]]; do
   # Remove anything up to the the suffix.
+
   str="${str#*${1}}"
 
   # Again, we get the string from the line up to the next separator
   # and build a pattern from it.
+
   if [[ $# -gt 2 ]]; then
-    test="${str%%${3}*}"
+    PREFIX="${str%%${3}*}"
   else
-    test="$str"
+    PREFIX="$str"
   fi
 
-  [[ -n "$_comp_correct" && $#test -le _comp_correct ]] && return 1
-
-  matchflags=""
-  _match_pattern _sep_parts test matchflags
-  [[ -n "$_comp_correct" ]] && matchflags="$matchflags(#a$_comp_correct)"
-
-  [[ "${compstate[pattern_match]-*}" != \** ]] && test="$test:gs/*//"
-
-  test="${matchflags}${test}"
-
   # We incrementally add suffixes by appending to them the seperators
   # and the strings from the next array that match the pattern we built.
 
@@ -146,26 +119,31 @@ while [[ $# -gt 0 && "$str" == *${1}* ]]; do
     tmparr=( ${=arr[2,-2]} )
     arr=tmparr
   fi
-  tmparr=( "${(@M)${(@P)arr}:#${~test}*}" )
-  tmparr=( "${(@)tmparr:#}" )
+
+  compadd -O tmparr - "${(@P)arr}"
+
   suffixes=("${(@)^suffixes[@]}${1}${(@)^tmparr}")
 
   # We want the completion code to generate the most specific suffix
   # for us, so we collect matching specifications that allow partial
   # word matching before the separators on the fly.
+
   matchers=("$matchers[@]" "r:|${1:q}=*")
   shift 2
 done
 
 # If we were given at least one more separator we make the completion
 # code offer it by appending it as a autoremovable suffix.
+
 (( $# )) && autosuffix=(-qS "$1")
 
 # If we have collected matching specifications, we build an array
 # from it that can be used as arguments to `compadd'.
+
 [[ $#matchers -gt 0 ]] && matchers=(-M "$matchers")
 
 # Add the matches for each of the suffixes.
+
 for i in "$suffixes[@]"; do
   compadd -U "$group[@]" "$expl[@]" "$matchers[@]" "$autosuffix[@]" \
           -i "$IPREFIX" -I "$ISUFFIX" -p "$prefix" -s "$i" - "$testarr[@]"
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 19a0fd1ad..20b1262ec 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -1,25 +1,23 @@
 # Initialisation for new style completion. This mainly contains some helper
-# function and aliases. Everything else is split into different files in this
-# directory that will automatically be made autoloaded (see the end of this
-# file).
+# functions and aliases. Everything else is split into different files that
+# will automatically be made autoloaded (see the end of this file).
 # The names of the files that will be considered for autoloading have to
-# start with a underscores (like `_setopt).
+# start with an underscores (like `_setopt).
 # The first line of these files will be read and has to say what should be
 # done with its contents:
 #
-#   `#defcomp <names ...>'
-#     if the first line looks like this, the file is
-#     autoloaded as a function and that function will
-#     be called to generate the matches when completing
-#     for one of the commands whose <name> is given
+#   `#compdef <names ...>'
+#     If the first line looks like this, the file is autoloaded as a
+#     function and that function will be called to generate the matches
+#     when completing for one of the commands whose <names> are given.
 #
-#   `#defpatcomp <pattern>'
-#     this defines a function that should be called to generate
-#     matches for commands whose name matches <pattern>; note
-#     that only one pattern may be given
+#   `#compdef -p <pattern>'
+#     This defines a function that should be called to generate matches
+#     for commands whose name matches <pattern>. Note that only one pattern
+#     may be given.
 #
-#   `#defkeycomp <style> [ <key-sequence> ... ]
-#     this is used to bind special completions to all the given
+#   `#compdef -k <style> [ <key-sequence> ... ]
+#     This is used to bind special completions to all the given
 #     <key-sequence>(s). The <style> is the name of one of the built-in
 #     completion widgets (complete-word, delete-char-or-list,
 #     expand-or-complete, expand-or-complete-prefix, list-choices,
@@ -41,11 +39,6 @@
 # were able to add matches and non-zero otherwise.
 #
 # See the file `compdump' for how to speed up initialisation.
-#
-# If you are using global matching specifications with `compctl -M ...'
-# have a look at the files `_match_test' and `_match_pattern'. To make
-# all the example functions use matching as specified with `-M' these
-# need some editing.
 
 # If we got the `-d'-flag, we will automatically dump the new state (at
 # the end).
@@ -220,17 +213,34 @@ compdef() {
 # and sets the according values in `compconfig'.
 # Arguments may be `foo=bar' to set key `foo' to `bar' or `baz' to
 # set key `baz' to the empty string.
+# If no arguments are given, all configurations keys set are displayed.
+# With the option `-l' as the first argument, the other arguments are
+# taken to be key names and the values for theses keys are printed, one
+# per line.
 
 compconf() {
   local i
 
-  for i; do
-    if [[ "$i" = *\=* ]]; then
-      compconfig[${i%%\=*}]="${i#*\=}"
+  if (( $# )); then
+    if [[ "$1" = -l ]]; then
+      shift
+      for i; do
+        print $compconfig[$i]
+      done
     else
-      compconfig[$i]=''
+      for i; do
+        if [[ "$i" = *\=* ]]; then
+          compconfig[${i%%\=*}]="${i#*\=}"
+        else
+          compconfig[$i]=''
+        fi
+      done
     fi
-  done
+  else
+    for i in ${(k)compconfig}; do
+      print ${(r:25:)i} $compconfig[$i]
+    done
+  fi
 }
 
 # Now we automatically make the definition files autoloaded.
@@ -262,12 +272,12 @@ if [[ -z "$_i_done" ]]; then
       read -rA _i_line < $_i_file
       _i_tag=$_i_line[1]
       shift _i_line
-      if [[ $_i_tag = '#defcomp' ]]; then
-        compdef -na "${_i_file:t}" "${_i_line[@]}"
-      elif [[ $_i_tag = '#defpatcomp' ]]; then
-        compdef -pa "${_i_file:t}" "${_i_line[@]}"
-      elif [[ $_i_tag = '#defkeycomp' ]]; then
-        compdef -ka "${_i_file:t}" "${_i_line[@]}"
+      if [[ $_i_tag = '#compdef' ]]; then
+	if [[ $_i_line[1] = -[pk] ]]; then
+	  compdef ${_i_line[1]}a "${_i_file:t}" "${(@)_i_line[2,-1]}"
+	else
+	  compdef -na "${_i_file:t}" "${_i_line[@]}"
+	fi
       elif [[ $_i_tag = '#autoload' ]]; then
 	autoload ${_i_file:t}
       fi
diff --git a/Completion/README b/Completion/README
index bf677066a..dbfb50534 100644
--- a/Completion/README
+++ b/Completion/README
@@ -1,356 +1,3 @@
-The subdirectories contain code for the new function-based completion
-system.  Broadly speaking, this uses shell functions defined for each
-command to determine how the arguments of a command should be completed.
-
-You should copy all the files you need or want to a directory of your own,
-which should be included in your autoload path as defined by $fpath.  Then
-in your .zshrc you should source the file which appears here in
-Core/compinit.  It is recommnded that you use the -d option, which outputs
-a file containing the necessary variables, bindkeys etc., making later
-loading much faster.  For example,
-  [[ -f ~/completion/compinit ]] && . ~/completion/compinit -d
-The name of the file to use may be given as an extra argument.
-
-This will rebind any keys which do completion to use the new system.
-For more detailed instructions, including how to add new completions, see
-the top of Core/compinit. For information about how to configure the code,
-see the section below.
-
-The subdirectories contain:
-
-Core:
-  The basic functions and files to be sourced.  You will certainly need
-  these, and will most likely not want to alter them --- if you do, it
-  would probably help to give your version a different name.  The files
-  are:
-  compinit
-    As already described, this is not a function, but is sourced once
-    (with the `source' or `.' commands) to set up the completion system.
-  compdump
-    This dumps the completions status for faster initialisation.  The
-    easiest way of doing this is to use the -d option to compinit rather
-    than calling compdump directly.
-  _approximate
-    A completer function that does correcting completion.
-  _compalso
-    Utility for calling a function to add additional completions to an
-    already existing set.
-  _complete
-    The main completer function that generates the completions by calling
-    the context and command specific functions.
-  _correct
-    A completer function that attempts correction on the word from the
-    line. Unlike _approximate this does only correction, not completion.
-  _expand
-    A completer function for expanding the word on the line.
-  _files
-    A frontend to _path_files which will default to any old file if the
-    specified file was not found.
-  _list
-    A completer function that allows showing only a list on the first
-    TAB and insert completions on the second one.
-  _match
-    A completer function that temporarily swicthes on pattern matching
-    when comparing the string from the line with possible completions.
-  _main_complete
-    The main entry point called by the key bindings which compinit sets
-    up (the main `completion widget' in zsh jargon). This mainly calls
-    completer functions like _complete, either those given as arguments
-    or (if it is called without arguments) those from the completer
-    configuration key (see below).
-  _multi_parts
-    Utility for completion parts of words given a separator character and 
-    a list of words.
-  _normal
-    The function called by _main_complete to handle the most common
-    cases, such as completing a command name or its arguments.  This
-    function dispatches to the various other functions for individual
-    commands.  (Actually, the system is fairly context-sensitive, so
-    it is wider than just command+argument.)
-  _options
-    Utility to complete option names, allowing the optional `no' prefix
-    and correctly handling upper case letters and underscores.
-  _parameters
-    This can be used to complete parameter names if you need some of the
-    options of compadd not supported by compgen.
-  _path_files
-    The function usually called to complete filenames and directories.  It
-    replaces the standard -f, -g and -/ options for the basic completion
-    commands:  it can do various extra tricks, such as expanding a whole
-    path at once, e.g. F/C/C/_p<TAB> -> Functions/Completion/Core/_path_files
-  _sep_parts
-    Utility used for completing words with multiple separate parts, such as
-    `<user>@<host>'
-  _set_options
-  _unset_options
-    These can be used to complete only set or unset options. For this to
-    work, you'll have to un-comment a few lines in _main_complete.
-Base:
-  You will almost certainly want these files, too, which handle standard
-  tasks like completing files.  However, you may want to edit them for
-  your own particular setup.  Files are:
-  _command_names
-    This handles completion of the command word, i.e. the first thing
-    on the command line.  You may want to alter this, for example,
-    to complete parameters to assign to.
-  _condition
-    This handles completing inside [[ ... ]] .
-  _default
-    This handles completion of command arguments when no special function
-    exists.  Usually this means completing files, but you can modify this
-    as you wish.
-  _long_options
-    This handles options beginning with `--', as in many GNU commands.
-    The command must accept the --help option to list the possible options.
-    __long_options can also take arguments to help it decide what to
-    complete as the value of the option.  Note that this is potentially
-    dangerous because the command from the line will be called with the
-    --help option and hence could cause damage if used with a command
-    that does not support it.
-  _match_pattern
-  _match_test
-    These are used by Base/_path_files (and hence also Base/_files)
-    and Base/_sep_parts for file completion with control over
-    matching (whether to complete case-insensitively, or to allow
-    insertion before `.', etc.)  See _match_test for instructions.
-    Note _path_files expects these files to be present.
-  _precommand
-    Allows completion when the first word on the line has to be ignored,
-    for example `noglob ...' should ignore the noglob and just complete
-    as if it wasn't there.  Add other such commands to the top line.
-  _redirect
-    Completes after `<' or `>': this version calls _files.
-  _subscript
-    For completion in subscripts of parameters, e.g $foo[...].
-  _vars
-    Completion for commands which need variables (so this could also be in
-    the Builtins directory), but also in math environments such as ((...)).
-  _tilde
-    Completion after `~', defaults to user names and named directories.
-  _equal
-    Completion after `=', normally command and alias names are used.
-  _parameter
-  _brace_parameter
-    For completion inside parameter expansions ($... and ${...).
-Builtins:
-  Define completions for various shell builtins.  The top line of each file
-  says which builtins they apply to; in many cases you can guess from the
-  name.  Note in particular that _zftp defines completions for all commands
-  beginning `zf', not just for the module command zftp.  This is only
-  really useful if you use zftp with the zf* function suite (zfopen, zfget,
-  ...).
-User:
-  This contains a pot pourri of completions for various external commands.
-  Not all will work unmodified on your system.
-Commands:
-  These functions define separate completion commands which do not use
-  the usual context information, and hence have to be bound separately
-  to keys.  As they appear, they have bindings which you can change or
-  delete by altering the top line of the file.  To bind a function
-  (strictly speaking, the corresponding completion widget) yourself
-  after completion is loaded, use `bindkey '<key-string>' <_function_name>'.
-  The files are:
-  _correct_filename, bound to \C-xc
-    Correct the word under the cursor as a filename.  This is significantly
-    more powerful than the standard \e$ (spell-word) binding.
-  _most_recent_file, bound to \C-xm
-    Insert the name of the most recent file matching the pattern
-    so far on the command line.
-
-
-Configuration
-
-You can configure several aspects of the completion functions and the
-overall completion behavior using the compconf shell function defined
-in compinit. This function gets any number of arguments of the form
-`key=value', where `key' is one of the keys described below and `value'
-is any string. Most configuration keys are defined by the completer
-functions.
-
-The completion widget function _main_complete currently understands
-one configuration key:
-
-  completer
-    This should be set to the names of the functions to generate the
-    matches separated by colons. E.g. with
-
-      compconf completer=_complete:_correct:_approximate
-
-    the code will first try normal completion. If that doesn't yield
-    any matches, correction is tried and if that doesn't yield
-    anything either, correcting completion is attempted.
-
-The keys understood by the _approximate completer function are:
-
-  approximate_accept
-    This should be set to a number, specifying the maximum number
-    of errors that should be accepted. If the string also contains
-    a `n' or `N', the code will use the numeric argument as the
-    maximum number of errors if a numeric argument was given. If no
-    numeric argument was given, the number from the value of this
-    key will be used. E.g. with `compconf approximate_accept=2n' two
-    errors will be accepted, but if the user gives another number
-    with the numeric argument, this will be prefered. Also, with
-    `compconf approximate_accept=0n', normally no correction will be
-    tried, but if a numeric argument is given, automatic correction
-    will be used. On the other hand, if the string contains an `!'
-    and a `n' or `N', correction is not attempted if a numeric
-    argument is given. Once the number of errors to accept is
-    determined, the code will repeatedly try to generate matches by
-    allowing one error, two errors, and so on. Independent of the
-    number of errors the user wants to accept, the code will allow
-    only fewer errors than there are characters in the string from
-    the line.
-
-  approximate_original
-    This value is used to determine if the original string should
-    be included in the list (and thus be presented to the user when
-    cycling through the corrections). If it is set to any non-empty
-    value, the original string will be offered. If it contains the
-    sub-string `last', the original string will appear as the last
-    string when cycling through the corrections, otherwise it will
-    appear as the first one (so that the command line does not
-    change immediately). Also, if the value contains the sub-string
-    `always', the original string will always be included, whereas
-    normally it is included only if more than one possible
-    correction was generated.
-
-  approximate_prompt
-    This can be set to a string that should be printed before the
-    list of corrected strings when cycling through them. This string
-    may contain the control sequences `%n', `%B', etc. known from
-    the `-X' option of `compctl'. Also, the sequence `%e' will be
-    replaced by the number of errors accepted to generate the
-    corrected strings.
-
-  approximate_insert
-    If this is set to a string starting with `unambig', the code
-    will try to insert a usable unambiguous string in the command
-    line instead of always cycling through the corrected strings.
-    If such a unambiguous string could be found, the original
-    string is not used, independent of the setting of
-    `approximate_original'. If no sensible string could be found,
-    one can cycle through the corrected strings as usual.
-
-If any of these keys is not set, but the the same key with the
-prefix `correct' instead of `approximate' is set, that value will
-be used. The forms beginning with `correct' are also used by the
-_correct completer function, and this function uses only them, not
-the ones starting with `approximate'. This allows one to give
-different value to be used with correction and correcting
-completion. For example, with:
-
-  compconf completer=_complete:_correct:_approximate
-  compconf correct_accept='2n!' approximate_accept=3n
-
-correction will accept up to two errors. If a numeric argument is
-given, correction will not be used, but correcting completion will
-and it will accept as many errors as given by the numeric argument.
-Without a numeric argument first correction and then correcting
-completion will be tried, with the first one accepting two errors 
-and the second one accepting three errors.
-
-The _match completer function, which allows to give patterns on the
-command line and complete all strings matching it from the set of
-possible completions, understands the following key:
-
-  match_original
-    If this is set to a `only', pattern matching will only be tried
-    with the string from the line. If it is set to any other non-empty
-    string, the original pattern will be tried first and if that yields
-    no completions, matching will be tried again with a `*' inserted
-    at the cursor position. If this key is not set or set to an empty
-    string, matching will only be attempted with the `*' inserted.
-
-The _expand completer allows one to do expansion on the word from the
-line. Note that you may either want to use the configuration keys or
-not use this completer at all if you also use the _match completer
-because the _expand completer will otherwise expand patterns before
-they are seen by the _match completer.
-Configuration keys supported are:
-
-  expand_substitute
-    If this is unset or set to the empty string, the code will first
-    try to expand all substitutions in the string (such as $(...) and
-    ${...}). If this is set to an non-empty string it should be 
-    an expression usable inside a $[...] arithmetical expression.
-    In this case, expansion of substitutions will be done if the
-    expression evaluates to `1'. For example, with
-
-      compconf expand_substitute='NUMERIC != 1'
-
-    substitution will be performed only if given an explicit numeric
-    argument other than `1', as by typing ESC 2 TAB.
-
-  expand_glob
-    If this is unset or set to an empty string, globbing will be
-    attempted on the word resulting from substitution or the
-    original string. The values accepted for this key are the same
-    as for expand_substitute.
-
-  expand_menu
-    If this is unset or set to the empty string, the words resulting
-    from expansion (if any) will simply be inserted in the ommand line,
-    replacing the original string. However, if this key is set to an
-    non-empty string, the user can cycle through the expansion as in
-    a menucompletion. Unless the value contains the sub-string `only',
-    the user will still be offered all expansions at once as one of
-    the strings to insert in the command line. Also, if the value
-    contains the sub-string `last', the string with all expansion will
-    be offered first, whereas normally it is offered as the last string
-    to insert. Finally, if the value contains the sub-string `sort',
-    the expansions will be sorted alphabetically, normally they are
-    kept in the order the expansion produced them in.
-    
-  expand_original
-    If this is set to an non-empty string, the original string from the
-    line will be included in the list of strings the user can cycle
-    through as in a menucompletion. If the value contains the sub-string
-    `last', the original string will appear as the last string, with
-    other values it is inserted as the first one (so that the command
-    line does not change immediatly).
-
-  expand_prompt
-    This may be set to a string that should be displayed before the
-    possible expansions. This is given to the -X option and thus may
-    contain the control sequences `%n', `%B', etc. Also, the sequence
-    `%o' in this string will be replaced by the original string.
-
-The _list completer allows one to delay the insertion of matches until
-completion is attempted a second time without the word on the line 
-being changed. On the first attempt, only the list of matches will
-be shown. Configuration keys understood are:
-
-  list_condition
-    If this key is unset or set to the empty string, this completer
-    will delay the insertion of matches unconditionally. However,
-    if this value is set, it should be set to an expression usable
-    inside a $[...] arithmetical expression. In this case, delaying
-    will be done if the expression evaluates to `1'.
-    For example, with
-
-      compconf list_condition='NUMERIC != 1'
-
-    delaying will be done only if given an explicit numeric argument
-    other than `1'.
-
-  list_word
-    To find out if only listing should be done, the code normally
-    compares the contents of the line with the contents the line
-    had at the time of the last invocation. If this key is set to
-    an non-empty string comparison is done using only the current
-    word. So if it is set, attempting completion on a word equal
-    to the one completion was called on the last time will not
-    delay the generation of matches.
-
-For more information about what the completers do, see the files
-containing them (_complete, _correct, _approximate, _match, and
-_expand in the Core directory).
-
-The _path_files function used to complete filenames has one
-configuration key:
-
-  path_expand
-    If this is set to a non-empty string, the partially typed path
-    from the line will be expanded as far as possible even if trailing
-    pathname components can not be completed.
+The subdirectories contain code for a shell-based system of command-line
+completion.  This is considerably more powerful than the old `compctl'
+method.  For details, see the compsys(1) manual page (`man zshcompsys').
diff --git a/Completion/User/_a2ps b/Completion/User/_a2ps
index 9923ae20d..26f4d200e 100644
--- a/Completion/User/_a2ps
+++ b/Completion/User/_a2ps
@@ -1,4 +1,4 @@
-#defcomp a2ps
+#compdef a2ps
 
 # This is for the GNU version of a2ps.
 
diff --git a/Completion/User/_compress b/Completion/User/_compress
index 860aeb5b0..84ed42fb2 100644
--- a/Completion/User/_compress
+++ b/Completion/User/_compress
@@ -1,3 +1,3 @@
-#defcomp compress
+#compdef compress
 
 _files -g '*~*.Z'
diff --git a/Completion/User/_configure b/Completion/User/_configure
index 7559852e8..01c12dd62 100644
--- a/Completion/User/_configure
+++ b/Completion/User/_configure
@@ -1,4 +1,9 @@
-#defcomp configure
+#compdef configure
 
-_long_options '*=(E|)PREFIX*' '_files -/' \
+_long_options -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
+              -s '(#--disable- --enable-
+	           #--enable- --disable-
+		   #--with- --without-
+		   #--without- --with-)' \
+	      '*=(E|)PREFIX*' '_files -/' \
               '*=PROGRAM*'    '_command_names'
diff --git a/Completion/User/_dd b/Completion/User/_dd
index 6b07a382c..6094d60b7 100644
--- a/Completion/User/_dd
+++ b/Completion/User/_dd
@@ -1,4 +1,4 @@
-#defcomp dd
+#compdef dd
 
 if compset -P 1 'conv\='; then
   # If there's a comma present, ignore up to the last one.  The
diff --git a/Completion/User/_dvi b/Completion/User/_dvi
index bb2fc293e..d49840ae9 100644
--- a/Completion/User/_dvi
+++ b/Completion/User/_dvi
@@ -1,3 +1,3 @@
-#defcomp xdvi dvips dvibook dviconcat dvicopy dvidvi dviselect dvitodvi dvitype
+#compdef xdvi dvips dvibook dviconcat dvicopy dvidvi dviselect dvitodvi dvitype
 
 _files -g '*.(dvi|DVI)'
diff --git a/Completion/User/_find b/Completion/User/_find
index 13d1d797e..116ee6f6b 100644
--- a/Completion/User/_find
+++ b/Completion/User/_find
@@ -1,4 +1,4 @@
-#defcomp find
+#compdef find
 
 local prev="$words[CURRENT-1]"
 
diff --git a/Completion/User/_gunzip b/Completion/User/_gunzip
index 35a27e774..7868e0c24 100644
--- a/Completion/User/_gunzip
+++ b/Completion/User/_gunzip
@@ -1,3 +1,3 @@
-#defcomp gunzip zcat
+#compdef gunzip zcat
 
 _files -g '*.[gG][z]'
diff --git a/Completion/User/_gzip b/Completion/User/_gzip
index 3cda1e4ed..59e74a441 100644
--- a/Completion/User/_gzip
+++ b/Completion/User/_gzip
@@ -1,3 +1,3 @@
-#defcomp gzip
+#compdef gzip
 
 _files -g '*~*.[gG][zZ]'
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index eb418c5b3..911cea03b 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -1,3 +1,3 @@
-#defcomp ftp ncftp ping rwho rup xping traceroute nslookup
+#compdef ftp ncftp ping rwho rup xping traceroute nslookup
 
 compgen -k hosts
diff --git a/Completion/User/_make b/Completion/User/_make
index 24d2cf3f5..f950ad754 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -1,3 +1,3 @@
-#defcomp make gmake pmake
+#compdef make gmake pmake
 
-compgen -s "\$(awk '/^[a-zA-Z0-9][^/ 	]+:/ {print \$1}' FS=: [mM]akefile)"
+compgen -s "\$(awk '/^[a-zA-Z0-9][^\/         ]+:/ {print \$1}' FS=: [mM]akefile)"
diff --git a/Completion/User/_man b/Completion/User/_man
index cd1badc4d..1a175506c 100644
--- a/Completion/User/_man
+++ b/Completion/User/_man
@@ -1,4 +1,4 @@
-#defcomp man
+#compdef man
 
 setopt localoptions rcexpandparam
 
diff --git a/Completion/User/_mh b/Completion/User/_mh
index ab78468d8..c2801b896 100644
--- a/Completion/User/_mh
+++ b/Completion/User/_mh
@@ -1,4 +1,4 @@
-#defcomp folder folders comp inc mark refile repl scan show next prev rmm pick whom mhn mhpath
+#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
diff --git a/Completion/User/_pdf b/Completion/User/_pdf
index 11abc216b..b8759864e 100644
--- a/Completion/User/_pdf
+++ b/Completion/User/_pdf
@@ -1,3 +1,3 @@
-#defcomp acroread
+#compdef acroread
 
 _files -g '*.(pdf|PDF)'
diff --git a/Completion/User/_ps b/Completion/User/_ps
index 6bc0643b2..6c0d91a23 100644
--- a/Completion/User/_ps
+++ b/Completion/User/_ps
@@ -1,3 +1,3 @@
-#defcomp  gs ghostview gview psnup psselect pswrap pstops pstruct lpr
+#compdef  gs ghostview gview psnup psselect pswrap pstops pstruct lpr
 
 _files -g '*([pP][sS]|eps)'
diff --git a/Completion/User/_rcs b/Completion/User/_rcs
index 5e53cb4da..af66739cb 100644
--- a/Completion/User/_rcs
+++ b/Completion/User/_rcs
@@ -1,4 +1,4 @@
-#defcomp co ci rcs
+#compdef co ci rcs
 
 local nm=$compstate[nmatches]
 
diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin
index 5d6daef9b..9f5f3d628 100644
--- a/Completion/User/_rlogin
+++ b/Completion/User/_rlogin
@@ -1,4 +1,4 @@
-#defcomp rlogin rsh ssh
+#compdef rlogin rsh ssh
 
 if [[ CURRENT -eq 2 ]]; then
   compgen -k hosts
diff --git a/Completion/User/_strip b/Completion/User/_strip
index 541c901ad..d9f44cc5e 100644
--- a/Completion/User/_strip
+++ b/Completion/User/_strip
@@ -1,3 +1,3 @@
-#defcomp strip
+#compdef strip
 
 _files -g '*(*)'
diff --git a/Completion/User/_stty b/Completion/User/_stty
index 73c860d54..32355be30 100644
--- a/Completion/User/_stty
+++ b/Completion/User/_stty
@@ -1,4 +1,4 @@
-#defcomp stty
+#compdef stty
 
 if [[ "$words[CURRENT-1]" = \
   (*erase|discard|status|dsusp|intr|kill|lnext|quit|reprint|start|s*p) ]]
diff --git a/Completion/User/_tar b/Completion/User/_tar
index d11ee76c8..f443fefb7 100644
--- a/Completion/User/_tar
+++ b/Completion/User/_tar
@@ -1,4 +1,4 @@
-#defcomp tar
+#compdef tar
 
 # Tar completion.  Features:
 #  - Tries to collect tar commands from second position, single letter
diff --git a/Completion/User/_tex b/Completion/User/_tex
index 1f645e2a2..ac926cfbe 100644
--- a/Completion/User/_tex
+++ b/Completion/User/_tex
@@ -1,3 +1,3 @@
-#defcomp tex latex slitex
+#compdef tex latex slitex
 
 _files -g '*.(tex|TEX|texinfo|texi)'
diff --git a/Completion/User/_uncompress b/Completion/User/_uncompress
index e25805d50..0aa1e073f 100644
--- a/Completion/User/_uncompress
+++ b/Completion/User/_uncompress
@@ -1,3 +1,3 @@
-#defcomp uncompress zmore
+#compdef uncompress zmore
 
 _files -g '*.Z'
diff --git a/Completion/User/_x_options b/Completion/User/_x_options
index 3190ee377..cd45c87f6 100644
--- a/Completion/User/_x_options
+++ b/Completion/User/_x_options
@@ -1,4 +1,4 @@
-#defpatcomp */X11/*
+#compdef -p */X11/*
 
 # A simple pattern completion, just as an example.
 
diff --git a/Completion/User/_xfig b/Completion/User/_xfig
index fcd2bba9f..a3b30bb81 100644
--- a/Completion/User/_xfig
+++ b/Completion/User/_xfig
@@ -1,3 +1,3 @@
-#defcomp xfig
+#compdef xfig
 
 _files -g '*.fig'