From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19179 invoked from network); 27 Apr 2001 09:04:00 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Apr 2001 09:04:00 -0000 Received: (qmail 8272 invoked by alias); 27 Apr 2001 09:03:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14133 Received: (qmail 8259 invoked from network); 27 Apr 2001 09:03:54 -0000 From: Sven Wischnowsky Date: Fri, 27 Apr 2001 11:03:45 +0200 (MET DST) Message-Id: <200104270903.LAA05634@beta.informatik.hu-berlin.de> To: zsh-workers@sunsite.dk Subject: Re: Another keep-prefix problem In-Reply-To: <3AE83054.3BE06044@u.genie.co.uk> Oliver Kiddle wrote: > ... > > To test I did: > c1=/home > c3=cvs > Now, > cd $c1/kiddleo/$c3/ expands both $c1 and $c3 which I don't want. > Having typed the / after $c3, I expect it to complete subdirectories > in my ~/cvs and not do expansion. As has already been said, this has to do with the suffix style (or should have to do with it). The patch below changes the test for that. Like Bart, I'm not exactly sure how the test should look like (for a really good test we would need more complicated code than can be expressed by a simple pattern). So there may be no better way than to commit the thing below and to invite everyone interested to play with the code and commit improvements (if we find more than one interesting setting, we can always add special values to select them to the suffix style). > Okay, so I tried setting keep-prefix to 1 and things start working nicely. > Except what is going on here (where I mix globs with variables): > cd /home/kiddle?/$c3/ results in: > cd /home/kiddle?/$c3//home/kiddleo/cvs/ > this definitely isn't right. That was caused by _path_files which found the $-expression, remembered everything up to and including it and later was unable to properly replace the prefixes of the generated pathnames with the original prefix. I don't see how we can solve that, so I've at least changed _path_files so that it doesn't complete anything in such cases. > So in what situations is the changed value of keep-prefix useful for? > It sounds something like subst-globs-only from the docs. I can't > remember why I used it and not a value of 1. It is slightly comparable to what s-g-o does and it also has to do (a bit) with what suffix does. And it's probably most useful for people who know what it does (although I think I hoped that it gives a quite natural behaviour, actually reducing the number of surprises for users). When thinking only aboyt expansion, I though that people would probably want the parameter substitution in `$foo/pat*' to be left alone. But if a user does that on `$foo/' or `~foo/', with other styles set up so that the keep-prefix style is tested for it at all, he probably wants the thing expanded. > Actually, talking of the docs for styles, the section on tag-order is > messed up and seems to have the same example twice. I've removed one of the places where that example was given. Bye Sven Index: Completion/Base/Completer/_expand =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v retrieving revision 1.2 diff -u -r1.2 _expand --- Completion/Base/Completer/_expand 2001/04/26 07:02:49 1.2 +++ Completion/Base/Completer/_expand 2001/04/27 09:03:14 @@ -28,8 +28,13 @@ ( "$word" = *\$[a-zA-Z0-9_]## && $+parameters[${word##*\$}] -eq 0 ) ]] && return 1 +### I'm not sure about the pattern to use in the following test. +# It once was: +# [[ "$word" = (\~*/|\$(|[=~#^+])[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]|\$\{*\}?)[^\$\{\}\(\)\<\>?^*#~]# ]] && + zstyle -T ":completion:${curcontext}:" suffix && - [[ "$word" = (\~*/|\$(|[=~#^+])[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]|\$\{*\}?)[^\$\{\}\(\)\<\>?^*#~]# ]] && + [[ "$word" = (\~*/|*\$(|[=~#^+])[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]|*\$\{*\}?) && + "${(e)word}" != *[][^~*?\<\>\{\}\|]* ]] && return 1 zstyle -t ":completion:${curcontext}:" accept-exact || Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v retrieving revision 1.3 diff -u -r1.3 _path_files --- Completion/Unix/Type/_path_files 2001/04/18 16:02:52 1.3 +++ Completion/Unix/Type/_path_files 2001/04/27 09:03:14 @@ -190,7 +190,7 @@ # Now let's have a closer look at the string to complete. -if [[ "$pre" = *(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \' ]]; then +if [[ "$pre" = [^][*?#^\|\<\>]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \' ]]; then # If there is a parameter expansion in the word from the line, we try # to complete the beast by expanding the prefix and completing anything Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.120 diff -u -r1.120 compsys.yo --- Doc/Zsh/compsys.yo 2001/04/26 14:40:11 1.120 +++ Doc/Zsh/compsys.yo 2001/04/27 09:03:17 @@ -1949,7 +1949,7 @@ kindex(suffix, completion style) item(tt(suffix))( This is used by the tt(_expand) completer if the word starts with a -tilde or parameter expansion. If it is set to `true', the word will +tilde or contains a parameter expansion. If it is set to `true', the word will only be expanded if it doesn't have a suffix, i.e. if it is something like `tt(~foo)' or `tt($foo)', but not if it is `tt(~foo/)' or `tt($foo/bar)', unless that suffix itself contains characters eligible @@ -2001,18 +2001,8 @@ var(label) starts with a hyphen, the var(tag) is prepended to the var(label) to form the name used for lookup. This can be used to make the completion system try a certain tag more than once, -supplying different style settings for each attempt. For example, - -example(zstyle ':completion:*:*:-command-:*' \ - tag-order 'functions:-non-comp' -zstyle ':completion:*:functions-non-comp' \ - ignored-patterns '_*') - -This makes completion in command position first try only names of shell -functions that don't match the pattern `tt(_*)'. If that generates no -matches, the default of trying all the other things that can be -completed in command position is used, including the names of all -shell functions. +supplying different style settings for each attempt, see below for an +example. The var(label) may optionally be followed by a second colon and a description. This description will then be used for the `tt(%d)' in -- Sven Wischnowsky wischnow@informatik.hu-berlin.de