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

PATCH: suggestion for completion lists



[I forgot to say... that last patch I sent may be offset, due to this
one here.]

I /think/ this was asked for before and personally I really like it:
this makes completion lists obey the NUMERIC_GLOB_SORT option. I.e.
if it is set matches with numbers in them are sorted in a better
vgrepable way.

Question is if this should use its own option and, if not, if we should 
document it. I guess we should, but where: at the option description
or somewhere in the completion docs?

Bye
 Sven

diff -u oldsrc/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- oldsrc/Zle/zle_tricky.c	Tue Oct 26 20:35:44 1999
+++ Src/Zle/zle_tricky.c	Tue Oct 26 20:43:44 1999
@@ -5529,11 +5529,33 @@
 	if (*b == '\\')
 	    b++;
 	if (*a != *b)
-	    return (int)(*a - *b);
+	    break;
 	if (*a)
 	    a++;
 	if (*b)
 	    b++;
+    }
+    if (isset(NUMERICGLOBSORT) && (idigit(*a) || idigit(*b))) {
+	for (; a > *aa && idigit(a[-1]); a--, b--);
+	if (idigit(*a) && idigit(*b)) {
+	    while (*a == '0')
+		a++;
+	    while (*b == '0')
+		b++;
+	    for (; idigit(*a) && *a == *b; a++, b++);
+	    if (idigit(*a) || idigit(*b)) {
+		int cmp = (int) STOUC(*a) - (int) STOUC(*b);
+
+		while (idigit(*a) && idigit(*b))
+		    a++, b++;
+		if (idigit(*a) && !idigit(*b))
+		    return 1;
+		if (idigit(*b) && !idigit(*a))
+		    return -1;
+
+		return cmp;
+	    }
+	}
     }
     return (int)(*a - *b);
 }

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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