summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-05-04 23:00:18 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-05-04 23:00:18 +0000
commit080155607ede1e392a8aaab446b1b345b54e492f (patch)
treeaba88827ba1b8f6980dff704cc2c507d8de2ae96
parentf8f6c27650f6469ee8b1427c733f0967b94159d9 (diff)
downloadzsh-080155607ede1e392a8aaab446b1b345b54e492f.tar.gz
zsh-080155607ede1e392a8aaab446b1b345b54e492f.tar.xz
zsh-080155607ede1e392a8aaab446b1b345b54e492f.zip
complete subscript flags (14227)
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Zsh/Context/_subscript31
2 files changed, 34 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c216788f..09ce4f4bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-05-04  Oliver Kiddle  <opk@zsh.org>
+
+	* 14227: Completion/Zsh/Context/_subscript, complete subscript flags
+
 2001-05-04  Bart Schaefer  <schaefer@zsh.org>
 
 	* 14224: Completion/Unix/Commmand/_cvs: Complete path prefixes for
diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript
index 8e1449357..c5e80d0ea 100644
--- a/Completion/Zsh/Context/_subscript
+++ b/Completion/Zsh/Context/_subscript
@@ -1,6 +1,6 @@
 #compdef -subscript-
 
-local expl ind osuf=']'
+local expl ind osuf=']' flags
 
 if [[ "$1" = -q ]]; then
   osuf='] '
@@ -8,10 +8,39 @@ if [[ "$1" = -q ]]; then
   shift
 fi
 
+compset -P '\([^\)]##\)' # remove subscript flags
+
 if [[ "$PREFIX" = :* ]]; then
   _wanted characters expl 'character class' \
       compadd -p: -S ':]' alnum alpha blank cntrl digit graph \
                           lower print punct space upper xdigit
+elif compset -P '\('; then
+  compset -S '\)*'
+
+  case ${(Pt)${compstate[parameter]}} in
+    assoc*) flags=(
+      '(R k K i I)r[return first matching value]'
+      '(r k K i I)R[return value of first matching key]'
+      '(r R K i I)k[return all values with matching keys]'
+      '(r R k i I)K[return value of first matching key]'
+      '(r R k K I)i[return first matching key]'
+      '(r R k K i)I[return all matching keys]'
+    );;
+    (|scalar*)) flags=(
+      'w[make subscripting work on words of scalar]'
+      's[specify word separator]'
+      'p[recognise escape sequences in subsequent s flag]'
+    );&
+    array*) flags=($flags
+      'n[specify match to return]'
+      'b[begin with specified element]'
+      '(r R k K i)I[reverse subscript giving index of last match]'
+      '(r k K i I)R[reverse subscripting giving last match]'
+      '(R k K i I)r[reverse subscripting giving first match]'
+    );;
+  esac
+
+  _values -s '' 'subscript flags' $flags
 elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
   local suf