zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: suggestion for completion lists
@ 1999-10-27  8:25 Sven Wischnowsky
  0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 1999-10-27  8:25 UTC (permalink / raw)
  To: zsh-workers


[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@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-10-27  8:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-27  8:25 PATCH: suggestion for completion lists Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).