From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15539 invoked from network); 21 Feb 2000 09:28:34 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Feb 2000 09:28:34 -0000 Received: (qmail 29313 invoked by alias); 21 Feb 2000 09:28:20 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9807 Received: (qmail 29306 invoked from network); 21 Feb 2000 09:28:19 -0000 Date: Mon, 21 Feb 2000 10:28:18 +0100 (MET) Message-Id: <200002210928.KAA05450@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Tanaka Akira's message of 20 Feb 2000 21:17:28 +0900 Subject: Re: PATCH: Re: completion after ../ Tanaka Akira wrote: > In article <200002180939.KAA30810@beta.informatik.hu-berlin.de>, > Sven Wischnowsky writes: > > > Or we name it `single-ignored' (yes, there must be a better name) and > > enhace it: if it's set to `show' we use the above. If it's set to > > `menu' we also add the string from the line in the alternate set (as > > usual, with -S '', in it's own group, with a call to _description and > > so on...) and start menu-completion (compstate[insert]=menu). > > I tried this. I inserted the following fragment just before line 83 > in _main_complete. > > if zstyle -s ":completion:${curcontext}:" single-ignored tmp && > [[ $compstate[old_list] != shown && > $compstate[nmatches] = 0 && > $compstate[alternate_nmatches] = 1 ]]; then > case "$tmp" in > show) compstate[insert]='' compstate[list]='list force';; > menu) compstate[insert]='menu';; > esac > tmp=false > [[ $tmp = menu ]] && tmp=true > else > tmp=false > fi > > if [[ $compstate[nmatches] -gt 1 ]] || $tmp; then > ... > > But I couldn't find the way to get the string from the alternate set. > So, it completes a word with a following space and the next > completes a next word. > > How can we get the string? I thought about something like the thing below, using the -a option to compadd to put the original in the alternate set. Note: no change to _zstyle and no doc, this is mostly Tanaka's code turned into a patch for everybodys convenience. Also, I'm not sure how to write that in the manual -- it's certainly one of the more obscure styles. Bye Sven diff -ru ../z.old/Completion/Core/_main_complete Completion/Core/_main_complete --- ../z.old/Completion/Core/_main_complete Fri Feb 18 15:42:41 2000 +++ Completion/Core/_main_complete Mon Feb 21 10:24:49 2000 @@ -19,7 +19,7 @@ setopt localoptions nullglob rcexpandparam extendedglob unsetopt markdirs globsubst shwordsplit nounset ksharrays -local comp post ret=1 _compskip format _comp_ignore \ +local comp post ret=1 tmp _compskip format _comp_ignore \ _completers _completer _completer_num \ _matchers _matcher _matcher_num \ context state line opt_args val_args curcontext="$curcontext" \ @@ -80,7 +80,24 @@ (( _completer_num++ )) done -if [[ $compstate[nmatches] -gt 1 ]]; then +if zstyle -s ":completion:${curcontext}:" single-ignored tmp && + [[ $compstate[old_list] != shown && + $compstate[nmatches] = 0 && + $compstate[alternate_nmatches] = 1 ]]; then + case "$tmp" in + show) compstate[insert]='' compstate[list]='list force' tmp='' ;; + menu) + local expl + + compstate[insert]='menu' + _description original expl original + compadd "$expl[@]" -a -S '' - "$PREFIX$SUFFIX" + ;; + *) tmp='' ;; + esac +fi + +if [[ -n "$tmp" || $compstate[nmatches] -gt 1 ]]; then [[ _last_nmatches -ge 0 && _last_nmatches -ne compstate[nmatches] ]] && _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" ) -- Sven Wischnowsky wischnow@informatik.hu-berlin.de