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

compadd -E 0 should imply -J and -2



With compadd -E, the -J (unsorted) and -2 (remove duplicates) options
are implied. They both affect the name space (group) into which matches
are added.

At certain terminal sizes, my function was using -E 0 and my layout was
all mucked up. The cause wasn't as obvious as it perhaps should have
been.

bin_compadd generates an error for negative arguments to -E. Being able
to pass -E 0 allows my function to be simpler so rather than change the
error condition from < 0 to < 1, this patch forces -E 0 to also imply the
-J and -2 options. I've also added a sentence to the documentation.

Oliver

diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 0c0a15d..40cabea 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -697,7 +697,9 @@ format completion lists and to make explanatory string be shown in
 completion lists (since empty matches can be given display strings
 with the tt(-d) option).  And because all but one empty string would
 otherwise be removed, this option implies the tt(-V) and tt(-2)
-options (even if an explicit tt(-J) option is given).
+options (even if an explicit tt(-J) option is given).  This can be
+important to note as it affects the name space into which matches are
+added.
 )
 xitem(tt(-))
 item(tt(-)tt(-))(
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index ba538ca..2cbb6ac 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2049,7 +2049,7 @@ addmatches(Cadata dat, char **argv)
     Heap oldheap;
 
     SWITCHHEAPS(oldheap, compheap) {
-        if (dat->dummies)
+        if (dat->dummies >= 0)
             dat->aflags = ((dat->aflags | CAF_NOSORT | CAF_UNIQCON) &
                            ~CAF_UNIQALL);
 
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 63e5b91..4cf88f3 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -537,7 +537,7 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
     dat.match = NULL;
     dat.flags = 0;
     dat.aflags = CAF_MATCH;
-    dat.dummies = 0;
+    dat.dummies = -1;
 
     for (; *argv && **argv ==  '-'; argv++) {
 	if (!(*argv)[1]) {



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