From 997d40c05d608fd849bb0f4377f31218dc266b02 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Tue, 2 May 2000 10:30:41 +0000 Subject: add -x option to compadd to display message unconditionally --- Src/Zle/comp.h | 1 + Src/Zle/compcore.c | 26 ++++++++++++++++++++++++++ Src/Zle/complete.c | 8 ++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) (limited to 'Src/Zle') 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; -- cgit 1.4.1