From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2411 invoked from network); 8 Jul 1999 09:05:12 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 Jul 1999 09:05:12 -0000 Received: (qmail 18814 invoked by alias); 8 Jul 1999 09:05:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7026 Received: (qmail 18807 invoked from network); 8 Jul 1999 09:05:02 -0000 Date: Thu, 8 Jul 1999 11:04:54 +0200 (MET DST) Message-Id: <199907080904.LAA11932@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Andrej Borsenkow"'s message of Sat, 3 Jul 1999 16:41:29 +0400 Subject: PATCH: Re: General comments on completion Andrej Borsenkow wrote: > Is it possible to insert prefix but still do not exit the current completion > "session"? So, that the list that was generated first is used also for possible > menu completion? I tried _oldlist - but it does not seem to work (this is with > modified _match that always inserts prefix): This adds the assoc array _lastcomp which is used by _main_complete to store information about the last completion. Then I enhanced _oldlist a bit: the oldlist_list key may be set to the name of a completer function and if we encounter an old list generated by that completer, oldlist makes this list be used independent of the widget currently used. Maybe we should use a different config key for this -- if you are using _oldlist and find some strange behavior, tell me. With that one can set match_insert=unambig and oldlist_list=_match to get the behavior described by Andrej -- a list generated by _match will be re-used. Since I'm planning to give incremental-complete-word some more support in the future, I wanted to add some code to make information about the last completion globally available anyway and it may also become useful in other places, I think. Bye Sven diff -u -r oc/Core/_main_complete Completion/Core/_main_complete --- oc/Core/_main_complete Wed Jul 7 08:50:57 1999 +++ Completion/Core/_main_complete Thu Jul 8 09:52:42 1999 @@ -33,7 +33,7 @@ # state than the global one for which you are completing. -local comp +local comp ret=1 setopt localoptions nullglob rcexpandparam unsetopt markdirs globsubst shwordsplit nounset ksharrays @@ -54,5 +54,19 @@ # And now just call the completer functions defined. for comp; do - "$comp" && return + if "$comp"; then + ret=0 + break; + fi done + +_lastcomp=( "${(@kv)compstate}" ) +_lastcomp[completer]="$comp" +_lastcomp[prefix]="$PREFIX" +_lastcomp[suffix]="$SUFFIX" +_lastcomp[iprefix]="$IPREFIX" +_lastcomp[isuffix]="$ISUFFIX" +_lastcomp[qiprefix]="$QIPREFIX" +_lastcomp[qisuffix]="$QISUFFIX" + +return ret diff -u -r oc/Core/_match Completion/Core/_match --- oc/Core/_match Wed Jul 7 08:50:57 1999 +++ Completion/Core/_match Thu Jul 8 08:58:03 1999 @@ -60,7 +60,7 @@ compstate[pattern_match]="$opm" compstate[matcher]="$compstate[total_matchers]" -[[ ret -eq 0 && "$compconfig[match_insert]" = unambig* && +[[ ret -eq 1 && "$compconfig[match_insert]" = unambig* && $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && compstate[pattern_insert]=unambiguous diff -u -r oc/Core/_oldlist Completion/Core/_oldlist --- oc/Core/_oldlist Wed Jul 7 08:50:57 1999 +++ Completion/Core/_oldlist Thu Jul 8 09:02:18 1999 @@ -4,10 +4,13 @@ # 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). +# Do this also if there is an old list and it was generated by the +# completer named by the oldlist_list key. if [[ -n $compstate[old_list] && $compconfig[oldlist_list] != never && - $WIDGET = *list* && - ( $compconfig[oldlist_list] = always || $compstate[old_list] != shown ) ]] -then + ( ( $WIDGET = *list* && + ( $compconfig[oldlist_list] = always || + $compstate[old_list] != shown ) ) || + $compconfig[oldlist_list] = *${_lastcomp[completer]}* ) ]]; then compstate[old_list]=keep return 0 fi diff -u -r oc/Core/compinit Completion/Core/compinit --- oc/Core/compinit Wed Jul 7 08:50:58 1999 +++ Completion/Core/compinit Thu Jul 8 08:59:32 1999 @@ -73,6 +73,11 @@ typeset -gA _comps _patcomps=() +# The associative array use to report information about the last +# cmpletion to the outside. + +typeset -gA _lastcomp + # This is the associative array used for configuration. typeset -gA compconfig -- Sven Wischnowsky wischnow@informatik.hu-berlin.de