From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9024 invoked from network); 12 Mar 2000 13:02:44 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 12 Mar 2000 13:02:44 -0000 Received: (qmail 19302 invoked by alias); 12 Mar 2000 13:02:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10086 Received: (qmail 19290 invoked from network); 12 Mar 2000 13:02:34 -0000 Date: Sun, 12 Mar 2000 13:02:33 +0000 From: Adam Spiers To: zsh-workers@sunsite.auc.dk Subject: Re: _files vs _path_files discussion (old thread) Message-ID: <20000312130233.A4744@thelonious.new.ox.ac.uk> Reply-To: Adam Spiers Mail-Followup-To: zsh-workers@sunsite.auc.dk References: <20000311222225.A27795@thelonious.new.ox.ac.uk> <1000312001854.ZM26814@candle.brasslantern.com> <20000312005127.A28688@thelonious.new.ox.ac.uk> <1000312062134.ZM27047@candle.brasslantern.com> <1000312063459.ZM27076@candle.brasslantern.com> <199909170728.JAA01949@beta.informatik.hu-berlin.de> <20000311222225.A27795@thelonious.new.ox.ac.uk> <1000312001854.ZM26814@candle.brasslantern.com> <20000312005127.A28688@thelonious.new.ox.ac.uk> <1000312062134.ZM27047@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <1000312062134.ZM27047@candle.brasslantern.com>; from schaefer@candle.brasslantern.com on Sun, Mar 12, 2000 at 06:21:34AM +0000 X-Home-Page: http://www.new.ox.ac.uk/~adam/ X-OS: Linux 2.2.12 i686 Thanks for these explanations Bart, and apologies for missing the thread the first time round. Bart Schaefer (schaefer@candle.brasslantern.com) wrote: > So you also need e.g.: > > zstyle ':completion::complete:tar::directories' file-patterns '*(-/)' > > You can of course replace :tar:: there with :*:*: to make all commands > that use _files complete directories; but as Sven mentions in 9864, > you may not want that, which is why the file-patterns are required to > be given in the first place. I've settled on the following for now, and it doesn't seem to have any of the unwanted side-effects mentioned: # Include non-hidden directories in globbed file completions compstyle '::complete:*' \ tag-order 'globbed-files directories' all-files compstyle '::complete:*:*:directories' file-patterns '*~.*(-/)' It's almost perfect ... The only problem left is in the handling of hidden directories; ideally, I would want hidden directories only to appear when the leading `.' is specified manually, because I have so many hidden directories in my home directory that they swamp the initial completion list. However, because they are not covered by the file-patterns style for the directories tag, if I do: $ tar zxf .foodir/ it's presumably using all-files, which has the initial problem of not listing directories by default. So what I'm really after is something like: zstyle ':completion::complete:*:*:directories' \ file-patterns '*(-/)' zstyle ':completion::complete:*:*:unhidden-directories' \ file-patterns '*~.*(-/)' zstyle ':completion::complete:*' tag-order \ 'globbed-files unhidden-directories' \ 'globbed-files directories' \ all-files except that that doesn't work, presumably because you can't just dream up new tags like that, and maybe you can't even mention tags twice in tag-order. So, is there a solution, and if not, would it be totally unrealistic to allow something like the above zstyle code? Actually, even if that code worked, it still wouldn't quite do what I want, because at the `.foodir/' stage it would be completing from the 'globbed-files directories' bit (or would it?), which would mean that it would list `.foodir/.bardir', which I wouldn't want it to. Looks like what I'm asking for would require considering each path component separately. Urgh. Now my head's spinning. > [*] Sven's suggested change was: > } ... should we make the directories tag with its usual pattern be > } tried automatically if the user explicitly sets the file-patterns tag > } for globbed-files? Or should we do that only if the directories tag, > } file-patterns style is given, but allow an empty value to stand for > } `the normal pattern'? > > I meant to reply to that and hadn't got around to it yet. > > My short answer is that I don't think there's any good solution. The > tag-order style is going to be confusing no matter what we do; people > are always going to wonder why, when they can see "directories" in the > tag-order style, they still don't get any directories completed. It's > a case of intuition being at odds with logical semantics, and I can't > think of any way to make the intuition work without ruining the logic. > > Automatically adding directories when globbed-files is given only makes > things cloudier; allowing an empty pattern to stand for '*(-/)' doesn't > alleviate the need to provide the directories style, which is the real > basis of the confusion. So I think I'd leave the code as is, and put > some kind of blaring all-caps text in the tag-order documentation: > > NAMING A TAG IN TAG-ORDER DOES NOT CAUSE COMPLETIONS FOR THAT TAG TO BE > GENERATED; RATHER, IT SORTS THE COMPLETIONS AFTER THEY ARE GENERATED. I'd agree. Actually, now I know the stuff in blaring all-caps, I don't find it that confusing anyway. > One additional thought: It would be nice to be able to specify that > _paths_ are completed, rather than merely directories; i.e. like the > difference between "compctl -g '*(-/)'" and "compctl -/". I'm not > convinced that "zstyle *directories file-patterns '*(-/)'" does that. What is the difference? I can't see any, but I'm probably missing something (again). > Hrm, maybe even add "... BUT ONLY _IF_ ANY ARE GENERATED FOR THAT TAG." Good plan. Adam