From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7546 invoked by alias); 27 Oct 2010 09:22:52 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28370 Received: (qmail 18261 invoked from network); 27 Oct 2010 09:22:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Wed, 27 Oct 2010 10:22:16 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: zle_line_init_functions (Re: accept-line-and-down-history and push-input) Message-ID: <20101027102216.16719058@pwslap01u.europe.root.pri> In-Reply-To: <101026220102.ZM29774@torch.brasslantern.com> References: <101026075546.ZM28500@torch.brasslantern.com> <20101026161947.19279c58@pwslap01u.europe.root.pri> <101026220102.ZM29774@torch.brasslantern.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Oct 2010 09:22:17.0252 (UTC) FILETIME=[72E95E40:01CB75B8] X-Scanned-By: MailControl A-10-90-03 (www.mailcontrol.com) on 10.71.0.140 On Tue, 26 Oct 2010 22:01:02 -0700 Bart Schaefer 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 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