Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: MH command completion problems



> Peter Stephenson wrote:
> >tstfn() { reply=("${1%/*}/foo" "${1%/*}/bar") }
> >compctl -K tstfn -S / -q tstfn
> >tstfn foo/<TAB>
> >
> >This certainly gives me the double / (you can't get any more because
> >of the way tstfn is defined), but autolist does work for me.
> 
> Yes, it's a shell bug.  In the above scenario, tstfn is getting
> arguments "foo" and "".  The already-present suffix is being ignored at
> that point, for completion purposes.  The function returns completions
> "foo/foo" and "foo/bar".  If I recall the internals correctly, this is
> being interpreted as requiring the addition of "/foo" or "/bar" to the
> existing string "foo".  However, the additions are being applied to the
> string actually there, "foo/", which the function saw no indication
> of.
> 
> Theoretically, it's a simple matter of programming to make the -S
> suffix be added in the right place.  Actually it's a bit of a
> nightmare.

I think it is not a nightmare.  Try this patch (for zsh-3.0.x go to the Src
directory first).

Zoltan


*** Src/Zle/zle_tricky.c	1997/01/06 03:06:15	3.1.1.8
--- Src/Zle/zle_tricky.c	1997/01/07 00:01:35
***************
*** 2253,2259 ****
  	/* If the suffix is already there, ignore it (and don't add *
  	 * it again).                                               */
  	if (*sd && (suffixll = strlen(sd)) >= sl &&
! 	    !strcmp(sdup, sd + suffixll - sl)) {
  	    ccsuffix = NULL;
  	    haswhat |= HAS_SUFFIX;
  	    s[suffixll - sl] = '\0';
--- 2253,2259 ----
  	/* If the suffix is already there, ignore it (and don't add *
  	 * it again).                                               */
  	if (*sd && (suffixll = strlen(sd)) >= sl &&
! 	    offs <= suffixll - sl && !strcmp(sdup, sd + suffixll - sl)) {
  	    ccsuffix = NULL;
  	    haswhat |= HAS_SUFFIX;
  	    s[suffixll - sl] = '\0';



Messages sorted by: Reverse Date, Date, Thread, Author