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

PATCH: context names



This makes context names (in the completion system) consistent (I
hope). The format is always:

  :completion:<func>:<completer>:<command>:<argument>:<tag>

<func>is used for the names of calling functions such as `predict' and 
the ones from the Commands directory. <command> is either the command
name from the line or one of our special context names (`-command-',
`-condition-' and so on). <argument> is controlled by the completion
function but should normally be something like `arguments-1' or
`-o-1', as expected. Commands with sub-commands append the sub-command 
to the command field, as in `:completion::complete:cvd-add:...'.

In the completion functions $curcontext contains only everything from
<func> to <argument>, without leading or trailing colons. This makes
it quite easy to modify the context names if you need that (it is
seldom needed). This also means that the normal call to zstyle will
now look like:

  zstyle ... ":completion:${curcontext}:<tag>" ...

Note the colons before and after the ${curcontext}, the last one
should be there even if no tag is used.

Also, when writing a bindable command, $curcontext should be set up
correctly, i.e. it should contain three colons -- see the example
functions.

Another small change for completion function writers is that the -C
option of _tags and friends no only modifies the <argument> field
instead of appending something.

There is one small change where I noticed a small inconsistency: the
_cvs function now does *not* use the `cvs' tag any more -- like the
Debian function which don't use tags either.

[ While I'm at it: we still look up the users, groups, ... styles by
using the `users' style on the `users' tag -- should we use an empty
tag here, too? ]

I haven't changed the nslookup function because in the CVS version I
have here it doesn't use contexts or styles. 

And finally, I made completion for zstyle a bit cleverer: it tells you 
the names of the fields when completing after `:completion:' -- could
be improved, but I don't know if that's worth it.

Bye
 Sven

diff -ru ../z.old/Completion/Base/_arguments Completion/Base/_arguments
--- ../z.old/Completion/Base/_arguments	Wed Feb  2 16:52:57 2000
+++ Completion/Base/_arguments	Thu Feb  3 12:40:00 2000
@@ -162,7 +162,7 @@
   esac
 done
 
-zstyle -s ":completion${curcontext}:options" auto-description autod
+zstyle -s ":completion:${curcontext}:options" auto-description autod
 
 if (( $# )) && comparguments -i "$autod" "$@"; then
   local nm="$compstate[nmatches]" action noargs aret expl local
@@ -172,7 +172,7 @@
 
   if comparguments -D descr action; then
     comparguments -C subc
-    curcontext="${oldcontext}:$subc"
+    curcontext="${oldcontext%:*}:$subc"
 
     if comparguments -O next direct odirect equal; then
       opts=yes
@@ -201,7 +201,7 @@
           comparguments -W line opt_args
           state="${${action[3,-1]##[ 	]#}%%[ 	]#}"
 	  if [[ -n "$usecc" ]]; then
-	    curcontext="${oldcontext}:$subc"
+	    curcontext="${oldcontext%:*}:$subc"
 	  else
 	    context="$subc"
 	  fi
@@ -259,7 +259,7 @@
       fi
 
       if [[ -z "$matched$mesg" ]] && _requested options &&
-          { ! zstyle -t ":completion${curcontext}:options" prefix-needed ||
+          { ! zstyle -t ":completion:${curcontext}:options" prefix-needed ||
             [[ "$origpre" = [-+]* ||
                ( -z "$aret$mesg" && nm -eq compstate[nmatches] ) ]] } ; then
 	local prevpre="$PREFIX" previpre="$IPREFIX"
@@ -320,7 +320,7 @@
 	matched=yes
 
 	comparguments -L "${equal[1]%%:*}" descr action subc
-	curcontext="${oldcontext}:$subc"
+	curcontext="${oldcontext%:*}:$subc"
 
 	_tags arguments
 
diff -ru ../z.old/Completion/Base/_combination Completion/Base/_combination
--- ../z.old/Completion/Base/_combination	Wed Feb  2 16:52:57 2000
+++ Completion/Base/_combination	Thu Feb  3 11:24:20 2000
@@ -11,7 +11,7 @@
 #  Assume an user sets the style `hosts-ports-users' as for the my-accounts
 #  tag:
 #
-#    zstyle ':completion:*:telnet*:my-accounts' hosts-ports-users \
+#    zstyle ':completion:*:*:telnet:*:my-accounts' hosts-ports-users \
 #      host0:: host1::user1 host2::user2
 #      mail-server:{smtp,pop3}:
 #      news-server:nntp:
@@ -78,7 +78,7 @@
 num="${${1##*:}:-1}"
 shift
 
-if zstyle -a ":completion${curcontext}:$tag" "$style" tmp; then
+if zstyle -a ":completion:${curcontext}:$tag" "$style" tmp; then
   eval "tmp=( \"\${(@M)tmp:#\${(j($sep))~pats}}\" )"
   if (( keys[(in:num:)$key] != 1 )); then
     eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}$sep} )"
diff -ru ../z.old/Completion/Base/_describe Completion/Base/_describe
--- ../z.old/Completion/Base/_describe	Wed Feb  2 16:52:57 2000
+++ Completion/Base/_describe	Thu Feb  3 11:24:35 2000
@@ -16,7 +16,7 @@
 
 _tags "$_type" || return 1
 
-zstyle -t ":completion${curcontext}:$_type" verbose && _showd=yes
+zstyle -t ":completion:${curcontext}:$_type" verbose && _showd=yes
 
 _description "$_type" _expl "$1"
 shift
@@ -28,7 +28,7 @@
 fi
 
 [[ "$_type" = options ]] &&
-    zstyle -t ":completion${curcontext}:options" prefix-hidden && _hide=yes
+    zstyle -t ":completion:${curcontext}:options" prefix-hidden && _hide=yes
 
 while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do
 
diff -ru ../z.old/Completion/Base/_first Completion/Base/_first
--- ../z.old/Completion/Base/_first	Wed Feb  2 16:52:57 2000
+++ Completion/Base/_first	Thu Feb  3 11:24:48 2000
@@ -50,7 +50,7 @@
 #       # We first search in the last ten words, then in the last
 #       # twenty words, and so on...
 #       while [[ i -le max ]]; do
-#         if zstyle -t ":completion${curcontext}:history-words" sort; then
+#         if zstyle -t ":completion:${curcontext}:history-words" sort; then
 #           _description history-words expl "history ($n)"
 #         else
 #           _description -V history-words expl "history ($n)"
diff -ru ../z.old/Completion/Base/_jobs Completion/Base/_jobs
--- ../z.old/Completion/Base/_jobs	Wed Feb  2 16:52:57 2000
+++ Completion/Base/_jobs	Thu Feb  3 11:25:34 2000
@@ -5,12 +5,12 @@
 _tags jobs || return 1
 
 if [[ "$1" = -t ]]; then
-  zstyle -t ":completion${curcontext}:jobs" prefix-needed &&
+  zstyle -t ":completion:${curcontext}:jobs" prefix-needed &&
       [[ "$PREFIX" != %* && compstate[nmatches] -ne 0 ]] && return 1
   shift
 fi
-zstyle -t ":completion${curcontext}:jobs" prefix-hidden && pfx=''
-zstyle -t ":completion${curcontext}:jobs" verbose       && desc=yes
+zstyle -t ":completion:${curcontext}:jobs" prefix-hidden && pfx=''
+zstyle -t ":completion:${curcontext}:jobs" verbose       && desc=yes
 
 if [[ "$1" = -r ]]; then
   jids=( "${(@k)jobstates[(R)running*]}" )
@@ -34,7 +34,7 @@
   done
 fi
 
-zstyle -s ":completion${curcontext}:jobs" numbers how
+zstyle -s ":completion:${curcontext}:jobs" numbers how
 
 if [[ "$how" = (yes|true|on|1) ]]; then
   jobs=( "$jids[@]" )
diff -ru ../z.old/Completion/Base/_subscript Completion/Base/_subscript
--- ../z.old/Completion/Base/_subscript	Wed Feb  2 16:52:58 2000
+++ Completion/Base/_subscript	Thu Feb  3 11:25:42 2000
@@ -21,7 +21,7 @@
   while _tags; do
     if _requested -V indexes expl 'array index'; then
       ind=( {1..${#${(P)${compstate[parameter]}}}} )
-      if zstyle -t ":completion${curcontext}:indexes" verbose; then
+      if zstyle -t ":completion:${curcontext}:indexes" verbose; then
         list=()
         for i in "$ind[@]"; do
           [[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
diff -ru ../z.old/Completion/Base/_tilde Completion/Base/_tilde
--- ../z.old/Completion/Base/_tilde	Wed Feb  2 16:52:58 2000
+++ Completion/Base/_tilde	Thu Feb  3 11:25:54 2000
@@ -22,9 +22,9 @@
       compadd "$suf[@]" "$expl[@]" "$@" - "${(@k)nameddirs}"
 
   if _requested -V directory-stack expl 'directory stack' &&
-     { ! zstyle -t ":completion${curcontext}:directory-stack" prefix-needed ||
+     { ! zstyle -t ":completion:${curcontext}:directory-stack" prefix-needed ||
        [[ "$PREFIX" = [-+]* || nm -eq compstate[nmatches] ]] }; then
-    if zstyle -t ":completion${curcontext}:directory-stack" verbose; then
+    if zstyle -t ":completion:${curcontext}:directory-stack" verbose; then
       integer i
 
       lines=("${PWD}" "${dirstack[@]}")
diff -ru ../z.old/Completion/Base/_values Completion/Base/_values
--- ../z.old/Completion/Base/_values	Wed Feb  2 16:52:58 2000
+++ Completion/Base/_values	Thu Feb  3 11:44:20 2000
@@ -20,7 +20,7 @@
 
     _tags values || return 1
 
-    curcontext="${oldcontext}:values"
+    curcontext="${oldcontext%:*}:values"
 
     compvalues -V noargs args opts
 
@@ -47,7 +47,7 @@
 	SUFFIX="$suffix"
         IPREFIX="${IPREFIX}${args[1]%%:*}="
 	compvalues -L "${args[1]%%:*}" descr action subc
-	curcontext="${oldcontext}:$subc"
+	curcontext="${oldcontext%:*}:$subc"
       fi
     else
       compvalues -d descr
@@ -68,7 +68,7 @@
     fi
   else
     compvalues -C subc
-    curcontext="${oldcontext}:$subc"
+    curcontext="${oldcontext%:*}:$subc"
   fi
 
   if ! _tags arguments; then
@@ -88,7 +88,7 @@
     compvalues -v val_args
     state="${${action[3,-1]##[ 	]#}%%[ 	]#}"
     if [[ -n "$usecc" ]]; then
-      curcontext="$subc"
+      curcontext="${oldcontext%:*}:$subc"
     else
       context="$subc"
     fi
diff -ru ../z.old/Completion/Builtins/_pids Completion/Builtins/_pids
--- ../z.old/Completion/Builtins/_pids	Wed Feb  2 16:53:00 2000
+++ Completion/Builtins/_pids	Thu Feb  3 11:26:20 2000
@@ -12,12 +12,12 @@
   shift 2
 fi
 
-zstyle -a ":completion${curcontext}:ps" arguments args
+zstyle -a ":completion:${curcontext}:ps" arguments args
 
 out="$(command ps $args 2>/dev/null)"
 
-if zstyle -t ":completion${curcontext}:processes" verbose; then
-  zstyle -a ":completion${curcontext}:ps" list-arguments listargs
+if zstyle -t ":completion:${curcontext}:processes" verbose; then
+  zstyle -a ":completion:${curcontext}:ps" list-arguments listargs
   (( $#listargs )) || listargs=( "$args[@]" )
   if [[ "$listargs" = "$args" ]]; then
     list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
diff -ru ../z.old/Completion/Builtins/_popd Completion/Builtins/_popd
--- ../z.old/Completion/Builtins/_popd	Wed Feb  2 16:53:00 2000
+++ Completion/Builtins/_popd	Thu Feb  3 11:26:35 2000
@@ -11,10 +11,10 @@
 
 _wanted -V directory-stack expl 'directory stack' || return 1
 
-! zstyle -t ":completion${curcontext}:directory-stack" prefix-needed ||
+! zstyle -t ":completion:${curcontext}:directory-stack" prefix-needed ||
     [[ $PREFIX = [-+]* ]] || return 1
 
-if zstyle -t ":completion${curcontext}:directory-stack" verbose; then
+if zstyle -t ":completion:${curcontext}:directory-stack" verbose; then
   # get the list of directories with their canonical number
   # and turn the lines into an array, removing the current directory
   lines=("${dirstack[@]}")
diff -ru ../z.old/Completion/Builtins/_sched Completion/Builtins/_sched
--- ../z.old/Completion/Builtins/_sched	Wed Feb  2 16:53:00 2000
+++ Completion/Builtins/_sched	Thu Feb  3 11:26:44 2000
@@ -7,7 +7,7 @@
     _wanted -C - jobs expl 'scheduled jobs' || return 1
 
     lines=(${(f)"$(sched)"})
-    if zstyle -t ":completion${curcontext}:jobs" verbose; then
+    if zstyle -t ":completion:${curcontext}:jobs" verbose; then
       disp=( -ld lines )
     else
       disp=()
diff -ru ../z.old/Completion/Builtins/_signals Completion/Builtins/_signals
--- ../z.old/Completion/Builtins/_signals	Wed Feb  2 16:53:01 2000
+++ Completion/Builtins/_signals	Thu Feb  3 11:26:56 2000
@@ -22,11 +22,11 @@
 
 if _wanted signals expl signal &&
        { [[ -z "$minus" ]] ||
-         ! zstyle -t ":completion${curcontext}:signals" prefix-needed ||
+         ! zstyle -t ":completion:${curcontext}:signals" prefix-needed ||
          [[ "$PREFIX" = -* ]] } ; then
   local disp tmp
 
-  if zstyle -t ":completion${curcontext}:signals" prefix-hidden; then
+  if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then
     tmp=( "${(@)signals[1,last]}" )
     disp=(-d tmp)
   else
diff -ru ../z.old/Completion/Builtins/_stat Completion/Builtins/_stat
--- ../z.old/Completion/Builtins/_stat	Wed Feb  2 16:53:01 2000
+++ Completion/Builtins/_stat	Thu Feb  3 11:27:05 2000
@@ -10,7 +10,7 @@
   while _tags; do
     _requested files && _files && ret=0
     _requested options expl 'inode element' &&
-        { ! zstyle -t ":completion${curcontext}:options" prefix-needed ||
+        { ! zstyle -t ":completion:${curcontext}:options" prefix-needed ||
           [[ "$PREFIX[1]" = + || ret -eq 1 ]] } &&
         compadd "$expl[@]" - +device +inode +mode +nlink +uid +gid +rdev \
                              +size +atime +mtime +ctime +blksize +block +link
diff -ru ../z.old/Completion/Builtins/_zftp Completion/Builtins/_zftp
--- ../z.old/Completion/Builtins/_zftp	Wed Feb  2 16:53:02 2000
+++ Completion/Builtins/_zftp	Thu Feb  3 14:58:46 2000
@@ -9,7 +9,7 @@
 # Don't try any more completion after this.
 _compskip=all
 
-local subcom expl
+local subcom expl curcontext="${curcontext}"
 
 if [[ $words[1] = zftp ]]; then
   if [[ $CURRENT -eq 2 ]]; then
@@ -20,6 +20,7 @@
     return
   fi
   subcom=$words[2]
+  curcontext="${curcontext/:zftp:/:zftp-${words[2]}:}"
 else
   subcom=$words[1]
 fi
@@ -27,27 +28,27 @@
 case $subcom in
   *(cd|ls|dir))
     # complete remote directories
-    _tags -C "$subcom" directories && zfcd_match $PREFIX $SUFFIX
+    _tags directories && zfcd_match $PREFIX $SUFFIX
     ;;
 
   *(get(|at)|gcp|delete|remote))
     # complete remote files
-    _tags -C "$subcom" files && zfget_match $PREFIX $SUFFIX
+    _tags files && zfget_match $PREFIX $SUFFIX
     ;;
 
   *(put(|at)|pcp))
     # complete local files
-    _tags -C "$subcom" files && _files
+    _tags files && _files
     ;;
 
   *(open|anon|params))
     # complete hosts:  should do cleverer stuff with user names
-    _tags -C "$subcom" hosts && _hosts
+    _tags hosts && _hosts
     ;;
 
   *(goto|mark))
     # complete bookmarks.  First decide if ncftp mode is go.
-    _wanted -C "$subcom" bookmarks expl bookmark || return 1
+    _wanted bookmarks expl bookmark || return 1
     if [[ $words[2] = -*n* ]]; then
       if [[ -f ~/.ncftp/bookmarks ]]; then
         compadd "$expl[@]" - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks)
@@ -61,7 +62,7 @@
 
   *session)
     # complete sessions, excluding the current one.
-    _wanted -C "$subcom" sessions expl 'another FTP session' &&
+    _wanted sessions expl 'another FTP session' &&
         compadd "$expl[@]" - ${$(zftp session):#$ZFTP_SESSION}
     ;;
 
@@ -69,7 +70,7 @@
     # complete arguments like sess1:file1 sess2:file2
     if [[ $PREFIX = *:* ]]; then
       # complete file in the given session
-      _tags -C "$subcom" files || return 1
+      _tags files || return 1
       local sess=${PREFIX%%:*} oldsess=$ZFTP_SESSION
       compset -p $(( $#sess + 1 ))
       [[ -n $sess ]] && zftp session $sess
@@ -77,7 +78,7 @@
       [[ -n $sess && -n $oldsess ]] && zftp session $oldsess
     else
       # note here we can complete the current session
-      _wanted -C "$subcom" sessions expl 'FTP session' &&
+      _wanted sessions expl 'FTP session' &&
           compadd "$expl[@]" -S : - $(zftp session)
     fi
     ;;
diff -ru ../z.old/Completion/Builtins/_zstyle Completion/Builtins/_zstyle
--- ../z.old/Completion/Builtins/_zstyle	Wed Feb  2 16:53:02 2000
+++ Completion/Builtins/_zstyle	Thu Feb  3 13:02:28 2000
@@ -1,7 +1,7 @@
 #compdef zstyle
 
 local curcontext="$curcontext" state context ostate line expl ctop
-local nm=$compstate[nmatches]
+local nm=$compstate[nmatches] mesg
 typeset -A opt_args
 
 typeset -A styles
@@ -17,6 +17,7 @@
   condition		 c:
   cursor		 c:bool
   disable-stat		 c:bool
+  domains                c:
   expand		 c:
   file-patterns		 c:
   format		 c:
@@ -87,9 +88,20 @@
 
   case "$ostate" in
     contexts)
-      if [[ $PREFIX != :*: ]]; then
-	_wanted contexts expl context &&
-	compadd -P : -S : "$expl[@]" completion zftp
+      if _wanted contexts expl context; then
+        if [[ $PREFIX != :*: ]]; then
+	  compadd -P : -S : "$expl[@]" completion zftp
+        elif [[ $PREFIX = :completion:* ]]; then
+          mesg=''
+          case "$PREFIX" in
+          :completion:[^:]#) mesg=function ;;
+          :completion:[^:]#:[^:]#) mesg=completer ;;
+          :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;;
+          :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;;
+          :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;;
+	  esac
+	  [[ -n "$mesg" ]] && _message "$mesg"
+        fi
       fi
       ;;
 
diff -ru ../z.old/Completion/Commands/_complete_help Completion/Commands/_complete_help
--- ../z.old/Completion/Commands/_complete_help	Wed Feb  2 16:53:03 2000
+++ Completion/Commands/_complete_help	Thu Feb  3 13:04:22 2000
@@ -12,7 +12,7 @@
 
   for i in "${(@k)help_funcs}"; do
     text="${text}
-tags in context ${i}"
+tags in context :completion:${i}"
     for j in "${(@s.:.)help_funcs[$i][2,-1]}"; do
       text="${text}${help_tags[${i}${j}]}	(${j})"
     done
diff -ru ../z.old/Completion/Commands/_correct_word Completion/Commands/_correct_word
--- ../z.old/Completion/Commands/_correct_word	Wed Feb  2 16:53:03 2000
+++ Completion/Commands/_correct_word	Thu Feb  3 11:47:01 2000
@@ -9,6 +9,10 @@
 
 local curcontext="$curcontext"
 
-[[ -z "$curcontext" ]] && curcontext=":correct-word"
+if [[ -z "$curcontext" ]]; then
+  curcontext="correct-word:::"
+else
+  curcontext="correct-word:${curcontext#*:}"
+fi
 
 _main_complete _correct
diff -ru ../z.old/Completion/Commands/_expand_word Completion/Commands/_expand_word
--- ../z.old/Completion/Commands/_expand_word	Wed Feb  2 16:53:03 2000
+++ Completion/Commands/_expand_word	Thu Feb  3 11:47:25 2000
@@ -7,6 +7,10 @@
 
 local curcontext="$curcontext"
 
-[[ -z "$curcontext" ]] && curcontext=":expand-word"
+if [[ -z "$curcontext" ]]; then
+  curcontext="correct-word:::"
+else
+  curcontext="expand-word:${curcontext#*:}"
+fi
 
 _main_complete _expand
diff -ru ../z.old/Completion/Commands/_history_complete_word Completion/Commands/_history_complete_word
--- ../z.old/Completion/Commands/_history_complete_word	Wed Feb  2 16:53:03 2000
+++ Completion/Commands/_history_complete_word	Thu Feb  3 11:27:49 2000
@@ -25,9 +25,9 @@
     direction=older
   fi
 
-  zstyle -s ":completion${curcontext}:history-words" stop stop
+  zstyle -s ":completion:${curcontext}:history-words" stop stop
 
-  zstyle -t ":completion${curcontext}:history-words" list || compstate[list]=''
+  zstyle -t ":completion:${curcontext}:history-words" list || compstate[list]=''
 
   if [[ -n "$compstate[old_list]" &&
         ( -n "$stop" || "$compstate[insert]" = menu ) ]] ; then
@@ -67,14 +67,14 @@
 }
 
 _history_complete_word_gen_matches () {
-  if zstyle -t ":completion${curcontext}:history-words" list; then
-    if zstyle -t ":completion${curcontext}:history-words" sort; then
+  if zstyle -t ":completion:${curcontext}:history-words" list; then
+    if zstyle -t ":completion:${curcontext}:history-words" sort; then
       _description history-words expl 'history word'
     else
       _description -V history-words expl 'history word'
     fi
   else
-    if zstyle -t ":completion${curcontext}:history-words" sort; then
+    if zstyle -t ":completion:${curcontext}:history-words" sort; then
       expl=()
     else
       expl=('-V' '')
@@ -84,7 +84,7 @@
   [[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
 
   local rem_dups
-  if zstyle -t ":completion${curcontext}:history-words" remove-all-dups; then
+  if zstyle -t ":completion:${curcontext}:history-words" remove-all-dups; then
     rem_dups=''
   else
     rem_dups='-1'
diff -ru ../z.old/Completion/Core/_alternative Completion/Core/_alternative
--- ../z.old/Completion/Core/_alternative	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_alternative	Thu Feb  3 11:50:27 2000
@@ -7,7 +7,7 @@
 while getopts 'O:C:' opt; do
   case "$opt" in
   O) subopts=( "${(@P)OPTARG}" ) ;;
-  C) curcontext="${curontext}:$OPTARG" ;;
+  C) curcontext="${curcontext%:*}:$OPTARG" ;;
   esac
 done
 
diff -ru ../z.old/Completion/Core/_approximate Completion/Core/_approximate
--- ../z.old/Completion/Core/_approximate	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_approximate	Thu Feb  3 14:18:32 2000
@@ -16,11 +16,12 @@
 
 [[ "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
 
-[[ "$curcontext" != *:correct* ]] && curcontext="${curcontext}:approximate"
+[[ "$curcontext" != [^:]#:correct:* ]] &&
+    curcontext="${curcontext/:[^:]#:/:approximate:}"
 
 oldcontext="$curcontext"
 
-zstyle -s ":completion${curcontext}:" max-errors cfgacc
+zstyle -s ":completion:${curcontext}:" max-errors cfgacc
 
 # Get the number of errors to accept.
 
@@ -73,18 +74,18 @@
 [[ -z "$compstate[pattern_match]" ]] && compstate[pattern_match]='*'
 
 while [[ _comp_correct -le comax ]]; do
-  curcontext="${oldcontext}:$_comp_correct"
+  curcontext="${oldcontext/(#b)([^:]#:[^:]#:)/${match[1][1,-2]}-${_comp_correct}:}"
 
   _description corrections _correct_expl corrections \
                "e:$_comp_correct" "o:$PREFIX$SUFFIX"
 
   if _complete; then
-    if zstyle -t ":completion${curcontext}:" insert-unambiguous &&
+    if zstyle -t ":completion:${curcontext}:" insert-unambiguous &&
        [[ "${#compstate[unambiguous]}" -ge "${#:-$PREFIX$SUFFIX}" ]]; then
       compstate[pattern_insert]=unambiguous
     elif _requested original &&
          ( [[ compstate[nmatches] -gt 1 ]] ||
-           zstyle -t ":completion${curcontext}:" original ); then
+           zstyle -t ":completion:${curcontext}:" original ); then
       local expl
 
       _description -V original expl original
diff -ru ../z.old/Completion/Core/_complete Completion/Core/_complete
--- ../z.old/Completion/Core/_complete	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_complete	Thu Feb  3 12:26:01 2000
@@ -4,16 +4,17 @@
 # a normal completion function, but as one possible value for the
 # completer style.
 
-local comp name curcontext="$curcontext" oldcontext
+local comp name oldcontext
+typeset -T curcontext="$curcontext" ccarray
 
-[[ "$funcstack[2]" = _main_complete ]] && curcontext="${curcontext}:complete"
+ccarray[2]=complete
 
 oldcontext="$curcontext"
 
 # If we have a user-supplied context name, use only that.
 
 if [[ -n "$compcontext" ]]; then
-  curcontext="${curcontext}:$compcontext"
+  ccarray[3]="$compcontext"
 
   comp="$_comps[$compcontext]"
   [[ -z "$comp" ]] || "$comp"
@@ -25,7 +26,7 @@
 
 comp="$_comps[-first-]"
 if [[ ! -z "$comp" ]]; then
-  curcontext="${curcontext}:-first-"
+  ccarray[3]=-first-
   "$comp"
   if [[ "$_compskip" = all ]]; then
     _compskip=''
@@ -46,7 +47,7 @@
 
   local cname="-${compstate[context]:s/_/-/}-"
 
-  curcontext="${oldcontext}:$cname"
+  ccarray[3]="$cname"
 
   comp="$_comps[$cname]"
 
diff -ru ../z.old/Completion/Core/_correct Completion/Core/_correct
--- ../z.old/Completion/Core/_correct	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_correct	Thu Feb  3 14:13:26 2000
@@ -8,9 +8,8 @@
 # Supported configuration keys are the same as for `_approximate', only
 # starting with `correct'.
 
-local ret=1 opm="$compstate[pattern_match]" curcontext="${curcontext}"
-
-[[ "$curcontext" != :correct* ]] && curcontext="${curcontext}:correct"
+local ret=1 opm="$compstate[pattern_match]"
+local curcontext="${curcontext/:[^:]#:/:correct:}"
 
 compstate[pattern_match]='-'
 
diff -ru ../z.old/Completion/Core/_description Completion/Core/_description
--- ../z.old/Completion/Core/_description	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_description	Thu Feb  3 11:28:29 2000
@@ -18,19 +18,19 @@
 
 name="$2"
 
-zstyle -s ":completion${curcontext}:$1" format format ||
-    zstyle -s ":completion${curcontext}:descriptions" format format
+zstyle -s ":completion:${curcontext}:$1" format format ||
+    zstyle -s ":completion:${curcontext}:descriptions" format format
 
-zstyle -s ":completion${curcontext}:$1" hidden hidden
+zstyle -s ":completion:${curcontext}:$1" hidden hidden
 if [[ "$hidden" = (all|yes|true|1|on) ]]; then
   [[ "$hidden" = all ]] && format=''
   hide=(-n)
 fi
-zstyle -s ":completion${curcontext}:$1" group-name gname &&
+zstyle -s ":completion:${curcontext}:$1" group-name gname &&
     [[ -z "$gname" ]] && gname="$1"
-zstyle -s ":completion${curcontext}:$1" matcher match &&
+zstyle -s ":completion:${curcontext}:$1" matcher match &&
     match=(-M "${(q)match}")
-if zstyle -a ":completion${curcontext}:$1" ignored-patterns _comp_ignore; then
+if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
   ign=(-F _comp_ignore)
 else
   _comp_ignore=()
diff -ru ../z.old/Completion/Core/_expand Completion/Core/_expand
--- ../z.old/Completion/Core/_expand	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_expand	Thu Feb  3 14:15:38 2000
@@ -7,13 +7,12 @@
 # the expansions done produce no result or do not change the original
 # word from the line.
 
-local exp word="$PREFIX$SUFFIX" sort expr expl curcontext="${curcontext}"
-
-[[ "$curcontext" != :expand* ]] && curcontext="${curcontext}:expand"
+local exp word="$PREFIX$SUFFIX" sort expr expl
+local curcontext="${curcontext/:[^:]#:/:expand:}"
 
 # First, see if we should insert all *completions*.
 
-if zstyle -s ":completion${curcontext}:" completions expr &&
+if zstyle -s ":completion:${curcontext}:" completions expr &&
    [[ "${(e):-\$[$expr]}" -eq 1 ]]; then
   compstate[insert]=all
   return 1
@@ -30,7 +29,7 @@
 # First try substitution. That weird thing spanning multiple lines
 # changes quoted spaces, tabs, and newlines into spaces.
 
-zstyle -s ":completion${curcontext}:" substitute expr &&
+zstyle -s ":completion:${curcontext}:" substitute expr &&
     [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
     exp=( "${(e)exp//\\[ 	
 ]/ }" )
@@ -41,7 +40,7 @@
 
 # Now try globbing.
 
-zstyle -s ":completion${curcontext}:" glob expr &&
+zstyle -s ":completion:${curcontext}:" glob expr &&
     [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
     exp=( ${~exp}(N) )
 
@@ -53,7 +52,7 @@
 
 # Now add as matches whatever the user requested.
 
-zstyle -s ":completion${curcontext}:" sort sort
+zstyle -s ":completion:${curcontext}:" sort sort
 
 [[ "$sort" = (yes|true|1|on) ]] && exp=( "${(@o)exp}" )
 
diff -ru ../z.old/Completion/Core/_files Completion/Core/_files
--- ../z.old/Completion/Core/_files	Wed Feb  2 16:53:04 2000
+++ Completion/Core/_files	Thu Feb  3 11:29:15 2000
@@ -25,11 +25,11 @@
   group=()
 fi
 
-if zstyle -s ":completion${curcontext}:all-files" file-patterns tmp &&
+if zstyle -s ":completion:${curcontext}:all-files" file-patterns tmp &&
    [[ -n "$tmp" ]]; then
   aopts=(-g "$tmp")
 fi
-if zstyle -s ":completion${curcontext}:directories" file-patterns tmp &&
+if zstyle -s ":completion:${curcontext}:directories" file-patterns tmp &&
    [[ -n "$tmp" ]]; then
   dopts=(-g "$tmp")
   if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then
@@ -38,7 +38,7 @@
     type="${type}dir"
   fi
 fi
-if zstyle -s ":completion${curcontext}:globbed-files" file-patterns tmp &&
+if zstyle -s ":completion:${curcontext}:globbed-files" file-patterns tmp &&
    [[ -n "$tmp" ]]; then
   gopts=(-g "$tmp")
   if [[ "$type" != (*dir*glob*|*glob*dir*) ]]; then
@@ -64,7 +64,7 @@
       group[2]=all-files
       _setup all-files
       [[ -z "$hasign" ]] &&
-        zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+        zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore &&
 	  ign=(-F _comp_ignore)
     fi
     _path_files "$opts[@]" "$ign[@]" "$aopts[@]"
@@ -75,7 +75,7 @@
         group[2]=globbed-files
 	_setup globbed-files
         [[ -z "$hasign" ]] &&
-          zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+          zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore &&
 	    ign=(-F _comp_ignore)
       fi
       _path_files "$opts[@]" "$ign[@]" "$dopts[@]" "$gopts[@]" && return 0
@@ -84,7 +84,7 @@
         group[2]=directories
 	_setup directories
         [[ -z "$hasign" ]] &&
-          zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+          zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore &&
 	    ign=(-F _comp_ignore)
       fi
       _path_files "$opts[@]" "$ign[@]" "$dopts[@]" && return 0
@@ -94,7 +94,7 @@
       group[2]=globbed-files
       _setup globbed-files
       [[ -z "$hasign" ]] &&
-        zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+        zstyle -a ":completion:${curcontext}:all-files" ignored-patterns _comp_ignore &&
 	  ign=(-F _comp_ignore)
     fi
     if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then
diff -ru ../z.old/Completion/Core/_list Completion/Core/_list
--- ../z.old/Completion/Core/_list	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_list	Thu Feb  3 14:15:48 2000
@@ -4,11 +4,11 @@
 # insert possible completions only after the list has been shown at
 # least once.
 
-local pre suf curcontext="${curcontext}:list" expr
+local pre suf expr curcontext="${curcontext/:[^:]#:/:list:}"
 
 # Get the strings to compare.
 
-if zstyle -t ":completion${curcontext}:" word; then
+if zstyle -t ":completion:${curcontext}:" word; then
   pre="$HISTNO$LBUFFER"
   suf="$RBUFFER"
 else
@@ -18,7 +18,7 @@
 
 # Should we only show a list now?
 
-zstyle -s ":completion${curcontext}:" condition expr
+zstyle -s ":completion:${curcontext}:" condition expr
 if [[ ( -z "$expr" || "${(e):-\$[$expr]}" -eq 1 ) &&
       ( "$pre" != "$_list_prefix" || "$suf" != "$_list_suffix" ) ]]; then
 
diff -ru ../z.old/Completion/Core/_main_complete Completion/Core/_main_complete
--- ../z.old/Completion/Core/_main_complete	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_main_complete	Thu Feb  3 12:29:45 2000
@@ -35,6 +35,8 @@
 
 typeset -U _lastdescr
 
+[[ -z "$curcontext" ]] && curcontext=:::
+
 # Special completion contexts after `~' and `='.
 
 if compset -P 1 '='; then
@@ -55,7 +57,7 @@
 if (( ! $# )); then
   local tmp
 
-  zstyle -a ":completion${curcontext}:" completer tmp
+  zstyle -a ":completion:${curcontext}:" completer tmp
   set -- "$tmp[@]"
 fi
 
@@ -123,7 +125,7 @@
   fi
 elif [[ compstate[matcher] -eq compstate[total_matchers] &&
         $#_lastdescr -ne 0 ]] &&
-     zstyle -s ":completion${curcontext}:warnings" format format; then
+     zstyle -s ":completion:${curcontext}:warnings" format format; then
   local str
 
   _lastdescr=( "\`${(@)^_lastdescr:#}'" )
diff -ru ../z.old/Completion/Core/_match Completion/Core/_match
--- ../z.old/Completion/Core/_match	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_match	Thu Feb  3 14:17:29 2000
@@ -1,7 +1,7 @@
 #autoload
 
 # This is intended to be used as a completer function after the normal
-# completer as in: `zstyle ":completion:*" completer _complete _match'.
+# completer as in: `zstyle ":completion:::::" completer _complete _match'.
 # It temporarily switches on pattern matching, allowing you to try 
 # completion on patterns without having to setopt glob_complete.
 #
@@ -10,7 +10,7 @@
 # be expanded using globbing.
 
 local tmp opm="$compstate[pattern_match]" ret=0 orig ins
-local curcontext="${curcontext}:match"
+local curcontext="${curcontext/:[^:]#:/:match:}"
 
 # Do nothing if we don't have a pattern or there are still global
 # match specifications to try.
@@ -19,8 +19,8 @@
 [[ "$tmp:q" = "$tmp" ||
    compstate[matcher] -ne compstate[total_matchers] ]] && return 1
 
-zstyle -s ":completion${curcontext}:" original orig
-zstyle -b ":completion${curcontext}:" insert-unambiguous ins
+zstyle -s ":completion:${curcontext}:" original orig
+zstyle -b ":completion:${curcontext}:" insert-unambiguous ins
 
 # Try completion without inserting a `*'?
 
diff -ru ../z.old/Completion/Core/_menu Completion/Core/_menu
--- ../z.old/Completion/Core/_menu	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_menu	Thu Feb  3 14:16:08 2000
@@ -1,12 +1,12 @@
 #autoload
 
-local curcontext="${curcontext}:menu"
+local curcontext="${curcontext/:[^:]#:/:menu:}"
 
 # This completer is an example showing how menucompletion can be
 # implemented with the new completion system.
 # Use this one before the normal _complete completer, as in:
 #
-#   zstyle ":completion:*" completer _menu _complete
+#   zstyle ":completion:::::" completer _menu _complete
 
 if [[ -n "$compstate[old_list]" ]]; then
 
diff -ru ../z.old/Completion/Core/_message Completion/Core/_message
--- ../z.old/Completion/Core/_message	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_message	Thu Feb  3 11:31:18 2000
@@ -4,8 +4,8 @@
 
 _tags messages || return 1
 
-zstyle -s ":completion${curcontext}:messages" format format ||
-    zstyle -s ":completion${curcontext}:descriptions" format format
+zstyle -s ":completion:${curcontext}:messages" format format ||
+    zstyle -s ":completion:${curcontext}:descriptions" format format
 
 if [[ -n "$format" ]]; then
   zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}"
diff -ru ../z.old/Completion/Core/_normal Completion/Core/_normal
--- ../z.old/Completion/Core/_normal	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_normal	Thu Feb  3 12:32:49 2000
@@ -16,7 +16,7 @@
 
 command="$words[1]"
 if [[ CURRENT -eq 1 ]]; then
-  curcontext="${curcontext}:-command-"
+  curcontext="${curcontext%:*:*}:-command-:"
 
   comp="$_comps[-command-]"
   [[ -z "$comp" ]] || "$comp" && ret=0
@@ -26,15 +26,15 @@
   if [[ "$command[1]" == '=' ]]; then
     eval cmd1\=$command
     cmd2="$command[2,-1]"
-    curcontext="${curcontext}::${cmd2}:"
+    curcontext="${curcontext%:*:*}:${cmd2}:"
   elif [[ "$command" == */* ]]; then
     cmd1="$command"
     cmd2="${command:t}"
-    curcontext="${curcontext}::${cmd2}:"
+    curcontext="${curcontext%:*:*}:${cmd2}:"
   else
     cmd1="$command"
     cmd2="$commands[$command]"
-    curcontext="${curcontext}::${cmd1}:"
+    curcontext="${curcontext%:*:*}:${cmd1}:"
   fi
 fi
 
diff -ru ../z.old/Completion/Core/_oldlist Completion/Core/_oldlist
--- ../z.old/Completion/Core/_oldlist	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_oldlist	Thu Feb  3 14:17:04 2000
@@ -1,8 +1,8 @@
 #autoload
 
-local curcontext="${curcontext}:oldlist" list
+local curcontext="${curcontext/:[^:]#:/:oldlist:}" list
 
-zstyle -s ":completion${curcontext}:" list list
+zstyle -s ":completion:${curcontext}:" list list
 
 # If this is a listing widget and there is already an old list,
 # and either the style :oldlist:list is `always', or it is not `never'
@@ -34,7 +34,7 @@
 if [[ -z $compstate[old_insert] && -n $compstate[old_list] ]]; then
   compstate[old_list]=keep
 elif [[ $WIDGET = *complete(|-prefix|-word) ]] &&
-     zstyle -t ":completion${curcontext}:" menu; then
+     zstyle -t ":completion:${curcontext}:" menu; then
   if [[ -n $compstate[old_insert] ]]; then
     compstate[old_list]=keep
     if [[ $WIDGET = *reverse* ]]; then
diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files	Wed Feb  2 16:53:05 2000
+++ Completion/Core/_path_files	Thu Feb  3 11:32:19 2000
@@ -82,7 +82,7 @@
 done
 
 if [[ -z "$_file_pat_checked" ]] &&
-   zstyle -s ":completion${curcontext}:files" file-patterns tmp1 &&
+   zstyle -s ":completion:${curcontext}:files" file-patterns tmp1 &&
    [[ -n "$tmp1" ]]; then
   if [[ "$tmp1" = '*(-/)' ]]; then
     gopt=''
@@ -126,7 +126,7 @@
   fi
 fi
 
-if zstyle -s ":completion${curcontext}:files" sort tmp1; then
+if zstyle -s ":completion:${curcontext}:files" sort tmp1; then
   case "$tmp1" in
   *size*)             sort=oL;;
   *links*)            sort=ol;;
@@ -159,7 +159,7 @@
 
 # Skip over sequences of slashes.
 
-zstyle -t ":completion${curcontext}:paths" squeeze-slashes && skips=yes
+zstyle -t ":completion:${curcontext}:paths" squeeze-slashes && skips=yes
 
 # We get the prefix and the suffix from the line and save the whole
 # original string. Then we see if we will do menucompletion.
@@ -293,7 +293,7 @@
       [[ ! -o globdots && "$PREFIX" = .* ]] &&
           tmp2=( "$tmp2[@]" ${^tmp1}.*(-/) )
       if [[ -o globdots || "$PREFIX" = .* ]] &&
-         zstyle -s ":completion${curcontext}:paths" special-dirs atmp; then
+         zstyle -s ":completion:${curcontext}:paths" special-dirs atmp; then
 	if [[ "$atmp" = (yes|true|1|on) ]]; then
 	  tmp2=( "$tmp2[@]" . .. )
 	elif [[ "$atmp" = .. ]]; then
@@ -305,7 +305,7 @@
       [[ ! -o globdots && "$PREFIX" = .* ]] &&
           tmp2=( "$tmp2[@]" ${^tmp1}.${^~pats} )
       if (( $#tmp2 )) &&
-         zstyle -s ":completion${curcontext}:files" ignore-parents rem &&
+         zstyle -s ":completion:${curcontext}:files" ignore-parents rem &&
 	 [[ ( "$rem" != *dir* || "$pats" = '*(-/)' ) &&
 	    ( "$rem" != *..* || "$tmp1" = *../* ) ]]; then
         if [[ "$rem" = *parent* ]]; then
@@ -330,7 +330,7 @@
            expl=( "$expl[@]" -F _comp_ignore )
       fi
       if [[ "$sopt" = *[/f]* && ( -o globdots || "$PREFIX" = .* ) ]] &&
-	  zstyle -s ":completion${curcontext}:paths" special-dirs atmp; then
+	  zstyle -s ":completion:${curcontext}:paths" special-dirs atmp; then
 	if [[ "$atmp" = (yes|true|1|on) ]]; then
 	  tmp2=( "$tmp2[@]" . .. )
 	elif [[ "$atmp" = .. ]]; then
@@ -465,8 +465,8 @@
       compquote tmp1 tmp2
 
       if [[ -n $menu ]] ||
-         ! zstyle -t ":completion${curcontext}:paths" expand suffix; then
-        (( $#tmp4 )) && zstyle -t ":completion${curcontext}:paths" cursor &&
+         ! zstyle -t ":completion:${curcontext}:paths" expand suffix; then
+        (( $#tmp4 )) && zstyle -t ":completion:${curcontext}:paths" cursor &&
             compstate[to_end]=''
         if [[ "$tmp3" = */* ]]; then
 	  compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \
@@ -555,7 +555,7 @@
 
 exppaths=( "${(@)exppaths:#$eorig}" )
 
-if zstyle -t ":completion${curcontext}:paths" expand prefix &&
+if zstyle -t ":completion:${curcontext}:paths" expand prefix &&
    [[ $#exppaths -gt 0 && nm -eq compstate[nmatches] ]]; then
   PREFIX="${opre}"
   SUFFIX="${osuf}"
diff -ru ../z.old/Completion/Core/_setup Completion/Core/_setup
--- ../z.old/Completion/Core/_setup	Wed Feb  2 16:53:06 2000
+++ Completion/Core/_setup	Thu Feb  3 11:32:43 2000
@@ -2,7 +2,7 @@
 
 local val nm="$compstate[nmatches]"
 
-if zstyle -a ":completion${curcontext}:$1" list-colors val; then
+if zstyle -a ":completion:${curcontext}:$1" list-colors val; then
   zmodload -e zsh/complist || zmodload -i zsh/complist
   if [[ "$1" = default ]]; then
     ZLS_COLORS="${(j.:.)${(@)val:gs/:/\\\:}}"
@@ -11,7 +11,7 @@
   fi
 fi
 
-if zstyle -s ":completion${curcontext}:$1" list-packed val; then
+if zstyle -s ":completion:${curcontext}:$1" list-packed val; then
   if [[ "$val" = (yes|true|1|on) ]]; then
     compstate[list]="${compstate[list]} packed"
   else
@@ -21,7 +21,7 @@
   compstate[list]="$_saved_list"
 fi
 
-if zstyle -s ":completion${curcontext}:$1" list-rows-first val; then
+if zstyle -s ":completion:${curcontext}:$1" list-rows-first val; then
   if [[ "$val" = (yes|true|1|on) ]]; then
     compstate[list]="${compstate[list]} rows"
   else
@@ -31,7 +31,7 @@
   compstate[list]="$_saved_list"
 fi
 
-if zstyle -s ":completion${curcontext}:$1" last-prompt val; then
+if zstyle -s ":completion:${curcontext}:$1" last-prompt val; then
   if [[ "$val" = (yes|true|1|on) ]]; then
     compstate[last_prompt]=yes
   else
@@ -41,7 +41,7 @@
   compstate[last_prompt]="$_saved_lastprompt"
 fi
 
-if zstyle -s ":completion${curcontext}:$1" accept-exact val; then
+if zstyle -s ":completion:${curcontext}:$1" accept-exact val; then
   if [[ "$val" = (yes|true|1|on) ]]; then
     compstate[exact]=accept
   else
@@ -54,7 +54,7 @@
 [[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] &&
     _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
-if zstyle -a ":completion${curcontext}:$1" menu val; then
+if zstyle -a ":completion:${curcontext}:$1" menu val; then
   _last_nmatches="$nm"
   _last_menu_style=( "$val[@]" )
 else
diff -ru ../z.old/Completion/Core/_sort_tags Completion/Core/_sort_tags
--- ../z.old/Completion/Core/_sort_tags	Wed Feb  2 16:53:06 2000
+++ Completion/Core/_sort_tags	Thu Feb  3 12:34:35 2000
@@ -6,15 +6,15 @@
 case "$curcontext" in
 # Some silly examples commented out:
 #
-# *::*p[bgpn]m:*)           # change the order for file-completion
+# *:*:*:*p[bgpn]m:*)           # change the order for file-completion
 #   comptry globbed-files directories
 #   comptry all-files
 #   ;;
-# *::dvips::-o*)            # automatic context set by _arguments
+# *:*:*:dvips:-o*)            # automatic context set by _arguments
 #   comptry all-files
 #   return
 #   ;;
-# *::kill:*)
+# *:*:*:kill:*)
 #   comptry processes
 #   return                  # this return ensures that we use only processes
 #   ;;
diff -ru ../z.old/Completion/Core/_tags Completion/Core/_tags
--- ../z.old/Completion/Core/_tags	Wed Feb  2 16:53:06 2000
+++ Completion/Core/_tags	Thu Feb  3 12:35:14 2000
@@ -7,10 +7,10 @@
   local curcontext="$curcontext" order tag nodef
 
   if [[ "$1" = -C?* ]]; then
-    curcontext="${curcontext}:${1[3,-1]}"
+    curcontext="${curcontext%:*}:${1[3,-1]}"
     shift
   elif [[ "$1" = -C ]]; then
-    curcontext="${curcontext}:${2}"
+    curcontext="${curcontext%:*}:${2}"
     shift 2
   else
     targs=()
@@ -18,7 +18,7 @@
 
   [[ "$1" = -(|-) ]] && shift
 
-  if zstyle -a ":completion${curcontext}" group-order order; then
+  if zstyle -a ":completion:${curcontext}:" group-order order; then
     local name
 
     for name in "$order[@]"; do
@@ -42,7 +42,7 @@
 
   if [[ -n "$_sort_tags" ]]; then
     "$_sort_tags" "$@"
-  elif zstyle -a ":completion${curcontext}" tag-order order; then
+  elif zstyle -a ":completion:${curcontext}:" tag-order order; then
 
     for tag in $order; do
       case $tag in
diff -ru ../z.old/Completion/Core/compinit Completion/Core/compinit
--- ../z.old/Completion/Core/compinit	Wed Feb  2 16:53:06 2000
+++ Completion/Core/compinit	Thu Feb  3 12:43:21 2000
@@ -475,11 +475,11 @@
 zstyle ':completion:*'                      verbose       'yes'
 zstyle ':completion:*'                      prefix-needed 'yes'
 zstyle ':completion:*'                      prefix-hidden 'no'
-zstyle ':completion:(correct|approximate):' max-errors    '2' numeric
-zstyle ':completion:correct:'               prompt        'correct to:'
-zstyle ':completion:*'                      completer     '_complete'
-zstyle ':completion*:default'               list-colors   "${(s.:.)ZLS_COLORS:-${ZLS_COLOURS:-no=0:fi=0:di=0:ln=0:pi=0:so=0:bd=0:cd=0:ex=0}}"
-(( $+SELECTMIN )) && zstyle ':completion*:default' menu "select=$SELECTMIN"
+zstyle ':completion:*:(correct|approximate):*' max-errors    '2' numeric
+zstyle ':completion:*:correct:*'               prompt        'correct to:'
+zstyle ':completion:*::::'                      completer     '_complete'
+zstyle ':completion:*::::default'               list-colors   "${(s.:.)ZLS_COLORS:-${ZLS_COLOURS:-no=0:fi=0:di=0:ln=0:pi=0:so=0:bd=0:cd=0:ex=0}}"
+(( $+SELECTMIN )) && zstyle ':completion:*::::default' menu "select=$SELECTMIN"
 zstyle ':completion:*' tag-order 'arguments values' options \
                                  globbed-files directories all-files
 
diff -ru ../z.old/Completion/Debian/_apt Completion/Debian/_apt
--- ../z.old/Completion/Debian/_apt	Wed Feb  2 16:53:09 2000
+++ Completion/Debian/_apt	Thu Feb  3 11:33:36 2000
@@ -106,7 +106,7 @@
 tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1})
 _describe -o option tmp2 -- tmp3 -S='
 
-  comp_opt='{ ! zstyle -t ":completion${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }"
+  comp_opt='{ ! zstyle -t ":completion:${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }"
 
   regex_short=()
   regex_long=()
diff -ru ../z.old/Completion/Debian/_deb_packages Completion/Debian/_deb_packages
--- ../z.old/Completion/Debian/_deb_packages	Wed Feb  2 16:53:09 2000
+++ Completion/Debian/_deb_packages	Thu Feb  3 11:33:47 2000
@@ -39,7 +39,7 @@
     return
   }
 
-  zstyle -s ":completion${curcontext}" packageset pkgset
+  zstyle -s ":completion:${curcontext}:" packageset pkgset
 
   [[ "$pkgset" = (installed|uninstalled|avail|available) ]] || {
     pkgset="$command"
diff -ru ../z.old/Completion/User/_cvs Completion/User/_cvs
--- ../z.old/Completion/User/_cvs	Wed Feb  2 16:53:12 2000
+++ Completion/User/_cvs	Thu Feb  3 12:36:56 2000
@@ -40,7 +40,7 @@
 
     cmd="${${(k)cmds[(R)* $words[1] *]}:-${(k)cmds[(i)$words[1]]}}"
     if (( $#cmd )); then
-      curcontext="${curcontext%:*}:$cmd"
+      curcontext="${curcontext%:*:*}:cvs-${cmd}:"
       _cvs_$cmd
     else
       _message "unknown cvs command: $words[1]"
@@ -390,7 +390,7 @@
 
 (( $+functions[_cvs_loadstat] )) ||
 _cvs_loadstat () {
-  zstyle -t ":completion${curcontext}:cvs" disable-stat && return
+  zstyle -t ":completion:${curcontext}:" disable-stat && return
   (( $+_cvs_loadstat_tried )) && return
   _cvs_loadstat_tried=yes
 
diff -ru ../z.old/Completion/User/_domains Completion/User/_domains
--- ../z.old/Completion/User/_domains	Wed Feb  2 16:53:13 2000
+++ Completion/User/_domains	Thu Feb  3 11:37:44 2000
@@ -2,7 +2,7 @@
 
 local expl domains tmp
 
-if ! zstyle -a ":completion${curcontext}:domains" domains domains; then
+if ! zstyle -a ":completion:${curcontext}:domains" domains domains; then
   if (( ! $+_cache_domains )); then
     _cache_domains=()
     if [[ -f /etc/resolv.conf ]]; then
diff -ru ../z.old/Completion/User/_groups Completion/User/_groups
--- ../z.old/Completion/User/_groups	Wed Feb  2 16:53:13 2000
+++ Completion/User/_groups	Thu Feb  3 11:37:54 2000
@@ -4,7 +4,7 @@
 
 _wanted groups expl group || return 1
 
-if ! zstyle -a ":completion${curcontext}:groups" groups groups; then
+if ! zstyle -a ":completion:${curcontext}:groups" groups groups; then
   (( $+_cache_groups )) ||
       if (( ${+commands[ypcat]} )); then
         : ${(A)_cache_groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP
diff -ru ../z.old/Completion/User/_hosts Completion/User/_hosts
--- ../z.old/Completion/User/_hosts	Wed Feb  2 16:53:14 2000
+++ Completion/User/_hosts	Thu Feb  3 11:38:05 2000
@@ -2,7 +2,7 @@
 
 local expl hosts
 
-if ! zstyle -a ":completion${curcontext}:hosts" hosts hosts; then
+if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
   (( $+_cache_hosts )) ||
       : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
 
diff -ru ../z.old/Completion/User/_ports Completion/User/_ports
--- ../z.old/Completion/User/_ports	Wed Feb  2 16:53:16 2000
+++ Completion/User/_ports	Thu Feb  3 11:38:29 2000
@@ -2,7 +2,7 @@
 
 local expl ports
 
-if ! zstyle -a ":completion${curcontext}:ports" ports ports; then
+if ! zstyle -a ":completion:${curcontext}:ports" ports ports; then
   (( $+_cache_ports )) ||
       : ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ 	]*}}
 
diff -ru ../z.old/Completion/User/_socket Completion/User/_socket
--- ../z.old/Completion/User/_socket	Wed Feb  2 16:53:17 2000
+++ Completion/User/_socket	Thu Feb  3 11:38:39 2000
@@ -9,7 +9,7 @@
 typeset -A opt_args
 
 [[ $CURRENT -eq 2 ]] && _wanted options expl option &&
-    { ! zstyle -t ":completion${curcontext}:options" prefix-needed ||
+    { ! zstyle -t ":completion:${curcontext}:options" prefix-needed ||
       [[ "$PREFIX" = -* ]] } &&
     compadd -M 'r:|[_-]=* r:|=*' "$expl[@]" - -version
 
diff -ru ../z.old/Completion/User/_urls Completion/User/_urls
--- ../z.old/Completion/User/_urls	Wed Feb  2 16:53:18 2000
+++ Completion/User/_urls	Thu Feb  3 11:38:59 2000
@@ -40,9 +40,9 @@
 
 local ipre scheme host user uhosts ret=1 expl
 local urls_path localhttp
-zstyle -s ":completion${curcontext}:urls" path urls_path ||
+zstyle -s ":completion:${curcontext}:urls" path urls_path ||
     urls_path="${ZDOTDIR:-$HOME}/.zsh/urls"
-zstyle -a ":completion${curcontext}:urls" local localhttp
+zstyle -a ":completion:${curcontext}:urls" local localhttp
 local localhttp_servername="$localhttp[1]"
 local localhttp_documentroot="$localhttp[2]"
 local localhttp_userdir="$localhttp[3]"
diff -ru ../z.old/Completion/User/_users Completion/User/_users
--- ../z.old/Completion/User/_users	Wed Feb  2 16:53:18 2000
+++ Completion/User/_users	Thu Feb  3 11:39:13 2000
@@ -7,7 +7,7 @@
 
 _wanted users expl user || return 1
 
-zstyle -a ":completion${curcontext}:users" users users &&
+zstyle -a ":completion:${curcontext}:users" users users &&
     compadd "$expl[@]" "$@" - "$users[@]" && return 0
 
 compadd "$@" "$expl[@]" - "${(@k)userdirs}"
diff -ru ../z.old/Completion/X/_x_color Completion/X/_x_color
--- ../z.old/Completion/X/_x_color	Wed Feb  2 16:53:20 2000
+++ Completion/X/_x_color	Thu Feb  3 11:39:23 2000
@@ -15,7 +15,7 @@
 
   # Cache of color names doesn't exist yet, create it.
 
-  zstyle -s ":completion${curcontext}:colors" path file
+  zstyle -s ":completion:${curcontext}:colors" path file
   if [[ -n "$file" ]]; then
     _color_cache=( "${(@)${(@f)$(< $file)}[2,-1]##*		}" )
   else
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Wed Feb  2 16:52:43 2000
+++ Doc/Zsh/compsys.yo	Thu Feb  3 14:51:11 2000
@@ -286,29 +286,62 @@
 command when completing an argument, and possibily also
 the name of an option when completing an argument to that option.
 
-The completion system represents contexts as hierarchical name s
-with components separated by colons. For example, take the context
-`tt(:completion:complete::dvips::-o-1)'.  The tt(:completion) at the
-beginning just says that this context is used in the completion system 
-and the tt(:complete) after it is the `completer', which is in overall
-control of how completion is to be performed; `tt(complete)' is the
-basic one for ordinary completion, but completers may perform various
-related tasks such as correction, or modify the behaviour of a later
-completer (see
+The context names always consists of the following fields, separated
+by colons:
+
+startitem()
+item()(
+The literal string tt(completion), saying that this style is used by
+the completion system.
+)
+item()(
+The var(function); in many cases this field will be blank, but when
+the completion system is called from other functions, like
+tt(predict-on) or one of the functions in the tt(Command) directory of 
+the distribution, this field contains the (probably abbreviated) name
+of that function.
+)
+item()(
+The var(completer) currently active, i.e. the name of the completer
+function without the leading underscore. Such a completer is in
+overall control of how completion is to be performed; `tt(complete)'
+is the basic one for ordinary completion, but completers may perform
+various related tasks such as correction, or modify the behaviour of a
+later completer (see
 ifzman(the section `Control Functions' below)\
 ifnzman(noderef(Control Functions)) 
-for more information).  Strictly, the completer is `tt(_complete)', but the
-underscore is omitted from the context; this is also true of `tt(correct)',
-`tt(approximate)', etc.  The tt(::dvips:) shows that we are
-completing arguments for the tt(dvips) command.  The doubled colon
-will appear only before and after the name of the command, but note
-that the second colon after the command name is only added when 
-there is at least one more component (otherwise the whole name ends in 
-a colon, e.g. `tt(...dvips:)').  Finally, the string tt(-o-1) says that we
-are completing the first argument of the option `tt(-o)' to the command.
-Note that the existence of a context like this does not necessarily mean it
-is handled specially by the completion system; this is determined by trying
-to match the context as specifically as possible, as described below.
+for more information).  
+)
+item()(
+The var(context) or var(command). This is either one of the special
+context names such as tt(-condition-) as explained for the
+tt(_complete) completer below, or the name of the command we are
+completing arguments for. Commands that have sub-commands usually
+modify this field to contain the name of the command followed by a
+minus sign and the sub-command (e.g. the completion function for the
+tt(cvs) command sets this field to striings such as tt(cvs-add) when
+completing for the tt(add) sub-command).
+)
+item()(
+The var(argument), describing which argument we are
+completing. Normally this is either a string of the form
+tt(argument-)var(n), where var(n) is the number of the argument or it
+is a string of the form tt(-)var(opt)tt(-)var(n) when completing the
+var(n)'th argument of the option var(opt).
+)
+item()(
+The var(tag). Tags are used for two purposes: completion functions use 
+them to describe the types of matches they can generate for a certain
+context and they use them to simplify the definition of styles that
+are tested.
+)
+enditem()
+
+As an example, leaving out the var(tag) for the moment, the context name
+`tt(:completion::complete:dvips:-o-1:files)' says that normal
+completion was attempted on an argument of the tt(dvips)
+command. More precisely: completion was attempted on the first
+argument after the tt(-o) option.
 
 In many of the possible contexts the completion system can generate
 matches, often multiple types of matches.  These types are represented as
@@ -335,9 +368,8 @@
 (see
 ifzman(zmanref(zshmodules))\
 ifnzman(noderef(The zsh/zutil Module))).
-The full context used in looking up styles is the prefix `tt(:completion)'
-followed by the context as described above, followed by another colon and
-the name of the tag currently being tried for completion.
+When looking up styles the completion system uses full context names,
+including the tag.
 
 Styles determine such things as how the matches are generated; some of them
 correspond to shell options (for example, the use of menu completion), but
@@ -366,14 +398,14 @@
 latter is achieved by calling the tt(ps) command). To make this builtin
 list the matches only as numbers one could call:
 
-example(zstyle ':completion:*::kill:*' verbose no)
+example(zstyle ':completion:*:*:kill:*' verbose no)
 
-Furhtermore, if one wanted to see the command lines for processes but not the
+Furthermore, if one wanted to see the command lines for processes but not the
 job texts one could use the fact that the tag name is appended to the
 context name when styles are looked up.  As the function for the tt(kill)
 builtin command uses the tags tt(jobs) and tt(processes), we have:
 
-example(zstyle ':completion:*::kill:*:jobs' verbose no)
+example(zstyle ':completion:*:*:kill:*:jobs' verbose no)
 
 Note that the order in which styles are em(defined) does not matter; the
 style mechanism uses the most specific possible match for a particular
@@ -440,9 +472,6 @@
 item(tt(cursors))(
 for cursor names used by X programs
 )
-item(tt(cvs))(
-used only to look up the value of the tt(disable-stat) style
-)
 item(tt(default))(
 used to look up default values for various styles that may also be set 
 for tags that are used when generating matches
@@ -681,9 +710,9 @@
 completion, completion and correction for incremental completion and
 only completion for prediction one could use:
 
-example(zstyle ':completion:*' completer _complete _correct _approximate
-zstyle ':completion:incremental' completer _complete _correct
-zstyle ':completion:predict' completer _complete)
+example(zstyle ':completion:::::' completer _complete _correct _approximate
+zstyle ':completion:incremental::::' completer _complete _correct
+zstyle ':completion:predict::::' completer _complete)
 )
 item(tt(completions))(
 This style is used by the tt(_expand) completer function.
@@ -704,7 +733,7 @@
 arithmetical expression. In this case, delaying will be done if the
 expression evaluates to `tt(1)'. For example, with
 
-example(zstyle ':completion:list' condition 'NUMERIC != 1')
+example(zstyle ':completion:*:list:::' condition 'NUMERIC != 1')
 
 delaying will be done only if given an explicit numeric argument
 other than `tt(1)'.
@@ -716,7 +745,7 @@
 is used.
 )
 item(tt(disable-stat))(
-This is used with the tt(cvs) tag by the function completing for the
+This is used with the an empty tag by the function completing for the
 tt(cvs) command to decide if the tt(zsh/stat) module should be used to
 generate only names of modified files in the appropriate places.
 )
@@ -761,7 +790,7 @@
 For example, to make the completion system first try only filenames
 matching the pattern tt(*.o) for the tt(rm) command, one would use:
 
-example(zstyle ':completion:*::rm*:globbed-files' file-patterns '*.o')
+example(zstyle ':completion:*:*:rm:*:globbed-files' file-patterns '*.o')
 
 With this, using only filenames ending in tt(.o) will be the first
 choice and other filenames will only be used if what is on the line
@@ -821,8 +850,8 @@
 completions. To have the external commands and shell functions listed
 separately, one can set:
 
-example(zstyle ':completion:*:-command-:commands' group-name commands
-zstyle ':completion:*:-command-:functions' group-name functions)
+example(zstyle ':completion:*:*:-command-:*:commands' group-name commands
+zstyle ':completion:*:*:-command-:*:functions' group-name functions)
 
 This also means that if the same name is used for different types of
 matches, then those matches will be displayed together in the same
@@ -851,7 +880,7 @@
 external commands appear in this order when completing in command
 position one would set:
 
-example(zstyle ':completion:*:-command-' group-order builtins functions commands)
+example(zstyle ':completion:*:*:-command-' group-order builtins functions commands)
 )
 item(tt(groups))(
 A style holding the names of the groups that should be completed. If
@@ -924,7 +953,11 @@
 This is used by the tt(_match) and tt(_approximate) completer
 functions. If it is set to `true', the completer will start menu
 completion only if no unambiguous string could be generated that is at
-least as long as the original string from the line.
+least as long as the original string from the line. Note that the
+tt(_approximate) completer uses it after setting the completer field
+in the context name to one of tt(correct-)var(num) or
+tt(approximate-)var(num), where var(num) is the number of errors that
+were accepted.
 )
 item(tt(last-prompt))(
 This is used to determine if the completion code should try to put the
@@ -1046,7 +1079,7 @@
 completer function will take any numeric argument as the
 maximum number of errors allowed. For example, with
 
-example(zstyle ':completion:approximate' accept 2 numeric)
+example(zstyle ':completion:*:approximate:::' max-errors 2 numeric)
 
 two errors will be allowed if no numeric argument is given. However,
 with a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six
@@ -1116,7 +1149,10 @@
 completers. The first two use it to decide if the original string should
 be added as one possible completion. Normally, this is done only if there
 at least  two possible corrections, but if this style is set to `true', it
-will always be added.
+will always be added. Note that these completers use this style after
+setting the completer field in the context name to
+tt(correct-)var(num) or tt(approximate-)var(num), where var(num) is
+the number of errors that were accepted.
 
 For the tt(_match) completer, if this style is set to
 tt(only), it will try to generate matches without inserting a
@@ -1129,7 +1165,7 @@
 A style containing an override for the default package set
 for that context.  For example,
 
-example(zstyle :completion:complete::dpkg::--status-1 packageset avail)
+example(zstyle :completion:*:complete:dpkg:--status-1: packageset avail)
 
 will cause available packages, rather than only installed packages,
 to be completed for `dpkg --status'.
@@ -1240,7 +1276,7 @@
 arithmetical expression. In this case, expansion of substitutions will
 be done if the expression evaluates to `tt(1)'. For example, with
 
-example(zstyle ':completion:expand' substitute '${NUMERIC:-1} != 1')
+example(zstyle ':completion:*:expand:::' substitute '${NUMERIC:-1} != 1')
 
 substitution will be performed only if given an explicit numeric
 argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'.
@@ -1256,7 +1292,7 @@
 For example,
 
 example(
-  zstyle :completion:complete::gunzip: tag-order \ 
+  zstyle ':completion:*:complete:gunzip:*' tag-order \ 
     'globbed-files directories' all-files
 )
 
@@ -1330,7 +1366,7 @@
 tt(completer) style. For example, to use normal completion and
 correction if that doesn't generate any matches:
 
-example(zstyle ':completion:*' completer _complete _correct)
+example(zstyle ':completion:::::' completer _complete _correct)
 
 after calling tt(compinit). The default value for this style set up
 in tt(compinit) is `tt(_complete)', i.e. normally only ordinary
@@ -1442,7 +1478,7 @@
 presented to the user. The intended use of this completer function is to
 try after the normal tt(_complete) completer by setting:
 
-example(zstyle ':completion:*' completer _complete _approximate)
+example(zstyle ':completion:::::' completer _complete _approximate)
 
 This will give correcting completion if and only if
 normal completion doesn't yield any possible completions. When
@@ -1471,9 +1507,9 @@
 
 For example, with:
 
-example(zstyle ':completion:*' completer _complete _correct _approximate
-zstyle ':completion:correct' accept 2 not-numeric
-zstyle ':completion:approximate' accept 3 numeric)
+example(zstyle ':completion:::::' completer _complete _correct _approximate
+zstyle ':completion:*:correct:::' accept 2 not-numeric
+zstyle ':completion:*:approximate:::' accept 3 numeric)
 
 correction will accept up to two errors. If a numeric argument is
 given, correction will not be performed, but correcting completion
@@ -1783,7 +1819,7 @@
 
 This function also accepts the tt(-C) option followed by a
 var(name). This name is temporarily (i.e. not visible outside
-tt(_tags)) appended (with a colon before it) to the contents of the
+tt(_tags)) stored in the argument field of the context name in the
 tt(curcontext) parameter. This allows to make tt(_tags) use a more
 specific context name without having to change and reset the
 tt(curcontext) parameter (which would otherwise have the same effect).
@@ -1868,8 +1904,8 @@
 to offer usernames and hostnames as possible matches (which are
 generated by the tt(_users) and tt(_hosts) functions respectively).
 
-Like tt(_tags) this function supports the tt(-C) option to give an
-additional context name component.
+Like tt(_tags) this function supports the tt(-C) option to give a
+different name for the argument context field.
 )
 findex(_describe)
 item(tt(_describe) var(descr) var(name1) [ var(name2) ] var(opts) ... tt(-)tt(-) ...)(
diff -ru ../z.old/Etc/completion-style-guide Etc/completion-style-guide
--- ../z.old/Etc/completion-style-guide	Wed Feb  2 16:52:49 2000
+++ Etc/completion-style-guide	Thu Feb  3 13:28:42 2000
@@ -3,26 +3,27 @@
 
 The completion system keeps track of the current context in the
 parameter `curcontext'. It's content is the hierarchical name for the
-current context sans the tag currently tried. The tags represent
-different types of matches. So, whenever you are about to add matches, 
-you should use a tag for them and test if the user wants this type of
-matches to be generated. However, this only really needs to be done if 
-no other function in the call chain has tested that already or if you
-can offer different types of matches.
+current context sans the `:completion:' and the last colon and the tag
+currently tried. The tags represent different types of matches. So,
+whenever you are about to add matches, you should use a tag for them
+and test if the user wants this type of matches to be generated.
+However, this only really needs to be done if no other function in the
+call chain has tested that already or if you can offer different types
+of matches.
 
 Most of the utility functions do the testing themselves, so you don't
 have to worry about that at all. For example if you are adding matches 
 with `_files', `_hosts' or functions like these, you can just call
 them and they do the tests needed. The functions `_arguments' and
 `_values' do that too, but there is a small difference. These
-functions effectively add a new component to the hierarchical context
-name and if you are using the `->state' form for actions, this new
-component has to be reported back to the function calling `_arguments'
-or `_values'. This is done with the parameter `context', so you have
-to make that local in the calling function in the same way as you have 
-to make local `line', `state', and `{opt,val}_args'. This parameter
-`context' should then be used when you start adding matches by giving
-it to functions like `_tags' via the `-C' options, as in:
+functions effectively change the context name and if you are using the
+`->state' form for actions, this changed name component has to be
+reported back to the function calling `_arguments' or `_values'. This
+is done with the parameter `context', so you have to make that local
+in the calling function in the same way as you have to make local
+`line', `state', and `{opt,val}_args'. This parameter `context' should
+then be used when you start adding matches by giving it to functions
+like `_tags' via the `-C' options, as in:
 
   local context ...
   ...
@@ -33,8 +34,8 @@
     ...
   fi
 
-This will append the context name given to the `curcontext' parameter
-(preceding it with a colon) and this context will then be used to look 
+This will put the context name given in the argument field of the
+`curcontext' parameter and this context will then be used to look 
 up styles for the tags.
 
 But since this is often used, `_arguments' and `_values' have support
@@ -46,7 +47,7 @@
 
   local curcontext="$curcontext" ...
   ...
-  _arguments ... 'foo:foo:->foo'
+  _arguments -C ... 'foo:foo:->foo'
   ...
   if [[ "$state" = foo ]]; then
     _tags ...
@@ -74,8 +75,8 @@
 
 Since this sequence of command is used so often, the `_wanted'
 function was added which just calls `_tags' with its first argument
-(i.e. the first argument os a tag) and then calls `_description' with
-all other arguments. The return value is as for `_tags' -- zero if the 
+(i.e. the first argument is a tag) and then calls `_description' with
+all its arguments. The return value is as for `_tags' -- zero if the 
 matches should be added. So the example becomes:
 
   _wanted names expl 'name' && compadd "$expl[@]" alice bob
@@ -106,16 +107,16 @@
     (( ret )) || break   # leave the loop if matches were added
   done
 
-`_tags' with tags as arguments registers those tags and calls
-`_sort_tags' so that the user can say which in which order the tags
-are to be tried. This means that internally these tags are stored in
-multiple sets. The types of matches represented by the tags from the
-first set should be tried first. If that generates no matches, the
-second set is tried and so on. `_tags' without arguments just makes
-the next set be tried (on the first call it makes the first set be
-used). The function `_requested' then tests if the tag given as its
-first argument is in the set currently used and returns zero if it is, 
-i.e. if matches of that type should be added now.
+`_tags' with tags as arguments registers those tags and checks which
+of them the user wants to see and in which order the tags are to be
+tried. This means that internally these tags are stored in multiple
+sets. The types of matches represented by the tags from the first set
+should be tried first. If that generates no matches, the second set is
+tried and so on. `_tags' without arguments just makes the next set be
+tried (on the first call it makes the first set be used). The function
+`_requested' then tests if the tag given as its first argument is in
+the set currently used and returns zero if it is,  i.e. if matches of
+that type should be added now.
 
 But `_requested' can do more: since it is very common that you add
 different types of matches in different groups, with each group having 
@@ -130,7 +131,7 @@
   _tags friends users hosts
 
   while _tags; do
-    _requested friends expl friend && compad "$expl[@]" alice bob && ret=0
+    _requested friends expl friend && compadd "$expl[@]" alice bob && ret=0
     _requested users && _users && ret=0
     _requested hosts && _hosts && ret=0
 
@@ -138,7 +139,7 @@
   done
 
 This looks better already. But in many cases such as this one you can
-also use the function `_laternative' which simply implements a loop
+also use the function `_alternative' which simply implements a loop
 like this one. It gets arguments of the form `tag:descr:action'. E.g.:
 
   _alternative \
@@ -148,7 +149,7 @@
 
 Which does the same as the previous examples. (Note the empty
 descriptions in the last two arguments -- the actions start with a
-space so that they are executed without giving the the description
+space so that they are executed without giving the description
 build by `_alternative', i.e. we just use the description added by
 `_users' and `_hosts').
 
@@ -162,11 +163,11 @@
 names in plural. Also, first have a look at the tag names already used 
 by other functions and if any of these names seem sensible for the
 type of matches you are about to add, the use those names. This will
-allow users to define styles for certain types of matches indepent of
-the place where they are added.
+allow users to define styles for certain types of matches independent
+of the place where they are added.
 
-One final comment about when to use your own sub-contexts: do this
-when the command you are writing a completion function for has
+One final comment about when to use your own argument-contexts: do
+this when the command you are writing a completion function for has
 different `modes'. E.g. if it accepts host names after a `-h' option
 and users or hosts after `-u' and for some reason you can't use
 `_arguments' to do the work for you, then use context names as in:
@@ -185,30 +186,31 @@
 ------
 
 Users can associate patterns for hierarchical context names with
-certain styles using the `compstyle' function. The completion code
+certain styles using the `zstyle' builtin. The completion code
 should then use these styles to decide how matches should be added and 
-to get user-configured values. This is done using the builtin `zstyle'.
+to get user-configured values. This, too,  is done using the builtin
+`zstyle'.
 
 Basically styles map names to a bunch of strings (the `value'). In
 many cases you want to treat the value as a boolean, so let's start
 with that. To test if, for example, the style `verbose' is set for 
 the tag `options' in the context you are currently in, you can just do:
 
-  if zstyle -t ":completion${curcontext}:options" verbose; then
+  if zstyle -t ":completion:${curcontext}:options" verbose; then
     # yes, it is set...
   fi
 
 I.e. with the -t option and two arguments `zstyle' takes the first one
-as a tag and the second one as a style name and returns zero if that
+as a context and the second one as a style name and returns zero if that
 style has the boolean value `true'. Internally it checks if the style
 is set to one of `yes', `true', `on', or `1' and interprets that as
 `true' and every other value as `false'.
 
-For more complicated style for which you want to test if the value
+For more complicated styles for which you want to test if the value
 matches a certain pattern, you can use `zstyle' with the -m option and
 three arguments:
 
-  if zstyle -m ":completion${curcontext}:foo" bar '*baz*'; then
+  if zstyle -m ":completion:${curcontext}:foo" bar '*baz*'; then
     ...
   fi
 
@@ -219,15 +221,15 @@
 equal to any of a number of a strings, you can use the -t option and
 give the strings after the style name:
 
-  if zstyle -t ":completion${curcontext}:foo" bar str1 str2; then
+  if zstyle -t ":completion:${curcontext}:foo" bar str1 str2; then
     ...
   fi
 
 But sometimes you want to actually get the value stored for a certain
 style instead of just testing it. For this `zstyle' supports four
 options: `-b', `-s', `-a', and `-h'. After these options, three
-arguments are expected, the tag, the style, and a parameter name. The
-parameter will then be set to the value of the style and the option
+arguments are expected, the context, the style, and a parameter name.
+The parameter will then be set to the value of the style and the option
 says how the strings stored as a value will be stored in the
 parameter:
 
@@ -287,8 +289,7 @@
   _description tag expl '...'
   compadd "$expl[@]" -1V foo - ...    # THIS IS WRONG!!!
 
-is *not* the right way to use a unsorted group. Instead do the
-simpler:
+is *not* the right way to use a unsorted group. Instead do:
 
   _description -1V tag expl '...'
   compadd "$expl[@]" - ...
@@ -301,7 +302,7 @@
 different tags anyway, so, see above.
 
 And since a tag directly corresponds to a group of matches, you'll
-often be using the tags function that allow you to give the
+often be using the tags function that allows you to give the
 explanation to the same function that is used to test if the tags are
 requested (again: see above). Just as a reminder:
 
@@ -337,8 +338,8 @@
     This guarantees that your functions will be re-usable because calling
     functions may rely on the correct return value.
 5)  When writing helper functions that generate matches, the arguments
-    of these should be given unchanged to `compadd' or `compgen' (if
-    they are not used by the helper function itself).
+    of these should be given unchanged to `compadd' (if they are not
+    used by the helper function itself).
 6)  When matches with a common prefix such as option names are generated,
     add them *with* the prefix (like `-', `+', or `--' for options).
     Then check the `prefix-needed' style to see if the matches are to be
@@ -355,9 +356,9 @@
     completely different modes), it should allow users to define
     functions that separately override the behavior for these
     different types. This can easily be achieved by using the
-    `funcall' utility function, as in:
+    `_funcall' utility function, as in:
 
-      funcall ret _command_$subcommand && return ret
+      _funcall ret _command_$subcommand && return ret
 
     This will try to call the function `_command_$subcommand' and if
     it exists, it will be called and the completion function exits
diff -ru ../z.old/Functions/Zle/incremental-complete-word Functions/Zle/incremental-complete-word
--- ../z.old/Functions/Zle/incremental-complete-word	Wed Feb  2 16:53:35 2000
+++ Functions/Zle/incremental-complete-word	Thu Feb  3 12:53:30 2000
@@ -18,14 +18,17 @@
 
   local key lbuf="$LBUFFER" rbuf="$RBUFFER" pmpt pstr word
   local lastl lastr wid twid num alt post toolong
-  local curcontext="${curcontext}:incremental" stop brk
+  local curcontext="${curcontext}" stop brk
 
-  zstyle -s ":completion${curcontext}" prompt pmpt ||
+  [[ -z "$curcontext" ]] && curcontext=:::
+  curcontext="${curcontext#*:}incremental:"
+
+  zstyle -s ":completion:${curcontext}" prompt pmpt ||
     pmpt='incremental (%c): %u%s  %l'
-  zstyle -s ":completion${curcontext}" stop stop
-  zstyle -s ":completion${curcontext}" break brk
+  zstyle -s ":completion:${curcontext}" stop stop
+  zstyle -s ":completion:${curcontext}" break brk
 
-  if zstyle -t ":completion${curcontext}" list; then
+  if zstyle -t ":completion:${curcontext}" list; then
     wid=list-choices
     post=( icw-list-helper )
   else
diff -ru ../z.old/Functions/Zle/predict-on Functions/Zle/predict-on
--- ../z.old/Functions/Zle/predict-on	Wed Feb  2 16:53:35 2000
+++ Functions/Zle/predict-on	Thu Feb  3 12:54:38 2000
@@ -53,7 +53,10 @@
 	  unsetopt automenu recexact
 	  integer curs=$CURSOR pos nchar=${#LBUFFER//[^${KEYS[-1]}]}
 	  local -a +h comppostfuncs
-	  local crs curcontext="${curcontext}:predict"
+	  local crs curcontext="${curcontext}"
+
+          [[ -z "$curcontext" ]] && curcontext=:::
+          curcontext="${curcontext#*:}predict:"
 
 	  comppostfuncs=( predict-limit-list )
 	  zle complete-word
@@ -61,7 +64,7 @@
 	  # get out of that `case'.
 	  repeat 1
 	  do
-	    zstyle -s ":completion${curcontext}" cursor crs
+	    zstyle -s ":completion:${curcontext}" cursor crs
 	    case $crs in
 	    (complete)
 	      # At the place where the completion left it, if it is after
@@ -119,7 +122,7 @@
   then
     compstate[list]=''
     compstate[force_list]=yes
-  elif zstyle -t ":completion:predict${curcontext}" list always
+  elif zstyle -t ":completion:predict::::" list always
   then
     compstate[force_list]=yes
   fi

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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