about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-02 10:30:41 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-02 10:30:41 +0000
commit997d40c05d608fd849bb0f4377f31218dc266b02 (patch)
treec7c222feed8b09bf976fd3d50b7209dc3b2898f7 /Src
parent304d5f9b3974f33c566b8e57bc1b79a99e9955d9 (diff)
downloadzsh-997d40c05d608fd849bb0f4377f31218dc266b02.tar.gz
zsh-997d40c05d608fd849bb0f4377f31218dc266b02.tar.xz
zsh-997d40c05d608fd849bb0f4377f31218dc266b02.zip
add -x option to compadd to display message unconditionally
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/comp.h1
-rw-r--r--Src/Zle/compcore.c26
-rw-r--r--Src/Zle/complete.c8
3 files changed, 33 insertions, 2 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index f513d4a5a..9239fbee0 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -257,6 +257,7 @@ struct cadata {
     char *opar;			/* array to store originals in (-O) */
     char *dpar;			/* array to delete non-matches in (-D) */
     char *disp;			/* array with display lists (-d) */
+    char *mesg;			/* message to show unconditionally (-x) */
 };
 
 /* List data. */
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 8e713348f..44ec8ef6a 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1538,6 +1538,8 @@ addmatches(Cadata dat, char **argv)
 		endcmgroup(NULL);
 		begcmgroup("default", 0);
 	    }
+	    if (dat->mesg)
+		addmesg(dat->mesg);
 	} SWITCHBACKHEAPS;
 
 	return 1;
@@ -1785,6 +1787,8 @@ addmatches(Cadata dat, char **argv)
 	    endcmgroup(NULL);
 	    begcmgroup("default", 0);
 	}
+	if (dat->mesg)
+	    addmesg(dat->mesg);
 	if (*argv) {
 	    if (dat->pre)
 		dat->pre = dupstring(dat->pre);
@@ -2366,6 +2370,28 @@ addexpl(void)
     newmatches = 1;
 }
 
+/* Add a message to the current group. Make sure it is shown. */
+
+/**/
+mod_export void
+addmesg(char *mesg)
+{
+    LinkNode n;
+    Cexpl e;
+
+    for (n = firstnode(expls); n; incnode(n)) {
+	e = (Cexpl) getdata(n);
+	if (!strcmp(mesg, e->str))
+	    return;
+    }
+    e = (Cexpl) zhalloc(sizeof(*e));
+    e->count = e->fcount = 1;
+    e->str = dupstring(mesg);
+    addlinknode(expls, e);
+    newmatches = 1;
+    mgroup->new = 1;
+}
+
 /* The comparison function for matches (used for sorting). */
 
 /**/
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 7a15eb077..8c8950303 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -413,7 +413,7 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 	zwarnnam(name, "can only be called from completion function", NULL, 0);
 	return 1;
     }
-    dat.ipre = dat.isuf = dat.ppre = dat.psuf = dat.prpre =
+    dat.ipre = dat.isuf = dat.ppre = dat.psuf = dat.prpre = dat.mesg =
 	dat.pre = dat.suf = dat.group = dat.rems = dat.remf = dat.disp = 
 	dat.ign = dat.exp = dat.apar = dat.opar = dat.dpar = NULL;
     dat.match = NULL;
@@ -507,6 +507,10 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 		sp = &(dat.exp);
 		e = "string expected after -%c";
 		break;
+	    case 'x':
+		sp = &(dat.mesg);
+		e = "string expected after -%c";
+		break;
 	    case 'r':
 		dat.flags |= CMF_REMOVE;
 		sp = &(dat.rems);
@@ -575,7 +579,7 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 
  ca_args:
 
-    if (!*argv && !dat.group &&
+    if (!*argv && !dat.group && !dat.mesg &&
 	!(dat.aflags & (CAF_NOSORT|CAF_UNIQALL|CAF_UNIQCON)))
 	return 1;