diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-06-22 08:42:36 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-06-22 08:42:36 +0000 |
commit | b9a533f3823c3b6d69fad80a21f573670856823f (patch) | |
tree | eca8b47b9101c1060f41500f9fb23e679ec8f94f /Completion/Commands | |
parent | 44b34667f844ce57b5b2eba0f2870c1ec7630348 (diff) | |
download | zsh-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/Commands')
-rw-r--r-- | Completion/Commands/_bash_completions | 4 | ||||
-rw-r--r-- | Completion/Commands/_history_complete_word | 49 |
2 files changed, 37 insertions, 16 deletions
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]= |