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

PATCH: compadd -y



While working on 6657 it occured to me that compadd doesn't support
the -y option (mostly for historical reasons). This patch fixes that
and changes the three example functions that use display lists.

Bye
 Sven

diff -u os/Zle/comp.h Src/Zle/comp.h
--- os/Zle/comp.h	Thu Jun 17 09:24:30 1999
+++ Src/Zle/comp.h	Thu Jun 17 11:33:08 1999
@@ -286,6 +286,7 @@
     char *pre;			/* prefix to insert (-P) */
     char *suf;			/* suffix to insert (-S) */
     char *group;		/* name of the group (-[JV]) */
+    char *ylist;		/* display list (-y) */
     char *rems;			/* remove suffix on chars... (-r) */
     char *remf;			/* function to remove suffix (-R) */
     char *ign;			/* ignored suffixes (-F) */
diff -u os/Zle/compctl.c Src/Zle/compctl.c
--- os/Zle/compctl.c	Thu Jun 17 09:24:30 1999
+++ Src/Zle/compctl.c	Thu Jun 17 11:29:19 1999
@@ -1727,7 +1727,7 @@
     }
     dat.ipre = dat.isuf = dat.ppre = dat.psuf = dat.prpre =
 	dat.pre = dat.suf = dat.group = dat.rems = dat.remf =
-	dat.ign = dat.exp = dat.apar = dat.opar = dat.dpar = NULL;
+	dat.ign = dat.exp = dat.apar = dat.opar = dat.dpar = dat.ylist = NULL;
     dat.match = NULL;
     dat.flags = 0;
     dat.aflags = CAF_MATCH;
@@ -1778,6 +1778,10 @@
 		    dat.aflags |= CAF_NOSORT;
 		sp = &(dat.group);
 		e = "group name expected after -%c";
+		break;
+	    case 'y':
+		sp = &(dat.ylist);
+		e = "string expected after -%c";
 		break;
 	    case 'i':
 		sp = &(dat.ipre);
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Thu Jun 17 11:18:04 1999
+++ Src/Zle/zle_tricky.c	Thu Jun 17 11:50:26 1999
@@ -3780,9 +3780,10 @@
 		} else
 		    dat->prpre = dupstring(dat->prpre);
 		/* Select the group in which to store the matches. */
-		if (dat->group) {
+		if (dat->group || dat->ylist) {
 		    endcmgroup(NULL);
-		    begcmgroup(dat->group, (dat->aflags & CAF_NOSORT));
+		    begcmgroup((dat->ylist ? NULL : dat->group),
+			       (dat->aflags & CAF_NOSORT));
 		    if (dat->aflags & CAF_NOSORT)
 			mgroup->flags |= CGF_NOSORT;
 		} else {
@@ -3869,6 +3870,10 @@
 		set_param(dat->opar, oparl);
 	    if (dat->dpar)
 		set_param(dat->dpar, dparl);
+	    if (dat->ylist) {
+		endcmgroup(get_user_var(dat->ylist));
+		begcmgroup("default", 0);
+	    }
 	} LASTALLOC;
     } SWITCHBACKHEAPS;
 
diff -u od/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- od/Zsh/compwid.yo	Thu Jun 17 09:24:40 1999
+++ Doc/Zsh/compwid.yo	Thu Jun 17 12:01:24 1999
@@ -347,7 +347,7 @@
 xitem([ tt(-P) var(prefix) ] [ tt(-S) var(suffix) ])
 xitem([ tt(-p) var(hidden-prefix) ] [ tt(-s) var(hidden-suffix) ])
 xitem([ tt(-i) var(ignored-prefix) ] [ tt(-I) var(ignored-suffix) ])
-xitem([ tt(-W) var(file-prefix) ])
+xitem([ tt(-W) var(file-prefix) ] [ tt(-y) var(array) ])
 xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ])
 xitem([ tt(-r) var(remove-chars) ] [ tt(-R) var(remove-func) ])
 xitem([ tt(-M) var(match-spec) ] [ tt(-O) var(array) ] [ tt(-A) var(array) ])
@@ -406,6 +406,12 @@
 )
 item(tt(-I) var(ignored-suffix))(
 Like tt(-i), but gives an ignored suffix.
+)
+item(tt(-y) var(array))(
+This gives a number of string to display instead of the matches. This
+is like the tt(-y) option of the tt(compctl) builtin command but the
+var(array) argument may only be the name of an array parameter or a
+literal array in parentheses containing the strings to display.
 )
 item(tt(-J) var(name))(
 As for tt(compctl) and tt(compgen), this gives the name of the group
diff -u -r oc/Builtins/_kill Completion/Builtins/_kill
--- oc/Builtins/_kill	Thu Jun 17 09:24:55 1999
+++ Completion/Builtins/_kill	Thu Jun 17 11:38:23 1999
@@ -9,7 +9,7 @@
 
   compgen -P '%' -j && ret=0
   list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
-  compgen -y '$list' -s '${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *}' &&
+  compadd -y list - ${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} &&
     ret=0
 
   return ret
diff -u -r oc/Builtins/_wait Completion/Builtins/_wait
--- oc/Builtins/_wait	Thu Jun 17 09:24:55 1999
+++ Completion/Builtins/_wait	Thu Jun 17 11:53:05 1999
@@ -15,6 +15,6 @@
 
 compgen -P '%' -j && ret=0
 list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
-compgen -y '$list' -s '${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *}' && ret=0
+compadd -y list - ${${${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0
 
 return ret
diff -u -r oc/User/_gdb Completion/User/_gdb
--- oc/User/_gdb	Thu Jun 17 09:24:59 1999
+++ Completion/User/_gdb	Thu Jun 17 11:56:11 1999
@@ -39,8 +39,9 @@
 
   if [[ $#w -gt 1 ]]; then
     _files && ret=0
-    list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${w[1]}}}")
-    compgen -y '$list' -s "\${\${\${(M)\${(f)\"\$(ps $compconfig[ps_args] 2>/dev/null)\"}:#*${w[1]:t}*}## #}%% *}" && ret=0
+    list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${w[1]:t}}}
+")
+    compadd -y list - ${${${(M)${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
 
     return ret
   else

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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