* menu-select doesn't work with zle -C/_describe
@ 2007-10-04 14:22 Julius Plenz
2007-10-04 16:55 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Julius Plenz @ 2007-10-04 14:22 UTC (permalink / raw)
To: zsh-users
Hi!
While writing a completion function, I noticed the following problem:
I have included the zsh/complist module and wanted to make a
completion widget bound to a specific key combination. My approach
looks like this:
_x () {
local -a x
x=(one two three four)
compadd -a x
}
zle -C x menu-select _x
bindkey '^Xx' x
If I press Ctrl-X x at any point, the completion axpands to any of the
four arguments or presents a menu (with the selected entry being
reversed).
Now I want to add a describtion, so I change the function to:
local -a x expl
x=(one two three four)
_description files expl 'xxx'
compadd "$expl[@]" -a x
When I press Ctrl-X x now, the menu is printed with a caption and the
prompt is re-printed below it, but I am not able to select anything
from the menu (no entry is highlighted). The same effect occurs when I
use
_wanted files expl 'xxx' compadd -a x
or
_describe -t files 'xxx' x
The only way to insert a caption and still get the menu-select
behaviour is to use `compadd -X ".."' and insert the format-code used
for descriptions by hand. But this can't be it, right?
I greatly appreciate any hint on what I'm doing wrong here! :-)
Julius
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: menu-select doesn't work with zle -C/_describe
2007-10-04 14:22 menu-select doesn't work with zle -C/_describe Julius Plenz
@ 2007-10-04 16:55 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2007-10-04 16:55 UTC (permalink / raw)
To: zsh-users
Julius Plenz wrote:
... abbreviated to the following effect ...
> _x() {
> local -a x expl
> x=(one two three four)
> _wanted files expl 'xxx' compadd -a x
> }
> zle -C x menu-select _x
> bindkey '^Xx' x
>
> When I press Ctrl-X x now, the menu is printed with a caption and the
> prompt is re-printed below it, but I am not able to select anything
> from the menu (no entry is highlighted).
The function is OK (the _wanted form is the preferred one) but
entering the completion system directly at menu-select is likely to do
odd things---most of the controls assume the completion system itself is
in charge of setting up menus etc.
Try using the function in the following manner (this replaces your "zle
-C" line):
zle -C x complete-word _generic
zstyle ':completion:x:*' completer _x
zstyle ':completion:x:*' menu select
Now you're entering the completion system the normal way, but with the
styles set to use menu selection. This should work better. Obviously,
if you use a more descriptive name, the "x"s in the style context need
to change, too.
See the description of the _generic completer in the zshcompsys manual.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-10-04 16:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-04 14:22 menu-select doesn't work with zle -C/_describe Julius Plenz
2007-10-04 16:55 ` Peter Stephenson
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).