about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-12-07 16:25:53 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-12-07 16:25:53 +0000
commit36b2667e6f7734597f987ee1e6189a6f93200b03 (patch)
tree297fa2c325286a096767e04fccfcf9b4e2506e67 /Completion
parent18e6f5f1ee7f58a5416c4a0341bc79827dfd3a8f (diff)
downloadzsh-36b2667e6f7734597f987ee1e6189a6f93200b03.tar.gz
zsh-36b2667e6f7734597f987ee1e6189a6f93200b03.tar.xz
zsh-36b2667e6f7734597f987ee1e6189a6f93200b03.zip
zsh-workers/8932
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_approximate53
-rw-r--r--Completion/Core/_description23
-rw-r--r--Completion/Core/_expand102
-rw-r--r--Completion/Core/_message5
-rw-r--r--Completion/Core/_tags1
5 files changed, 56 insertions, 128 deletions
diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate
index c0d409cb3..fc2d6afa0 100644
--- a/Completion/Core/_approximate
+++ b/Completion/Core/_approximate
@@ -5,8 +5,7 @@
 # shown in a list and one can cycle through them as in a menucompletion
 # or get the corrected prefix.
 
-local _comp_correct _correct_prompt comax
-local cfgacc cfgorig cfgps cfgins
+local _comp_correct _correct_expl comax cfgacc
 local curcontext="${curcontext}" oldcontext
 
 # Only if all global matchers have been tried.
@@ -22,9 +21,6 @@ local curcontext="${curcontext}" oldcontext
 oldcontext="$curcontext"
 
 _style -s '' max-errors cfgacc
-_style -s '' original cfgorig
-_style -s '' prompt cfgps
-_style -s '' insert cfgins
 
 # Get the number of errors to accept.
 
@@ -44,6 +40,8 @@ fi
 
 [[ "$comax" -lt 1 ]] && return 1
 
+_tags corrections original
+
 # Otherwise temporarily define functions to use instead of
 # the builtins that add matches. This is used to be able
 # to stick the `(#a...)' into the right place (after an
@@ -58,11 +56,7 @@ compadd() {
   else
     PREFIX="(#a${_comp_correct})$PREFIX"
   fi
-  if [[ -n "$_correct_prompt" ]]; then
-    builtin compadd -X "$_correct_prompt" -J corrections "$@"
-  else
-    builtin compadd -J corrections "$@"
-  fi
+  builtin compadd "$_correct_expl[@]" "$@"
 }
 
 # Now initialise our counter. We also set `compstate[matcher]'
@@ -76,39 +70,28 @@ compadd() {
 _comp_correct=1
 compstate[matcher]=-1
 
-_correct_prompt="${cfgps//\\%e/1}"
-
-_setup corrections
-
-[[ "$cfgorig" != *last* ]] && builtin compadd -V original
-builtin compadd -J corrections
-
 [[ -z "$compstate[pattern_match]" ]] && compstate[pattern_match]='*'
 
 while [[ _comp_correct -le comax ]]; do
   curcontext="${oldcontext}:$_comp_correct"
 
+  _description corrections _correct_expl corrections \
+               "e:$_comp_correct" "o:$PREFIX$SUFFIX"
+
   if _complete; then
-    if [[ "$cfgins" = unambig* &&
-          "${#compstate[unambiguous]}" -ge "${#:-$PREFIX$SUFFIX}" ]]; then
+    if _style '' insert-unambiguous &&
+       [[ "${#compstate[unambiguous]}" -ge "${#:-$PREFIX$SUFFIX}" ]]; then
       compstate[pattern_insert]=unambiguous
-    elif [[ compstate[nmatches] -gt 1 || "$cfgorig" = *always* ]]; then
-      local expl format
-
-      if [[ "$cfgorig" = *show* ]]; then
-        if _style -s descriptions format format; then
-	  expl=(-X "${format//\\%d/original}")
-        else
-	  expl=()
-        fi
-      else
-        expl=(-n)
-      fi
-      _setup original
-      builtin compadd "$expl[@]" -U -V original -Q - "$PREFIX$SUFFIX"
+    elif _requested original &&
+         ( [[ compstate[nmatches] -gt 1 ]] || _style '' original ); then
+      local expl
+
+      _description -V original expl original
+
+      builtin compadd "$expl[@]" -U -Q - "$PREFIX$SUFFIX"
 
       # If you always want to see the list of possible corrections,
-      # set `compstate[list]=list' here.
+      # set `compstate[list]=list force' here.
 
       [[ "$compstate[list]" != list* ]] &&
           compstate[list]="$compstate[list] force"
@@ -121,8 +104,6 @@ while [[ _comp_correct -le comax ]]; do
 
   [[ "${#:-$PREFIX$SUFFIX}" -le _comp_correct+1 ]] && break
   (( _comp_correct++ ))
-
-  _correct_prompt="${cfgps//\\%e/$_comp_correct}"
 done
 
 compstate[matcher]="$compstate[total_matchers]"
diff --git a/Completion/Core/_description b/Completion/Core/_description
index 0d28284ed..9f315f9b1 100644
--- a/Completion/Core/_description
+++ b/Completion/Core/_description
@@ -1,8 +1,9 @@
 #autoload
 
-local gropt format gname
+local name gropt format gname hidden hide
 
 gropt=(-J)
+hide=()
 
 if [[ "$1" = -[VJ] ]]; then
   gropt=("$1")
@@ -16,20 +17,30 @@ _lastdescr=( "$_lastdescr[@]" "$3" )
 
 _setup "$1"
 
-_style -s descriptions format format
+name="$2"
+
+_style -s "$1" format format || _style -s descriptions format format
+_style -s "$1" hidden hidden
+if [[ "$hidden" = (all|yes|true|1|on) ]]; then
+  [[ "$hidden" = all ]] && format=''
+  hide=(-n)
+fi
 _style -s "$1" group-name gname && [[ -z "$gname" ]] && gname="$1"
 
+shift 2
+[[ -n "$format" ]] && compfmt format "$format" "d:$1" "${(@)argv[2,-1]}"
+
 if [[ -n "$gname" ]]; then
   if [[ -n "$format" ]]; then
-    eval "$2=($gropt ${(q)gname} -X ${(q)format//\\%d/$3})"
+    eval "${name}=($hide $gropt ${(q)gname} -X \"${format}\")"
   else
-    eval "$2=($gropt ${(q)gname})"
+    eval "${name}=($hide $gropt ${(q)gname})"
   fi
 else
   if [[ -n "$format" ]]; then
-    eval "$2=(-J -default- -X ${(q)format//\\%d/$3})"
+    eval "${name}=($hide -J -default- -X \"${format}\")"
   else
-    eval "$2=(-J -default-)"
+    eval "${name}=($hide -J -default-)"
   fi
 fi
 
diff --git a/Completion/Core/_expand b/Completion/Core/_expand
index 471ad370e..bde5ee2f8 100644
--- a/Completion/Core/_expand
+++ b/Completion/Core/_expand
@@ -7,10 +7,9 @@
 # the expansions done produce no result or do not change the original
 # word from the line.
 
-local exp word="$PREFIX$SUFFIX" group=-V expl expl2 disp orig menu prompt
-local curcontext="${curcontext}" expr descr
+local exp word="$PREFIX$SUFFIX" sort expr expl curcontext="${curcontext}"
 
-[[ "$curcontext" != :correct* ]] && curcontext="${curcontext}:correct"
+[[ "$curcontext" != :expand* ]] && curcontext="${curcontext}:expand"
 
 # First, see if we should insert all *completions*.
 
@@ -49,97 +48,34 @@ _style -s '' glob expr && [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
 [[ $#exp -eq 0 ||
    ( $#exp -eq 1 && "$exp[1]" = "$word"(|\(N\)) ) ]] && return 1
 
-# Get the options for adding the original string and `all'-string.
+# Now add as matches whatever the user requested.
 
-_style -s '' original orig
-_style -s '' menu menu
-_style -s '' prompt prompt
-_style -s descriptions format descr
+_style -s '' sort sort
 
-if [[ "$orig" = *show* ]]; then
-  if [[ -n "$descr" ]]; then
-    expl=(-X "${descr//\\%d/original}")
-  else
-    expl=()
-  fi
-else
-  expl=(-n)
-fi
-
-if [[ -n "$menu" && "$menu" != *only* && "$menu" = *show-all* ]]; then
-  if [[ -n "$descr" ]]; then
-    expl2=(-ld disp -X "${descr//\\%d/all words}")
-  else
-    expl2=(-ld disp )
-  fi
-  disp=( "$exp" )
-  if [[ ${#disp[1]} -gt COLUMNS-5 ]]; then
-    disp=( "${disp[1][1,COLUMNS-5]}..." )
-  fi
-else
-  expl2=(-n)
-fi
-
-# Quote the results and remove unnecessary quotes before `='s.
-
-exp=( "${(@)${(@)${(@q)exp}//\\\\=/=}/#=/\\=}" )
+[[ "$sort" = (yes|true|1|on) ]] && exp=( "${(@o)exp}" )
 
-# We have expansions, should we menucomplete them?
+if [[ -z "$compstate[insert]" ]] ;then
+  _description all-expansions expl 'all expansions' "o:$word"
 
-if [[ -z "$menu" ]]; then
+  compadd "$expl[@]" -UQ - "$exp"
+else
+  _tags all-expansions expansions original
 
-  # No, so if the user only wants a list, we add the strings
-  # separately. Otherwise we add the whole array as one string,
-  # probably also adding the original string.
 
-  if [[ -z "$compstate[insert]" ]]; then
-    _setup all-expansions
-    compadd -U -V all-expansions -Q - "$exp[@]"
-  else
-    if [[ -n "$orig" && "$orig" != *last* ]]; then
-      _setup original
-      compadd "$expl[@]" -UQ -V original - "$word"
-    fi
-    _setup expansions
-    compadd -UQ -V expansions - "$exp"
+  _requested all-expansions expl 'all expansions' "o:$word" &&
+      compadd "$expl[@]" -UQ "$exp"
 
-    if [[ -n "$orig" && "$orig" = *last* ]]; then
-      _setup original
-      compadd "$expl[@]" -UQ -V original - "$word"
+  if _requested expansions; then
+    if [[ "$sort" = menu ]]; then
+      _description expansions expl expansions "o:$word"
+    else
+      _description -V expansions expl expansions "o:$word"
     fi
-    compstate[insert]=menu
+    compadd "$expl[@]" -UQ - "$exp[@]"
   fi
-else
-  # Sorting? We just use a different group type then.
 
-  [[ "$menu" = *sort* ]] && group=-J
+  _requested original expl original && compadd "$expl[@]" -UQ - "$word"
 
-  # Now add the expansion string, probably also adding the original
-  # and/or the string containing all expanded string.
-
-  if [[ -n "$orig" && "$orig" != *last* ]]; then
-    _setup original
-    compadd "$expl[@]" -UQ -V original - "$word"
-  fi
-  if [[ $#exp -ne 1 && "$menu" = *last* && "$menu" != *only* ]]; then
-    _setup all-expansions
-    compadd "$expl2[@]" -UQ -V all-expansions - "$exp"
-  fi
-  _setup expansions
-  if [[ -z "$prompt" ]]; then
-    compadd -UQ $group expansions - "$exp[@]"
-  else
-    compadd -UQ -X "${prompt//\\%o/$word}" \
-            $group expansions - "$exp[@]"
-  fi
-  if [[ $#exp -ne 1 && "$menu" != *last* && "$menu" != *only* ]]; then
-    _setup all-expansions
-    compadd "$expl2[@]" -UQ -V all-expansions - "$exp"
-  fi
-  if [[ -n "$orig" && "$orig" = *last* ]]; then
-    _setup original
-    compadd "$expl[@]" -UQ -V original - "$word"
-  fi
   compstate[insert]=menu
 fi
 
diff --git a/Completion/Core/_message b/Completion/Core/_message
index b2730a331..6b2666253 100644
--- a/Completion/Core/_message
+++ b/Completion/Core/_message
@@ -7,11 +7,12 @@ _tags messages || return 1
 _style -s messages format format || _style -s descriptions format format
 
 if [[ -n "$format" ]]; then
+  compfmt format "$format" "d:$1" "${(@)argv[2,-1]}"
   if [[ $compstate[nmatches] -eq 0 ]]; then
     compstate[list]='list force'
     compstate[insert]=''
-    compadd -UX "${format//\\%d/$1}" -n ''
+    compadd -UX "${format}" -n ''
   else
-    compadd -X "${format//\\%d/$1}" -n '' && compstate[list]='list force'
+    compadd -X "${format}" -n '' && compstate[list]='list force'
   fi
 fi
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index 5519cc6cf..b39c0fff5 100644
--- a/Completion/Core/_tags
+++ b/Completion/Core/_tags
@@ -18,7 +18,6 @@ if (( $# )); then
 
   [[ "$1" = -(|-) ]] && shift
 
-
   if _style -a '' group-order order; then
     local name