zsh-workers
 help / color / mirror / code / Atom feed
* Re: zstyle question: enter menu selection on lots of ambiguity
@ 2000-07-27 10:58 Sven Wischnowsky
  2000-07-27 17:19 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-07-27 10:58 UTC (permalink / raw)
  To: zsh-workers


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
again.

> ...
> 
> 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?


Bye
 Sven

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
     compstate[insert]=menu
   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
         compstate[insert]=menu
     else
       sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )
@@ -230,6 +231,7 @@
   fi
 
   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@informatik.hu-berlin.de


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

* Re: zstyle question: enter menu selection on lots of ambiguity
  2000-07-27 10:58 zstyle question: enter menu selection on lots of ambiguity Sven Wischnowsky
@ 2000-07-27 17:19 ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-07-27 17:19 UTC (permalink / raw)
  To: zsh-workers

On Jul 27, 12:58pm, Sven Wischnowsky wrote:
} Subject: Re: zstyle question: enter menu selection on lots of ambiguity
}
} Bart Schaefer wrote:
} 
} > 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.

Hmm, I'm not sure how to react to that.  C-d doesn't stop normal menu
completion; you have to type space or slash or whatever to "accept" the
match before generating a new list.  I suppose that's because in the
absence of `autolist' there won't be any listing yet, whereas with menu-
selection there's always a listing.

} So, with this patch, 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>'.

OK, great, thanks!  So now ... how do I combine it with select=<num> in
such a way that I get menu-selection on the first tab when the list is
too long for the screen and on the second tab when the list is more than
<num> elements long?

E.g. on a 80x24 display, yes=long select=30 would work most of the time;
but if each match were more than 40 characters wide, fewer than 30 of
them would still be more than a screenful.

-- 
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] 5+ messages in thread

* Re: zstyle question: enter menu selection on lots of ambiguity
  2000-07-28  7:00 Sven Wischnowsky
@ 2000-07-30  4:34 ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-07-30  4:34 UTC (permalink / raw)
  To: zsh-workers

On Jul 28,  9:00am, Sven Wischnowsky wrote:
} 
} You can give `select=*' more than once, which especially makes sense
} if it's once with a number and once with `long*':
} 
}   zstyle '*' menu yes=long select=long select=10
} 
} (the manual says `In addition to (or instead of)...').

Yeah, it says `select' can be in addition to or instead of `yes' et al.
It doesn't say what happens when `select' is in addition to itself.  It
might be nice to clarify; are there other cases where it's meaningful to
give similar strings multiple times in the value of a style?

(I wasn't going to bother to reply to this, but one of my other messages
to zsh-workers seems to have vanished, so this is doubling as a test.)

-- 
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] 5+ messages in thread

* Re: zstyle question: enter menu selection on lots of ambiguity
@ 2000-07-28  7:00 Sven Wischnowsky
  2000-07-30  4:34 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-07-28  7:00 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Jul 27, 12:58pm, Sven Wischnowsky wrote:
> } Subject: Re: zstyle question: enter menu selection on lots of ambiguity
> }
> } Bart Schaefer wrote:
> } 
> } > 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.
> 
> Hmm, I'm not sure how to react to that.  C-d doesn't stop normal menu
> completion; you have to type space or slash or whatever to "accept" the
> match before generating a new list.  I suppose that's because in the
> absence of `autolist' there won't be any listing yet, whereas with menu-
> selection there's always a listing.

You could do:

  bindkey -M menuselect '^D' redisplay

to make ^D have no (visible) effect.

> } So, with this patch, 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>'.
> 
> OK, great, thanks!  So now ... how do I combine it with select=<num> in
> such a way that I get menu-selection on the first tab when the list is
> too long for the screen and on the second tab when the list is more than
> <num> elements long?

You can give `select=*' more than once, which especially makes sense
if it's once with a number and once with `long*':

  zstyle '*' menu yes=long select=long select=10

(the manual says `In addition to (or instead of)...').

Bye
 Sven


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


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

* zstyle question: enter menu selection on lots of ambiguity
@ 2000-07-27  9:51 Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-07-27  9:51 UTC (permalink / raw)
  To: zsh-workers

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).

So I hit upon this scheme:

zstyle -e ':completion:*' menu \
  '[[ $compstate[list] == ambiguous ]] && \
     compstate[list]="$compstate[list] list" reply=(select=long-list)'

This *almost* works -- if the list doesn't fill the screen, then I get a
list on the first tab and menu completion on the second, and if the list
does fill the screen then I get menu-selection on the first tab.  Yay!
BUT:  As soon as menu selection has started once this way, it starts for
ALL menu completions -- on the second tab for short lists, on the first
tab for long ones.  I don't want it to start on the second tab for short
lists.  (Actually, I want it to start on the second tab for lists longer
than 12 items, but I thought I'd work on that separately.)

I also worry about appending "list" to the value of compstate[list]; it
produces values like "ambiguous list" which doesn't *appear* to break any
other code, but ...

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

-- 
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] 5+ messages in thread

end of thread, other threads:[~2000-07-30  9:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-27 10:58 zstyle question: enter menu selection on lots of ambiguity Sven Wischnowsky
2000-07-27 17:19 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-07-28  7:00 Sven Wischnowsky
2000-07-30  4:34 ` Bart Schaefer
2000-07-27  9:51 Bart Schaefer

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).