zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Re: still confused about completion and matching
Date: Mon, 16 Oct 2000 05:01:37 +0000	[thread overview]
Message-ID: <1001016050138.ZM2458@candle.brasslantern.com> (raw)
In-Reply-To: <200010121956.PAA08723@soup.ql.org>

On Oct 12,  3:56pm, E. Jay Berkenbilt wrote:
} 
} What I want is effectively for the completion system to wait as long
} as possible before replacing a pattern with a match and to leave my
} cursor where it is when I hit TAB.

It took me at least as long to decide whether to answer this, and then
how much I had to add to what Sven said already, as Jay reported that
it took to compose his message in the first place; on top of that I've
been feverish all weekend, so I hope what I've finally ended up saying
makes at least a little bit of sense.

} If I type
} 
} zsh% ls u?/**/a_TAB
} 
} ideally, I like to see
} 
} zsh% ls u?/**/a_
} u2/q1/e2/a1  u2/q1/e2/a2  u4/q/a1  u4/q/a2
} 
} if I have extended_glob set (which is actually the thing that first
} made me switch to zsh).  Does this make sense?

One random aside:  You don't need extended_glob to use **.

It appears that _path_files isn't entirely prepared to deal with ** in
the input string.  The code after line 411 ("Step over to the next
component, if any") lops the ** out of the pattern, thus reducing the 
set of paths that are considered from ( u1/q1 u2/q1 u3/q1 u4/q ) to
just ( u4/q/a1 u4/q/a2 ).  So as things now stand:

	zsh -f
	% zstyle ':completion:*' completer _complete _match
	% autoload -U compinit; compinit -D
	% ls u?/**/a<C-D>
	u4/

Only `u4' is listed, even though `u1' and `u2' also contain matches of
the recursive pattern.  This means that even if you could get _path_files
to insert more than just the ambiguous prefix, you still won't see all
four of the possible completions you desire.

On Oct 13,  1:03pm, Sven Wischnowsky wrote:
> 
> [...] the path-prefixes and -suffixes [...]
> are still matched `normally'. And it has to be this way because the
> completion code (the C-code) has to be able to build a common string
> for them which it can if they differ only as far as match specs allow, 
> but it can't do that for arbitrary strings matched by a pattern.

It seems to me that _path_files (or perhaps even the C code) could employ
an algorithm similar to that cooked up by PWS for "zmv -w", to identify
glob patterns in the string from the command line and implicitly put them
in parens where necessary so that "match references" (there's another
overloading of "match") are generated, then used to identify "equivalent"
substrings in each of the potential matches.

> That leaves only the possibility to move the suffixes into the words
> given to compadd. This would be done in lines 488-510 in _path_files.
> That together with using a non-empty value for compstate[pattern_match]
> should bring you nearer to what you want. But note that this won't be
> added to _path_files if it is done unconditionally. Seeing only the
> ambiguous component is much clearer for most cases.

I mostly agree; however, with ** involved, there may be more than one
consecutive ambiguous path component.  This leads to confusing behavior
in which it's not clear without actually entering menu-completion exactly
where in the command line the listed completions would be inserted.  (The
`ambiguous' style notwithstanding.)

I had a bit more to ask about, but I came to the conclustion that I'm not
coherent enough yet to write it down, so I guess I'll leave it at that.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


  parent reply	other threads:[~2000-10-16  5:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-12 19:56 E. Jay Berkenbilt
2000-10-12 20:32 ` E. Jay Berkenbilt
2000-10-16  5:01 ` Bart Schaefer [this message]
2000-10-13 11:03 Sven Wischnowsky
2000-10-16  8:05 Sven Wischnowsky
2000-10-17 19:30 ` E. Jay Berkenbilt
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-23 13:20 Sven Wischnowsky
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-25  7:12 Sven Wischnowsky
2000-10-25  7:41 ` Andrej Borsenkow
2000-10-25  7:50 Sven Wischnowsky
2000-11-06 15:34 ` E. Jay Berkenbilt

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=1001016050138.ZM2458@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --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).