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

Re: ${(k)widgets} v. 'zle -la'



Bart Schaefer wrote on Tue, Jul 05, 2016 at 14:01:20 -0700:
> On Jul 5,  4:57am, Daniel Shahaf wrote:
> } $ zsh -f
> } % bindkey zzzzzz foobar
> } % zle -la | grep foobar                   
> } % print -rl -- ${(k)widgets} | grep foobar 
> } foobar
> } % 
> 
> "zle -la" lists only USER-DEFINED widgets, wheras $widgets includes ALL
> widgets.  In your example the "foobar" widget doesn't exist yet, so it
> isn't user-defined, so "zle -la" doesn't show it.

Thanks for the explanation.

Is the following behaviour also intentional?  Testing a key's presence
in the associative array in different ways gives different results:

    % bindkey foo bar
    % () { print $(( $argv[(I)bar] > 0 )) } ${(k)widgets}
    1
    % print ${+widgets[bar]}
    0

I ran into this while trying to clarify the docs of $widgets in line
with your answer.

Thanks again,

Daniel



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