about summary refs log tree commit diff
path: root/Completion/Core/_history
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-22 08:42:36 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-22 08:42:36 +0000
commitb9a533f3823c3b6d69fad80a21f573670856823f (patch)
treeeca8b47b9101c1060f41500f9fb23e679ec8f94f /Completion/Core/_history
parent44b34667f844ce57b5b2eba0f2870c1ec7630348 (diff)
downloadzsh-b9a533f3823c3b6d69fad80a21f573670856823f.tar.gz
zsh-b9a533f3823c3b6d69fad80a21f573670856823f.tar.xz
zsh-b9a533f3823c3b6d69fad80a21f573670856823f.zip
allow subscripts for compadd -[ak]; new style for history completion; better list-colors handling (12029)
Diffstat (limited to 'Completion/Core/_history')
-rw-r--r--Completion/Core/_history33
1 files changed, 26 insertions, 7 deletions
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] ))