about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-22 12:29:47 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-22 12:29:47 +0000
commit3d9d13e918c195f974ff7b2f1dc5b65f6b20a441 (patch)
treed571aef9c8152287ed94dae1199108de80f0b984 /Completion/Core
parenta76b36928c5cbeef3fe015ca30bbf910ab2a107e (diff)
downloadzsh-3d9d13e918c195f974ff7b2f1dc5b65f6b20a441.tar.gz
zsh-3d9d13e918c195f974ff7b2f1dc5b65f6b20a441.tar.xz
zsh-3d9d13e918c195f974ff7b2f1dc5b65f6b20a441.zip
zsh-workers/8720
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_approximate12
-rw-r--r--Completion/Core/_complete6
-rw-r--r--Completion/Core/_correct6
-rw-r--r--Completion/Core/_expand8
-rw-r--r--Completion/Core/_list6
-rw-r--r--Completion/Core/_main_complete2
-rw-r--r--Completion/Core/_match14
-rw-r--r--Completion/Core/_menu6
-rw-r--r--Completion/Core/_oldlist17
-rw-r--r--Completion/Core/compinit14
10 files changed, 26 insertions, 65 deletions
diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate
index 910742fee..0c0c8566f 100644
--- a/Completion/Core/_approximate
+++ b/Completion/Core/_approximate
@@ -7,7 +7,7 @@
 
 local _comp_correct _correct_prompt comax
 local cfgacc cfgorig cfgps cfgins
-local curcontext="$curcontext" oldcontext
+local curcontext="${curcontext}" oldcontext
 
 # Only if all global matchers have been tried.
 
@@ -17,23 +17,21 @@ local curcontext="$curcontext" oldcontext
 
 [[ "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
 
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':approximate'
+[[ "$curcontext" != *:correct ]] && curcontext="${curcontext}:approximate"
 
 oldcontext="$curcontext"
 
-_style -s '' accept cfgacc
+_style -s '' max-errors cfgacc
 _style -s '' original cfgorig
 _style -s '' prompt cfgps
 _style -s '' insert cfgins
 
 # Get the number of errors to accept.
 
-if [[ "$cfgacc" = *[nN]* && ${NUMERIC:-1} -ne 1 ]]; then
+if [[ "$cfgacc" = *numeric* && ${NUMERIC:-1} -ne 1 ]]; then
   # Stop if we also have a `!'.
 
-  [[ "$cfgacc" = *\!* ]] && return 1
+  [[ "$cfgacc" = *not-numeric* ]] && return 1
 
   # Prefer the numeric argument if that has a sensible value.
 
diff --git a/Completion/Core/_complete b/Completion/Core/_complete
index 235265326..1468e46ce 100644
--- a/Completion/Core/_complete
+++ b/Completion/Core/_complete
@@ -4,11 +4,7 @@
 # a normal completion function, but as one possible value for the
 # completer style.
 
-local comp name curcontext="$curcontext" oldcontext
-
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':complete'
+local comp name curcontext="${curcontext}:complete" oldcontext
 
 oldcontext="$curcontext"
 
diff --git a/Completion/Core/_correct b/Completion/Core/_correct
index abd70ddeb..c958bdb83 100644
--- a/Completion/Core/_correct
+++ b/Completion/Core/_correct
@@ -8,11 +8,7 @@
 # Supported configuration keys are the same as for `_approximate', only
 # starting with `correct'.
 
-local ret=1 opm="$compstate[pattern_match]" curcontext="$curcontext"
-
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':correct'
+local ret=1 opm="$compstate[pattern_match]" curcontext="${curcontext}:correct"
 
 compstate[pattern_match]='-'
 
diff --git a/Completion/Core/_expand b/Completion/Core/_expand
index 97728bd3b..68c09ddbb 100644
--- a/Completion/Core/_expand
+++ b/Completion/Core/_expand
@@ -8,11 +8,7 @@
 # word from the line.
 
 local exp word="$PREFIX$SUFFIX" group=-V expl expl2 disp orig menu prompt
-local curcontext="$curcontext" expr descr
-
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':expand'
+local curcontext="${curcontext}:expand" expr descr
 
 # First, see if we should insert all *completions*.
 
@@ -68,7 +64,7 @@ else
   expl=(-n)
 fi
 
-if [[ -n "$menu" && "$menu" != *only* && "$menu" = *showall* ]]; then
+if [[ -n "$menu" && "$menu" != *only* && "$menu" = *show-all* ]]; then
   if [[ -n "$descr" ]]; then
     expl2=(-ld disp -X "${descr//\\%d/all words}")
   else
diff --git a/Completion/Core/_list b/Completion/Core/_list
index 803da2f71..ea2ed36aa 100644
--- a/Completion/Core/_list
+++ b/Completion/Core/_list
@@ -4,11 +4,7 @@
 # insert possible completions only after the list has been shown at
 # least once.
 
-local pre suf curcontext="$curcontext" expr
-
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':list'
+local pre suf curcontext="${curcontext}:list" expr
 
 # Get the strings to compare.
 
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index ba31399b3..51f72d504 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -91,7 +91,7 @@ if [[ compstate[nmatches] -eq 0 &&
   compadd -UX "${format//\\%d/$str}" -n ''
 fi
 
-_style '' last-prompt always && compstate[last_prompt]=yes
+_style '' last-prompt && compstate[last_prompt]=yes
 
 _lastcomp=( "${(@kv)compstate}" )
 _lastcomp[completer]="$comp"
diff --git a/Completion/Core/_match b/Completion/Core/_match
index 35d7c2ecb..d5556dfcd 100644
--- a/Completion/Core/_match
+++ b/Completion/Core/_match
@@ -9,8 +9,8 @@
 # expand-or-complete function because otherwise the pattern will
 # be expanded using globbing.
 
-local tmp opm="$compstate[pattern_match]" ret=0 curcontext="$curcontext"
-local orig ins
+local tmp opm="$compstate[pattern_match]" ret=0 orig ins
+local curcontext="${curcontext}:match"
 
 # Do nothing if we don't have a pattern or there are still global
 # match specifications to try.
@@ -19,12 +19,8 @@ tmp="${${:-$PREFIX$SUFFIX}#[~=]}"
 [[ "$tmp:q" = "$tmp" ||
    compstate[matcher] -ne compstate[total_matchers] ]] && return 1
 
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':match'
-
 _style -s '' original orig
-_style -s '' insert ins
+_style -b '' insert-unambiguous ins
 
 # Try completion without inserting a `*'?
 
@@ -36,7 +32,7 @@ if [[ -n "$orig" ]]; then
   compstate[matcher]="$compstate[total_matchers]"
 
   if (( ret )); then
-    [[ "$ins" = unambig* &&
+    [[ "$ins" = yes &&
        $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && 
         compstate[pattern_insert]=unambiguous
     return 0
@@ -53,7 +49,7 @@ _complete && ret=1
 compstate[pattern_match]="$opm"
 compstate[matcher]="$compstate[total_matchers]"
 
-[[ ret -eq 1 && "$ins" = unambig* &&
+[[ ret -eq 1 && "$ins" = yes &&
    $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && 
     compstate[pattern_insert]=unambiguous
 
diff --git a/Completion/Core/_menu b/Completion/Core/_menu
index e9558fe05..5b864c6a1 100644
--- a/Completion/Core/_menu
+++ b/Completion/Core/_menu
@@ -1,10 +1,6 @@
 #autoload
 
-local curcontext="$curcontext"
-
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':menu'
+local curcontext="${curcontext}:menu"
 
 # This completer is an example showing how menucompletion can be
 # implemented with the new completion system.
diff --git a/Completion/Core/_oldlist b/Completion/Core/_oldlist
index 2408613da..ba57ed6b4 100644
--- a/Completion/Core/_oldlist
+++ b/Completion/Core/_oldlist
@@ -1,13 +1,8 @@
 #autoload
 
-local curcontext="$curcontext" list menu
-
-# Probably set initial context.
-
-[[ -z "$curcontext" ]] && curcontext=':oldlist'
+local curcontext="${curcontext}:oldlist" list
 
 _style -s '' list list
-_style -s '' menu menu
 
 # 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'
@@ -33,16 +28,12 @@ if [[ -n $compstate[old_list] && $list != never ]]; then
 fi
 
 # If this is a completion widget, and we have a completion inserted already,
-# and the style :oldlist:menu is not never, then we cycle through the
+# and the style :oldlist:menu is `true', then we cycle through the
 # existing list (even if it was generated by another widget).
 
-if [[ $menu = verbose &&
-      $LASTWIDGET = _verbose_list && $WIDGET != _verbose_list &&
-      -z $compstate[old_insert] &&
-      -n $compstate[old_list] ]]; then
+if [[ -z $compstate[old_insert] && -n $compstate[old_list] ]]; then
   compstate[old_list]=keep
-elif [[ $WIDGET = *complete(|-prefix|-word) &&
-        $menu != (never|verbose) ]]; then
+elif [[ $WIDGET = *complete(|-prefix|-word) ]] && _style '' menu; then
   if [[ -n $compstate[old_insert] ]]; then
     compstate[old_list]=keep
     if [[ $WIDGET = *reverse* ]]; then
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 34967f8e3..746b6c4d4 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -349,10 +349,10 @@ Have fun
       tmp="'*:urls' local ${${(qqs.:.)val}}"
       ;;
     describe_options)
-      tmp="'*:options' description ${(qq)val}"
+      tmp="'*:options' verbose 'yes'"
       ;;
     describe_values)
-      tmp="'*:values' description ${(qq)val}"
+      tmp="'*:values' verbose 'yes'"
       ;;
     autodescribe_options)
       tmp="'*:options' auto-description ${(qq)val}"
@@ -412,7 +412,7 @@ compstyle '*:options' prefix-hidden yes"
       tmp="'*' completer ${${(qqs.:.)val}}"
       ;;
     last_prompt)
-      tmp="'*' last-prompt ${(qq)val}"
+      tmp="'*' last-prompt 'yes'"
       ;;
     esac
     [[ -n "$tmp" ]] && style="${style}${cmt}compstyle ${tmp}
@@ -426,11 +426,7 @@ compstyle '*:options' prefix-hidden yes"
 
 # Very simple interface for setting styles:
 #
-#   compstyle context -styles... context -styles ...
-#
-# Where context is of the form :ctxt-pats:...:tag-pat.
-#
-# This will be improved if needed. Promised.
+#   compstyle pattern style values...
 
 compstyle() {
   local long
@@ -490,7 +486,7 @@ compstyle() {
 
 # Default styles. This should be executed conditionally somehow.
 
-compstyle '*'        description   'yes'
+compstyle '*'        verbose       'yes'
 compstyle '*'        prefix-needed 'yes'
 compstyle '*'        prefix-hidden 'no'
 compstyle ':correct' accept        '2n'