From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 992 invoked from network); 26 Aug 1998 10:20:56 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 26 Aug 1998 10:20:56 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id GAA02057; Wed, 26 Aug 1998 06:10:23 -0400 (EDT) Resent-Date: Wed, 26 Aug 1998 06:10:18 -0400 (EDT) Sender: B.Stephens@isode.com To: zsh-users@math.gatech.edu Subject: Re: Completion for gtar References: <980825104831.ZM15886@candle.brasslantern.com> Mime-Version: 1.0 (generated by tm-edit 7.108) Content-Type: text/plain; charset=US-ASCII From: Bruce Stephens Date: 26 Aug 1998 11:12:31 +0100 In-Reply-To: "Bart Schaefer"'s message of "Tue, 25 Aug 1998 10:48:31 -0700" Message-ID: X-Mailer: Gnus v5.6.27/XEmacs 20.4 - "Emerald" Resent-Message-ID: <"6t2bu1.0.bV.Ayzur"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1757 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu "Bart Schaefer" writes: > Have you looked at PWS's tar completion in Misc/compctl-examples in > 3.1.4? It even has a function to extract completable file names > from the tar file. No, I hadn't. Partly deliberately---this was as much an exercise as anything. Now I look at it, and the two look reassuringly similar, although PWS's provides more. > You can just do > > compctl -f -x 'p[1]' -k taropts -- gtar > > unless you want to unset taropts and not have it hanging around. Yes. Or rather, I didn't want to rely on taropts sticking around. > I don't think that means what you think it means. If you put the "-" > in the list of -g patterns, then it's treated as a file name. It just > so happens that, because it has no wildcards, it never gets dropped > from the list of completions. So you'll find that you can complete > e.g. like this: > > zsh% gtar zxf ~/ > zsh% gtar zxf ~/- > > even when there's no file named "-" in your home dir. That's clearly not what I want. You're right, there's no advantage in having - complete to itself, so I ought to remove it. > compctl -f -x 'p[1]' -k taropts \ > - 'p[2] W[1,*z*]' -/g '*.tar.(gz|Z)' -k '(-)' \ > -- gtar > > BTW, don't you want to add W[1,*f*] to that? You don't want to complete > file names if there's no "f" option. I don't care about not having the f option---I never use gtar except on files. (Backups and so on are done differently, and by somebody else.) > That is what alternation is about, but alternation works differently. > The -x branches are short-circuited on whether their patterns match, so > once you take a -x branch you can never see completions from any of the > other branches, even if no completions result from the branch where the > patterns matched. > > Alternation with "+", on the other hand, short-circuits on whether the > list of possible completions is empty, so it'll keep trying until it > runs out of alternatives or finds one that produces something. OK. I don't think this is clear from the documentation. Not as clear as the two paragraphs you've just given, anyway.