zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: predict-on (Re: Completeinword and ambiguous completions)
@ 1999-10-22 12:29 Sven Wischnowsky
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 1999-10-22 12:29 UTC (permalink / raw)
  To: zsh-workers


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:

    SUFFIX=''
    compstate[list]=''
    compstate[insert]=''
    return 1

   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)
   again.

5) Then you can look at `_lastcomp[nmatches]' to see if there were
   matches.

I think this should work... but maybe I'm overlooking something.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: PATCH: predict-on (Re: Completeinword and ambiguous completions)
@ 1999-10-22  6:40 Sven Wischnowsky
  1999-10-22 10:16 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-10-22  6:40 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Oct 21,  9:10am, Sven Wischnowsky wrote:
> } Subject: Re: Completeinword and ambiguous completions
> }
> } Bart Schaefer wrote:
> } > zsh% setopt prompt
> } > (feep, cursor stays on "m")
> } > 
> } > What I'd like is, in the first of those cases, the cursor doesn't stay
> } > on the "m" but rather moves to the end of the unambiguous prefix, so that
> } > I can immediately start menu completion for the rest of the word.
> } 
> }   compmatchers=('' 'r:|=*')
> } 
> } Is that good enough?
> 
> It seems to work some, but not all, of the time.  For example:
> 
> zagzig<4> setopt promptt
> 
> If the cursor is on the second `t' there are two possible completions
> (promptsubst and promptpercent).  So when the cursor is on the `m' I
> expect TAB to move it to the second `t'.  Instead I get a feep.

Ugh. The completion code doesn't try to do that at all, right.

You can try the (probably expensive):

  compmatchers=('r:|?=* r:|=*')

of course. This works for me at least with your example. Another way
would be to try completion again and again while moving the
cursor. But that would even be more expensive.

> Maybe the following will explain why I'm interested in this.  I want to
> press TAB in the middle of a predictivly-inserted line to jump ahead to
> the next spot where I might want to edit.

Almost-DWIM?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: Completeinword and ambiguous completions
@ 1999-10-21  7:10 Sven Wischnowsky
  1999-10-21 16:40 ` PATCH: predict-on (Re: Completeinword and ambiguous completions) Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-10-21  7:10 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> Consider the following situation:
> 
> zsh% setopt completeinword
> zsh% setopt pro<TAB>
> zsh% setopt prompt<TAB>
> promptbang     promptcr       promptpercent  promptsubst    promptvars
> 
> Note that the prefix "prompt" is unambiguous.  Now consider what happens
> if the cursor is over the "m" when TAB is hit in each of these cases:
> 
> zsh% setopt prompt
> (feep, cursor stays on "m")
> zsh% setopt promptvars
> zsh% setopt promptvars
> (cursor is one space past end of word)
> 
> What I'd like is, in the first of those cases, the cursor doesn't stay
> on the "m" but rather moves to the end of the unambiguous prefix, so that
> I can immediately start menu completion for the rest of the word.  The
> following almost does it:

That's a case for global match specs, since what you want is that the
code finds out that you are in a prefix for possible matches and moves 
you at the end of the unambiguous string. Since completeinword
normally doesn't test this, but instead looks only for strings ending
with the stuff after the cursor, it doesn't help. But with:

  compmatchers=('r:|=*')

It takes the string from the line only as a prefix, builds the
possible matches you were expecting and puts you at the place were
something is missing, i.e. the end in your example.

This is then independent of the setting of completeinword (at least in 
this example). And, of course, you may prefer to use:

  compmatchers=('' 'r:|=*')

to first try to generate matches without this strings-is-a-prefix
behaviour.


Is that good enough?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-10-22 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-22 12:29 PATCH: predict-on (Re: Completeinword and ambiguous completions) Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-10-22  6:40 Sven Wischnowsky
1999-10-22 10:16 ` Bart Schaefer
1999-10-21  7:10 Completeinword and ambiguous completions Sven Wischnowsky
1999-10-21 16:40 ` PATCH: predict-on (Re: Completeinword and ambiguous completions) Bart Schaefer

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).