Zsh Mailing List Archive
Messages sorted by:
Re: zle_line_init_functions (Re: accept-line-and-down-history and push-input)
- X-seq: zsh-workers 28370
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: zle_line_init_functions (Re: accept-line-and-down-history and push-input)
- Date: Wed, 27 Oct 2010 10:22:16 +0100
- In-reply-to: <101026220102.ZM29774@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <AANLkTin4qeNKcBt_TDzY2xt-XJ6aHVH257FOa6iriPSm@xxxxxxxxxxxxxx> <101026075546.ZM28500@xxxxxxxxxxxxxxxxxxxxxx> <20101026161947.19279c58@xxxxxxxxxxxxxxxxxxxxxxxxx> <101026220102.ZM29774@xxxxxxxxxxxxxxxxxxxxxx>
On Tue, 26 Oct 2010 22:01:02 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } I've been thinking along those lines, except that the array of hook
> } functions would be the alternative to the widget, as with chpwd and
> } friends
> I don't much like the idea of having an array of *widget names*.
> What's the benefit of invoking a series of widgets, rather than
> having one widget that calls a series of functions?
It looks like the way other hooks work. If you have the behaviour
buried in the widget itself it looks different from the other hooks
which are independent of the definition of the base function.
Also, if you do it the other way, within zle you have to do something
more complicated than I've just written that performs an extra level of
indirection to call a whole heap of other widgets. Then all the
widgets have to be predefined in the appropriate configuration file. (I
imagine there would be a template C function where the widget examined
its name.) Before, no widget needed to exist at all; the whole thing
just required a single universal function and a simple function call
for each hook and you only created widgets as needed. That's the
system I want to extend.
> The context is
> the same either way (i.e., "zle" with no args returns zero status
> and you can access all the line editor variables) and all the work
> of creating and destroying thingys can be avoided.
There's no work of creating and destroying thingies. Either the widget
exists, in which cases it's already referenced, or it doesn't, in which
case nothing is created and NULL returned. It doesn't make sense to me
to have a whole new set of callable zle functions that aren't widgets,
it creates a new category that blurs the boundaries.
> } i.e. you could still define zle-line-init if you wanted a
> } simple life but zle_line_init_functions could contain an additional
> set } of widgets.
> Wouldn't you still get that effect if zle-line-init was a builtin
> widget that you could override with your own via zle -N ?
Depends if you want the current behaviour as well. If someone submits a
suggestion that uses zle-line-init directly, which is how the shell
currently works, and someone else a suggestion that involves the hook
function, which would be neater, they can't both work without
modification. Of course two suggestions using zle-line-init need work
combining anyway, but it's obvious in that case that the function/widget
can't do two different things. It's less obvious --- particularly if
you've happily been using an earlier version of the shell and not
noticed the way the behaviour has changed --- that redefining
zle-line-init causes other facilities to disappear. I don't want
to have to keep explaining this.
> } Not sure how to keep the name of the array entirely within zle
> I don't know what you're reaching for, there. The array has to be
> outside of zle at some point or you can't assign anything to it ...?
That depends on the interface, but I can't think of a better way
than an array.
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by: