zsh-workers
 help / color / mirror / code / Atom feed
* About the new long/short options changes
@ 2001-07-20  5:01 Bart Schaefer
  2001-07-20  7:38 ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2001-07-20  5:01 UTC (permalink / raw)
  To: zsh-workers

Just now had a chance to compile this up and try it.

I mostly like the way it looks in listings, though I wish it would line up
the single-letter options in a column (or else always list the short form
first when there is one, though that might look odd when some of the long
forms have no short form).

However, I strongly *dis*like the way it works in menu-selection.  So much
so that I'd rather just turn it off entirely if it can't be made to work
better.  In particular I don't want selection to consume twice as many
lines (half of which are largely blank) as listing consumes.  I find it
better to have listing consume more lines in the first place than to have
the display change so radically when switching from listing to selection.

Sven wrote:
} Adding a style so that menu selection allows to select only one of the
} options would be a lot easier to write.  Making it display only one of
} the options per line (instead of a duplicated `-H, --help') is something
} I thought about, too, but that would require that we are able to tell in
} _describe if we are going to enter menu selection.  And that isn't
} always possible because it might depend on the number of matches
} generated.  If people would be satisfied with an approximation, i.e.
} simplifying the strings if it thinks it will enter menu selection, but
} probably sometimes entering menu selection with duplicated `-H, --help',
} I could probably implement that without much work.

I would not be happy with an approximation (if that's what gets done, so
be it, I'll just turn it all off).  Offering only one of the choices when
menu-selecting would be much better than what's happening now.  Best would
be if both could be selected right where they first appear, from the same
single line with the explanation string (which is, in part, why I ask for
the short forms to appear in a column).

} And about using `"' instead of the `|': [...]
} 
}   % foo -<TAB>
}   -H  --help    -- print help
}       "         --     "

This would, IMO, serve no purpose other than to emphasize the amount of
screen real estate that we're wasting on useless white space.

} Anyone else want to draw some pictures? ;-)

What I'd like to see, I think, is something like the following (where `['
and `]' delimit the menu-selection highlight).  For purposes of drawing
a more interesting picure, suppose that the -X option doesn't exist.

  Completing option
 [--binary                ] -b -- Unix line endings LF
  --change-cygdrive-prefix  -c -- cygdrive prefix
  --cygwin-executable          -- all files under mountpoint are cygwin e
  --executable              -x -- all files under mountpoint are executab
  --force                   -f -- be silent
  --import-old-mounts       -i -- import old mounts
  --show-cygdrive-prefix    -p -- show cygdrive prefix
  --system                  -s -- system-wide mount point
  --text                    -t -- (default) DOS line endings CR-LF
  --user                    -u -- (default)user private mount point

TAB to the next selection (list now truncated for brevity):

  Completing option
  --binary                 [-b -- Unix line endings LF                   ]
  --change-cygdrive-prefix  -c -- cygdrive prefix
  --cygwin-executable          -- all files under mountpoint are cygwin e
  --executable              -x -- all files under mountpoint are executab
  --force                   -f -- be silent

After three more TABs:

  Completing option
  --binary                  -b -- Unix line endings LF
  --change-cygdrive-prefix  -c -- cygdrive prefix
 [--cygwin-executable          -- all files under mountpoint are cygwin e]
  --executable              -x -- all files under mountpoint are executab
  --force                   -f -- be silent

See where this is going?

I recognize that this is probably quite difficult to pull off, especially
in cases where there might be more than two options that have the same
description.  So I'd settle for only being able to select one of the
choices on each line (provided that ordinary menu completion can at least
optionally still cycle through all possibilities).

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-20  5:01 About the new long/short options changes Bart Schaefer
@ 2001-07-20  7:38 ` Sven Wischnowsky
  2001-07-20  9:26   ` Bart Schaefer
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-20  7:38 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:

> I mostly like the way it looks in listings, though I wish it would line up
> the single-letter options in a column (or else always list the short form
> first when there is one, though that might look odd when some of the long
> forms have no short form).

My only problem with that is that there may be cases where we have more
than two matches with the same description, something like:

--foo          --Foo  --fOO  -- turn on fooing
--long-option                -- turn on longing

If that gets out of hand... But then I don't know how often this will
happen at all.

> However, I strongly *dis*like the way it works in menu-selection.  So much
> so that I'd rather just turn it off entirely if it can't be made to work
> better.  In particular I don't want selection to consume twice as many
> lines (half of which are largely blank) as listing consumes.  I find it
> better to have listing consume more lines in the first place than to have
> the display change so radically when switching from listing to selection.

I think you have seen from the discussion that I'm not happy about it,
too.  One thing we could do is allow users to de-select the long/short
form as has been suggested (there is a slight problem with
auto-descriptions, btw).

The other is to try to implement what you and we prefer anyway:

> ...
> 
> What I'd like to see, I think, is something like the following (where `['
> and `]' delimit the menu-selection highlight).  For purposes of drawing
> a more interesting picure, suppose that the -X option doesn't exist.
> 
>   Completing option
>  [--binary                ] -b -- Unix line endings LF
> ...
> 
> TAB to the next selection (list now truncated for brevity):
> 
>   Completing option
>   --binary                 [-b -- Unix line endings LF                   ]
> ...

Really that or: 

    --binary                 [-b] -- Unix line endings LF

?
 
> After three more TABs:
> 
>   Completing option
>   --binary                  -b -- Unix line endings LF
>   --change-cygdrive-prefix  -c -- cygdrive prefix
>  [--cygwin-executable          -- all files under mountpoint are cygwin e]
> ...

Same here.

I have some ideas how we could achive this, part of the stuff we need is
already there.  Think of some combination of list-packed, list-rows-first
and `dummy' matches that get slots in the listing but show nothing and
can't be selected.  We'll have to find a way to make this easy to select
and handle.  I'll think about this at the weekend.


What are we coming to... ;-)


Bye
  Sven


-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-20  7:38 ` Sven Wischnowsky
@ 2001-07-20  9:26   ` Bart Schaefer
  2001-07-20  9:43     ` Andrej Borsenkow
  2001-07-25  8:49     ` Sven Wischnowsky
  0 siblings, 2 replies; 17+ messages in thread
From: Bart Schaefer @ 2001-07-20  9:26 UTC (permalink / raw)
  To: zsh-workers

On Jul 20,  9:38am, Sven Wischnowsky wrote:
} Subject: Re: About the new long/short options changes
}
} Bart Schaefer wrote:
} 
} > I mostly like the way it looks in listings, though I wish

Not so incidentally, Sven:  That praise sounds rather faint, so I want to
say that I really do think the stuff you come up with is quite amazing,
and I apologize for not saying so more often.

} > TAB to the next selection (list now truncated for brevity):
} > 
} >   Completing option
} >   --binary                 [-b -- Unix line endings LF                   ]
} > ...
} 
} Really that or: 
} 
}     --binary                 [-b] -- Unix line endings LF
} 
} ?

That would be fine, too; but as the current selection code highlights
both the option name and the description, I thought it might be easier
to split the display into only two kinds of columns:  Options for which
the descriptions have been suppressed because they're identical to some
other option, and the options that have that identical description.  On
some hunch that it might be easier to line up the rows that way.
 
} I have some ideas how we could achive this, part of the stuff we need is
} already there.  Think of some combination of list-packed, list-rows-first
} and `dummy' matches that get slots in the listing but show nothing and
} can't be selected.

Yes, that is what I was thinking, though rather than dummy matches I
was thinking about chopping up the display into groups with different
columnations, as already happens when matches are explicitly added in
different groups.

} What are we coming to... ;-)

I'm not sure ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: About the new long/short options changes
  2001-07-20  9:26   ` Bart Schaefer
@ 2001-07-20  9:43     ` Andrej Borsenkow
  2001-07-25  8:49     ` Sven Wischnowsky
  1 sibling, 0 replies; 17+ messages in thread
From: Andrej Borsenkow @ 2001-07-20  9:43 UTC (permalink / raw)
  To: zsh-workers

> 
> Not so incidentally, Sven:  That praise sounds rather faint, so I want to
> say that I really do think the stuff you come up with is quite amazing,
> and I apologize for not saying so more often.
>

Yes. I wish to second every word of it.
 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-20  9:26   ` Bart Schaefer
  2001-07-20  9:43     ` Andrej Borsenkow
@ 2001-07-25  8:49     ` Sven Wischnowsky
  2001-07-25  9:15       ` Borsenkow Andrej
  1 sibling, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-25  8:49 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:

> ...
>  
> } I have some ideas how we could achive this, part of the stuff we need is
> } already there.  Think of some combination of list-packed, list-rows-first
> } and `dummy' matches that get slots in the listing but show nothing and
> } can't be selected.
> 
> Yes, that is what I was thinking, though rather than dummy matches I
> was thinking about chopping up the display into groups with different
> columnations, as already happens when matches are explicitly added in
> different groups.

I first thought about that, too, but it would require some serious
changes to the listing code, so I decided to first try it with only
those dummy matches I mentioned.

The result is the patch below, which is already quite satisfying, I
think.  It took a bit longer and the patch is a bit larger, because of
the needed re-implementation of the guts of compdescribe.  And because I
wasn't too happy with the amount of screen space wasted due to
LIST_TYPES.  So I dug into the listing code to make it add that extra
space only for groups that contain at least one file [*] and I also made
it try a bit harder to find an optimal columnation for LIST_PACKED.

If you try it, you'll see that this now behaves slightly different when
completion options with and without groups in menu selection.  In the
first case, only the matches are highlighted, in the latter case the
whole lines are highlighted.  I'm torn in two here, because I like it
that the description is highlighted, too if there is a one-to-one
correspondence between matches and descriptions.  If I get complaints, I
can change it quite easily, though.  But then I'd prefer to find a
solution that makes that more easily usable from shell code (and I'm not
happy that the code that uses such line-oriented dummy matches currently
has to take care of things like the screen width itself), so that we
could use it for, e.g., process listings and the like, too.  I was
thinking about allowing display strings to be defined as `expandable',
meaning that we would like to see as much of the strings as the screen
width permits, but that they may be shortened to make them fit on the
current line of the completion listing.  But that, too, would require
some serious changes to the listing code.  Hm.
 

Bye
  Sven

[*] This does not change it to not add a space to normal files -- the
    thing we discussed some time ago, when comparing it to what GNU ls
    does.

Index: Completion/Base/Utility/_describe
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_describe,v
retrieving revision 1.3
diff -u -r1.3 _describe
--- Completion/Base/Utility/_describe	2001/07/19 08:40:37	1.3
+++ Completion/Base/Utility/_describe	2001/07/25 08:36:54
@@ -2,8 +2,9 @@
 
 # This can be used to add options or values with descriptions as matches.
 
-local _opt _expl _tmps _tmpd _tmph _tmpmd _tmpms _tmpmh
-local _type=values _descr _ret=1 _showd _nm _hide _args _grp
+local _opt _expl _tmpm _tmpd
+local _type=values _descr _ret=1 _showd _nm _hide _args _grp _sep
+local csl="$compstate[list]" csl2
 
 # Get the option.
 
@@ -27,6 +28,7 @@
 
   _argv=( "$@" )
   _grp=(-g)
+  _sep='-- '
   _new=( "$1" )
   shift
 
@@ -66,43 +68,33 @@
   set - "$_argv[@]"
 else
   _grp=()
+  _sep=' -- '
 fi
 
 _descr="$1"
 shift
 
 [[ "$_type" = options ]] &&
-    zstyle -t ":completion:${curcontext}:options" prefix-hidden && _hide=yes
+    zstyle -t ":completion:${curcontext}:options" prefix-hidden &&
+        _hide="${(M)PREFIX##(--|[-+])}"
 
 _tags "$_type"
 while _tags; do
   while _next_label "$_type" _expl "$_descr"; do
 
     if [[ -n "$_showd" ]]; then
-      compdescribe -I ' -- ' "$_grp[@]" "$@"
+      compdescribe -I "$_hide" "$_sep" _expl "$_grp[@]" "$@"
     else
-      compdescribe -i "$@"
+      compdescribe -i "$_hide" "$@"
     fi
 
-    while compdescribe -g _args _tmpd _tmpmd _tmph _tmpmh _tmps _tmpms; do
+    compstate[list]="$csl"
 
-      # See if we should remove the option prefix characters.
+    while compdescribe -g csl2 _args _tmpm _tmpd; do
 
-      if [[ -n "$_hide" ]]; then
-        if [[ "$PREFIX" = --* ]]; then
-          _tmpd=( "${(@)_tmpd#--}" )
-          _tmph=( "${(@)_tmph#--}" )
-          _tmps=( "${(@)_tmps#--}" )
-        elif [[ "$PREFIX" = [-+]* ]]; then
-          _tmpd=( "${(@)_tmpd#[-+]}" )
-          _tmph=( "${(@)_tmph#[-+]}" )
-          _tmps=( "${(@)_tmps#[-+]}" )
-        fi
-      fi
-
-      compadd "$_args[@]" "$_expl[@]" -ld _tmpd -a _tmpmd && _ret=0
-      compadd -n "$_args[@]" "$_expl[@]" -ld _tmph -a _tmpmh && _ret=0
-      compadd "$_args[@]" "$_expl[@]" -d _tmps  -a _tmpms && _ret=0
+      compstate[list]="$csl $csl2"
+
+      compadd "$_args[@]" -d _tmpd -a _tmpm && _ret=0
     done
   done
   (( _ret )) || return 0
Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.30
diff -u -r1.30 compwid.yo
--- Doc/Zsh/compwid.yo	2001/04/01 16:19:17	1.30
+++ Doc/Zsh/compwid.yo	2001/07/25 08:36:57
@@ -441,6 +441,7 @@
 xitem([ tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ] [ tt(-x) var(message) ])
 xitem([ tt(-r) var(remove-chars) ] [ tt(-R) var(remove-func) ])
 xitem([ tt(-D) var(array) ] [ tt(-O) var(array) ] [ tt(-A) var(array) ])
+xitem([ tt(-E) var(number) ])
 item([ tt(-M) var(match-spec) ] [ tt(--) ] [ var(words) ... ])(
 
 This builtin command can be used to add matches directly and control
@@ -663,6 +664,17 @@
 match.  If no string is given, it will be shown as a string containing 
 the strings that would be inserted for the other matches, truncated to 
 the width of the screen.
+)
+item(tt(-E))(
+This option adds var(number) empty matches after the var(words) have
+been added.  An empty match takes up space in completion listings but
+will never be inserted in the line and can't be selected with menu
+completion or menu selection.  This makes empty matches only useful to
+format completion lists and to make explanatory string be shown in
+completion lists (since empty matches can be given display strings
+with the tt(-d) option).  And because all but one empty string would
+otherwise be removed, this option implies the tt(-V) and tt(-1)
+options (even if an explicit tt(-J) option is given).
 )
 xitem(tt(-))
 item(tt(-)tt(-))(
Index: Src/Zle/comp.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/comp.h,v
retrieving revision 1.10
diff -u -r1.10 comp.h
--- Src/Zle/comp.h	2001/01/11 10:06:50	1.10
+++ Src/Zle/comp.h	2001/07/25 08:36:58
@@ -85,6 +85,7 @@
 #define CGF_UNIQCON 16		/* remove consecutive duplicates */
 #define CGF_PACKED  32		/* LIST_PACKED for this group */
 #define CGF_ROWS    64		/* LIST_ROWS_FIRST for this group */
+#define CGF_FILES   128		/* contains file names */
 
 /* This is the struct used to hold matches. */
 
@@ -125,6 +126,7 @@
 #define CMF_MULT     (1<<11)	/* string appears more than once */
 #define CMF_FMULT    (1<<12)	/* first of multiple equal strings */
 #define CMF_ALL      (1<<13)	/* a match representing all other matches */
+#define CMF_DUMMY    (1<<14)	/* unselectable dummy match */
 
 /* Stuff for completion matcher control. */
 
@@ -264,6 +266,7 @@
     char *dpar;			/* array to delete non-matches in (-D) */
     char *disp;			/* array with display lists (-d) */
     char *mesg;			/* message to show unconditionally (-x) */
+    int dummies;               /* add that many dummy matches */
 };
 
 /* List data. */
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.46
diff -u -r1.46 compcore.c
--- Src/Zle/compcore.c	2001/07/10 09:25:43	1.46
+++ Src/Zle/compcore.c	2001/07/25 08:37:12
@@ -1558,6 +1558,40 @@
     return ret;
 }
 
+static void
+addmatch(char *str, int flags, char ***dispp, int line)
+{
+    Cmatch cm = (Cmatch) zhalloc(sizeof(struct cmatch));
+    char **disp = *dispp;
+
+    memset(cm, 0, sizeof(struct cmatch));
+    cm->str = dupstring(str);
+    cm->flags = (flags |
+                 (complist ?
+                  ((strstr(complist, "packed") ? CMF_PACKED : 0) |
+                   (strstr(complist, "rows")   ? CMF_ROWS   : 0)) : 0));
+    if (disp) {
+        if (!*++disp)
+            disp = NULL;
+        if (disp)
+            cm->disp = dupstring(*disp);
+    } else if (line) {
+        cm->disp = dupstring("");
+        cm->flags |= CMF_DISPLINE;
+    }
+    mnum++;
+    ainfo->count++;
+    if (curexpl)
+        curexpl->count++;
+
+    addlinknode(matches, cm);
+
+    newmatches = 1;
+    mgroup->new = 1;
+
+    *dispp = disp;
+}
+
 /* This is used by compadd to add a couple of matches. The arguments are
  * the strings given via options. The last argument is the array with
  * the matches. */
@@ -1583,7 +1617,7 @@
     Brinfo bp, bpl = brbeg, obpl, bsl = brend, obsl;
     Heap oldheap;
 
-    if (!*argv && !(dat->aflags & CAF_ALL)) {
+    if (!*argv && !dat->dummies && !(dat->aflags & CAF_ALL)) {
 	SWITCHHEAPS(oldheap, compheap) {
 	    /* Select the group in which to store the matches. */
 	    gflags = (((dat->aflags & CAF_NOSORT ) ? CGF_NOSORT  : 0) |
@@ -1602,6 +1636,8 @@
 
 	return 1;
     }
+    if (dat->dummies)
+        dat->aflags = dat->aflags | CAF_NOSORT | CAF_UNIQALL;
     for (bp = brbeg; bp; bp = bp->next)
 	bp->curpos = ((dat->aflags & CAF_QUOTE) ? bp->pos : bp->qpos);
     for (bp = brend; bp; bp = bp->next)
@@ -2022,35 +2058,12 @@
 	if (dat->exp)
 	    addexpl();
 	if (!hasallmatch && (dat->aflags & CAF_ALL)) {
-	    Cmatch cm = (Cmatch) zhalloc(sizeof(struct cmatch));
-
-	    memset(cm, 0, sizeof(struct cmatch));
-	    cm->str = dupstring("<all>");
-	    cm->flags = (dat->flags | CMF_ALL |
-			 (complist ?
-			  ((strstr(complist, "packed") ? CMF_PACKED : 0) |
-			   (strstr(complist, "rows")   ? CMF_ROWS   : 0)) : 0));
-	    if (disp) {
-		if (!*++disp)
-		    disp = NULL;
-		if (disp)
-		    cm->disp = dupstring(*disp);
-	    } else {
-		cm->disp = dupstring("");
-		cm->flags |= CMF_DISPLINE;
-	    }
-	    mnum++;
-	    ainfo->count++;
-	    if (curexpl)
-		curexpl->count++;
-
-	    addlinknode(matches, cm);
-
-	    newmatches = 1;
-	    mgroup->new = 1;
-
+            addmatch("<all>", dat->flags | CMF_ALL, &disp, 1);
 	    hasallmatch = 1;
 	}
+        while (dat->dummies--)
+            addmatch("", dat->flags | CMF_DUMMY, &disp, 0);
+
     } SWITCHBACKHEAPS(oldheap);
 
     /* We switched back to the current heap, now restore the stack of
Index: Src/Zle/complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.16
diff -u -r1.16 complete.c
--- Src/Zle/complete.c	2001/05/31 09:44:00	1.16
+++ Src/Zle/complete.c	2001/07/25 08:37:16
@@ -435,6 +435,7 @@
     dat.match = NULL;
     dat.flags = 0;
     dat.aflags = CAF_MATCH;
+    dat.dummies = 0;
 
     for (; *argv && **argv ==  '-'; argv++) {
 	if (!(*argv)[1]) {
@@ -564,6 +565,23 @@
 		break;
 	    case 'l':
 		dat.flags |= CMF_DISPLINE;
+		break;
+	    case 'E':
+                if (p[1]) {
+                    dat.dummies = atoi(p + 1);
+                    p = "" - 1;
+                } else if (argv[1]) {
+                    argv++;
+                    dat.dummies = atoi(*argv);
+                    p = "" - 1;
+                } else {
+                    zwarnnam(name, "number expected after -%c", NULL, *p);
+                    return 1;
+                }
+                if (dat.dummies < 0) {
+                    zwarnnam(name, "invalid number: %d", NULL, dat.dummies);
+                    return 1;
+                }
 		break;
 	    case '-':
 		argv++;
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.43
diff -u -r1.43 complist.c
--- Src/Zle/complist.c	2001/07/18 13:10:10	1.43
+++ Src/Zle/complist.c	2001/07/25 08:37:22
@@ -1394,7 +1394,7 @@
 
     mlastm = m->gnum;
     if (m->disp && (m->flags & CMF_DISPLINE)) {
-	if (mselect >= 0) {
+	if (mselect >= 0 && !(m->flags & CMF_DUMMY)) {
 	    int mm = (mcols * ml), i;
 
 	    for (i = mcols; i--; ) {
@@ -1441,7 +1441,7 @@
 	} else
 	    mx = mc * g->width;
 
-	if (mselect >= 0) {
+	if (mselect >= 0 && !(m->flags & CMF_DUMMY)) {
 	    int mm = mcols * ml, i;
 
 	    for (i = (width ? width : mcols); i--; ) {
@@ -1482,7 +1482,7 @@
 	len = niceztrlen(m->disp ? m->disp : m->str);
 	mlprinted = len / columns;
 
-	if (isset(LISTTYPES) && buf) {
+	if ((g->flags & CGF_FILES) && buf) {
 	    if (m->gnum != mselect) {
 		zcoff();
 		zcputs(&mcolors, g->name, COL_TC);
@@ -1684,6 +1684,7 @@
     noselect = 1;
     while ((menuacc &&
 	    !hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) ||
+	   ((*minfo.cur)->flags & CMF_DUMMY) ||
 	   (((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) &&
 	    (!(*minfo.cur)->str || !*(*minfo.cur)->str)))
 	do_menucmp(0);
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.38
diff -u -r1.38 compresult.c
--- Src/Zle/compresult.c	2001/07/18 13:10:10	1.38
+++ Src/Zle/compresult.c	2001/07/25 08:37:30
@@ -1160,6 +1160,7 @@
 	}
     } while ((menuacc &&
 	      !hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) ||
+             ((*minfo.cur)->flags & CMF_DUMMY) ||
 	     (((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) &&
 	      (!(*minfo.cur)->str || !*(*minfo.cur)->str)));
     /* ... and insert it into the command line. */
@@ -1183,6 +1184,7 @@
 	    minfo.cur--;
     } while ((menuacc &&
 	      !hasbrpsfx(*(minfo.cur), minfo.prebr, minfo.postbr)) ||
+	     ((*minfo.cur)->flags & CMF_DUMMY) ||
 	     (((*minfo.cur)->flags & (CMF_NOLIST | CMF_MULT)) &&
 	      (!(*minfo.cur)->str || !*(*minfo.cur)->str)));
     metafy_line();
@@ -1378,7 +1380,7 @@
     Cmgroup g;
     Cmatch *p, m;
     Cexpl *e;
-    int hidden = 0, nlist = 0, nlines = 0, add = 2 + isset(LISTTYPES);
+    int hidden = 0, nlist = 0, nlines = 0, add;
     int max = 0, i;
     VARARR(int, mlens, nmatches + 1);
 
@@ -1392,6 +1394,7 @@
     for (g = amatches; g; g = g->next) {
 	char **pp = g->ylist;
 	int nl = 0, l, glong = 1, gshort = columns, ndisp = 0, totl = 0;
+        int hasf = 0;
 
 	g->flags |= CGF_PACKED | CGF_ROWS;
 
@@ -1437,6 +1440,8 @@
 	    }
 	} else if (!onlyexpl) {
 	    for (p = g->matches; (m = *p); p++) {
+                if (m->flags & CMF_FILE)
+                    hasf = 1;
 		if (menuacc && !hasbrpsfx(m, minfo.prebr, minfo.postbr)) {
 		    m->flags |= CMF_HIDE;
 		    continue;
@@ -1496,6 +1501,11 @@
 		e++;
 	    }
 	}
+        if (isset(LISTTYPES) && hasf) {
+            g->flags |= CGF_FILES;
+            add = 3;
+        } else
+            add = 2;
 	g->totl = totl + (ndisp * add);
 	g->dcount = ndisp;
 	g->width = glong + add;
@@ -1513,6 +1523,7 @@
 	int *ws, tlines, tline, tcols, maxlen, nth, width, glines;
 
 	for (g = amatches; g; g = g->next) {
+            add = 2 + !!(g->flags & CGF_FILES);
 	    glines = 0;
 
 	    zfree(g->widths, 0);
@@ -1523,7 +1534,8 @@
 		    if (g->cols) {
 			glines += (arrlen(pp) + g->cols - 1) / g->cols;
 			if (g->cols > 1)
-			    g->width += (max - (g->width * g->cols - add)) / g->cols;
+			    g->width += ((max - (g->width * g->cols - add)) /
+                                         g->cols);
 		    } else {
 			g->cols = 1;
 			g->width = 1;
@@ -1559,6 +1571,8 @@
 	    if (!(g->flags & CGF_PACKED))
 		continue;
 
+            add = 2 + !!(g->flags & CGF_FILES);
+
 	    ws = g->widths = (int *) zalloc(columns * sizeof(int));
 	    memset(ws, 0, columns * sizeof(int));
 	    tlines = g->lins;
@@ -1666,7 +1680,7 @@
 	    } else if (g->width) {
 		if (g->flags & CGF_ROWS) {
 		    int addlen, count, tcol, maxlines = 0, llines, i;
-		    int beg = columns / g->shortest, end = g->cols;
+		    int beg = columns / g->shortest, end = g->cols, fe = 1;
 		    Cmatch *first;
 
 		    while (1) {
@@ -1677,7 +1691,8 @@
 				 count = g->dcount;
 			     count > 0; count--) {
 			    m = *p;
-			    addlen = mlens[m->gnum] + add;
+			    addlen = (mlens[m->gnum] +
+                                      (tcol == tcols - 1 ? 0 : add));
 			    if (addlen > maxlen)
 				maxlen = addlen;
 			    for (i = tcols; i && *p; i--)
@@ -1706,15 +1721,21 @@
 			    break;
 
 			if (beg == end) {
-			    beg--;
-			    end--;
+                            if (fe) {
+                                beg += 2;
+                                end += 2;
+                                fe = 0;
+                            } else {
+                                beg--;
+                                end--;
+                            }
 			} else if (width < columns) {
 			    if ((end = tcols) == beg - 1)
 				end++;
 			} else {
 			    if ((beg = tcols) - 1 == end)
 				end++;
-			}
+                        }
 		    }
 		    if (tcols > g->cols)
 			tlines = maxlines;
@@ -1723,7 +1744,7 @@
 		    int smask = ((showall ? 0 : (CMF_NOLIST | CMF_MULT)) |
 				 CMF_HIDE);
 		    int beg = ((g->totl + columns) / columns);
-		    int end = g->lins;
+		    int end = g->lins, fe = 1;
 
 		    while (1) {
 			tlines = (beg + end) >> 1;
@@ -1755,8 +1776,14 @@
 			    break;
 
 			if (beg == end) {
-			    beg++;
-			    end++;
+                            if (fe) {
+                                beg -= 2;
+                                end -= 2;
+                                fe = 0;
+                            } else {
+                                beg++;
+                                end++;
+                            }
 			} else if (width < columns) {
 			    if ((end = tlines) == beg + 1)
 				end--;
@@ -1783,6 +1810,7 @@
 	    }
 	}
 	for (g = amatches; g; g = g->next) {
+            add = 2 + !!(g->flags & CGF_FILES);
 	    if (g->widths) {
 		int *p, a = (max - g->totl + add) / g->cols;
 
@@ -2152,7 +2180,7 @@
 	nicezputs(m->str, shout);
 	len = niceztrlen(m->str);
 
-	if (isset(LISTTYPES) && buf) {
+	if ((g->flags & CGF_FILES) && buf) {
 	    putc(file_type(buf->st_mode), shout);
 	    len++;
 	}
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.66
diff -u -r1.66 computil.c
--- Src/Zle/computil.c	2001/07/20 10:54:38	1.66
+++ Src/Zle/computil.c	2001/07/25 08:37:34
@@ -35,6 +35,7 @@
 
 typedef struct cdset *Cdset;
 typedef struct cdstr *Cdstr;
+typedef struct cdrun *Cdrun;
 
 struct cdstate {
     int showd;			/* != 0 if descriptions should be shown */
@@ -43,6 +44,11 @@
     Cdset sets;			/* the sets of matches */
     int pre;                    /* longest prefix (before description) */
     int suf;                    /* longest suffix (description) */
+    int maxg;                   /* size of largest group */
+    int groups;                 /* number of groups */
+    int descs;                  /* number of non-group matches with desc */
+    int gpre;                   /* prefix length for group display */
+    Cdrun runs;                 /* runs to report to shell code */
 };
 
 struct cdstr {
@@ -50,10 +56,25 @@
     char *str;                  /* the string to display */
     char *desc;                 /* the description or NULL */
     char *match;                /* the match to add */
+    int len;                    /* length of str or match */
     Cdstr other;                /* next string with the same description */
     int kind;                   /* 0: not in a group, 1: the first, 2: other */
+    Cdset set;                  /* the set this string is in */
+    Cdstr run;                  /* next in this run */
 };
 
+struct cdrun {
+    Cdrun next;                 /* ... */
+    int type;                   /* see CRT_* below */
+    Cdstr strs;                 /* strings in this run */
+    int count;                  /* number of strings in this run */
+};
+
+#define CRT_SIMPLE 0
+#define CRT_DESC   1
+#define CRT_SPEC   2
+#define CRT_DUMMY  3
+
 struct cdset {
     Cdset next;			/* guess what */
     char **opts;		/* the compadd-options */
@@ -62,11 +83,6 @@
     int desc;                   /* number of matches with description */
 };
 
-/* Maximum string length when used with descriptions. */
-
-#define CD_MAXLEN 30
-
-
 static struct cdstate cd_state;
 static int cd_parsed = 0;
 
@@ -75,6 +91,7 @@
 {
     Cdset n;
     Cdstr s, sn;
+    Cdrun r, rn;
 
     for (; p; p = n) {
 	n = p->next;
@@ -88,6 +105,10 @@
                 zsfree(s->match);
             zfree(s, sizeof(*s));
         }
+        for (r = cd_state.runs; r; r = rn) {
+            rn = r->next;
+            zfree(r, sizeof(*r));
+        }
 	zfree(p, sizeof(*p));
     }
 }
@@ -99,14 +120,14 @@
 {
     Cdset set1, set2;
     Cdstr str1, str2, *strp;
-    int yep = 0;
-    char *buf;
+    int num;
 
     for (set1 = cd_state.sets; set1; set1 = set1->next) {
         for (str1 = set1->strs; str1; str1 = str1->next) {
             if (!str1->desc || str1->kind != 0)
                 continue;
 
+            num = 1;
             strp = &(str1->other);
 
             for (set2 = set1; set2; set2 = set2->next)
@@ -115,33 +136,18 @@
                     if (str2->desc && !strcmp(str1->desc, str2->desc)) {
                         str1->kind = 1;
                         str2->kind = 2;
-                        zsfree(str2->desc);
-                        str2->desc = ztrdup("|");
+                        num++;
                         *strp = str2;
                         strp = &(str2->other);
-                        yep = 1;
                     }
             *strp = NULL;
-        }
-    }
-    if (!yep)
-        return;
-
-    for (set1 = cd_state.sets; set1; set1 = set1->next) {
-        for (str1 = set1->strs; str1; str1 = str1->next) {
-            if (str1->kind != 1)
-                continue;
+            if (num > 1)
+                cd_state.groups++;
+            else
+                cd_state.descs++;
 
-            buf = str1->str;
-            for (str2 = str1->other; str2; str2 = str2->other)
-                buf = zhtricat(buf, ", ", str2->str);
-
-            for (str2 = str1; str2; str2 = str2->other) {
-                if (str2->str == str2->match)
-                    str2->match = ztrdup(str2->match);
-                zsfree(str2->str);
-                str2->str = ztrdup(buf);
-            }
+            if (num > cd_state.maxg)
+                cd_state.maxg = num;
         }
     }
 }
@@ -170,15 +176,173 @@
                     cd_state.suf = l;
             }
         }
+    }
+}
+
+static int
+cd_sort(const void *a, const void *b)
+{
+    return strcmp((*((Cdstr *) a))->str, (*((Cdstr *) b))->str);
+}
+
+static void
+cd_prep()
+{
+    Cdrun run, *runp;
+    Cdset set;
+    Cdstr str, *strp;
+
+    runp = &(cd_state.runs);
+
+    if (cd_state.groups) {
+        int lines = cd_state.groups + cd_state.descs;
+        VARARR(Cdstr, grps, lines);
+        VARARR(int, wids, cd_state.maxg);
+        Cdstr gs, gp, gn, *gpp;
+        int i, j;
+
+        memset(wids, 0, cd_state.maxg * sizeof(int));
+        strp = grps;
+
+        for (set = cd_state.sets; set; set = set->next)
+            for (str = set->strs; str; str = str->next) {
+                if (str->kind != 1) {
+                    if (!str->kind && str->desc) {
+                        str->other = NULL;
+                        *strp++ = str;
+                    }
+                    continue;
+                }
+                gs = str;
+                gs->kind = 2;
+                gp = str->other;
+                gs->other = NULL;
+                for (; gp; gp = gn) {
+                    gn = gp->other;
+                    gp->other = NULL;
+                    for (gpp = &gs; *gpp && (*gpp)->len > gp->len;
+                         gpp = &((*gpp)->other));
+                    gp->other = *gpp;
+                    *gpp = gp;
+                }
+                for (gp = gs, i = 0; gp; gp = gp->other, i++)
+                    if (gp->len > wids[i])
+                        wids[i] = gp->len;
+
+                *strp++ = gs;
+            }
+
+        qsort(grps, lines, sizeof(Cdstr), cd_sort);
+
+        for (i = lines, strp = grps; i; i--, strp++) {
+            for (j = 0, gs = *strp; gs->other; gs = gs->other, j++) {
+                *runp = run = (Cdrun) zalloc(sizeof(*run));
+                runp = &(run->next);
+                run->type = CRT_SPEC;
+                run->strs = gs;
+                gs->run = NULL;
+                run->count = 1;
+            }
+            *runp = run = (Cdrun) zalloc(sizeof(*run));
+            runp = &(run->next);
+            run->type = CRT_DUMMY + cd_state.maxg - j - 1;
+            run->strs = gs;
+            gs->run = NULL;
+            run->count = 1;
+        }
+        for (set = cd_state.sets; set; set = set->next) {
+            for (i = 0, gs = NULL, gpp = &gs, str = set->strs;
+                 str; str = str->next) {
+                if (str->kind || str->desc)
+                    continue;
+
+                i++;
+                *gpp = str;
+                gpp = &(str->run);
+            }
+            *gpp = NULL;
+            if (i) {
+                *runp = run = (Cdrun) zalloc(sizeof(*run));
+                runp = &(run->next);
+                run->type = CRT_SIMPLE;
+                run->strs = gs;
+                run->count = i;
+            }
+        }
+        cd_state.gpre = 0;
+        for (i = 0; i < cd_state.maxg; i++)
+            cd_state.gpre += wids[i] + 2;
+    } else if (cd_state.showd) {
+        for (set = cd_state.sets; set; set = set->next) {
+            if (set->desc) {
+                *runp = run = (Cdrun) zalloc(sizeof(*run));
+                runp = &(run->next);
+                run->type = CRT_DESC;
+                strp = &(run->strs);
+                for (str = set->strs; str; str = str->next)
+                    if (str->desc) {
+                        *strp = str;
+                        strp = &(str->run);
+                    }
+                *strp = NULL;
+                run->count = set->desc;
+            }
+            if (set->desc != set->count) {
+                *runp = run = (Cdrun) zalloc(sizeof(*run));
+                runp = &(run->next);
+                run->type = CRT_SIMPLE;
+                strp = &(run->strs);
+                for (str = set->strs; str; str = str->next)
+                    if (!str->desc) {
+                        *strp = str;
+                        strp = &(str->run);
+                    }
+                *strp = NULL;
+                run->count = set->count - set->desc;
+            }
+        }
+    } else {
+        for (set = cd_state.sets; set; set = set->next)
+            if (set->count) {
+                *runp = run = (Cdrun) zalloc(sizeof(*run));
+                runp = &(run->next);
+                run->type = CRT_SIMPLE;
+                run->strs = set->strs;
+                for (str = set->strs; str; str = str->next)
+                    str->run = str->next;
+                run->count = set->count;
+            }
     }
-    if (cd_state.pre > CD_MAXLEN)
-        cd_state.pre = CD_MAXLEN;
+    *runp = NULL;
 }
 
+/* Duplicate and concatenate two arrays.  Return the result. */
+
+static char **
+cd_arrcat(char **a, char **b)
+{
+    if (!b)
+        return zarrdup(a);
+    else {
+        char **r = (char **) zalloc((arrlen(a) + arrlen(b) + 1) *
+                                    sizeof(char *));
+        char **p = r;
+
+        for (; *a; a++)
+            *p++ = ztrdup(*a);
+        for (; *b; b++)
+            *p++ = ztrdup(*b);
+
+        *p = NULL;
+
+        return r;
+    }
+}
+
 /* Initialisation. Store and calculate the string and matches and so on. */
 
 static int
-cd_init(char *nam, char *sep, char **args, int disp)
+cd_init(char *nam, char *hide, char *sep, char **opts, char **args, int disp)
 {
     Cdset *setp, set;
     Cdstr *strp, str;
@@ -195,6 +359,7 @@
     cd_state.slen = ztrlen(sep);
     cd_state.sets = NULL;
     cd_state.showd = disp;
+    cd_state.maxg = cd_state.groups = cd_state.descs = 0;
 
     if (*args && !strcmp(*args, "-g")) {
         args++;
@@ -219,6 +384,7 @@
 
             str->kind = 0;
             str->other = NULL;
+            str->set = set;
 
             for (tmp = *ap; *tmp && *tmp != ':'; tmp++)
                 if (*tmp == '\\' && tmp[1])
@@ -230,6 +396,7 @@
                 str->desc = NULL;
             *tmp = '\0';
             str->str = str->match = ztrdup(rembslash(*ap));
+            str->len = strlen(str->str);
         }
         if (str)
             str->next = NULL;
@@ -246,13 +413,23 @@
 
 	    args++;
 	}
+        if (hide && *hide) {
+            for (str = set->strs; str; str = str->next) {
+                if (str->str == str->match)
+                    str->str = ztrdup(str->str);
+                if (hide[1] && str->str[0] == '-' && str->str[1] == '-')
+                    strcpy(str->str, str->str + 2);
+                else if (str->str[0] == '-' || str->str[0] == '+')
+                    strcpy(str->str, str->str + 1);
+            }
+        }
 	for (ap = args; *args &&
 		 (args[0][0] != '-' || args[0][1] != '-' || args[0][2]);
 	     args++);
 
 	tmp = *args;
 	*args = NULL;
-	set->opts = zarrdup(ap);
+	set->opts = cd_arrcat(ap, opts);
 	if ((*args = tmp))
 	    args++;
     }
@@ -260,79 +437,157 @@
         cd_group();
 
     cd_calc();
+    cd_prep();
 
     cd_parsed = 1;
     return 0;
 }
 
+/* Copy an array with one element in reserve (at the beginning). */
+
+static char **
+cd_arrdup(char **a)
+{
+    char **r = (char **) zalloc((arrlen(a) + 2) * sizeof(char *));
+    char **p = r + 1;
+
+    while (*a)
+        *p++ = ztrdup(*a++);
+    *p = NULL;
+
+    return r;
+}
+
 /* Get the next set. */
 
 static int
 cd_get(char **params)
 {
-    Cdset set;
+    Cdrun run;
 
-    if ((set = cd_state.sets)) {
-	char **sd, **sdp, **md, **mdp, **sh, **shp, **mh, **mhp;
-        char **ss, **ssp, **ms, **msp;
+    if ((run = cd_state.runs)) {
         Cdstr str;
-        VARARR(char, buf, cd_state.pre + cd_state.suf + cd_state.slen + 1);
-        char *sufp = NULL, *disp;
+        char **mats, **mp, **dpys, **dp, **opts, *csl = "";
 
-        if (cd_state.showd) {
-            memcpy(buf + cd_state.pre, cd_state.sep, cd_state.slen);
-            sufp = buf + cd_state.pre + cd_state.slen;
-        }
-	sd = (char **) zalloc((set->desc + 1) * sizeof(char *));
-	md = (char **) zalloc((set->desc + 1) * sizeof(char *));
-	sh = (char **) zalloc((set->desc + 1) * sizeof(char *));
-	mh = (char **) zalloc((set->desc + 1) * sizeof(char *));
-	ss = (char **) zalloc((set->count + 1) * sizeof(char *));
-	ms = (char **) zalloc((set->count + 1) * sizeof(char *));
-
-        for (sdp = sd, mdp = md, shp = sh, mhp = mh,
-             ssp = ss, msp = ms, str = set->strs;
-             str;
-             str = str->next) {
-            if (cd_state.showd && str->desc) {
-                if (strlen(str->str) > CD_MAXLEN)
-                    disp = tricat(str->str, cd_state.sep, str->desc);
-                else {
-                    strcpy(sufp, str->desc);
-                    memset(buf, ' ', cd_state.pre);
-                    memcpy(buf, str->str, strlen(str->str));
-                    disp = ztrdup(buf);
+        cd_state.runs = run->next;
+
+        switch (run->type) {
+        case CRT_SIMPLE:
+            mats = mp = (char **) zalloc((run->count + 1) * sizeof(char *));
+            dpys = dp = (char **) zalloc((run->count + 1) * sizeof(char *));
+
+            for (str = run->strs; str; str = str->run) {
+                *mp++ = ztrdup(str->match);
+                *dp++ = ztrdup(str->str ? str->str : str->match);
+            }
+            *mp = *dp = NULL;
+            opts = zarrdup(run->strs->set->opts);
+            if (cd_state.groups) {
+                /* We are building a columnised list with dummy matches
+                 * but there are also matches without descriptions.
+                 * Those end up in a different group, so make sure that
+                 * groupd doesn't have an explanation. */
+
+                for (mp = dp = opts; *mp; mp++) {
+                    if (dp[0][0] == '-' && dp[0][1] == 'X') {
+                        if (!dp[0][2] && dp[1])
+                            mp++;
+                    } else
+                        *dp++ = *mp;
                 }
-                if (strlen(disp) >= columns)
-                    disp[columns - 1] = '\0';
+                *dp = NULL;
+            }
+            break;
+
+        case CRT_DESC:
+            {
+                VARARR(char, buf,
+                       cd_state.pre + cd_state.suf + cd_state.slen + 1);
+                char *sufp = NULL;
+
+                memcpy(buf + cd_state.pre, cd_state.sep, cd_state.slen);
+                sufp = buf + cd_state.pre + cd_state.slen;
 
-                if (str->kind == 2) {
-                    *shp++ = disp;
-                    *mhp++ = ztrdup(str->match);
-                } else {
-                    *sdp++ = disp;
-                    *mdp++ = ztrdup(str->match);
+                mats = mp = (char **) zalloc((run->count + 1) * sizeof(char *));
+                dpys = dp = (char **) zalloc((run->count + 1) * sizeof(char *));
+
+                for (str = run->strs; str; str = str->run) {
+                    *mp++ = ztrdup(str->match);
+                    memset(buf, ' ', cd_state.pre);
+                    memcpy(buf, str->str, str->len);
+                    strcpy(sufp, str->desc);
+                    if (strlen(buf) >= columns)
+                        buf[columns] = '\0';
+                    *dp++ = ztrdup(buf);
                 }
-            } else {
-                *ssp++ = ztrdup(str->str);
-                *msp++ = ztrdup(str->match);
-            }
-        }
-        *sdp = *mdp = *shp = *mhp = *ssp = *msp = NULL;
-
-	setaparam(params[0], zarrdup(set->opts));
-	setaparam(params[1], sd);
-	setaparam(params[2], md);
-	setaparam(params[3], sh);
-	setaparam(params[4], mh);
-	setaparam(params[5], ss);
-	setaparam(params[6], ms);
-
-	cd_state.sets = set->next;
-	set->next = NULL;
-	freecdsets(set);
+                *mp = *dp = NULL;
+                opts = cd_arrdup(run->strs->set->opts);
+                opts[0] = ztrdup("-l");
+                break;
+            }
+        case CRT_SPEC:
+            mats = (char **) zalloc(2 * sizeof(char *));
+            dpys = (char **) zalloc(2 * sizeof(char *));
+            mats[0] = ztrdup(run->strs->match);
+            dpys[0] = ztrdup(run->strs->str);
+            mats[1] = dpys[1] = NULL;
+            opts = cd_arrdup(run->strs->set->opts);
+            for (dp = opts + 1; *dp; dp++)
+                if (dp[0][0] == '-' && dp[0][1] == 'J')
+                    break;
+            if (*dp) {
+                char *s = tricat("-1V", "", dp[0] + 2);
+
+                zsfree(*dp);
+                *dp = s;
+
+                memmove(opts, opts + 1,
+                        (arrlen(opts + 1) + 1) * sizeof(char *));
+                
+            } else
+                opts[0] = ztrdup("-1V-default-");
+            csl = "packed rows";
+            break;
+
+        default:
+            {
+                int dlen = columns - cd_state.gpre - cd_state.slen;
+                VARARR(char, dbuf, dlen + cd_state.slen);
+                char buf[20];
+                int i = run->type - CRT_DUMMY;
+
+                sprintf(buf, "-E%d", i + 1);
+
+                mats = (char **) zalloc(2 * sizeof(char *));
+                dpys = (char **) zalloc((3 + i) * sizeof(char *));
+                mats[0] = ztrdup(run->strs->match);
+                dpys[0] = ztrdup(run->strs->str);
+                for (dp = dpys + 1; i; i--, dp++)
+                    *dp = ztrdup("");
+                memset(dbuf + cd_state.slen, ' ', dlen - 1);
+                dbuf[dlen + cd_state.slen - 1] = '\0';
+                strcpy(dbuf, cd_state.sep);
+                memcpy(dbuf + cd_state.slen,
+                       run->strs->desc,
+                       (strlen(run->strs->desc) >= dlen ? dlen - 1 :
+                        strlen(run->strs->desc)));
+                *dp++ = ztrdup(dbuf);
+                mats[1] = *dp = NULL;
+
+                opts = cd_arrdup(run->strs->set->opts);
+                opts[0] = ztrdup(buf);
+
+                csl = "packed rows";
+            }
+        }
+        setsparam(params[0], ztrdup(csl));
+        setaparam(params[1], opts);
+        setaparam(params[2], mats);
+        setaparam(params[3], dpys);
 
-	return 0;
+        zfree(run, sizeof(*run));
+
+        return 0;
     }
     return 1;
 }
@@ -341,6 +596,8 @@
 static int
 bin_compdescribe(char *nam, char **args, char *ops, int func)
 {
+    int n = arrlen(args);
+
     if (incompfunc != 1) {
 	zwarnnam(nam, "can only be called from completion function", NULL, 0);
 	return 1;
@@ -351,15 +608,30 @@
     }
     switch (args[0][1]) {
     case 'i':
-	return cd_init(nam, "", args + 1, 0);
+        if (n < 2) {
+            zwarnnam(nam, "not enough arguments", NULL, 0);
+
+            return 1;
+        }
+	return cd_init(nam, args[1], "", NULL, args + 2, 0);
     case 'I':
-	return cd_init(nam, args[1], args + 2, 1);
+        if (n < 5) {
+            zwarnnam(nam, "not enough arguments", NULL, 0);
+
+            return 1;
+        } else {
+            char **opts;
+
+            if (!(opts = getaparam(args[3]))) {
+		zwarnnam(nam, "unknown parameter: %s", args[2], 0);
+		return 1;
+            }
+            return cd_init(nam, args[1], args[2], opts, args + 4, 1);
+        }
     case 'g':
 	if (cd_parsed) {
-	    int n = arrlen(args);
-
-	    if (n != 8) {
-		zwarnnam(nam, (n < 8 ? "not enough arguments" :
+	    if (n != 5) {
+		zwarnnam(nam, (n < 5 ? "not enough arguments" :
 			      "too many arguments"), NULL, 0);
 		return 1;
 	    }

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: About the new long/short options changes
  2001-07-25  8:49     ` Sven Wischnowsky
@ 2001-07-25  9:15       ` Borsenkow Andrej
  2001-07-25  9:20         ` Sven Wischnowsky
  2001-07-25 10:13         ` Peter Stephenson
  0 siblings, 2 replies; 17+ messages in thread
From: Borsenkow Andrej @ 2001-07-25  9:15 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

> 
> The result is the patch below, which is already quite satisfying, I
> think.

It looks a bit strange to me (no change in setup):

bor@itsrm2% gdiff -TAB
bor@itsrm2% gdiff --brief
Completing option
--brief                                     
-q                                          
                                            
-- output only whether files differ         
--changed-group-format                      
                                            
-- set changed group format                 
--context                                   
                                            
-- context diff                             
--ed                                        
-e                                          
                                            
...

Is it expected result?

-andrej


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: RE: About the new long/short options changes
  2001-07-25  9:15       ` Borsenkow Andrej
@ 2001-07-25  9:20         ` Sven Wischnowsky
  2001-07-25  9:24           ` Borsenkow Andrej
  2001-07-25 10:13         ` Peter Stephenson
  1 sibling, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-25  9:20 UTC (permalink / raw)
  To: zsh-workers

Borsenkow Andrej wrote:

> > 
> > The result is the patch below, which is already quite satisfying, I
> > think.
> 
> It looks a bit strange to me (no change in setup):
> 
> bor@itsrm2% gdiff -TAB
> bor@itsrm2% gdiff --brief
> Completing option
> --brief                                     
> -q                                          
>                                             
> -- output only whether files differ         

Of course not.  Could you tell me your zstyles and options?


Bye
  Sven


-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: RE: About the new long/short options changes
  2001-07-25  9:20         ` Sven Wischnowsky
@ 2001-07-25  9:24           ` Borsenkow Andrej
  0 siblings, 0 replies; 17+ messages in thread
From: Borsenkow Andrej @ 2001-07-25  9:24 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> > >
> > > The result is the patch below, which is already quite satisfying, I
> > > think.
> >
> > It looks a bit strange to me (no change in setup):
> >
> > bor@itsrm2% gdiff -TAB
> > bor@itsrm2% gdiff --brief
> > Completing option
> > --brief
> > -q
> >
> > -- output only whether files differ
>
> Of course not.  Could you tell me your zstyles and options?
>
>

.zshrc:

bindkey -e
bindkey '^I' complete-word
bindkey '^[q' push-line-or-edit
bindkey -M menuselect '/' accept-and-infer-next-history
bindkey -M menuselect ',' accept-and-menu-complete
setopt autopushd
setopt cdablevars
setopt extendedhistory
setopt extendedglob
setopt histexpiredupsfirst
setopt histignorealldups
setopt histignoredups
setopt histreduceblanks
setopt histsavenodups
setopt ignoreeof
setopt menucomplete
setopt nobanghist
setopt nolistambiguous
setopt nolistbeep
setopt numericglobsort
setopt pushdminus

and styles:

bor@itsrm2% zstyle -L
zstyle ':completion:*' completer _oldlist _complete _match
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*' format '%BCompleting %d%b'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the
character to insert%s'
zstyle ':completion:*' match-original both
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' '+r:|[._-]=** r:|=**'
zstyle ':completion:*' menu 'select=long-list' 'select=0'
zstyle ':completion:*' verbose true
zstyle :compinstall filename /home/bor/.zcompletion
zstyle ':completion:*:*:configure:*' tag-order 'options:-with:with\ options
options:-other:other\ options' 'options:-without:without\ options'
zstyle ':completion:*:options-with' ignored-patterns '^--with-*'
zstyle ':completion:*:options-without' ignored-patterns '^--without-*'
zstyle ':completion:*:options-other' ignored-patterns '--with(|out)-*'
zstyle ':completion:*' ambiguous true
zstyle ':completion:*' list-rows-first true
zstyle ':completion:*:processes' command '
        if (($EUID && !${+NUMERIC})); then
            ps -fu $EUID
        else
            ps -fe
        fi
'


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-25  9:15       ` Borsenkow Andrej
  2001-07-25  9:20         ` Sven Wischnowsky
@ 2001-07-25 10:13         ` Peter Stephenson
  2001-07-25 10:43           ` Sven Wischnowsky
  1 sibling, 1 reply; 17+ messages in thread
From: Peter Stephenson @ 2001-07-25 10:13 UTC (permalink / raw)
  To: Zsh hackers list

Borsenkow Andrej wrote:
> > 
> > The result is the patch below, which is already quite satisfying, I
> > think.
> 
> It looks a bit strange to me (no change in setup):

I don't get this, even with the complete set of styles and options.  Are
you sure you've installed the new libraries?

The format looks extremely impressive.  The only point I'd make is the
utterly trivial one that using `--' to introduce the description is a bit
confusing when there are lots of --'s around introducing options.  How
about `#'?

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-25 10:13         ` Peter Stephenson
@ 2001-07-25 10:43           ` Sven Wischnowsky
  2001-07-25 11:36             ` Borsenkow Andrej
  2001-07-25 17:49             ` Bart Schaefer
  0 siblings, 2 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-25 10:43 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:

> Borsenkow Andrej wrote:
> > > 
> > > The result is the patch below, which is already quite satisfying, I
> > > think.
> > 
> > It looks a bit strange to me (no change in setup):
> 
> I don't get this, even with the complete set of styles and options.  Are
> you sure you've installed the new libraries?

It doesn't happen for all commands -- I used `-1' instead of `-2', which
removed consecutive dummy matches.  Ahem.  And then I found a possible
problem in the code that calculates the width needed for the options
(which didn't happen in this case, though).

> The format looks extremely impressive.  The only point I'd make is the
> utterly trivial one that using `--' to introduce the description is a bit
> confusing when there are lots of --'s around introducing options.  How
> about `#'?

Yes, I was slightly worried, too.  I'm not too sure about `#', I'd
prefer something less `bold' (I hope you understand what I mean, the `#'
is so `dark', err... ;-).  And the `--' is used elsewhere, but what
about making it configurable, it's just a little style, after all -- and
then we can use `#' or `--' as the default.


Bye
  Sven

Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.31
diff -u -r1.31 compwid.yo
--- Doc/Zsh/compwid.yo	2001/07/25 08:52:34	1.31
+++ Doc/Zsh/compwid.yo	2001/07/25 10:38:26
@@ -673,7 +673,7 @@
 format completion lists and to make explanatory string be shown in
 completion lists (since empty matches can be given display strings
 with the tt(-d) option).  And because all but one empty string would
-otherwise be removed, this option implies the tt(-V) and tt(-1)
+otherwise be removed, this option implies the tt(-V) and tt(-2)
 options (even if an explicit tt(-J) option is given).
 )
 xitem(tt(-))
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.47
diff -u -r1.47 compcore.c
--- Src/Zle/compcore.c	2001/07/25 08:52:34	1.47
+++ Src/Zle/compcore.c	2001/07/25 10:38:27
@@ -1637,7 +1637,7 @@
 	return 1;
     }
     if (dat->dummies)
-        dat->aflags = dat->aflags | CAF_NOSORT | CAF_UNIQALL;
+        dat->aflags = (dat->aflags | CAF_NOSORT | CAF_UNIQCON) & ~CAF_UNIQALL;
     for (bp = brbeg; bp; bp = bp->next)
 	bp->curpos = ((dat->aflags & CAF_QUOTE) ? bp->pos : bp->qpos);
     for (bp = brend; bp; bp = bp->next)
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.67
diff -u -r1.67 computil.c
--- Src/Zle/computil.c	2001/07/25 08:52:34	1.67
+++ Src/Zle/computil.c	2001/07/25 10:38:47
@@ -208,6 +208,8 @@
             for (str = set->strs; str; str = str->next) {
                 if (str->kind != 1) {
                     if (!str->kind && str->desc) {
+                        if (str->len > wids[0])
+                            wids[0] = str->len;
                         str->other = NULL;
                         *strp++ = str;
                     }
@@ -536,7 +538,7 @@
                 if (dp[0][0] == '-' && dp[0][1] == 'J')
                     break;
             if (*dp) {
-                char *s = tricat("-1V", "", dp[0] + 2);
+                char *s = tricat("-2V", "", dp[0] + 2);
 
                 zsfree(*dp);
                 *dp = s;
@@ -545,7 +547,7 @@
                         (arrlen(opts + 1) + 1) * sizeof(char *));
                 
             } else
-                opts[0] = ztrdup("-1V-default-");
+                opts[0] = ztrdup("-2V-default-");
             csl = "packed rows";
             break;
 

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: About the new long/short options changes
  2001-07-25 10:43           ` Sven Wischnowsky
@ 2001-07-25 11:36             ` Borsenkow Andrej
  2001-07-25 12:16               ` Sven Wischnowsky
  2001-07-25 17:49             ` Bart Schaefer
  1 sibling, 1 reply; 17+ messages in thread
From: Borsenkow Andrej @ 2001-07-25 11:36 UTC (permalink / raw)
  To: zsh-workers

>
> > The format looks extremely impressive.

Wow! That's awsome. Now it's really time to ask what are we going to ... :-)

-andrej

Just noticed:

gdiff --TAB
bor@itsrm2% gdiff --unidirectional-new-file
...
--unidirectional-new-file-- treat absent first files as empty
                        ^^^
there is no space. Is it correct?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: RE: About the new long/short options changes
  2001-07-25 11:36             ` Borsenkow Andrej
@ 2001-07-25 12:16               ` Sven Wischnowsky
  2001-07-25 12:35                 ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-25 12:16 UTC (permalink / raw)
  To: zsh-workers

Borsenkow Andrej wrote:

> >
> > > The format looks extremely impressive.
> 
> Wow! That's awsome. Now it's really time to ask what are we going to ... :-)
> 
> -andrej
> 
> Just noticed:
> 
> gdiff --TAB
> bor@itsrm2% gdiff --unidirectional-new-file
> ...
> --unidirectional-new-file-- treat absent first files as empty
>                         ^^^
> there is no space. Is it correct?

Urk.  It gets embarrassing now...

But this was really only a display problem -- I changed the separator to
not start with a spcae because that moves the explanation too far to the
right with grouping.

And since I had to fiddle with this anyway, I also added the
`list-separator' style to make the separator string configurable.  Peter
can now set that to `#' (spaces are added automatically).


Bye
  Sven

Index: Completion/AIX/Command/_lscfg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/AIX/Command/_lscfg,v
retrieving revision 1.1
diff -u -r1.1 _lscfg
--- Completion/AIX/Command/_lscfg	2001/04/02 12:18:51	1.1
+++ Completion/AIX/Command/_lscfg	2001/07/25 12:13:41
@@ -1,6 +1,6 @@
 #compdef lscfg
 
-local state line expl curcontext="$curcontext" disp list devs
+local state line expl curcontext="$curcontext" disp list devs sep
 
 _arguments -C -s \
   '-l[display device information for named device]:device:->device' \
@@ -9,7 +9,8 @@
 if [[ "$state" = device ]]; then
   devs=( ${${${${(f)"$(lscfg)"}[6,-1]:# *}##??}/ ##[^ ]# #/:} )
   if zstyle -T ":completion:${curcontext}:devices" verbose; then
-    zformat -a list ' -- ' "$devs[@]"
+    zstyle -s ":completion:${curcontext}:devices" list-separator sep || sep=--
+    zformat -a list " $sep " "$devs[@]"
     disp=(-ld list)
   else
     disp=()
Index: Completion/AIX/Type/_logical_volumes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/AIX/Type/_logical_volumes,v
retrieving revision 1.1
diff -u -r1.1 _logical_volumes
--- Completion/AIX/Type/_logical_volumes	2001/04/02 12:17:27	1.1
+++ Completion/AIX/Type/_logical_volumes	2001/07/25 12:13:41
@@ -1,11 +1,12 @@
 #autoload
 
-local expl list names disp
+local expl list names disp sep
 
 list=( $(lsvg -l $(lsvg)|sed  -e '2d'|awk '/[^:]* / {if ( $7 != "N/A" ) print $1 ":" $7; else print $1}' ) )
 names=(${list%%:*})
-if zstyle -T ":completion:${curcontext}" verbose; then
-  zformat -a list ' -- ' $list
+if zstyle -T ":completion:${curcontext}:" verbose; then
+  zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
+  zformat -a list " $sep " $list
   disp=(-d list)
 else
   disp=()
Index: Completion/Base/Utility/_describe
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_describe,v
retrieving revision 1.4
diff -u -r1.4 _describe
--- Completion/Base/Utility/_describe	2001/07/25 08:52:34	1.4
+++ Completion/Base/Utility/_describe	2001/07/25 12:13:41
@@ -23,12 +23,13 @@
 
 zstyle -T ":completion:${curcontext}:$_type" verbose && _showd=yes
 
+zstyle -s ":completion:${curcontext}:$_type" list-separator _sep || _sep=--
+
 if zstyle -T ":completion:${curcontext}:$_type" list-grouped; then
   local _argv _new _strs _mats _opts _i=2
 
   _argv=( "$@" )
   _grp=(-g)
-  _sep='-- '
   _new=( "$1" )
   shift
 
@@ -68,7 +69,6 @@
   set - "$_argv[@]"
 else
   _grp=()
-  _sep=' -- '
 fi
 
 _descr="$1"
@@ -83,7 +83,7 @@
   while _next_label "$_type" _expl "$_descr"; do
 
     if [[ -n "$_showd" ]]; then
-      compdescribe -I "$_hide" "$_sep" _expl "$_grp[@]" "$@"
+      compdescribe -I "$_hide" "$_sep " _expl "$_grp[@]" "$@"
     else
       compdescribe -i "$_hide" "$@"
     fi
Index: Completion/Unix/Type/_printers
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_printers,v
retrieving revision 1.1
diff -u -r1.1 _printers
--- Completion/Unix/Type/_printers	2001/04/02 11:41:05	1.1
+++ Completion/Unix/Type/_printers	2001/07/25 12:13:42
@@ -1,6 +1,6 @@
 #autoload
 
-local expl ret=1 list disp
+local expl ret=1 list disp sep
 
 if (( $+commands[lsallq] )); then
   # Use AIX's command to list print queues
@@ -8,6 +8,8 @@
   return
 fi
 
+zstyle -s ":completion:${curcontext}:printers" list-separator sep || sep=--
+
 if (( ! $+_lp_cache )); then
   local file entry names i
 
@@ -42,7 +44,7 @@
 fi
 
 if zstyle -T ":completion:${curcontext}:printers" verbose; then
-  zformat -a list ' -- ' "$_lp_cache[@]"
+  zformat -a list " $sep " "$_lp_cache[@]"
   disp=(-ld list)
 else
   disp=()
@@ -53,7 +55,7 @@
 (( $+_lp_alias_cache )) || return 1
 
 if zstyle -T ":completion:${curcontext}:printers" verbose; then
-  zformat -a list ' -- ' "$_lp_alias_cache[@]"
+  zformat -a list " $sep " "$_lp_alias_cache[@]"
   disp=(-ld list)
 else
   disp=()
Index: Completion/Zsh/Command/_zstyle
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_zstyle,v
retrieving revision 1.3
diff -u -r1.3 _zstyle
--- Completion/Zsh/Command/_zstyle	2001/07/18 13:10:10	1.3
+++ Completion/Zsh/Command/_zstyle	2001/07/25 12:13:42
@@ -59,6 +59,7 @@
   list-packed		 c:bool
   list-prompt            c:
   list-rows-first	 c:bool
+  list-separator	 c:separator
   list-suffixes		 c:bool
   local			 c:
   match-original	 c:match-orig
@@ -308,6 +309,10 @@
 
     preserve-prefix)
       _message 'pattern matching prefix to keep'
+      ;;
+
+    separator)
+      _message 'separator string'
       ;;
 
     urgh) 
Index: Completion/Zsh/Context/_subscript
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_subscript,v
retrieving revision 1.6
diff -u -r1.6 _subscript
--- Completion/Zsh/Context/_subscript	2001/05/08 15:09:57	1.6
+++ Completion/Zsh/Context/_subscript	2001/07/25 12:13:42
@@ -1,6 +1,6 @@
 #compdef -subscript-
 
-local expl ind osuf=']' flags
+local expl ind osuf=']' flags sep
 
 if [[ "$1" = -q ]]; then
   osuf='] '
@@ -91,7 +91,8 @@
 	      list=( "$list[@]" '' )
 	  fi
         done
-        zformat -a list ' -- ' "$list[@]"
+        zstyle -s ":completion:${curcontext}:indexes" list-separator sep || sep=--
+        zformat -a list " $sep " "$list[@]"
 	disp=( -d list)
       else
         disp=()
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.130
diff -u -r1.130 compsys.yo
--- Doc/Zsh/compsys.yo	2001/07/18 13:10:10	1.130
+++ Doc/Zsh/compsys.yo	2001/07/25 12:14:06
@@ -1563,6 +1563,12 @@
 components starting with the first one for which more than one match
 could be generated will be shown.
 )
+kindex(list-separator, completion style)
+item(tt(list-separator))(
+The value of this style is used in completion listing to separate the
+string to complete from a description when possible (e.g. when
+completing options).  It defaults to `tt(-)tt(-)' (two hyphens).
+)
 kindex(local, completion style)
 item(tt(local))(
 This style is used by completion functions which generate URLs as
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.68
diff -u -r1.68 computil.c
--- Src/Zle/computil.c	2001/07/25 10:45:59	1.68
+++ Src/Zle/computil.c	2001/07/25 12:14:12
@@ -504,11 +504,12 @@
         case CRT_DESC:
             {
                 VARARR(char, buf,
-                       cd_state.pre + cd_state.suf + cd_state.slen + 1);
+                       cd_state.pre + cd_state.suf + cd_state.slen + 3);
                 char *sufp = NULL;
 
-                memcpy(buf + cd_state.pre, cd_state.sep, cd_state.slen);
-                sufp = buf + cd_state.pre + cd_state.slen;
+                memcpy(buf + cd_state.pre + 2, cd_state.sep, cd_state.slen);
+                buf[cd_state.pre] = buf[cd_state.pre + 1] = ' ';
+                sufp = buf + cd_state.pre + cd_state.slen + 2;
 
                 mats = mp = (char **) zalloc((run->count + 1) * sizeof(char *));
                 dpys = dp = (char **) zalloc((run->count + 1) * sizeof(char *));

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: RE: About the new long/short options changes
  2001-07-25 12:16               ` Sven Wischnowsky
@ 2001-07-25 12:35                 ` Sven Wischnowsky
  0 siblings, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-25 12:35 UTC (permalink / raw)
  To: zsh-workers

I wrote:

> ...
> 
> And since I had to fiddle with this anyway, I also added the
> `list-separator' style to make the separator string configurable.  Peter
> can now set that to `#' (spaces are added automatically).

I knew that couldn't be all places...


Btw, I use list-colors to make the separator less visible:

  zstyle ':completion:*:(jobs|directory-stack|indexes)' list-colors \
    '=(#b)(*)-- (*)=35;1=31;1=33;1'
  zstyle ':completion:*:(options|values)' list-colors \
    '=(#b)(*)-- (*)=35;1=31;1=33;1' '=*=31;1'

(You'll get different and probably very ugly colors with this, for me
`35' is a light grey.)


Bye
  Sven

Index: Completion/Unix/Command/_lzop
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_lzop,v
retrieving revision 1.1
diff -u -r1.1 _lzop
--- Completion/Unix/Command/_lzop	2001/04/02 11:56:31	1.1
+++ Completion/Unix/Command/_lzop	2001/07/25 12:34:59
@@ -1,6 +1,6 @@
 #compdef lzop
 
-local expl state line decompress disp curcontext="$curcontext"
+local expl state line decompress disp curcontext="$curcontext" sep
 typeset -A opt_args
 
 _arguments -C -s \
@@ -91,12 +91,13 @@
     fi
   ;;
   flags)
+    zstyle -s ":completion:${curcontext}:flags" list-separator sep || sep=--
     disp=( \
-      "F -- Append a \`*' for executable files" \
-      "G -- Inhibit display of group information" \
-      "Q -- Enclose file names in double quotes" )
-    disp=( ${disp[@]%[Z$PREFIX] -*} )
+      "F $sep Append a \`*' for executable files" \
+      "G $sep Inhibit display of group information" \
+      "Q $sep Enclose file names in double quotes" )
+    disp=( ${disp[@]:#[Z$PREFIX]*} )
     compset -P '[FGQ]*'
-    compadd -d disp - ${disp[@]% -*}
+    compadd -d disp - ${disp[@]%% *}
   ;;
 esac
Index: Completion/Zsh/Type/_directory_stack
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_directory_stack,v
retrieving revision 1.4
diff -u -r1.4 _directory_stack
--- Completion/Zsh/Type/_directory_stack	2001/04/17 09:12:27	1.4
+++ Completion/Zsh/Type/_directory_stack	2001/07/25 12:35:01
@@ -7,11 +7,13 @@
 
 setopt localoptions nonomatch
 
-local expl list lines revlines disp
+local expl list lines revlines disp sep
 
 ### we decided against this, for now...
 #! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
 
+zstyle -s ":completion:${curcontext}:directory-stack" list-separator sep || sep=--
+
 [[ $PREFIX = [-+]* ]] || return 1
 
 if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
@@ -24,11 +26,11 @@
     integer i
     revlines=( $lines )
     for (( i = 1; i <= $#lines; i++ )); do
-      lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[	 ]#}"
+      lines[$i]="$((i-1)) $sep ${revlines[-$i]##[0-9]#[	 ]#}"
     done
   else
     for (( i = 1; i <= $#lines; i++ )); do
-      lines[$i]="$i -- ${lines[$i]##[0-9]#[	 ]#}"
+      lines[$i]="$i $sep ${lines[$i]##[0-9]#[	 ]#}"
     done
   fi
   # get the array of numbers only
Index: Completion/Zsh/Type/_file_descriptors
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_file_descriptors,v
retrieving revision 1.1
diff -u -r1.1 _file_descriptors
--- Completion/Zsh/Type/_file_descriptors	2001/04/02 11:19:30	1.1
+++ Completion/Zsh/Type/_file_descriptors	2001/07/25 12:35:01
@@ -1,20 +1,22 @@
 #autoload
 
-local i fds expl list link
+local i fds expl list link sep
 
 for i in {0..9}; [[ -e /dev/fd/$i ]] && fds=( ${fds[@]} $i )
 
-if zstyle -T ":completion:${curcontext}" verbose && [[ -e /proc/$$/fd ]]; then
+if zstyle -T ":completion:${curcontext}:" verbose && [[ -e /proc/$$/fd ]]; then
+  zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
+
   if zmodload -e zsh/stat; then
     for i in "${fds[@]}"; do
       stat +link -A link /proc/$$/fd/$i
-      list=( ${list[@]} "$i -- ${link[1]}" )
+      list=( ${list[@]} "$i $sep ${link[1]}" )
     done
   elif (( $+commands[readlink] )); then
-    for i in "${fds[@]}"; list=( ${list[@]} "$i -- $(readlink /proc/$$/fd/$i)" )
+    for i in "${fds[@]}"; list=( ${list[@]} "$i $sep $(readlink /proc/$$/fd/$i)" )
   else
     for i in "${fds[@]}"; do
-      list=( ${list[@]} "$i -- $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
+      list=( ${list[@]} "$i $sep $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
     done
   fi
   _wanted file-descriptors expl 'file descriptors' compadd "$@" -d list -a fds
Index: Completion/Zsh/Type/_jobs
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_jobs,v
retrieving revision 1.1
diff -u -r1.1 _jobs
--- Completion/Zsh/Type/_jobs	2001/04/02 11:17:48	1.1
+++ Completion/Zsh/Type/_jobs	2001/07/25 12:35:04
@@ -1,6 +1,6 @@
 #autoload
 
-local expl disp jobs job jids pfx='%' desc how expls
+local expl disp jobs job jids pfx='%' desc how expls sep
 
 if [[ "$1" = -t ]]; then
   zstyle -T ":completion:${curcontext}:jobs" prefix-needed &&
@@ -26,9 +26,10 @@
 
 if [[ -n "$desc" ]]; then
   disp=()
+  zstyle -s ":completion:${curcontext}:jobs" list-separator sep || sep=--
   for job in "$jids[@]"; do
     [[ -n "$desc" ]] &&
-        disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
+        disp=( "$disp[@]" "${pfx}${(r:2:: :)job} $sep ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
   done
 fi
 

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-25 10:43           ` Sven Wischnowsky
  2001-07-25 11:36             ` Borsenkow Andrej
@ 2001-07-25 17:49             ` Bart Schaefer
  2001-07-27 12:53               ` Sven Wischnowsky
  1 sibling, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 2001-07-25 17:49 UTC (permalink / raw)
  To: zsh-workers

On Jul 25, 10:49am, Sven Wischnowsky wrote:
} Subject: Re: About the new long/short options changes
}
} The result is the patch below, which is already quite satisfying, I
} think.

Yes, this (plus the several followups) is quite good.  The only thing
more I could wish for is that TAB would move down the columns in menu
selection, rather than across, so that you don't get equivalent options
offered consecutively.  But that's such a minor thing that it's likely
not worth expending effort.

} If you try it, you'll see that this now behaves slightly different when
} completion options with and without groups in menu selection.  In the
} first case, only the matches are highlighted, in the latter case the
} whole lines are highlighted.

Having seen it both ways (thanks to that typo in _describe) I think this
is just fine.

My only other suggestion at this point would be to change the default
separator from `--' to one of `-', `=', or `:', but as it's configurable
that is again an exceptionally minor issue.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-25 17:49             ` Bart Schaefer
@ 2001-07-27 12:53               ` Sven Wischnowsky
  2001-07-30  8:22                 ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-27 12:53 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:

> On Jul 25, 10:49am, Sven Wischnowsky wrote:
> } Subject: Re: About the new long/short options changes
> }
> } The result is the patch below, which is already quite satisfying, I
> } think.
> 
> Yes, this (plus the several followups) is quite good.  The only thing
> more I could wish for is that TAB would move down the columns in menu
> selection, rather than across, so that you don't get equivalent options
> offered consecutively.  But that's such a minor thing that it's likely
> not worth expending effort.

But then again it's the kind of extra nicety I like to offer to people
(almost on the same range as auto-removable suffixes).

The patch below does that and finally really cleans up the listpacked
code, making it shorter and much clearer (and not much slower, if at all
(without listrowsfirst it can even be faster)).  And now it can be sure
to always find one of the optimal layouts -- different from before,
that's why I started to fiddle with it.  (And that's the biggest part of
the patch.)

Maybe I'll work that into the 4.0.2 branch sometime (but it wasn't
really a `bug' -- it just sometimes didn't find the best solution).

> My only other suggestion at this point would be to change the default
> separator from `--' to one of `-', `=', or `:', but as it's configurable
> that is again an exceptionally minor issue.

Hm.  I like that at other places where we use the separator string...
but since I could change it for me, I wouldn't be against changing it if
enough people care enought about it to support a change.  Otherwise:
feel free to change it.


Bye
  Sven

Index: Completion/Base/Utility/_describe
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_describe,v
retrieving revision 1.7
diff -u -r1.7 _describe
--- Completion/Base/Utility/_describe	2001/07/25 17:40:31	1.7
+++ Completion/Base/Utility/_describe	2001/07/27 12:46:06
@@ -78,9 +78,9 @@
         fi
     
         if [[ -n $_mats ]]; then
-          compadd "$_opts[@]" "$_expl[@]" -O $_strs -D $_mats -s $_strs
+          compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -O $_strs -D $_mats -s $_strs
         else
-          compadd "$_opts[@]" "$_expl[@]" -O $_strs -a $_strs
+          compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -O $_strs -a $_strs
         fi
       done
       set - "$_argv[@]"
@@ -97,6 +97,7 @@
     while compdescribe -g csl2 _args _tmpm _tmpd; do
 
       compstate[list]="$csl $csl2"
+      [[ -n "$csl2" ]] && compstate[list]="${compstate[list]:s/rows//}"
 
       compadd "$_args[@]" -d _tmpd -a _tmpm && _ret=0
     done
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.39
diff -u -r1.39 compresult.c
--- Src/Zle/compresult.c	2001/07/25 08:52:34	1.39
+++ Src/Zle/compresult.c	2001/07/27 12:46:07
@@ -1588,214 +1588,142 @@
 			ylens[i] = ztrlen(*pp) + add;
 
 		    if (g->flags & CGF_ROWS) {
-			int count, tcol, first, maxlines = 0, llines;
-			int beg = columns / g->shortest, end = g->cols;
+                        int nth, tcol, len;
 
-			while (1) {
-			    tcols = (beg + end) >> 1;
+                        for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                             tcols--) {
 
-			    for (nth = first = maxlen = width = maxlines =
-				     llines = tcol = 0,
-				     count = g->dcount;
-				 count > 0; count--) {
-				if (ylens[nth] > maxlen)
-				    maxlen = ylens[nth];
-				nth += tcols;
-				tlines++;
-				if (nth >= g->dcount) {
-				    if ((width += maxlen) >= columns)
-					break;
-				    ws[tcol++] = maxlen;
-				    maxlen = 0;
-				    nth = ++first;
-				    if (llines > maxlines)
-					maxlines = llines;
-				    llines = 0;
-				}
-			    }
-			    if (nth < yl) {
-				ws[tcol++] = maxlen;
-				width += maxlen;
-			    }
-			    if (!count && width <= columns &&
-				(tcols <= 0 || beg == end))
-				break;
-
-			    if (beg == end) {
-				beg--;
-				end--;
-			    } else if (width < columns) {
-				if ((end = tcols) == beg - 1)
-				    end++;
-			    } else {
-				if ((beg = tcols) - 1 == end)
-				    end++;
-			    }
-			}
-			if (tcols > g->cols)
-			    tlines = maxlines;
+                            memset(ws, 0, tcols * sizeof(int));
+
+                            for (width = nth = tcol = 0, tlines = 1;
+                                 width < columns && nth < g->dcount;
+                                 nth++, tcol++) {
+
+                                m = *p;
+
+                                if (tcol == tcols) {
+                                    tcol = 0;
+                                    tlines++;
+                                }
+                                len = ylens[nth];
+
+                                if (len > ws[tcol]) {
+                                    width += len - ws[tcol];
+                                    ws[tcol] = len;
+                                }
+                            }
+                            if (width < columns)
+                                break;
+                        }
 		    } else {
-			int beg = ((g->totl + columns) / columns);
-			int end = g->lins;
+                        int nth, tcol, tline, len;
 
-			while (1) {
-			    tlines = (beg + end) >> 1;
+                        for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                             tcols--) {
 
-			    for (pp = g->ylist, nth = tline = width =
-				     maxlen = tcols = 0;
-				 *pp; pp++) {
-				if (ylens[nth] > maxlen)
-				    maxlen = ylens[nth];
-				if (++tline == tlines) {
-				    if ((width += maxlen) >= columns)
-					break;
-				    ws[tcols++] = maxlen;
-				    maxlen = tline = 0;
-				}
-				nth++;
-			    }
-			    if (tline) {
-				ws[tcols++] = maxlen;
-				width += maxlen;
-			    }
-			    if (nth == yl && width <= columns &&
-				(beg == end || tlines >= g->lins))
-				break;
-
-			    if (beg == end) {
-				beg++;
-				end++;
-			    } else if (width < columns) {
-				if ((end = tlines) == beg + 1)
-				    end--;
-			    } else {
-				if ((beg = tlines) + 1 == end)
-				    end--;
-			    }
-			}
-			if (tlines > g->lins)
-			    tlines = g->lins;
+                            if ((tlines = (g->dcount + tcols - 1) / tcols) <= 0)
+                                tlines = 1;
+
+                            memset(ws, 0, tcols * sizeof(int));
+
+                            for (width = nth = tcol = tline = 0;
+                                 width < columns && nth < g->dcount;
+                                 nth++, tline++) {
+
+                                m = *p;
+
+                                if (tline == tlines) {
+                                    tcol++;
+                                    tline = 0;
+                                }
+                                if (tcol == tcols) {
+                                    tcol = 0;
+                                    tlines++;
+                                }
+                                len = ylens[nth];
+
+                                if (len > ws[tcol]) {
+                                    width += len - ws[tcol];
+                                    ws[tcol] = len;
+                                }
+                            }
+                            if (width < columns)
+                                break;
+                        }
 		    }
 		}
 	    } else if (g->width) {
 		if (g->flags & CGF_ROWS) {
-		    int addlen, count, tcol, maxlines = 0, llines, i;
-		    int beg = columns / g->shortest, end = g->cols, fe = 1;
-		    Cmatch *first;
-
-		    while (1) {
-			tcols = (beg + end) >> 1;
-
-			p = first = skipnolist(g->matches, showall);
-			for (maxlen = width = maxlines = llines = tcol = 0,
-				 count = g->dcount;
-			     count > 0; count--) {
-			    m = *p;
-			    addlen = (mlens[m->gnum] +
-                                      (tcol == tcols - 1 ? 0 : add));
-			    if (addlen > maxlen)
-				maxlen = addlen;
-			    for (i = tcols; i && *p; i--)
-				p = skipnolist(p + 1, showall);
-
-			    llines++;
-			    if (!*p) {
-				if (llines > maxlines)
-				    maxlines = llines;
-				llines = 0;
-
-				if ((width += maxlen) >= columns)
-				    break;
-				ws[tcol++] = maxlen;
-				maxlen = 0;
-
-				p = first = skipnolist(first + 1, showall);
-			    }
-			}
-			if (tlines) {
-			    ws[tcol++] = maxlen;
-			    width += maxlen;
-			}
-			if (!count && width <= columns &&
-			    (tcols <= 0 || beg == end))
-			    break;
-
-			if (beg == end) {
-                            if (fe) {
-                                beg += 2;
-                                end += 2;
-                                fe = 0;
-                            } else {
-                                beg--;
-                                end--;
-                            }
-			} else if (width < columns) {
-			    if ((end = tcols) == beg - 1)
-				end++;
-			} else {
-			    if ((beg = tcols) - 1 == end)
-				end++;
+                    int nth, tcol, len;
+
+                    for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                         tcols--) {
+
+                        memset(ws, 0, tcols * sizeof(int));
+
+                        for (width = nth = tcol = 0, tlines = 1,
+                             p = skipnolist(g->matches, showall);
+                             *p && width < columns && nth < g->dcount;
+                             nth++, p = skipnolist(p + 1, showall), tcol++) {
+
+                            m = *p;
+
+                            if (tcol == tcols) {
+                                tcol = 0;
+                                tlines++;
+                            }
+                            len = (mlens[m->gnum] +
+                                   (tcol == tcols - 1 ? 0 : add));
+
+                            if (len > ws[tcol]) {
+                                width += len - ws[tcol];
+                                ws[tcol] = len;
+                            }
                         }
-		    }
-		    if (tcols > g->cols)
-			tlines = maxlines;
+                        if (width < columns)
+                            break;
+                    }
 		} else {
-		    int addlen;
-		    int smask = ((showall ? 0 : (CMF_NOLIST | CMF_MULT)) |
-				 CMF_HIDE);
-		    int beg = ((g->totl + columns) / columns);
-		    int end = g->lins, fe = 1;
-
-		    while (1) {
-			tlines = (beg + end) >> 1;
-
-			for (p = g->matches, nth = tline = width =
-				 maxlen = tcols = 0;
-			     (m = *p); p++) {
-			    if (!(m->flags &
-				  (m->disp ? (CMF_DISPLINE | CMF_HIDE) :
-				   smask))) {
-				addlen = mlens[m->gnum] + add;
-				if (addlen > maxlen)
-				    maxlen = addlen;
-				if (++tline == tlines) {
-				    if ((width += maxlen) >= columns)
-					break;
-				    ws[tcols++] = maxlen;
-				    maxlen = tline = 0;
-				}
-				nth++;
-			    }
-			}
-			if (tline) {
-			    ws[tcols++] = maxlen;
-			    width += maxlen;
-			}
-			if (nth == g->dcount && width <= columns &&
-			    (beg == end || tlines >= g->lins))
-			    break;
-
-			if (beg == end) {
-                            if (fe) {
-                                beg -= 2;
-                                end -= 2;
-                                fe = 0;
-                            } else {
-                                beg++;
-                                end++;
-                            }
-			} else if (width < columns) {
-			    if ((end = tlines) == beg + 1)
-				end--;
-			} else {
-			    if ((beg = tlines) + 1 == end)
-				end--;
-			}
-		    }
-		    if (tlines > g->lins)
-			tlines = g->lins;
+                    int nth, tcol, tline, len;
+
+                    for (tcols = columns / (g->shortest + add); tcols > g->cols;
+                         tcols--) {
+
+                        if ((tlines = (g->dcount + tcols - 1) / tcols) <= 0)
+                            tlines = 1;
+
+                        memset(ws, 0, tcols * sizeof(int));
+
+                        for (width = nth = tcol = tline = 0,
+                             p = skipnolist(g->matches, showall);
+                             *p && width < columns && nth < g->dcount;
+                             nth++, p = skipnolist(p + 1, showall), tline++) {
+
+                            m = *p;
+
+                            if (tline == tlines) {
+                                tcol++;
+                                tline = 0;
+                            }
+                            if (tcol == tcols) {
+                                tcol = 0;
+                                tlines++;
+                            }
+                            len = (mlens[m->gnum] +
+                                   (tcol == tcols - 1 ? 0 : add));
+
+                            if (len > ws[tcol]) {
+                                width += len - ws[tcol];
+                                ws[tcol] = len;
+                            }
+                        }
+                        if (width < columns)
+                            break;
+                    }
 		}
 	    }
+            if (tcols <= g->cols)
+                tlines = g->lins;
 	    if (tlines == g->lins) {
 		zfree(ws, columns * sizeof(int));
 		g->widths = NULL;
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.69
diff -u -r1.69 computil.c
--- Src/Zle/computil.c	2001/07/25 12:18:24	1.69
+++ Src/Zle/computil.c	2001/07/27 12:46:08
@@ -74,6 +74,7 @@
 #define CRT_DESC   1
 #define CRT_SPEC   2
 #define CRT_DUMMY  3
+#define CRT_EXPL   4
 
 struct cdset {
     Cdset next;			/* guess what */
@@ -199,7 +200,9 @@
         VARARR(Cdstr, grps, lines);
         VARARR(int, wids, cd_state.maxg);
         Cdstr gs, gp, gn, *gpp;
-        int i, j;
+        int i, j, d;
+        Cdrun expl;
+        Cdstr *strp2;
 
         memset(wids, 0, cd_state.maxg * sizeof(int));
         strp = grps;
@@ -236,22 +239,59 @@
 
         qsort(grps, lines, sizeof(Cdstr), cd_sort);
 
-        for (i = lines, strp = grps; i; i--, strp++) {
-            for (j = 0, gs = *strp; gs->other; gs = gs->other, j++) {
-                *runp = run = (Cdrun) zalloc(sizeof(*run));
-                runp = &(run->next);
-                run->type = CRT_SPEC;
-                run->strs = gs;
-                gs->run = NULL;
-                run->count = 1;
-            }
+        expl =  (Cdrun) zalloc(sizeof(*run));
+        expl->type = CRT_EXPL;
+        expl->strs = grps[0];
+        expl->count = lines;
+
+        for (i = lines, strp = grps, strp2 = NULL; i; i--, strp++) {
+            str = *strp;
+            *strp = str->other;
+            if (strp2)
+                *strp2 = str;
+            strp2 = &(str->run);
+
             *runp = run = (Cdrun) zalloc(sizeof(*run));
             runp = &(run->next);
-            run->type = CRT_DUMMY + cd_state.maxg - j - 1;
-            run->strs = gs;
-            gs->run = NULL;
+            run->type = CRT_SPEC;
+            run->strs = str;
             run->count = 1;
         }
+        *strp2 = NULL;
+
+        for (i = cd_state.maxg - 1; i; i--) {
+            for (d = 0, j = lines, strp = grps; j; j--, strp++) {
+                if ((str = *strp)) {
+                    if (d) {
+                        *runp = run = (Cdrun) zalloc(sizeof(*run));
+                        runp = &(run->next);
+                        run->type = CRT_DUMMY;
+                        run->strs = expl->strs;
+                        run->count = d;
+                        d = 0;
+                    }
+                    *runp = run = (Cdrun) zalloc(sizeof(*run));
+                    runp = &(run->next);
+                    run->type = CRT_SPEC;
+                    run->strs = str;
+                    run->strs->run = NULL;
+                    run->count = 1;
+
+                    *strp = str->other;
+                } else
+                    d++;
+            }
+            if (d) {
+                *runp = run = (Cdrun) zalloc(sizeof(*run));
+                runp = &(run->next);
+                run->type = CRT_DUMMY;
+                run->strs = expl->strs;
+                run->count = d;
+            }
+        }
+        *runp = expl;
+        runp = &(expl->next);
+
         for (set = cd_state.sets; set; set = set->next) {
             for (i = 0, gs = NULL, gpp = &gs, str = set->strs;
                  str; str = str->next) {
@@ -528,6 +568,7 @@
                 opts[0] = ztrdup("-l");
                 break;
             }
+
         case CRT_SPEC:
             mats = (char **) zalloc(2 * sizeof(char *));
             dpys = (char **) zalloc(2 * sizeof(char *));
@@ -549,39 +590,56 @@
                 
             } else
                 opts[0] = ztrdup("-2V-default-");
-            csl = "packed rows";
+            csl = "packed";
             break;
+  
+        case CRT_DUMMY:
+            {
+                char buf[20];
+
+                sprintf(buf, "-E%d", run->count);
+
+                mats = (char **) zalloc(sizeof(char *));
+                dpys = (char **) zalloc(sizeof(char *));
+                mats[0] = dpys[0] = NULL;
+
+                opts = cd_arrdup(run->strs->set->opts);
+                opts[0] = ztrdup(buf);
 
-        default:
+                csl = "packed";
+            }
+            break;
+
+        case CRT_EXPL:
             {
                 int dlen = columns - cd_state.gpre - cd_state.slen;
                 VARARR(char, dbuf, dlen + cd_state.slen);
                 char buf[20];
-                int i = run->type - CRT_DUMMY;
+                int i = run->count;
 
-                sprintf(buf, "-E%d", i + 1);
+                sprintf(buf, "-E%d", i);
 
-                mats = (char **) zalloc(2 * sizeof(char *));
-                dpys = (char **) zalloc((3 + i) * sizeof(char *));
-                mats[0] = ztrdup(run->strs->match);
-                dpys[0] = ztrdup(run->strs->str);
-                for (dp = dpys + 1; i; i--, dp++)
-                    *dp = ztrdup("");
-                memset(dbuf + cd_state.slen, ' ', dlen - 1);
-                dbuf[dlen + cd_state.slen - 1] = '\0';
-                strcpy(dbuf, cd_state.sep);
-                memcpy(dbuf + cd_state.slen,
-                       run->strs->desc,
-                       (strlen(run->strs->desc) >= dlen ? dlen - 1 :
-                        strlen(run->strs->desc)));
-                *dp++ = ztrdup(dbuf);
-                mats[1] = *dp = NULL;
+                mats = (char **) zalloc(sizeof(char *));
+                dpys = (char **) zalloc((i + 1) * sizeof(char *));
 
+                for (dp = dpys, str = run->strs; str; str = str->run) {
+                    memset(dbuf + cd_state.slen, ' ', dlen - 1);
+                    dbuf[dlen + cd_state.slen - 1] = '\0';
+                    strcpy(dbuf, cd_state.sep);
+                    memcpy(dbuf + cd_state.slen,
+                           str->desc,
+                           (strlen(str->desc) >= dlen ? dlen - 1 :
+                            strlen(str->desc)));
+                    *dp++ = ztrdup(dbuf);
+                }
+                mats[0] = *dp = NULL;
+
                 opts = cd_arrdup(run->strs->set->opts);
                 opts[0] = ztrdup(buf);
 
-                csl = "packed rows";
+                csl = "packed";
             }
+            break;
         }
         setsparam(params[0], ztrdup(csl));
         setaparam(params[1], opts);

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-27 12:53               ` Sven Wischnowsky
@ 2001-07-30  8:22                 ` Sven Wischnowsky
  2001-07-30  8:38                   ` Sven Wischnowsky
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-30  8:22 UTC (permalink / raw)
  To: zsh-workers

Two last bits of cleanup.

First, we need compgroups to add empty groups in a different order.  I'm
not too happy about hardcoding that (although the patch makes it most to
least `special', so to say, so it almost makes sense), maybe I'll add
options to say in which order they should be defined if I ever think
it's too weird.

Second, trying `gzip <TAB>' with `prefix-needed == false' didn't show
files because of the return value of _arguments.  We've (ok: I) changed
this several times now and can only hope it doesn't interfere with other
complicated functions using _arguments.


Bye
  Sven

Index: Completion/Base/Utility/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_arguments,v
retrieving revision 1.8
diff -u -r1.8 _arguments
--- Completion/Base/Utility/_arguments	2001/06/06 09:31:54	1.8
+++ Completion/Base/Utility/_arguments	2001/07/30 08:16:49
@@ -428,6 +428,8 @@
 
   if [[ -n "$aret" ]]; then
     [[ -n $rawret ]] && return 300
+
+    return 1
   else
     [[ -n "$noargs" && nm -eq "$compstate[nmatches]" ]] && _message "$noargs"
   fi
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.70
diff -u -r1.70 computil.c
--- Src/Zle/computil.c	2001/07/27 12:56:57	1.70
+++ Src/Zle/computil.c	2001/07/30 08:16:50
@@ -4281,9 +4281,7 @@
     SWITCHHEAPS(oldheap, compheap) {
 	while ((n = *args++)) {
 	    endcmgroup(NULL);
-	    begcmgroup(n, 0);
-	    endcmgroup(NULL);
-	    begcmgroup(n, CGF_NOSORT);
+	    begcmgroup(n, CGF_NOSORT|CGF_UNIQCON);
 	    endcmgroup(NULL);
 	    begcmgroup(n, CGF_UNIQALL);
 	    endcmgroup(NULL);
@@ -4291,7 +4289,9 @@
 	    endcmgroup(NULL);
 	    begcmgroup(n, CGF_UNIQALL);
 	    endcmgroup(NULL);
-	    begcmgroup(n, CGF_NOSORT|CGF_UNIQCON);
+	    begcmgroup(n, CGF_NOSORT);
+	    endcmgroup(NULL);
+	    begcmgroup(n, 0);
 	}
     } SWITCHBACKHEAPS(oldheap);
 

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: About the new long/short options changes
  2001-07-30  8:22                 ` Sven Wischnowsky
@ 2001-07-30  8:38                   ` Sven Wischnowsky
  0 siblings, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2001-07-30  8:38 UTC (permalink / raw)
  To: zsh-workers

I wrote:

> ...
> 
> Second, trying `gzip <TAB>' with `prefix-needed == false' didn't show
> files because of the return value of _arguments.  We've (ok: I) changed
> this several times now and can only hope it doesn't interfere with other
> complicated functions using _arguments.

Urgh.  Thinko.  This doesn't work because there may be no matches in the
completions generated by the calling function.  Damn.

I comment this out for now.  If noone sees a better solution, the thing
to do might be to make all functions using `->state' actions compare
$compstate[nmatches] to its previous value on exit.


Bye
  Sven

? Completion/Unix/Command/_gzip#
Index: Completion/Base/Utility/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_arguments,v
retrieving revision 1.8
diff -u -r1.8 _arguments
--- Completion/Base/Utility/_arguments	2001/06/06 09:31:54	1.8
+++ Completion/Base/Utility/_arguments	2001/07/30 08:36:39
@@ -428,6 +428,14 @@
 
   if [[ -n "$aret" ]]; then
     [[ -n $rawret ]] && return 300
+
+### Returning non-zero would allow the calling function to add its own
+### completions if we generated only options and have to use a ->state
+### action.  But if that then doesn't generate matches, the calling
+### function's return value would be wrong unless it compares
+### $compstate[nmatches] to its previous value.  Ugly.
+###
+###    return 1
   else
     [[ -n "$noargs" && nm -eq "$compstate[nmatches]" ]] && _message "$noargs"
   fi
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.70
diff -u -r1.70 computil.c
--- Src/Zle/computil.c	2001/07/27 12:56:57	1.70
+++ Src/Zle/computil.c	2001/07/30 08:36:40
@@ -4281,9 +4281,7 @@
     SWITCHHEAPS(oldheap, compheap) {
 	while ((n = *args++)) {
 	    endcmgroup(NULL);
-	    begcmgroup(n, 0);
-	    endcmgroup(NULL);
-	    begcmgroup(n, CGF_NOSORT);
+	    begcmgroup(n, CGF_NOSORT|CGF_UNIQCON);
 	    endcmgroup(NULL);
 	    begcmgroup(n, CGF_UNIQALL);
 	    endcmgroup(NULL);
@@ -4291,7 +4289,9 @@
 	    endcmgroup(NULL);
 	    begcmgroup(n, CGF_UNIQALL);
 	    endcmgroup(NULL);
-	    begcmgroup(n, CGF_NOSORT|CGF_UNIQCON);
+	    begcmgroup(n, CGF_NOSORT);
+	    endcmgroup(NULL);
+	    begcmgroup(n, 0);
 	}
     } SWITCHBACKHEAPS(oldheap);
 

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2001-07-30  8:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-20  5:01 About the new long/short options changes Bart Schaefer
2001-07-20  7:38 ` Sven Wischnowsky
2001-07-20  9:26   ` Bart Schaefer
2001-07-20  9:43     ` Andrej Borsenkow
2001-07-25  8:49     ` Sven Wischnowsky
2001-07-25  9:15       ` Borsenkow Andrej
2001-07-25  9:20         ` Sven Wischnowsky
2001-07-25  9:24           ` Borsenkow Andrej
2001-07-25 10:13         ` Peter Stephenson
2001-07-25 10:43           ` Sven Wischnowsky
2001-07-25 11:36             ` Borsenkow Andrej
2001-07-25 12:16               ` Sven Wischnowsky
2001-07-25 12:35                 ` Sven Wischnowsky
2001-07-25 17:49             ` Bart Schaefer
2001-07-27 12:53               ` Sven Wischnowsky
2001-07-30  8:22                 ` Sven Wischnowsky
2001-07-30  8:38                   ` Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).