summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Builtins/_arrays6
-rw-r--r--Completion/Builtins/_zstyle2
-rw-r--r--Completion/Commands/_bash_completions4
-rw-r--r--Completion/Commands/_history_complete_word49
-rw-r--r--Completion/Core/_history33
-rw-r--r--Completion/Core/_main_complete8
-rw-r--r--Completion/Core/_parameters8
-rw-r--r--Completion/Core/_setup12
-rw-r--r--Completion/Core/_tags14
-rw-r--r--Completion/Debian/_apt2
-rw-r--r--Completion/X/_x_extension2
11 files changed, 85 insertions, 55 deletions
diff --git a/Completion/Builtins/_arrays b/Completion/Builtins/_arrays
index cbeac7118..5ab6d41f0 100644
--- a/Completion/Builtins/_arrays
+++ b/Completion/Builtins/_arrays
@@ -1,3 +1,5 @@
-#defcomp shift
+#compdef shift
 
-complist -A
+local expl
+
+_wanted arrays expl array compadd -k "parameters[(R)*array*~*local*]"
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index 764afb5a1..fefa8af51 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -136,7 +136,7 @@ while [[ -n $state ]]; do
         ctop=cz
       fi
       _wanted styles expl style \
-         compadd -M 'r:|-=* r:|=*' - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]}
+         compadd -M 'r:|-=* r:|=*' -k "styles[(R)[^:]#[$ctop][^:]#:*]"
       ;;
       
     style-arg)
diff --git a/Completion/Commands/_bash_completions b/Completion/Commands/_bash_completions
index 50600290d..fd2222797 100644
--- a/Completion/Commands/_bash_completions
+++ b/Completion/Commands/_bash_completions
@@ -33,8 +33,8 @@ local key=$KEYS[-1] expl
 case $key in
   '!') _main_complete _command_names
        ;;
-  '$') _main_complete - _wanted parameters expl 'exported parameters' \
-                            compadd - "${(@k)parameters[(R)*export*]}"
+  '$') _main_complete - parameters _wanted parameters expl 'exported parameters' \
+                                       compadd -k 'parameters[(R)*export*]'
        ;;
   '@') _main_complete _hosts
        ;;
diff --git a/Completion/Commands/_history_complete_word b/Completion/Commands/_history_complete_word
index 300100f59..01cd32fce 100644
--- a/Completion/Commands/_history_complete_word
+++ b/Completion/Commands/_history_complete_word
@@ -7,20 +7,26 @@
 #
 # Available styles:
 #
-#   :history-words:list -- display lists of available matches
-#   :history-words:stop -- prevent looping at beginning and end of matches
-#                          during menu-completion
-#   :history-words:sort -- sort matches lexically (default is to sort by age)
-#   :history-words:remove-all-dups --
-#                          remove /all/ duplicate matches rather than just
-#                          consecutives
-#
+#   list --  display lists of available matches
+#   stop --  prevent looping at beginning and end of matches during
+#            menu-completion
+#   sort --  sort matches lexically (default is to sort by age)
+#   remove-all-dups --
+#            remove /all/ duplicate matches rather than just consecutives
+#   range -- range of history words to complete
 
 _history_complete_word () {
   setopt localoptions nullglob rcexpandparam extendedglob
   unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
-  local expl direction stop
+  local expl direction stop curcontext="$curcontext"
+  local max slice hmax=$#historywords
+
+  if [[ -z "$curcontext" ]]; then
+    curcontext=history-words:::
+  else
+    curcontext="history-words${curcontext#*:}"
+  fi
 
   if [[ $WIDGET = *newer ]]; then
     direction=newer
@@ -32,6 +38,19 @@ _history_complete_word () {
 
   zstyle -t ":completion:${curcontext}:history-words" list || compstate[list]=''
 
+  if zstyle -s ":completion:${curcontext}:history-words" range max; then
+    if [[ $max = *:* ]]; then
+      slice=${max#*:}
+      max=${max%:*}
+    else
+      slice=$max
+    fi
+    [[ max -gt hmax ]] && max=$hmax
+  else
+    max=$hmax
+    slice=$max
+  fi
+
   if [[ -n "$compstate[old_list]" &&
         ( -n "$stop" || "$compstate[insert]" = menu ) ]] ; then
     # array of matches is newest -> oldest (reverse of history order)
@@ -66,11 +85,11 @@ _history_complete_word () {
     _history_complete_word_gen_matches
   fi
 
-  [[ -n "$compstate[nmatches]" ]]
+  (( $compstate[nmatches] ))
 }
 
 _history_complete_word_gen_matches () {
-  local opt h_words
+  local opt beg=2
 
   [[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
 
@@ -90,9 +109,11 @@ _history_complete_word_gen_matches () {
   SUFFIX="$SUFFIX$ISUFFIX"
   ISUFFIX=
 
-  h_words=( "${(@)historywords[2,-1]}" )
-  _wanted "$opt" history-words expl 'history word' \
-      compadd -Q -a h_words
+  while [[ $compstate[nmatches] -eq 0 && beg -lt max ]]; do
+    _main_complete - history _wanted "$opt" history-words expl 'history word' \
+                                 compadd -Q -a 'historywords[beg,beg+slice]'
+    (( beg+=slice ))
+  done
 
   zstyle -t ":completion:${curcontext}:history-words" list ||
       compstate[list]=
diff --git a/Completion/Core/_history b/Completion/Core/_history
index 109bda91f..dafd61407 100644
--- a/Completion/Core/_history
+++ b/Completion/Core/_history
@@ -11,12 +11,12 @@
 #
 # Available styles:
 #
-#   :history-words:sort -- sort matches lexically (default is to sort by age)
-#   :history-words:remove-all-dups --
-#                          remove /all/ duplicate matches rather than just
-#                          consecutives
+#   sort --  sort matches lexically (default is to sort by age)
+#   remove-all-dups --
+#            remove /all/ duplicate matches rather than just consecutives
+#   range -- range of history words to complete
 
-local opt expl h_words
+local opt expl max slice hmax=$#historywords beg=2
 
 if zstyle -t ":completion:${curcontext}:" remove-all-dups; then
   opt=-
@@ -30,6 +30,19 @@ else
   opt="${opt}V"
 fi
 
+if zstyle -s ":completion:${curcontext}:" range max; then
+  if [[ $max = *:* ]]; then
+    slice=${max#*:}
+    max=${max%:*}
+  else
+    slice=$max
+  fi
+  [[ max -gt hmax ]] && max=$hmax
+else
+  max=$hmax
+  slice=$max
+fi
+
 PREFIX="$IPREFIX$PREFIX"
 IPREFIX=
 SUFFIX="$SUFFIX$ISUFFIX"
@@ -37,5 +50,11 @@ ISUFFIX=
 
 # We skip the first element of historywords so the current word doesn't
 # interfere with the completion
-h_words=( "${(@)historywords[2,-1]}" )
-_wanted "$opt" history-words expl 'history word' compadd -Q -a h_words
+
+while [[ $compstate[nmatches] -eq 0 && beg -lt max ]]; do
+  _wanted "$opt" history-words expl 'history word' \
+      compadd -Q -a 'historywords[beg,beg+slice]'
+  (( beg+=slice ))
+done
+
+(( $compstate[namtches] ))
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index b0798f67d..f238c88ac 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -34,7 +34,7 @@ local func funcs ret=1 tmp _compskip format nm call match \
       _saved_insert="${compstate[insert]}" \
       _saved_colors="$ZLS_COLORS"
 
-typeset -U _lastdescr _comp_ignore
+typeset -U _lastdescr _comp_ignore _comp_colors
 
 [[ -z "$curcontext" ]] && curcontext=:::
 
@@ -263,7 +263,11 @@ fi
    ( "$_comp_force_list" = ?*  && nm -ge _comp_force_list ) ]] &&
     compstate[list]="${compstate[list]//messages} force"
 
-[[ "$compstate[old_list]" = keep ]] && ZLS_COLORS="$_saved_colors"
+if [[ "$compstate[old_list]" = keep ]]; then
+  ZLS_COLORS="$_saved_colors"
+else
+  ZLS_COLORS="${(j.:.)_comp_colors}"
+fi
 
 # Now call the post-functions.
 
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters
index 0e8c548f7..d3a163b49 100644
--- a/Completion/Core/_parameters
+++ b/Completion/Core/_parameters
@@ -1,8 +1,8 @@
 #autoload
 
 # This should be used to complete parameter names if you need some of the
-# extra options of compadd. It first tries to complete only non-local
-# parameters. All arguments are given to compadd.
+# extra options of compadd. It completes only non-local parameters.
 
-compadd "$@" - "${(@)${(@)${(@)${(@f)$(typeset)}:#*local *\=*}%%\=*}##* }" ||
-    compadd "$@" - "${(@)${(@)${(@f)$(typeset)}%%\=*}##* }"
+local expl
+
+_wanted parameters expl parameter compadd "$@" -k 'parameters[(R)^*local*]'
diff --git a/Completion/Core/_setup b/Completion/Core/_setup
index 50e3dbfd8..1278fa1ba 100644
--- a/Completion/Core/_setup
+++ b/Completion/Core/_setup
@@ -7,16 +7,10 @@ local val nm="$compstate[nmatches]"
 if zstyle -a ":completion:${curcontext}:$1" list-colors val; then
   zmodload -i zsh/complist
   if [[ "$1" = default ]]; then
-    ZLS_COLORS="${(j.:.)${(@)val:gs/:/\\\:}}"
+    _comp_colors=( "$val[@]" )
   else
-    local simple grouped
-
-    simple=( "(${2})${(@)^val:#\(*\)*}" )
-    grouped=( "${(M@)val:#\(*\)*}" )
-    simple="${(j.:.)simple}:"
-    grouped="${(j.:.)grouped}:"
-    [[ "$ZLS_COLORS" != *${simple}*  ]] && ZLS_COLORS="${simple}$ZLS_COLORS"
-    [[ "$ZLS_COLORS" != *${grouped}* ]] && ZLS_COLORS="${grouped}$ZLS_COLORS"
+    _comp_colors=( "$_comp_colors[@]"
+                   "(${2})${(@)^val:#\(*\)*}" "${(M@)val:#\(*\)*}" )
   fi
 
 # Here is the problem mentioned in _main_complete.
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index c98990cec..5a1015356 100644
--- a/Completion/Core/_tags
+++ b/Completion/Core/_tags
@@ -30,18 +30,8 @@ if (( $# )); then
 
   [[ "$1" = -(|-) ]] && shift
 
-  if zstyle -a ":completion:${curcontext}:" group-order order; then
-    local name
-
-    for name in "$order[@]"; do
-      compadd -J "$name"
-      compadd -V "$name"
-      compadd -J "$name" -1
-      compadd -V "$name" -1
-      compadd -J "$name" -2
-      compadd -V "$name" -2
-    done
-  fi
+  zstyle -a ":completion:${curcontext}:" group-order order &&
+      compgroups "$order[@]"
 
   # Set and remember offered tags.
 
diff --git a/Completion/Debian/_apt b/Completion/Debian/_apt
index 8fa056594..cfc6880df 100644
--- a/Completion/Debian/_apt
+++ b/Completion/Debian/_apt
@@ -469,7 +469,7 @@ _apt-config () {
     -- \
     /$'shell\0'/ \
       \( \
-	/$'[^\0]#\0'/ ':parameters:shell variable to assign:compadd "$expl[@]" - "${(@k)parameters}"' \
+	/$'[^\0]#\0'/ ':parameters:shell variable to assign:_parameters' \
 	/$'[^\0]#\0'/ ':values:configuration key:compadd "$expl[@]" - ${${(f)"$(apt-config dump 2>&1)"}% *}' \
       \) \# \| \
     /$'dump\0'/ \| \
diff --git a/Completion/X/_x_extension b/Completion/X/_x_extension
index 690226975..d1a299e8b 100644
--- a/Completion/X/_x_extension
+++ b/Completion/X/_x_extension
@@ -15,5 +15,5 @@ else
   [[ "$1" = - ]] && shift
 
   _wanted extensions expl 'X extensions' \
-      compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - _xe_cache
+      compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' -a _xe_cache
 fi