From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18657 invoked from network); 19 Sep 2000 02:10:18 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 19 Sep 2000 02:10:18 -0000 Received: (qmail 29327 invoked by alias); 19 Sep 2000 02:09:24 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3441 Received: (qmail 29318 invoked from network); 19 Sep 2000 02:09:22 -0000 From: "Bart Schaefer" Message-Id: <1000919020251.ZM30124@candle.brasslantern.com> Date: Tue, 19 Sep 2000 02:02:50 +0000 In-Reply-To: <000401c0219b$6fc3e310$21c9ca95@mow.siemens.ru> Comments: In reply to "Andrej Borsenkow" "RE: completion with globbing, take 2" (Sep 18, 10:08pm) References: <000401c0219b$6fc3e310$21c9ca95@mow.siemens.ru> X-Mailer: Z-Mail (5.0.0 30July97) To: "Andrej Borsenkow" , Subject: Re: completion with globbing, take 2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 18, 10:08pm, Andrej Borsenkow wrote: } Subject: RE: completion with globbing, take 2 } } > Not quite; he's written a stripped-down version of "_expand with the } > completions style defaulted to true, followed by _match". } } I tentatively disagree. The main difference between _expand and } _match is who generates matches. Completion aside, _expand generates } "matches" (that are actually expansions in this case) itself. Not when the completions style is set. Then it assigns compstate[insert] and returns, leaving it to the following completers to generate matches. } _match takes all possible completions and tries to match them against } given pattern. See the difference? Yes, but ... _match doesn't "take" anything; it, too, calls _complete, maybe more than once, with different values of compstate[pattern_match]. Try this in zsh -f: zstyle ':completion:*' completer _expand _match zstyle ':completion:*' completions true autoload -U compinit ; compinit -D and then look at a trace from ^X?. The only interesting things that happen before _complete is called are assignments to compstate[insert] and compstate[pattern_match], exactly as in Jay's little function. } To write stripped-down version of _expand means [...] I didn't say "stripped-down version of _expand", I said "stripped-down version of _expand with the completions style defaulted to true", which takes a completely different code branch. } As I wrote, it is just a coincidence that file completion is using the same } pattern from command line, hence _expand and _match look alike. I'd mostly agree with you if _match were replaced by _complete in the style above. } BTW thank you all for finally making it clear to me :-))) It's getting a lot clearer to me, too ... } > The most obvious thing would be to have _match itself recognize the } > completions style. } } Is is not enough. See later. Not enough for what? } O.K. about adding completions style to _match. Note, that if } completions style is set for _expand it just calls _complete. No. If the completions style is set for _expand it doesn't call anything. It only calls _complete in the expand-word:* context; we're talking about the :completion:* context. } If no matches were generated, it does it itself and now has full } control over possible tags. No, it always returns without doing anything itself when the completions style is set. expand-word:* just determines whether it returns success, otherwise it always returns failure. } But what we actually need, is to get completions that _complete just } generated No, we just need to call complete and let it generate things, just like _match always does. We just have to tell _complete to insert everything that it generates. Try the following patch with zstyle ':completion:*' completer _match zstyle ':completion:*' completions true bindkey '\t' complete-word (Arguably "completions" is not the best name for this style as it's used here, but for purposes of example ...) Index: Completion/Core/_match =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Completion/Core/_match,v retrieving revision 1.14 diff -c -r1.14 _match --- Completion/Core/_match 2000/04/11 15:07:44 1.14 +++ Completion/Core/_match 2000/09/19 01:58:57 @@ -20,6 +20,7 @@ zstyle -s ":completion:${curcontext}:" match-original orig zstyle -b ":completion:${curcontext}:" insert-unambiguous ins +zstyle -t ":completion:${curcontext}:" completions && compstate[insert]=all # Try completion without inserting a `*'? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net