Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zstyle question: enter menu selection on lots of ambiguity

Bart Schaefer wrote:

> So even after all Sven's hard work, I'm still not satisfied with the way
> the menu style and long-list work together.
> What I want is:
> - automenu (first tab lists, second tab menu completes), except
> - when the list won't fit on the screen, the first tab should
>   enter menu selection immediately, but
> - simply asking for a listing with C-d should never do menu-selection,
>   no matter how long the list is
> If I use 'select=long-list' I get menu-selection on the second tab.
> If I use 'yes=long-list' I get menu completion started when I type C-d
> (and some other pretty odd behavior besides, I might add).
> If I use both, I get menu-selection on the second tab and on C-d, and
> sometimes more of the strange behavior (the same match inserted on the
> line multiple times and stuff like that -- I think it happens if you hit
> C-d repeatedly after completion or selection has started when the match
> on the line (highlighted, in selection) is NOT a directory).

That perfectly ok'ish, actually. The ^D leaves menu selection, keeping 
the currently selected match on the line, and makes the widget bound
to it be executed. Which does completion and starts menu-selection,
inserting the first match and when you hit ^D, it happens again and

> ...
> So what's the right way to accomplish all of this?

This should have been possible, of course. The reason why it wasn't
was a mixture of three things:

- a bug in the treatment of the `special' value `00' for MENUSELECT
  (used to indicate that selection was started because of
  select=long*); it wasn't reset
- a wrong test for `yes=long'
- and a missing description for that (i.e. that `yes', like `select',
  supports `=long' and not only `=long-list')

Sorry for all that.

So, with this patch, you can do:

  zstyle ':completion:*' menu yes=long select

if you always want menu selection instead of menu completion (i.e. if
you want it even if the list of matches fits onto the screen). Or you
can do:

  zstyle ':completion:*' menu yes=long select=long

if you want selection only if the list is too long for the screen.
Of course you can also combine it with `select=<num>'.

Better now?


Index: Completion/Core/_main_complete
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.38
diff -u -r1.38 _main_complete
--- Completion/Core/_main_complete	2000/07/27 07:25:07	1.38
+++ Completion/Core/_main_complete	2000/07/27 10:46:27
@@ -177,7 +177,8 @@
           -n "$_menu_style[(r)(yes|true|on|1)=long-list]" ) ]]; then
   elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then
-    if [[ -n "$_menu_style[(r)(yes|true|1|on)=long]" && tmp -gt LINES ]]; then
+    if [[ -n "$compstate[insert]" &&
+          -n "$_menu_style[(r)(yes|true|1|on)=long]" && tmp -gt LINES ]]; then
       sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )
@@ -230,6 +231,7 @@
   if [[ "$compstate[insert]" = *menu* ]]; then
+    [[ "$MENUSELECT" = 00 ]] && MENUSELECT=0
     if [[ -n "$_menu_style[(r)no-select*]" ]]; then
       unset MENUSELECT
     elif [[ -n "$_menu_style[(r)select=long*]" ]]; then
Index: Doc/Zsh/compsys.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.85
diff -u -r1.85 compsys.yo
--- Doc/Zsh/compsys.yo	2000/07/26 08:54:58	1.85
+++ Doc/Zsh/compsys.yo	2000/07/27 10:46:29
@@ -1628,8 +1628,11 @@
 em(not) be used if there are var(num) or more matches.  Of course,
 this is only useful when menu completion is normally used, e.g. by
 setting the tt(MENU_COMPLETE) option.  The `true' values may also be
-used in the form `tt(yes=long-list)' to turn on menu completion
-whenever listing is done and the list does not fit onto the screen.
+used in the form `tt(yes=long)' to turn on menu completion
+if the list does not fit onto the screen.  This will start menu
+completion only if normal completion was attempted, not when only the
+list of possible completions was requested.  To start menu completion
+even then, the value `tt(yes=long-list)' can be used.
 In addition to (or instead of) the above possibilities, the value may
 contain the string `tt(select)', optionally followed by an equal sign and a

Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx

Messages sorted by: Reverse Date, Date, Thread, Author