zsh-workers
 help / color / mirror / code / Atom feed
* gripes
@ 2001-12-14 21:51 Clint Adams
  2001-12-14 22:15 ` gripes Bart Schaefer
  2002-01-07 14:40 ` gripes Sven Wischnowsky
  0 siblings, 2 replies; 9+ messages in thread
From: Clint Adams @ 2001-12-14 21:51 UTC (permalink / raw)
  To: zsh-workers

I keep finding myself wanting a parameter expansion flag that
removes duplicate array elements (like typeset -U).

Also, this is from a user:

-----------------
I set:
	setopt nomenucomplete bashautolist noautomenu
but, after pressing TAB a few times, it still starts cycling.
Also, there does not appear to be an option to put the cursor below the
listed possible completions. These abberations are especially annoying
for people who are addicted to bash's tab-completion but would like to
switch to zsh for its more advanced feature-set.

------------------

I assume that he is using the new completion system, since it does start
cycling even if the options are set as he says.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gripes
  2001-12-14 21:51 gripes Clint Adams
@ 2001-12-14 22:15 ` Bart Schaefer
  2001-12-16 20:50   ` PATCH: remove duplicate array values in parameter expansion Clint Adams
  2002-01-07 14:40 ` gripes Sven Wischnowsky
  1 sibling, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2001-12-14 22:15 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-workers

On Dec 14,  4:51pm, Clint Adams wrote:
> 
> I keep finding myself wanting a parameter expansion flag that
> removes duplicate array elements (like typeset -U).

Hrm.  That might not be a bad idea.  It'd be nice if we could figure out
a way to optimize it when combined with (o) or (O).

> -----------------
> Also, there does not appear to be an option to put the cursor below the
> listed possible completions.

setopt no_always_last_prompt


^ permalink raw reply	[flat|nested] 9+ messages in thread

* PATCH: remove duplicate array values in parameter expansion
  2001-12-14 22:15 ` gripes Bart Schaefer
@ 2001-12-16 20:50   ` Clint Adams
  2001-12-16 21:05     ` Clint Adams
                       ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Clint Adams @ 2001-12-16 20:50 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> Hrm.  That might not be a bad idea.  It'd be nice if we could figure out
> a way to optimize it when combined with (o) or (O).

Other than replacing qsort for the combined base, I wouldn't know what
to do.  Here it is; I used (n) since it was an unused letter in
'unique'.

Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.52
diff -u -r1.52 params.c
--- Src/params.c	2001/11/03 23:36:33	1.52
+++ Src/params.c	2001/12/16 20:42:50
@@ -2490,6 +2490,23 @@
 	    }
 }
 
+/**/
+void
+zhuniqarray(char **x)
+{
+    char **t, **p = x;
+
+    if (!x || !*x)
+	return;
+    while (*++p)
+	for (t = x; t < p; t++)
+	    if (!strcmp(*p, *t)) {
+		*p = NULL;
+		for (t = p--; (*t = t[1]) != NULL; t++);
+		break;
+	    }
+}
+
 /* Function to get value of special parameter `#' and `ARGC' */
 
 /**/
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.25
diff -u -r1.25 subst.c
--- Src/subst.c	2001/11/03 23:34:50	1.25
+++ Src/subst.c	2001/12/16 20:42:50
@@ -767,6 +767,7 @@
     int flags = 0;
     int flnum = 0;
     int sortit = 0, casind = 0;
+    int unique = 0;
     int casmod = 0;
     int quotemod = 0, quotetype = 0, quoteerr = 0;
     int visiblemod = 0;
@@ -996,6 +997,10 @@
 		    shsplit = 1;
 		    break;
 
+		case 'n':
+		    unique = 1;
+		    break;
+
 		default:
 		  flagerr:
 		    zerr("error in flags", NULL, 0);
@@ -1872,6 +1877,14 @@
 	    strcpy(*str, fstr);
 	    setdata(n, y);
 	    return n;
+	}
+	if (unique) {
+/*	    if(!copied) */
+		aval = arrdup(aval);
+
+	    i = arrlen(aval);
+	    if (i > 1)
+		zhuniqarray(aval);
 	}
 	if (sortit) {
 	    static CompareFn sortfn[] = {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PATCH: remove duplicate array values in parameter expansion
  2001-12-16 20:50   ` PATCH: remove duplicate array values in parameter expansion Clint Adams
@ 2001-12-16 21:05     ` Clint Adams
  2001-12-16 22:58     ` Zefram
  2001-12-17  4:24     ` Bart Schaefer
  2 siblings, 0 replies; 9+ messages in thread
From: Clint Adams @ 2001-12-16 21:05 UTC (permalink / raw)
  To: zsh-workers

> Other than replacing qsort for the combined base, I wouldn't know what
                                              ^ that should be a 'c'.

I forgot the extremely brief documentation.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.38
diff -u -r1.38 expn.yo
--- Doc/Zsh/expn.yo	2001/09/09 06:17:03	1.38
+++ Doc/Zsh/expn.yo	2001/12/16 21:02:36
@@ -761,6 +761,9 @@
 in `tt(${${(z)foo}[2]})'. Likewise, to remove the quotes in the
 resulting words one would do: `tt(${(Q)${(z)foo}})'.
 )
+item(tt(n))(
+Expand only the first occurrence of each unique word.
+)
 enditem()
 
 The following flags (except tt(p)) are followed by one or more arguments


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PATCH: remove duplicate array values in parameter expansion
  2001-12-16 20:50   ` PATCH: remove duplicate array values in parameter expansion Clint Adams
  2001-12-16 21:05     ` Clint Adams
@ 2001-12-16 22:58     ` Zefram
  2001-12-17  1:12       ` Clint Adams
  2001-12-17  4:24     ` Bart Schaefer
  2 siblings, 1 reply; 9+ messages in thread
From: Zefram @ 2001-12-16 22:58 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-workers

Clint Adams wrote:
>+    while (*++p)
>+	for (t = x; t < p; t++)
>+	    if (!strcmp(*p, *t)) {
>+		*p = NULL;
>+		for (t = p--; (*t = t[1]) != NULL; t++);
>+		break;
>+	    }

"*p = NULL" is redundant (*p gets overwritten immediately).

>+	if (unique) {
>+/*	    if(!copied) */
>+		aval = arrdup(aval);

Is the commented-out code supposed to be there or not?

-zefram


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PATCH: remove duplicate array values in parameter expansion
  2001-12-16 22:58     ` Zefram
@ 2001-12-17  1:12       ` Clint Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Clint Adams @ 2001-12-17  1:12 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-workers

> "*p = NULL" is redundant (*p gets overwritten immediately).
> Is the commented-out code supposed to be there or not?

Yes.  I'll fix this in CVS.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PATCH: remove duplicate array values in parameter expansion
  2001-12-16 20:50   ` PATCH: remove duplicate array values in parameter expansion Clint Adams
  2001-12-16 21:05     ` Clint Adams
  2001-12-16 22:58     ` Zefram
@ 2001-12-17  4:24     ` Bart Schaefer
  2001-12-17 14:03       ` Clint Adams
  2 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2001-12-17  4:24 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-workers

On Dec 16,  3:50pm, Clint Adams wrote:
}
} Here it is; I used (n) since it was an unused letter in 'unique'.

Hrm.  I think I'd have preferred to save (n) for numeric sorting.  What
was wrong with lower-case (u)?  It's not used yet.  If that's a problem,
just use the digit (1)?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PATCH: remove duplicate array values in parameter expansion
  2001-12-17  4:24     ` Bart Schaefer
@ 2001-12-17 14:03       ` Clint Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Clint Adams @ 2001-12-17 14:03 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> Hrm.  I think I'd have preferred to save (n) for numeric sorting.  What
> was wrong with lower-case (u)?  It's not used yet.  If that's a problem,
> just use the digit (1)?

Nothing; In my quick search for a letter, I mistakenly took :u for (u).

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.39
diff -u -r1.39 expn.yo
--- Doc/Zsh/expn.yo	2001/12/16 21:06:12	1.39
+++ Doc/Zsh/expn.yo	2001/12/17 14:02:35
@@ -727,6 +727,9 @@
 )
 enditem()
 )
+item(tt(u))(
+Expand only the first occurrence of each unique word.
+)
 item(tt(U))(
 Convert all letters in the result to upper case.
 )
@@ -760,9 +763,6 @@
 access single words in the result, one has to use nested expansions as 
 in `tt(${${(z)foo}[2]})'. Likewise, to remove the quotes in the
 resulting words one would do: `tt(${(Q)${(z)foo}})'.
-)
-item(tt(n))(
-Expand only the first occurrence of each unique word.
 )
 enditem()
 
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.27
diff -u -r1.27 subst.c
--- Src/subst.c	2001/12/17 01:16:37	1.27
+++ Src/subst.c	2001/12/17 14:02:36
@@ -997,7 +997,7 @@
 		    shsplit = 1;
 		    break;
 
-		case 'n':
+		case 'u':
 		    unique = 1;
 		    break;
 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: gripes
  2001-12-14 21:51 gripes Clint Adams
  2001-12-14 22:15 ` gripes Bart Schaefer
@ 2002-01-07 14:40 ` Sven Wischnowsky
  1 sibling, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 2002-01-07 14:40 UTC (permalink / raw)
  To: zsh-workers


Clint Adams wrote:

> ...
> 
> Also, this is from a user:
> 
> -----------------
> I set:
> 	setopt nomenucomplete bashautolist noautomenu
> but, after pressing TAB a few times, it still starts cycling.
> Also, there does not appear to be an option to put the cursor below the
> listed possible completions. These abberations are especially annoying
> for people who are addicted to bash's tab-completion but would like to
> switch to zsh for its more advanced feature-set.
> 
> ------------------
> 
> I assume that he is using the new completion system, since it does start
> cycling even if the options are set as he says.

Yep. This was never easy. The patch below fixes it for me. It isn't
nice (because it tests the AUTO_MENU option), but the whole logic of
it is getting too complicated for me.

Bye
  Sven

Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.51
diff -u -r1.51 compcore.c
--- Src/Zle/compcore.c	2001/10/09 09:50:21	1.51
+++ Src/Zle/compcore.c	2002/01/07 14:41:46
@@ -842,7 +842,8 @@
 	}
 	startauto = ((compinsert &&
 		      !strcmp(compinsert, "automenu-unambiguous")) ||
-		     (bashlistfirst && (!compinsert || !*compinsert)));
+		     (bashlistfirst && isset(AUTOMENU) &&
+                      (!compinsert || !*compinsert)));
 	useexact = (compexact && !strcmp(compexact, "accept"));
 
 	if (!comptoend || !*comptoend)

-- 
Sven Wischnowsky                           wischnow@berkom.de


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-01-07 14:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-14 21:51 gripes Clint Adams
2001-12-14 22:15 ` gripes Bart Schaefer
2001-12-16 20:50   ` PATCH: remove duplicate array values in parameter expansion Clint Adams
2001-12-16 21:05     ` Clint Adams
2001-12-16 22:58     ` Zefram
2001-12-17  1:12       ` Clint Adams
2001-12-17  4:24     ` Bart Schaefer
2001-12-17 14:03       ` Clint Adams
2002-01-07 14:40 ` gripes 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).