Zsh Mailing List Archive
Messages sorted by:
Re: PATCH: predict-on (Re: Completeinword and ambiguous completions)
- X-seq: zsh-workers 8374
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: predict-on (Re: Completeinword and ambiguous completions)
- Date: Fri, 22 Oct 1999 14:29:04 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Fri, 22 Oct 1999 10:16:52 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> [ ... ] What I want to do is described precisely by:
> (0) Assume no global compmatchers.
> (1) Generate the possible matches at the current cursor position as
> if for expand-or-complete-prefix, i.e. ignoring what follows.
> (2) Compute the common prefix of those matches.
> (3) If the common prefix matches what follows on the line, move the
> cursor to the end of the common prefix, else no change.
> (4) Recompute matches at this (new?) position as if for completeinword.
> (5) If exactly one, insert it and put the cursor at the end of it.
> (5) Else if none, move the cursor back to the original position.
> (6) Otherwise (and if autolist) list the matches from (4).
Haven't tried, but:
1) write a simple pseudo-completer which only does:
I.e. make the completion code only test for matches.
2) in the prediction function call the completion code with this
completer as the first argument and all other completer you want to
use as other arguments
3) After that you have the unambiguous prefix in
`_lastcomp[unambiguous]'. With `compmatchers' out of the way it
should really be only a prefix in most cases, only functions like
`_path_files' and functions that use their own `-M' flags may result
in unambiguous strings which are not only prefixes. But a bit of
comparing that string to the stuff on the line (the prefix used by
the completion system is saved in `_lastcomp[prefix]') and probably
cutting `_lastcomp[unambiguous]' at the `_lastcomp[unambiguous_cursor]'
position may reveal that.
4) Now cut off the original prefix from the unambiguous string and
compare the rest to the beginning of `RBUFFER'. If it matches,
move forward and try completion (without the dummy completer)
5) Then you can look at `_lastcomp[nmatches]' to see if there were
I think this should work... but maybe I'm overlooking something.
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by: