zsh-workers
 help / color / mirror / code / Atom feed
From: "E. Jay Berkenbilt" <ejb@ql.org>
To: wischnow@informatik.hu-berlin.de
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: still confused about completion and matching
Date: Tue, 17 Oct 2000 15:30:55 -0400	[thread overview]
Message-ID: <200010171930.PAA14404@soup.ql.org> (raw)
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))


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


  reply	other threads:[~2000-10-17 19:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-16  8:05 Sven Wischnowsky
2000-10-17 19:30 ` E. Jay Berkenbilt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-10-25  7:50 Sven Wischnowsky
2000-11-06 15:34 ` E. Jay Berkenbilt
2000-10-25  7:12 Sven Wischnowsky
2000-10-25  7:41 ` Andrej Borsenkow
2000-10-24  7:44 Sven Wischnowsky
2000-10-24 15:00 ` E. Jay Berkenbilt
2000-10-24 15:15   ` Bart Schaefer
2000-10-24 15:28     ` Andrej Borsenkow
2000-10-23 13:20 Sven Wischnowsky
2000-10-19  9:11 Sven Wischnowsky
2000-10-20 16:38 ` E. Jay Berkenbilt
2000-10-20 16:57   ` Andrej Borsenkow
2000-10-20 20:45     ` E. Jay Berkenbilt
2000-10-23  7:15       ` Andrej Borsenkow
2000-10-23 13:11         ` E. Jay Berkenbilt
2000-10-13 11:03 Sven Wischnowsky
2000-10-12 19:56 E. Jay Berkenbilt
2000-10-12 20:32 ` E. Jay Berkenbilt
2000-10-16  5:01 ` 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=200010171930.PAA14404@soup.ql.org \
    --to=ejb@ql.org \
    --cc=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.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).