Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: compadd -X
- X-seq: zsh-workers 5543
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: compadd -X
- Date: Fri, 26 Feb 1999 14:53:20 +0100 (MET)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart asked how explanation strings could be used with the new style
completion stuff, which reminded me...
The patch below fixes a little memory problem (forgetting to copy the
string from `complist') which I didn't find before because
accidentally at the time I tried it, the memory wasn't overwritten.
The patch also adds the `-X' option to `compadd' (but not the `-Y'
option).
I also found some `...' in the manual. Have I sent it in this state??
Ugh, sorry, seems as if I didn't send the last version I had.
Bye
Sven
diff -u os/Zle/comp1.c Src/Zle/comp1.c
--- os/Zle/comp1.c Fri Feb 26 12:50:48 1999
+++ Src/Zle/comp1.c Fri Feb 26 14:32:16 1999
@@ -49,7 +49,7 @@
/* pointers to functions required by compctl and defined by zle */
/**/
-void (*addmatchesptr) _((char *, char *, char *, char *, char *, char *, char *, char *, char *, char *, int, int, Cmatcher, char **));
+void (*addmatchesptr) _((char *, char *, char *, char *, char *, char *, char *, char *, char *, char *, int, int, Cmatcher, char *, char **));
/**/
char *(*comp_strptr) _((int*, int*, int));
diff -u os/Zle/compctl.c Src/Zle/compctl.c
--- os/Zle/compctl.c Fri Feb 26 12:50:49 1999
+++ Src/Zle/compctl.c Fri Feb 26 14:32:04 1999
@@ -1676,7 +1676,7 @@
char *p, **sp, *e;
char *ipre = NULL, *ppre = NULL, *psuf = NULL, *prpre = NULL;
char *pre = NULL, *suf = NULL, *group = NULL, *m = NULL, *rs = NULL;
- char *ign = NULL, *rf = NULL;
+ char *ign = NULL, *rf = NULL, *expl = NULL;
int f = 0, a = 0, dm;
Cmatcher match = NULL;
@@ -1757,6 +1757,10 @@
e = "matching specification expected after -%c";
dm = 1;
break;
+ case 'X':
+ sp = &expl;
+ e = "string expected after -%c";
+ break;
case 'r':
f |= CMF_REMOVE;
sp = &rs;
@@ -1802,7 +1806,7 @@
match = cpcmatcher(match);
addmatchesptr(ipre, ppre, psuf, prpre, pre, suf, group,
- rs, rf, ign, f, a, match, argv);
+ rs, rf, ign, f, a, match, expl, argv);
freecmatcher(match);
return 0;
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Fri Feb 26 12:50:50 1999
+++ Src/Zle/zle_tricky.c Fri Feb 26 14:34:14 1999
@@ -3905,7 +3905,7 @@
void
addmatches(char *ipre, char *ppre, char *psuf, char *prpre, char *pre,
char *suf, char *group, char *rems, char *remf, char *ign,
- int flags, int aflags, Cmatcher match, char **argv)
+ int flags, int aflags, Cmatcher match, char *exp, char **argv)
{
char *s, *t, *e, *me, *ms, *lipre = NULL, *lpre, *lsuf, **aign = NULL;
int lpl, lsl, i, pl, sl, test, bpl, bsl, llpl, llsl;
@@ -3932,6 +3932,13 @@
* was invoked. */
SWITCHHEAPS(compheap) {
HEAPALLOC {
+ if (exp) {
+ expl = (Cexpl) halloc(sizeof(struct cexpl));
+ expl->count = expl->fcount = 0;
+ expl->str = dupstring(exp);
+ } else
+ expl = NULL;
+
/* Store the matcher in our stack of matchers. */
if (match) {
mst.next = mstack;
@@ -4190,6 +4197,8 @@
}
}
compnmatches = mnum;
+ if (exp)
+ addexpl();
} LASTALLOC;
} SWITCHBACKHEAPS;
@@ -6495,7 +6504,8 @@
}
if ((tt = cc->explain)) {
- if (cc->mask & CC_EXPANDEXPL && !parsestr(tt = dupstring(tt))) {
+ tt = dupstring(tt);
+ if ((cc->mask & CC_EXPANDEXPL) && !parsestr(tt)) {
singsub(&tt);
untokenize(tt);
}
@@ -6509,7 +6519,8 @@
begcmgroup("default", 0);
}
else if ((tt = cc->explain)) {
- if (cc->mask & CC_EXPANDEXPL && !parsestr(tt = dupstring(tt))) {
+ tt = dupstring(tt);
+ if ((cc->mask & CC_EXPANDEXPL) && !parsestr(tt)) {
singsub(&tt);
untokenize(tt);
}
diff -u od/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- od/Zsh/compwid.yo Fri Feb 26 12:50:16 1999
+++ Doc/Zsh/compwid.yo Fri Feb 26 14:51:40 1999
@@ -162,7 +162,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(-W) var(file-prefix) ])
-xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ])
+xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ])
xitem([ tt(-r) var(remove-chars) ] [ tt(-R) var(remove-func) ])
item([ tt(-M) var(match-spec) ] [ tt(--) ] [ var(words) ... ])(
@@ -182,14 +182,17 @@
Like tt(-P) but gives a string that has to be inserted after the match.
)
item(tt(-p) var(hidden-prefix))(
-This gives a string that should be
-...
+This gives a string that should be inserted in the line before the
+match but that should not appear in the list of matches.
)
item(tt(-s) var(hidden-suffix))(
-...
+Like `tt(-p)', but gives a string to insert after the match.
)
item(tt(-i) var(ignored-prefix))(
-...
+This gives a string to insert into the command line just before any
+string given with the `tt(-P)' option. Without `tt(-P)' the string is
+inserted before the string given with `tt(-p)' or directly before the
+match.
)
item(tt(-J) var(name))(
As for tt(compctl) and tt(complist) this gives the name of the group
@@ -197,6 +200,10 @@
)
item(tt(-V) var(name))(
Like tt(-J) but naming a unsorted group.
+)
+item(tt(-X) var(explanation))(
+The var(explanation) string will be printed with the list of matches,
+as for tt(compctl -X).
)
item(tt(-q))(
This flag has the same meaning as for tt(compctl) and tt(complist),
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author