zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: widget called when zle starts.
@ 2003-12-12 22:53 Peter Stephenson
  2003-12-13 19:34 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2003-12-12 22:53 UTC (permalink / raw)
  To: Zsh hackers list

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-<something-else>-<init-or-exit-or-change>
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 <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-12-15 19:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-12 22:53 PATCH: widget called when zle starts Peter Stephenson
2003-12-13 19:34 ` Bart Schaefer
2003-12-15 10:57   ` Peter Stephenson
2003-12-15 18:43     ` Bart Schaefer
2003-12-15 18:50       ` Peter Stephenson
2003-12-15 19:21         ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).