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

Re: Calling a zle widget from a function



Peter Stephenson <pws@xxxxxxx>:
> Frank Terbeck wrote:
> > So, that means that (no matter if using v4.2 or v4.3) you cannot call
> > widgets from the commandline, right?
> 
> From the *command line* you can: type Esc x and enter the name of the
> widget (or bind it with bindkey).  From something executed as an
> ordinary piece of shell code from the command line, and in particular
> from a trap, you can't.

Yes, I knew 'execute-named-cmd'. I meant the latter. Thanks for
clarifying.

> > And how would you 'hook' into zle? I don't know what you meant by
> > that.
> 
> You can redefine any standard widget to get it to execute your own code
> as well as its normal function.  This is sometimes done with
> accept-line:
> 
>   accept-line() {
>     my-code
>     zle .accept-line
>   }
>   zle -N accept-line

So, .widgetname always calls the original widget. That is really
helpful. Thanks for mentioning it. :-)
I always created some differently named widget and rebound the original
key, which is kind of a PITA, if you don't know to which key the
original widget may have been bound to.

> However, I don't think there's anything you can intercept when zle is
> idle.  You can "kick" zle with "zle -I" from outside it to cause it to
> redisplay, but as far as I can see that doesn't go through any
> user-redefinable widgets.  So that doesn't seem to help either.

Okay.

> There are a limited number of "real" hooks (zle-line-init and
> zle-keymap-select), although I called them "special widgets" which
> wasn't a particular clever name, but neither of them helps here either.

Again, something new (for me). I'll look into these.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



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