Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: still confused about completion and matching
- X-seq: zsh-workers 13012
- From: "E. Jay Berkenbilt" <ejb@xxxxxx>
- To: wischnow@xxxxxxxxxxxxxxxxxxxxxxx
- Subject: Re: still confused about completion and matching
- Date: Tue, 17 Oct 2000 15:30:55 -0400
- Cc: zsh-workers@xxxxxxxxxxxxxx
- In-reply-to: <200010160805.KAA04037@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> (message from Sven Wischnowsky on Mon, 16 Oct 2000 10:05:17 +0200 (MET DST))
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <200010160805.KAA04037@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
This patch does help, but it there are several things about it that
don't quite work. I spent some time trying to debug it, but I really
don't have time today to spend on this. I'm quite under the gun on a
work-related deadline. I'll share what I have so far though.
Start zsh and run the following:
PS1='zsh%% '
setopt noautomenu
autoload -U compinit
compinit
bindkey "^I" complete-word
rm -rf /tmp/z
mkdir /tmp/z
cd /tmp/z
mkdir u{1,2,3,4,5}
mkdir u{1,2,3,4}/q
mkdir u5/q1
mkdir u1/q/e1
mkdir u2/q/e2
mkdir u2/q/e2/a{1,2}
zstyle ':completion:*' completer _complete _match
zstyle ':completion:*:match:*' insert-unambiguous pattern
zstyle ':completion:*:paths' list-suffixes yes
zstyle ':completion:*:paths' expand prefix suffix
Now:
zsh% ls u? TAB
is good.
zsh% ls u?/q TAB
is good.
zsh% ls u?/q/e? TAB
is good.
zsh% ls u?/q/e?/ TAB
finds no matches. The problem has to do with the code that is in the
if (( tmp4 )) block in _path_files starting at line 463.
In this case, the compfiles -r call at line 452 gets called four
times.
1. tmp1=(u2/q/e2/a1 u2/q/e2/a2)
tmp3=(u?/q/e?/)
tmp4=0
2. tmp1=(q/e2/a1 q/e2/a2)
tmp3=(q/e?/)
tmp4=0
3. tmp1=(e2/a1 e2/a2)
tmp3=(e?/)
tmp4=0
4. tmp1=(a1 a2)
tmp3=()
tmp4=1
If you cheat and set enter the if block even though tmp4=0 (i.e.,
change 469 to "if (( 1 )); then") then you get
zsh% ls u?/q/e?/ TAB
u2/q/e2/a1 u2/q/e2/a2/
When you do
zsh% ls u?/q/e?/a2 TAB
the commandline gets replaced with the expansion done.
Obviously this is an incorrect change... Entering that block
unconditionally breaks many other cases. But I think it shows that
compfiles -r returning 1 is no longer a sufficient condition for
entering that block.
By tweaking bits of this code here and there I was able to get
behavior sufficiently close to what I wanted to be satisfying in all
cases, but not in all cases at the same time. :-) In other words, I
could fix one problem and break another case. This is just because I
haven't done a systematic job of understanding the code due to lack of
time, but it seems like this is really almost there.
The functionality I was able to get differs from what I originally
described in two ways: if partial expansion is possible (i.e.,
expansion of the first metacharacter but not the second), it is still
not done. Expansion is done only when *all* metacharacters match
unambiguously. This is fine -- in fact, it's probably better than
what I originally specified. The other thing is that the code doesn't
complete as far as possible. For example, ls u?/ TAB should complete
through u?/q since all the choices start with q. I can live without
this too though I don't see exactly why it doesn't work.
On a final note, if you start with the above initialization except
omit the "zstyle ':completion:*:paths' expand prefix suffix" line
only, then
zsh% ls u?/
gives you u1// u2// u3// u4// u5// as choices (with the extraneous
/). I don't know whether it would make sense to run in this mode, but
I thought it was worth pointing this out.
Sorry I can't spend more time on this now. I would be happy to at
least test additional changes though.
Jay
Messages sorted by:
Reverse Date,
Date,
Thread,
Author