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

Re: Strange _values completion on accept-and-menu-complete and menu selection



On Sat, 11 Dec 2004, Andrey Borzenkov wrote:

> Apparently it does not work any more for _values; I presume it did work 
> once because _urpmi completion includes _values usage in question.

Looking at the code, I can't see any way it ever worked.  There's been no 
interesting change anywhere near or beyond (in the function call sense) 
the point where complist.c handles accept-and-menu-complete.

The problem is that accept_last() is called, which eventually always calls 
iremovesuffix(' ', 1).  If "compadd -R" had been used, the suffix function
would be called and could subvert the behavior of iremovesuffix(), but as
it stands the suffix is always zapped.

The deeper problem seems to be that the complist module doesn't really 
know anything about compvalues; e.g., as far as complist is concerned it's 
selecting among shell words, not from a set of values that are part of a 
word.  That it comes as close as it does to working is serendipitous.

A fix seems to be something in the direction of this pseudo-patch (do NOT
apply it as-is) to compresult.c, but I don't know how to get the boolean
value for "we are not completing values from compvalues" at this location.

@@ -1241,16 +1241,19 @@
 	lastbrbeg->str[l + 1] = '\0';
     } else {
 	int l;
+	int rem = /* We are not completing values from compvalues */;
 
 	cs = minfo.pos + minfo.len + minfo.insc;
-	iremovesuffix(' ', 1);
+	if (rem)
+	  iremovesuffix(' ', 1);
 	l = cs;
 	cs = minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))->qisl;
 	if (cs < l)
 	    foredel(l - cs);
 	else if (cs > ll)
 	    cs = ll;
-	inststrlen(" ", 1, 1);
+	if (rem)
+	  inststrlen(" ", 1, 1);
 	minfo.insc = minfo.len = 0;
 	minfo.pos = cs;
 	minfo.we = 1;



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