From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29976 invoked from network); 22 Oct 1999 12:29:27 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Oct 1999 12:29:27 -0000 Received: (qmail 4657 invoked by alias); 22 Oct 1999 12:29:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8374 Received: (qmail 4650 invoked from network); 22 Oct 1999 12:29:15 -0000 Date: Fri, 22 Oct 1999 14:29:04 +0200 (MET DST) Message-Id: <199910221229.OAA02576@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Fri, 22 Oct 1999 10:16:52 +0000 Subject: Re: PATCH: predict-on (Re: Completeinword and ambiguous completions) 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