about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-13 10:41:28 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-13 10:41:28 +0000
commit7eb928e2663197d52898b55cd2ccbe10c3222236 (patch)
treec20c9867c251eac584a9f1c4e1271ed060d42624 /Completion/Base
parent2ef449a71d2f681a85453e68b10d3af97dec14ff (diff)
downloadzsh-7eb928e2663197d52898b55cd2ccbe10c3222236.tar.gz
zsh-7eb928e2663197d52898b55cd2ccbe10c3222236.tar.xz
zsh-7eb928e2663197d52898b55cd2ccbe10c3222236.zip
manual/7796
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_arguments19
-rw-r--r--Completion/Base/_values60
2 files changed, 54 insertions, 25 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index b9af1c072..e0443930b 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -209,7 +209,7 @@ if [[ "$*" != "$_args_cache_descr" ]]; then
 
     # Description for both the `-foo' and `+foo' form?
 
-    if [[ "$1" = (\*|)(-+|+-)* ]]; then
+    if [[ "$1" = (\*|)(-+|+-)[^:]* ]]; then
 
       # With a `*' at the beginning, the option may appear more than
       # once.
@@ -257,7 +257,7 @@ if [[ "$*" != "$_args_cache_descr" ]]; then
         [[ "$tmp" = *[-+] ]] && tmp="$tmp[1,-2]"
       else
         tmp="${1%%:*}"
-        [[ "$tmp" = *[-+] ]] && tmp="$tmp[1,-2]"
+        [[ "$tmp" = [-+]?*[-+] ]] && tmp="$tmp[1,-2]"
 	xor="$xor ${tmp%\=}"
       fi
 
@@ -275,7 +275,7 @@ if [[ "$*" != "$_args_cache_descr" ]]; then
       else
         _args_cache_opts[$tmp]=''
       fi
-      _args_cache_odescr=( "$_args_cache_odescr[@]" "${tmp%[-+=]}:$descr" )
+      _args_cache_odescr=( "$_args_cache_odescr[@]" "${tmp%\=}:$descr" )
       [[ -n "$xor" ]] && 
           _args_cache_xors[${tmp%\=}]="${${xor##[ 	]#}%%[ 	]#}"
     elif [[ "$1" = \*::* ]]; then
@@ -774,11 +774,16 @@ while true; do
 
         eval ws\=\( "${action[3,-3]}" \)
 
-	if _display tmp ws -M 'r:|[_-]=* r:|=*'; then
-          compadd "$expl[@]" -y tmp - "${(@)ws%%:*}"
+	if [[ -n "$compconfig[describe_values]" &&
+              "$compconfig[describe_values]" != *\!${cmd}* ]]; then
+          if _display tmp ws -M 'r:|[_-]=* r:|=*'; then
+            compadd "$expl[@]" -y tmp - "${(@)ws%%:*}"
+          else
+            [[ -n "$matched" ]] && compadd -Q -S -s "$SUFFIX" - "$PREFIX"
+            _message "$descr"
+          fi
         else
-          [[ -n "$matched" ]] && compadd -Q -S -s "$SUFFIX" - "$PREFIX"
-          _message "$descr"
+	  compadd "$expl[@]" - "${(@)ws%%:*}"
         fi
       elif [[ "$action" = \(*\) ]]; then
 
diff --git a/Completion/Base/_values b/Completion/Base/_values
index 4be3e8203..9be2d97f3 100644
--- a/Completion/Base/_values
+++ b/Completion/Base/_values
@@ -3,7 +3,7 @@
 setopt localoptions extendedglob
 
 local name arg def descr xor str tmp ret=1 expl nm="$compstate[nmatches]"
-local snames odescr gdescr sep
+local snames odescr gdescr sep esep spat
 typeset -A names onames xors _values
 
 # Probably fill our cache.
@@ -11,7 +11,7 @@ typeset -A names onames xors _values
 if [[ "$*" != "$_vals_cache_args" ]]; then
   _vals_cache_args="$*"
 
-  unset _vals_cache_{sep,descr,names,onames,snames,xors,odescr}
+  unset _vals_cache_{sep,esep,descr,names,onames,snames,xors,odescr}
 
   typeset -gA _vals_cache_{names,onames,xors}
   _vals_cache_snames=()
@@ -21,6 +21,7 @@ if [[ "$*" != "$_vals_cache_args" ]]; then
 
   if [[ "$1" = -s ]]; then
     _vals_cache_sep="$2"
+    [[ -z "$2" ]] && _vals_cache_esep=yes
     shift 2
   fi
 
@@ -107,20 +108,33 @@ xors=( "${(@kv)_vals_cache_xors}" )
 odescr=( "$_vals_cache_odescr[@]" )
 gdescr="$_vals_cache_descr"
 sep="$_vals_cache_sep"
+esep="$_vals_cache_esep"
 
-if [[ -n "$sep" ]]; then
+if [[ -n "$sep$esep" ]]; then
 
   # We have a separator character. We parse the PREFIX and SUFFIX to
   # see if any of the values that must not appear more than once are
   # already on the line.
 
-  while [[ "$PREFIX" = *${sep}* ]]; do
+  if [[ -n "$esep" ]]; then
+    spat='?*'
+  else
+    spat="*${sep}*"
+  fi
+
+  while [[ "$PREFIX" = $~spat ]]; do
 
     # Get one part, remove it from PREFIX and put it into IPREFIX.
 
-    tmp="${PREFIX%%${sep}*}"
-    PREFIX="${PREFIX#*${sep}}"
-    IPREFIX="${IPREFIX}${tmp}${sep}"
+    if [[ -n "$esep" ]]; then
+      tmp="$PREFIX[1]"
+      IPREFIX="${IPREFIX}${tmp}"
+      PREFIX="${PREFIX[2,-1]}"
+    else
+      tmp="${PREFIX%%${sep}*}"
+      PREFIX="${PREFIX#*${sep}}"
+      IPREFIX="${IPREFIX}${tmp}${sep}"
+    fi
 
     # Get the value `name'.
 
@@ -138,24 +152,34 @@ if [[ -n "$sep" ]]; then
     if [[ -n "$xors[$name]" ]]; then
       snames=( "${(@)snames:#(${(j:|:)~${=xors[$name]}})}" )
       odescr=( "${(@)odescr:#(${(j:|:)~${=xors[$name]}}):*}" )
-      unset {names,onames,xors}\[${^=tmp}\]
+      unset {names,onames,xors}\[$name\]
     fi
   done
-  if [[ "$SUFFIX" =  *${sep}* ]]; then
+  if [[ "$SUFFIX" = $~spat ]]; then
 
     # The same for the suffix.
 
-    str="${SUFFIX%%${sep}*}"
-    SUFFIX="${SUFFIX#*${sep}}"
+    if [[ -n "$esep" ]]; then
+      str=''
+    else
+      str="${SUFFIX%%${sep}*}"
+      SUFFIX="${SUFFIX#*${sep}}"
+    fi
+
     while [[ -n "$SUFFIX" ]]; do
-      tmp="${PREFIX%%${sep}*}"
-      if [[ "$SUFFIX" = *${sep}* ]]; then
-        SUFFIX="${SUFFIX#*${sep}}"
+      if [[ -n "$esep" ]]; then
+        tmp="$SUFFIX[-1]"
+        ISUFFIX="${SUFFIX[-1]}$ISUFFIX"
+	SUFFIX="$SUFFIX[1,-2]"
       else
-        SUFFIX=''
+        tmp="${SUFFIX##*${sep}}"
+        if [[ "$SUFFIX" = *${sep}* ]]; then
+          SUFFIX="${SUFFIX%${sep}*}"
+        else
+          SUFFIX=''
+        fi
+	ISUFFIX="${sep}${tmp}${ISUFFIX}"
       fi
-      PREFIX="${PREFIX#*${sep}}"
-      IPREFIX="${IPREFIX}${tmp}${sep}"
 
       name="${tmp%%\=*}"
 
@@ -168,7 +192,7 @@ if [[ -n "$sep" ]]; then
       if [[ -n "$xors[$name]" ]]; then
         snames=( "${(@)snames:#(${(j:|:)~${=xors[$name]}})}" )
         odescr=( "${(@)odescr:#(${(j:|:)~${=xors[$name]}}):*}" )
-        unset {names,onames,xors}\[${^=tmp}\]
+        unset {names,onames,xors}\[$name\]
       fi
     done
     SUFFIX="$str"