diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Commands/_next_tags | 62 | ||||
-rw-r--r-- | Completion/Core/_main_complete | 17 | ||||
-rw-r--r-- | Completion/Core/compinit | 3 |
3 files changed, 44 insertions, 38 deletions
diff --git a/Completion/Commands/_next_tags b/Completion/Commands/_next_tags index 818b73fe0..028ba4d61 100644 --- a/Completion/Commands/_next_tags +++ b/Completion/Commands/_next_tags @@ -1,49 +1,45 @@ -#autoload +#compdef -k complete-word \C-xn -# To use this, put _next_tags at the beginning of the completer style, -# define it as a completion widget and bind it to a key, e.g.: -# -# zle -C _next_tags complete-word _next_tags -# bindkey '^Xn' _next_tags -# -# Makes it be bound to ^Xn. - - -# Main widget/completer. +# Main widget. _next_tags() { + local comp - if [[ $#funcstack -gt 1 ]]; then + if [[ -z $compstate[old_list] ]]; then + comp=() + else + comp=(_complete) + fi - # Called as completer, probably `remove' our helper function. A better - # test would be nice, but I think one should still be able to edit the - # current word between attempts to complete it. + (( $+_sort_tags )) || _next_tags_not= - [[ $_next_tags_pre != ${LBUFFER%${PREFIX}} ]] && unset _sort_tags + _sort_tags=_next_tags_sort + _next_tags_pre="${LBUFFER%${PREFIX}}" + _next_tags_not="$_next_tags_not $_lastcomp[tags]" - return 1 - else - local comp + _main_complete "$comp[@]" - if [[ -z $compstate[old_list] ]]; then - comp=() - else - comp=(_next_tags _complete) - fi + [[ $compstate[insert] = automenu ]] && + compstate[insert]=automenu-unambiguous - (( $+_sort_tags )) || _next_tags_not= + compstate[insert]='' + compstate[list]='list force' - _sort_tags=_next_tags_sort - _next_tags_pre="${LBUFFER%${PREFIX}}" - _next_tags_not="$_next_tags_not $_lastcomp[tags]" + compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) +} - _main_complete "$comp[@]" +# Pre-completion function. - [[ $compstate[insert] = automenu ]] && - compstate[insert]=automenu-unambiguous +_next_tags_pre() { - compstate[insert]='' - compstate[list]='list force' + # Probably `remove' our sort function. A better test would be nice, but + # I think one should still be able to edit the current word between + # attempts to complete it. + + if [[ $_next_tags_pre != ${LBUFFER%${PREFIX}} ]]; then + unset _sort_tags + else + compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) fi } diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index fedea9b51..244f06b7e 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -19,7 +19,7 @@ setopt localoptions nullglob rcexpandparam extendedglob unsetopt markdirs globsubst shwordsplit nounset ksharrays -local ctxt post ret=1 tmp _compskip format _comp_ignore \ +local ctxt func funcs ret=1 tmp _compskip format _comp_ignore \ _completers _completer _completer_num curtag \ _matchers _matcher _matcher_num _comp_tags \ context state line opt_args val_args curcontext="$curcontext" \ @@ -68,6 +68,14 @@ _last_menu_style=() _completers=( "$@" ) _completer_num=1 +# Call the pre-functions. + +funcs=( "$compprefuncs[@]" ) +compprefuncs=() +for func in "$funcs[@]"; do + "$func" +done + for _completer; do ctxt=":completion:${curcontext/::/:${_completer[2,-1]}-${(M)#_completers[1,_completer_num]:#$_completer}:}:" @@ -190,10 +198,11 @@ fi # Now call the post-functions. -for post in "$comppostfuncs[@]"; do - "$post" -done +funcs=( "$comppostfuncs[@]" ) comppostfuncs=() +for func in "$funcs[@]"; do + "$func" +done _lastcomp=( "${(@kv)compstate}" ) _lastcomp[completer]="$_completer" diff --git a/Completion/Core/compinit b/Completion/Core/compinit index a421c2d8d..014729e90 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -98,9 +98,10 @@ else _comp_dumpfile="${ZDOTDIR:-$HOME}/.zcompdump" fi -# This can hold names of functions that are to be called after all +# These can hold names of functions that are to be called before/after all # matches have been generated. +compprefuncs=() comppostfuncs=() # Loading it now ensures that the `funcstack' parameter is always correct. |