From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11918 invoked from network); 8 May 2000 08:43:23 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 May 2000 08:43:23 -0000 Received: (qmail 27912 invoked by alias); 8 May 2000 08:43:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11244 Received: (qmail 27896 invoked from network); 8 May 2000 08:43:07 -0000 Date: Mon, 8 May 2000 10:42:59 +0200 (MET DST) Message-Id: <200005080842.KAA12390@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Fri, 5 May 2000 14:46:44 +0000 Subject: PATCH: Re: Expand only completions, complete only uncompleted completions Bart Schaefer wrote: > This is after applying patches up to 11195 (but not 11194, yet). > > zagzig[116] cvs add _l* > zagzig[116] cvs add _lzop > Completing file > _lzop _look > > > Hmm, what I wanted was for `_l*' to expand to exactly `_lzop _look'. But > then I remember that I don't have the `completions' style set. So I try > again, just to see if I can make it do what I wanted: > > zagzig[116] cvs add _l* > zagzig[116] cvs add _look _lp _lynx _lzop > Completing all expansions > _look _lp _lynx _lzop > Completing expansions > _look _lp _lynx _lzop > Completing original > _l* > > Is this the expected behavior? Shouldn't _expand_word use the completion > context to eliminate _lp and _lynx? Not unless you set the completions style. Without that it just works like expansion always worked (in terms of generating words). However, there was a problem I didn't realise before. With completions set _expand just returned with a value of one to make the following completers be called. But with _expand_word there aren't any following completers... So the patch makes _expand call _complete when called from _expand_word. > On a slightly different topic: > > zagzig[117] cvs add _lzop _l > Completing file > _lzop _look > > No, I don't need _lzop any more, it's already there. I've seen Akira's reply, fixing this for _cvs. But... this is a much more general problem and has been annoying me for ages. Only now that I thought about it again had I the idea that with the mechanism behind ignored-patterns in place, we can easily solve this. So, the patch also adds the ignore-line style (there may be better names) which is tested for tags used for generating matches. If it is true, then the words from the line will be ignored. Note the comment in the manual about setting it for very non-specific contexts. Very handy for things like diff, mv, etc. Bye Sven Index: Completion/Builtins/_zstyle =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_zstyle,v retrieving revision 1.10 diff -u -r1.10 _zstyle --- Completion/Builtins/_zstyle 2000/05/08 08:16:32 1.10 +++ Completion/Builtins/_zstyle 2000/05/08 08:41:48 @@ -36,6 +36,7 @@ hosts c:_hosts hosts-ports c:host-port users-hosts-ports c:user-host-port + ignore-line c:bool ignore-parents c:ignorepar ignored-patterns c: insert-ids c:insert-ids Index: Completion/Core/_description =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/_description,v retrieving revision 1.3 diff -u -r1.3 _description --- Completion/Core/_description 2000/04/17 08:04:42 1.3 +++ Completion/Core/_description 2000/05/08 08:41:48 @@ -29,9 +29,16 @@ opts=($opts -M "${(q)match}") [[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}") -if [[ -z "$_comp_no_ignore" ]] && - zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then - opts=( $opts -F _comp_ignore ) +if [[ -z "$_comp_no_ignore" ]]; then + if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then + opts=( $opts -F _comp_ignore ) + zstyle -t ":completion:${curcontext}:$1" ignore-line && + _comp_ignore=( "$_comp_ignore[@]" "$words[@]}" ) + elif zstyle -t ":completion:${curcontext}:$1" ignore-line; then + _comp_ignore=( "$words[@]}]" ) + else + _comp_ignore=() + fi else _comp_ignore=() fi Index: Completion/Core/_expand =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v retrieving revision 1.9 diff -u -r1.9 _expand --- Completion/Core/_expand 2000/05/08 08:16:32 1.9 +++ Completion/Core/_expand 2000/05/08 08:41:48 @@ -30,6 +30,7 @@ { zstyle -s ":completion:${curcontext}:" completions expr && [[ "${(e):-\$[$expr]}" -eq 1 ]] }; then compstate[insert]=all + [[ "$curcontext" = expand-word:* ]] && _complete && return 0 return 1 fi Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.36 diff -u -r1.36 compsys.yo --- Doc/Zsh/compsys.yo 2000/05/08 08:16:33 1.36 +++ Doc/Zsh/compsys.yo 2000/05/08 08:41:50 @@ -1175,6 +1175,17 @@ example, the hostname is already typed, only those ports will be completed for which pairs with the hostname from the line exist. ) +kindex(ignore-line, completion style) +item(tt(ignore-line))( +This style is tested for the tags used when generating matches. If it +is set to `true', then none of the words that are already on the line +will be considered possible completions. + +Note that you almost certainly don't want to set this for a general +context such as `tt(:completion:*)'. This because it would disallow +completion of, for example, options multiple times even if the command +in question accepts the option more than once. +) kindex(ignore-parents, completion style) item(tt(ignore-parents))( The style is tested for the tt(files) tag to determine whether to ignore -- Sven Wischnowsky wischnow@informatik.hu-berlin.de