zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: Another keep-prefix problem
Date: Fri, 27 Apr 2001 11:03:45 +0200 (MET DST)	[thread overview]
Message-ID: <200104270903.LAA05634@beta.informatik.hu-berlin.de> (raw)
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/<tab> 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/<tab> 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*<TAB>' to be left alone. 
But if a user does that on `$foo/<TAB>' or `~foo/<TAB>', 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


  parent reply	other threads:[~2001-04-27  9:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-26 14:27 Oliver Kiddle
2001-04-26 15:43 ` Wayne Davison
2001-04-26 17:18   ` Bart Schaefer
2001-04-26 23:38     ` Wayne Davison
2001-04-27  9:03 ` Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-04-24  0:46 Wayne Davison
2001-04-24 16:50 ` Bart Schaefer
2001-04-24 19:18   ` Wayne Davison
2001-04-25 13:25     ` Sven Wischnowsky
2001-04-26  4:33       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200104270903.LAA05634@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).