From 2018dc20a5e817afd37065c4cc23968bceed59a7 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Tue, 27 Apr 1999 17:36:17 +0000 Subject: zsh-workers:6118 --- Completion/Core/_oldlist | 29 +++++++++++++++++++++++++++++ Doc/Zsh/compsys.yo | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 Completion/Core/_oldlist diff --git a/Completion/Core/_oldlist b/Completion/Core/_oldlist new file mode 100644 index 000000000..9e791b3a5 --- /dev/null +++ b/Completion/Core/_oldlist @@ -0,0 +1,29 @@ +#autoload + +# If this is a listing widget and there is already an old list, +# and either the compconfig key oldlist_list is `always', or it is not `never' +# and the list is not already shown, then use the existing list for listing +# (even if it was generated by another widget). +if [[ -n $compstate[old_list] && $compconfig[oldlist_list] != never && + $WIDGET = *list* && + ( $compconfig[oldlist_list] = always || $compstate[old_list] != shown ) ]] +then + compstate[old_list]=keep + return 0 +fi + +# If this is a completion widget, and we have a completion inserted already, +# and the compconfig key oldlist_menu is not never, then we cycle through the +# existing list (even if it was generated by another widget). +if [[ -n $compstate[old_insert] && $WIDGET = *complete(|-prefix) && + $compconfig[oldlist_menu] != never ]]; then + compstate[old_list]=keep + if [[ $WIDGET = *reverse* ]]; then + compstate[insert]=$(( compstate[old_insert] - 1 )) + else + compstate[insert]=$(( compstate[old_insert] + 1 )) + fi + return 0 +fi + +return 1 diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 159f944c3..cedc4ec8c 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -528,6 +528,53 @@ tt(MENU_COMPLETE) option and does not work with the other menucompletion widgets such as tt(reverse-menu-complete), or tt(accept-and-menu-complete). ) +item(tt(_oldlist))( +This completer controls how the standard completion widgets behave when +there is an existing list of completions which may have been generated by a +special completion (i.e. a separately-bound completion command). It should +appear in the list of completers before any of the widgets which generate +matches. It understands two configuration keys: + +startitem() +item(tt(oldlist_list))( +If this is set to tt(always), then standard widgets which perform listing +will retain the current list of matches, however they were generated. If +it is set to tt(never), this will not be done (the behaviour without the +tt(_oldlist) completer). If it is unset, or any other value, then the +existing list of completions will be displayed if it is not already; +otherwise, the standard completion list will be generated: this is the +default behaviour of tt(_oldlist). + +For example, suppose you type tt(^Xc) to use the tt(_correct_word) +widget, which generates a list of corrections for the word under the +cursor. Usually, typing tt(^D) would generate a standard list of +completions for the word on the command line, and show that. With +tt(_oldlist), it will instead show the list of corrections already +generated. +) +item(tt(oldlist_menu))( +Controls how menu completion behaves when a completion has already been +inserted and the user types a standard completion key type as tt(TAB). +The default behaviour of tt(_oldlist) is that menu completion always +continues with the existing list of completions. If this key is set to +tt(never), however, a new completion is started if the old list was +generated by a different completion command (the behaviour without the +tt(_oldlist) completer). +For example, suppose you type tt(^Xc) to generate a list of corrections, +and menu completion is started in one of the usual ways. Usually, typing +tt(TAB) at this point would start trying to complete the line as it now +appears. With tt(_oldlist), it will instead continue to cycle through the +list of completions. +) +enditem() +) +item(tt(_closequotes))( +When a completion starts in quotes, this completer will recognise the fact +and insert a matching closing quote if there is not already one later on +the line. It should come earlier in the list of completers than any of the +completers which generate matches. It can be confused by some of the more +sophisticated forms of completion. +) enditem() texinode(Completion Functions)()(Control Functions)(Completion System) -- cgit 1.4.1