Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: aggregated options in completion lists
- X-seq: zsh-workers 17212
- From: Sven Wischnowsky <wischnow@xxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: aggregated options in completion lists
- Date: Thu, 23 May 2002 14:13:06 +0200
- In-reply-to: <20020521085001.GA3752@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <1021212626.4179.3.camel@xxxxxxxxxxxxxxxxxxxxx> <15584.50137.133265.722041@xxxxxxxxxxxxxxxxxx> <15593.65325.907154.556245@xxxxxxxxxxxxxxxxxx> <20020521085001.GA3752@xxxxxxxxxx>
Oliver Kiddle wrote:
> ...
>
> > Below is a patch. This is the simple implementation. One could thing
> > about how nice it were if the code could do:
> >
> > % foo <TAB>
> > description
> > --long-option1 --long-option2
> > --long-option3 -- description
> >
> > I.e., to not repeat the description for every sub-set of matches it
> > creates. That, however is much harder to implement and, if uses often,
> > could probably be slightly irritating, I think.
> >
> > Opinions?
>
> It would be better.
Ok, here is the patch.
> Another possibility would be to vary the position of the description
> from one line to the next which would be good in situations such as
> where only a couple out of many options have multiple options for the
> same description.
I'm not too sure I'd like that and anyway we'd have to find good
thresholds. Dunno.
Bye
Sven
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.80
diff -u -r1.80 computil.c
--- Src/Zle/computil.c 21 May 2002 08:04:35 -0000 1.80
+++ Src/Zle/computil.c 23 May 2002 12:13:01 -0000
@@ -260,8 +260,6 @@
*strp++ = gs;
}
- qsort(grps, lines, sizeof(Cdstr), cd_sort);
-
cd_state.gpre = 0;
for (i = 0; i < cd_state.maxg; i++)
cd_state.gpre += wids[i] + 2;
@@ -269,6 +267,23 @@
if (cd_state.gpre > cd_state.maxmlen && cd_state.maxglen > 1)
return 1;
+ qsort(grps, lines, sizeof(Cdstr), cd_sort);
+
+ for (i = lines, strp = grps; i > 1; i--, strp++) {
+ strp2 = strp + 1;
+ if (!strcmp((*strp)->desc, (*strp2)->desc))
+ continue;
+ for (j = i - 2, strp2++; j > 0; j--, strp2++)
+ if (!strcmp((*strp)->desc, (*strp2)->desc)) {
+ Cdstr tmp = *strp2;
+
+ memmove(strp + 2, strp + 1,
+ (strp2 - strp - 1) * sizeof(Cdstr));
+
+ *++strp = tmp;
+ i--;
+ }
+ }
expl = (Cdrun) zalloc(sizeof(*run));
expl->type = CRT_EXPL;
expl->strs = grps[0];
@@ -666,6 +681,10 @@
dpys = (char **) zalloc((i + 1) * sizeof(char *));
for (dp = dpys, str = run->strs; str; str = str->run) {
+ if (str->run && !strcmp(str->desc, str->run->desc)) {
+ *dp++ = ztrdup("");
+ continue;
+ }
memset(dbuf + cd_state.slen, ' ', dlen - 1);
dbuf[dlen + cd_state.slen - 1] = '\0';
strcpy(dbuf, cd_state.sep);
--
Sven Wischnowsky wischnow@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author