zsh-workers
 help / color / mirror / code / Atom feed
* compadd -E 0 should imply -J and -2
@ 2015-07-06 14:26 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2015-07-06 14:26 UTC (permalink / raw)
  To: Zsh workers

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]) {


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

only message in thread, other threads:[~2015-07-06 14:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06 14:26 compadd -E 0 should imply -J and -2 Oliver Kiddle

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).