about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_first72
-rw-r--r--Completion/Base/_subscript14
2 files changed, 17 insertions, 69 deletions
diff --git a/Completion/Base/_first b/Completion/Base/_first
index 8b4da019d..655e3569f 100644
--- a/Completion/Base/_first
+++ b/Completion/Base/_first
@@ -1,63 +1,11 @@
-#compdef -first-
+#compdef -subscript-
 
-# This function is called at the very beginning before any other
-# function for a specific context.
-#
-# This just gives some examples of things you might want to do here.
-#
-#
-# If you use the vared builtin and want completion in there to act the 
-# way completion on the right hand side of assignments is done, add
-# (or un-comment) this code:
-#
-#     if [[ -n $compstate[vared] ]]; then
-#       if [[ $compstate[vared] = *\[* ]]; then
-#         # vared on an array-element
-#         compstate[parameter]=${compstate[vared]%%\[*}
-#         compstate[context]=value
-#       else
-#         # vared on a parameter, let's see if it is an array
-#         compstate[parameter]=$compstate[vared]
-#         if [[ ${(tP)compstate[vared]} = *(array|assoc)* ]]; then
-#           compstate[context]=array_value
-#         else
-#           compstate[context]=value
-#         fi
-#       fi
-#       return
-#     fi
-#
-#
-#
-# Other things you can do here is to complete different things if the
-# word on the line matches a certain pattern. This example allows
-# completion of words from the history by adding two commas at the end 
-# and hitting TAB.
-#
-#     if [[ "$PREFIX" = *,, ]]; then
-#       local max i=1
-#     
-#       PREFIX="$PREFIX[1,-2]"
-#       # If a numeric prefix is given, we use it as the number of
-#       # lines (multiplied by ten below) in the history to search.
-#       if [[ ${NUMERIC:-1} -gt 1 ]]; then
-#         max=$NUMERIC
-#         unset NUMERIC
-#       else
-#         # The default is to search the last 100 lines.
-#         max=10
-#       fi
-#       # We first search in the last ten lines, then in the last
-#       # twenty lines, and so on...
-#       while [[ i -le max ]]; do
-#         if compgen -X "%Bhistory ($n):%b" -Q -H $(( i*10 )) ''; then
-#           # We have found at least one matching word, so we switch
-#           # on menu-completion and make sure that no other
-#           # completion function is called by setting _comp_skip.
-#           compstate[insert]=menu
-#           _comp_skip=1
-#           return
-#         fi
-#         (( i++ ))
-#       done
-#     fi
+if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
+  if [[ "$RBUFFER" = \]* ]]; then
+    compadd -S '' - "${(@kP)${compstate[parameter]}}"
+  else
+    compadd -S ']' - "${(@kP)${compstate[parameter]}}"
+  fi
+else
+  _compalso -math-
+fi
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript
index 66d88b00c..00b2b6506 100644
--- a/Completion/Base/_subscript
+++ b/Completion/Base/_subscript
@@ -13,15 +13,15 @@ elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
   list=()
   for i in "$ind[@]"; do
     [[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
-        list=( "$list[@]" 
-	  "${(r:4:: ::):)i} $(print -D ${(P)${compstate[parameter]}[$i]})" )
+        list=( "$list[@]" "${(r:4:: ::):)i} ${(P)${compstate[parameter]}[$i]}
+)
   done
 
-  if [[ "$RBUFFER" = \]* ]]; then
-    compadd -S '' -V default -y list - "$ind[@]"
-  else
-    compadd -S ']' -V default -y list - "$ind[@]"
-  fi
+ if [[ "$RBUFFER" = \]* ]]; then
+   compadd -S '' -y list - "$ind[@]"
+ else
+   compadd -S ']' -y list - "$ind[@]"
+ fi
 else
   _compalso -math-
 fi