From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10243 invoked by alias); 26 Oct 2010 16:02:01 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15493 Received: (qmail 8222 invoked from network); 26 Oct 2010 16:01:46 -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: Tue, 26 Oct 2010 16:19:47 +0100 From: Peter Stephenson To: Zsh Users Subject: Re: accept-line-and-down-history and push-input Message-ID: <20101026161947.19279c58@pwslap01u.europe.root.pri> In-Reply-To: <101026075546.ZM28500@torch.brasslantern.com> References: <101026075546.ZM28500@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: 26 Oct 2010 15:19:47.0789 (UTC) FILETIME=[3A03CFD0:01CB7521] X-Scanned-By: MailControl A-10-90-03 (www.mailcontrol.com) on 10.68.0.133 On Tue, 26 Oct 2010 07:55:44 -0700 Bart Schaefer wrote: > (I'm beginning to think that zle-line-init should be a builtin widget > that calls an array of hook functions, ala precmd.) 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.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. Something like the following. zle_line_init_functions=(zle-le-test) zle-le-test() { zle -M Initialised.; } zle -N zle-le-test Not sure how to keep the name of the array entirely within zle, but I'm not sure it's necessary: using variables with a prefix zle_ is natural enough. Index: Src/Zle/zle_utils.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v retrieving revision 1.57 diff -p -u -r1.57 zle_utils.c --- Src/Zle/zle_utils.c 20 Sep 2010 09:27:46 -0000 1.57 +++ Src/Zle/zle_utils.c 26 Oct 2010 15:16:42 -0000 @@ -1250,21 +1250,48 @@ viundochange(char **args) void zlecallhook(char *name, char *arg) { - Thingy thingy = rthingy_nocreate(name); + Thingy thingy; int saverrflag, savretflag; - char *args[3]; + char *args[3], *arrname, **funcarray, *ptr; + const char suffix[] = "_functions"; - if (!thingy) - return; + /* Get the name of the corresponding hook array */ + arrname = zalloc(strlen(name) + strlen(suffix) + 1); + sprintf(arrname, "%s%s", name, suffix); + for (ptr = arrname; *ptr; ptr++) { + if (*ptr == '-') + *ptr = '_'; + } saverrflag = errflag; savretflag = retflag; - args[0] = thingy->nam; args[1] = arg; args[2] = NULL; - execzlefunc(thingy, args, 1); - unrefthingy(thingy); + + thingy = rthingy_nocreate(name); + if (thingy) { + args[0] = thingy->nam; + execzlefunc(thingy, args, 1); + unrefthingy(thingy); + } + + funcarray = getaparam(arrname); + if (funcarray) { + /* in case the array changes during use */ + funcarray = arrdup(funcarray); + for (; *funcarray; funcarray++) { + errflag = 0; + retflag = 0; + + thingy = rthingy_nocreate(*funcarray); + if (thingy) { + args[0] = thingy->nam; + execzlefunc(thingy, args, 1); + unrefthingy(thingy); + } + } + } errflag = saverrflag; retflag = savretflag; -- 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