From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 857 invoked from network); 17 Oct 2000 19:31:04 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Oct 2000 19:31:04 -0000 Received: (qmail 8768 invoked by alias); 17 Oct 2000 19:30:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13012 Received: (qmail 8761 invoked from network); 17 Oct 2000 19:30:57 -0000 Date: Tue, 17 Oct 2000 15:30:55 -0400 Message-Id: <200010171930.PAA14404@soup.ql.org> X-Authentication-Warning: soup.ql.org: ejb set sender to ejb@ql.org using -f From: "E. Jay Berkenbilt" To: wischnow@informatik.hu-berlin.de CC: zsh-workers@sunsite.auc.dk In-reply-to: <200010160805.KAA04037@beta.informatik.hu-berlin.de> (message from Sven Wischnowsky on Mon, 16 Oct 2000 10:05:17 +0200 (MET DST)) Subject: Re: still confused about completion and matching References: <200010160805.KAA04037@beta.informatik.hu-berlin.de> Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII 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