From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16591 invoked from network); 4 Nov 1998 09:20:31 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 4 Nov 1998 09:20:31 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id EAA13016; Wed, 4 Nov 1998 04:07:02 -0500 (EST) Resent-Date: Wed, 4 Nov 1998 04:07:02 -0500 (EST) Date: Wed, 4 Nov 1998 10:04:50 +0100 (MET) Message-Id: <199811040904.KAA29172@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@math.gatech.edu CC: greg@alphatech.com In-reply-to: greg@alphatech.com's message of Tue, 3 Nov 1998 12:28:43 -0500 (EST) Subject: Re: bug in 3.1.4 completion Resent-Message-ID: <"tooPh3.0.GB3.sa1Gs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4528 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu greg@alphatech.com wrote: > Hi, > > I have found a minor bug in zsh 3.1.4 completion related to the > automagic removal of completed slashes. If I invoke zsh -f, > > % mkdir test > % cd test > % mkdir foo > % mkdir foo/bar foo/barbaz > > % ls f ; now type TAB > -> foo/ ; now type TAB > -> foo/bar ; now type SPACE > -> foo/ba ; notice the "r" got removed. > > This only seems to happen if you complete "foo" then > immediately hit TAB again. If you type part of "bar" and > then TAB it functions correctly. > There was a missing fixsuffix() when inserting the unambiguous string for normal completion. It's fixed by the second hunk in the patch below (this is for 3.1.5, but you can easily insert the call to fixsuffix() in 3.1.4 in do_ambiguous() in the else-branch of the `if(p)'). > While I'm at it I have a few other nits about the completion system > (which on the whole I think is excellent). > > First, another somewhat inconvenient behavior related to slash removal > (again zsh -f, and with the same directories created above): > > % ls fo bar ; position the cursor on the space after the "o", hit TAB > -> foo/ bar ; now, the cursor is still on the space after the "/". > ; hit Control-d to delete the space > -> foo/bar ; with cursor on "b". now Control-e (end-of-line) and > -> foobar ; the "/" gets removed. ugh. > Here is another missing call to fixsuffix() (fixed by the first hunk). This one goes into deletecharorlist() which has to do the itself since the calling code doesn't call fixsuffix() since it may use the completion code. > > Another behavior that's not quite right IMHO is completeinword: > > % setopt noalwaystoend completeinword > % ls fo/bar ; position cursor on "/", hit TAB > -> foo/bar/ ; hit TAB again > -> foo/bar// ; hit TAB again > -> foo/bar/// ; etc, never listing possible completions > > Even if I move past the "/", or even "b" it never jumps to the end of > "bar". This is fixed in 3.1.5 with my last patches. > Setting alwaystoend helps, though it is still very picky about > the stuff on both sides matching, which often makes the feature > useless. I have modified emacs to do what I believe is the right > thing: > > * look for completions using both text on left and right. > if there are none, look only for completions from the left. this > way having some garbage on the right doesn't hose you, it just > gets pushed right (it may match later, after more completing). > * now, insert the completed text, placing cursor at the end of the > insertion. > * remove the longest substring to the right (with start anchored at > the cursor) which matches a substring to the left (with end > anchored at the cursor). there may be none. > > How hard would it be to add this to zsh? > That would be expand-or-complete-prefix with a little hacking (the remove- the-matched-prefix-of-the-suffix part), not too hard. > While I'm on little nits, it would be nice if the FIGNORE variable > were not used when listing completions: > > % FIGNORE='.o' > % touch foo.o foo.c > % ls fo ; type Control-d to list completions, you only see "foo.c" > I'm not too sure about this one, since C-d should list the completions and if there are other matching files the ignored ones aren't completions. If there are no other files fignore will be ignored and the files will be listed. I could be convinced to list the ignored files separately (this indeed may make sense). > One last feature that'd be nice is automatic case conversion. When > completing, if no completions are found, try again for a case > insensitive completion. Would this be easy to add? We got many requests for this. For 3.1.5 there is a proposed patch that adds a generic way to control the matching behavior of completion. With this you can get case-insensitive completion, partial word completion and several other things. Bye Sven diff -c os/Zle/zle_tricky.c Src/Zle/zle_tricky.c *** os/Zle/zle_tricky.c Wed Nov 4 08:57:00 1998 --- Src/Zle/zle_tricky.c Wed Nov 4 09:17:18 1998 *************** *** 309,316 **** usemenu = isset(MENUCOMPLETE); useglob = isset(GLOBCOMPLETE); ! if (cs != ll) deletechar(); else docomplete(COMP_LIST_COMPLETE); --- 309,318 ---- usemenu = isset(MENUCOMPLETE); useglob = isset(GLOBCOMPLETE); ! if (cs != ll) { ! fixsuffix(); deletechar(); + } else docomplete(COMP_LIST_COMPLETE); *************** *** 4789,4794 **** --- 4791,4798 ---- int ics = cs, ocs, pl = 0, l, lp, ls; char *ps; Cline lc; + + fixsuffix(); /* Delete the old stuff from the command line. */ cs = wb; -- Sven Wischnowsky wischnow@informatik.hu-berlin.de