From 993db7cf0267b4d9c7f8faaa40af8948ba26a2e2 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 23 Mar 2000 23:59:08 +0000 Subject: zsh-workers/10210 --- Completion/Commands/_next_tags | 62 ++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'Completion/Commands') 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 } -- cgit 1.4.1