diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2001-04-02 11:07:11 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2001-04-02 11:07:11 +0000 |
commit | e4ca49fe01aca613209e5d25362d7e323c2eae24 (patch) | |
tree | f65fa26aee12aab2bdff242138af13a5f5d46c73 /Completion | |
parent | 2db1c53cb90d9f299f4a7636244d8024ed235ae7 (diff) | |
download | zsh-e4ca49fe01aca613209e5d25362d7e323c2eae24.tar.gz zsh-e4ca49fe01aca613209e5d25362d7e323c2eae24.tar.xz zsh-e4ca49fe01aca613209e5d25362d7e323c2eae24.zip |
moved from Completion/Core/_history
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Base/Completer/_history | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Completion/Base/Completer/_history b/Completion/Base/Completer/_history new file mode 100644 index 000000000..63878ac1c --- /dev/null +++ b/Completion/Base/Completer/_history @@ -0,0 +1,60 @@ +#autoload + +# Hm, this *can* sensibly be used as a completer. But it could also be used +# as a utility function, so maybe it should be moved into another directory. +# Or maybe not. Hm. +# +# +# Complete words from the history +# +# Code taken from _history_complete_words. +# +# Available styles: +# +# 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 max slice hmax=$#historywords beg=2 + +if zstyle -t ":completion:${curcontext}:" remove-all-dups; then + opt=- +else + opt=-1 +fi + +if zstyle -t ":completion:${curcontext}:" sort; then + opt="${opt}J" +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" +ISUFFIX= + +# We skip the first element of historywords so the current word doesn't +# interfere with the completion + +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[nmatches] )) |