From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26384 invoked from network); 12 Dec 2003 22:48:13 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 12 Dec 2003 22:48:13 -0000 Received: (qmail 15974 invoked by alias); 12 Dec 2003 22:47:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19281 Received: (qmail 15863 invoked from network); 12 Dec 2003 22:47:56 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 12 Dec 2003 22:47:56 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [195.92.195.175] by sunsite.dk (MessageWall 1.0.8) with SMTP; 12 Dec 2003 22:47:56 -0000 Received: from modem-10.north-dakota.dialup.pol.co.uk ([62.137.85.10] helo=pwstephenson.fsnet.co.uk) by cmailg5.svr.pol.co.uk with esmtp (Exim 4.14) id 1AUw4g-0007Yu-KL for zsh-workers@sunsite.dk; Fri, 12 Dec 2003 22:47:55 +0000 Received: by pwstephenson.fsnet.co.uk (Postfix, from userid 501) id AE2BA84C8; Fri, 12 Dec 2003 17:53:14 -0500 (EST) Received: from pwstephenson.fsnet.co.uk (localhost [127.0.0.1]) by pwstephenson.fsnet.co.uk (Postfix) with ESMTP id 97CD284C7 for ; Fri, 12 Dec 2003 22:53:14 +0000 (GMT) To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: widget called when zle starts. Date: Fri, 12 Dec 2003 22:53:13 +0000 From: Peter Stephenson Message-Id: <20031212225314.AE2BA84C8@pwstephenson.fsnet.co.uk> If it's really this simple, it's definitely worth having. Comment on the name, if you like. The idea is that there could conceivably be other zle-- special widgets in future. An extra chunk simply shuts up a long-standing warning from gcc. Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.37 diff -u -r1.37 zle_main.c --- Src/Zle/zle_main.c 3 Nov 2003 13:57:53 -0000 1.37 +++ Src/Zle/zle_main.c 12 Dec 2003 22:42:21 -0000 @@ -348,7 +348,8 @@ { long exp100ths; int ret; -#ifdef HAS_TIO +#if defined(HAS_TIO) && \ + (defined(sun) || (!defined(HAVE_POLL) && !defined(HAVE_SELECT))) struct ttyinfo ti; #endif #ifndef HAVE_POLL @@ -739,6 +740,7 @@ unsigned char *s; int old_errno = errno; int tmout = getiparam("TMOUT"); + Thingy initthingy; #if defined(HAVE_POLL) || defined(HAVE_SELECT) baud = getiparam("BAUD"); @@ -820,6 +822,14 @@ lastcol = -1; initmodifier(&zmod); prefixflag = 0; + + if ((initthingy = rthingy_nocreate("zle-line-init"))) { + char *args[2]; + args[0] = initthingy->nam; + args[1] = NULL; + execzlefunc(initthingy, args); + unrefthingy(initthingy); + } zlecore(); Index: Src/Zle/zle_thingy.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v retrieving revision 1.11 diff -u -r1.11 zle_thingy.c --- Src/Zle/zle_thingy.c 29 Oct 2003 19:17:48 -0000 1.11 +++ Src/Zle/zle_thingy.c 12 Dec 2003 22:42:22 -0000 @@ -164,6 +164,17 @@ return refthingy(t); } +/**/ +Thingy +rthingy_nocreate(char *nam) +{ + Thingy t = (Thingy) thingytab->getnode2(thingytab, nam); + + if(!t) + return NULL; + return refthingy(t); +} + /***********/ /* widgets */ /***********/ Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.30 diff -u -r1.30 zle.yo --- Doc/Zsh/zle.yo 22 May 2003 09:48:28 -0000 1.30 +++ Doc/Zsh/zle.yo 12 Dec 2003 22:42:28 -0000 @@ -695,6 +695,26 @@ The name of the widget currently being executed; read-only. ) enditem() + +subsect(Special Widget) + +There is one user-defined widget which is special to the shell. +If it does not exist, no special action is taken. The environment +provided is identical to that for any other editing widget. + +startitem() +tindex(zle-line-init) +item(tt(zle-line-init))( +Executed every time the line editor is started to read a new line +of input. The following example puts the line editor into vi command +mode when it starts up. + +example(zle-line-init() { zle -K vicmd; } +zle -N zle-line-init) + +) +enditem() + sect(Standard Widgets) cindex(widgets, standard) The following is a list of all the standard widgets, -- Peter Stephenson Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk