1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-29 19:00:57 +02:00

28282: new function zlecallhook()

fix arguments to zle-keymap-select
This commit is contained in:
Peter Stephenson 2010-09-20 09:27:46 +00:00
parent 9530331b4f
commit 8856dc878e
4 changed files with 44 additions and 35 deletions

View file

@ -1,3 +1,9 @@
2010-09-20 Peter Stephenson <pws@csr.com>
* 28282: Src/Zle/zle_keymap.c, Src/Zle/zle_main.c,
Src/zle_utils.c: new function zlecallhook() and fix argument to
zle-keymap-select.
2010-09-19 Barton E. Schaefer <schaefer@zsh.org>
* 28268: Src/builtin.c: I/O to a terminated (or never created)
@ -13662,5 +13668,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.5084 $
* $Revision: 1.5085 $
*****************************************************

View file

@ -486,22 +486,11 @@ selectkeymap(char *name, int fb)
}
if(name != curkeymapname) {
char *oname = curkeymapname;
Thingy chgthingy;
curkeymapname = ztrdup(name);
if (oname && zleactive && strcmp(oname, curkeymapname) &&
(chgthingy = rthingy_nocreate("zle-keymap-select"))) {
char *args[2];
int saverrflag = errflag, savretflag = retflag;
args[0] = oname;
args[1] = NULL;
errflag = retflag = 0;
execzlefunc(chgthingy, args, 1);
unrefthingy(chgthingy);
errflag = saverrflag;
retflag = savretflag;
}
if (oname && zleactive && strcmp(oname, curkeymapname))
zlecallhook("zle-keymap-select", oname);
zsfree(oname);
}
curkeymap = km;

View file

@ -1115,7 +1115,6 @@ zleread(char **lp, char **rp, int flags, int context)
char *s;
int old_errno = errno;
int tmout = getiparam("TMOUT");
Thingy initthingy;
#if defined(HAVE_POLL) || defined(HAVE_SELECT)
/* may not be set, but that's OK since getiparam() returns 0 == off */
@ -1215,32 +1214,15 @@ zleread(char **lp, char **rp, int flags, int context)
zrefresh();
if ((initthingy = rthingy_nocreate("zle-line-init"))) {
char *args[2];
args[0] = initthingy->nam;
args[1] = NULL;
execzlefunc(initthingy, args, 1);
unrefthingy(initthingy);
errflag = retflag = 0;
}
zlecallhook("zle-line-init", NULL);
zlecore();
if (errflag)
setsparam("ZLE_LINE_ABORTED", zlegetline(NULL, NULL));
if (done && !exit_pending && !errflag &&
(initthingy = rthingy_nocreate("zle-line-finish"))) {
int saverrflag = errflag;
int savretflag = retflag;
char *args[2];
args[0] = initthingy->nam;
args[1] = NULL;
execzlefunc(initthingy, args, 1);
unrefthingy(initthingy);
errflag = saverrflag;
retflag = savretflag;
}
if (done && !exit_pending && !errflag)
zlecallhook("zle-line-finish", NULL);
statusline = NULL;
invalidatelist();

View file

@ -1237,3 +1237,35 @@ viundochange(char **args)
} else
return undo(args);
}
/*
* Call a ZLE hook: a user-defined widget called at a specific point
* within the line editor.
*
* A single argument arg is passed to the function (in addition to the
* function name). It may be NULL.
*/
/**/
void
zlecallhook(char *name, char *arg)
{
Thingy thingy = rthingy_nocreate(name);
int saverrflag, savretflag;
char *args[3];
if (!thingy)
return;
saverrflag = errflag;
savretflag = retflag;
args[0] = thingy->nam;
args[1] = arg;
args[2] = NULL;
execzlefunc(thingy, args, 1);
unrefthingy(thingy);
errflag = saverrflag;
retflag = savretflag;
}