From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: Bad effect of error in zle-line-pre-redraw
Date: Sun, 13 Nov 2016 10:55:20 -0800 [thread overview]
Message-ID: <161113105520.ZM18677@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3RheHpKthzySAFdNz1sXu+7vPc+Hc-b0b5g8ZNsYqqqZA@mail.gmail.com>
On Nov 13, 3:45pm, Mikael Magnusson wrote:
}
} IIRC, and looking at the code, it needed to save more stuff around
} calling the hook function. I think when I wrote the code,
} zlecallhook() didn't exist, and the similar places I borrowed the code
} from didn't have the errflag resetting. It does seem pretty likely
} that restoring the errflag won't hurt.
Well, zlecallhook() has been around since 2010 and git says that
redrawhook() was 2015 ... but, no matter; how about:
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 04b9357..1652b7c 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1041,28 +1041,43 @@ getrestchar(int inchar, char *outstr, int *outcount)
#endif
/**/
-void redrawhook(void)
+void
+redrawhook(void)
{
Thingy initthingy;
if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {
+ /* Duplicating most of zlecallhook() to save additional state */
+ int saverrflag = errflag, savretflag = retflag;
int lastcmd_prev = lastcmd;
int old_incompfunc = incompfunc;
char *args[2];
Thingy lbindk_save = lbindk, bindk_save = bindk;
+
refthingy(lbindk_save);
refthingy(bindk_save);
args[0] = initthingy->nam;
args[1] = NULL;
+
+ /* The generic redraw hook cannot be a completion function, so
+ * temporarily reset state for special variable handling etc.
+ */
incompfunc = 0;
execzlefunc(initthingy, args, 1);
incompfunc = old_incompfunc;
+
+ /* Restore errflag and retflag as zlecallhook() does */
+ errflag = saverrflag | (errflag & ERRFLAG_INT);
+ retflag = savretflag;
+
unrefthingy(initthingy);
unrefthingy(lbindk);
unrefthingy(bindk);
lbindk = lbindk_save;
bindk = bindk_save;
+
/* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so
- * restore lastcmd manually so that we don't mess up the global state */
+ * restore lastcmd manually so that we don't mess up the global state
+ */
lastcmd = lastcmd_prev;
}
}
next prev parent reply other threads:[~2016-11-13 18:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-12 17:03 Bart Schaefer
2016-11-12 17:54 ` Mikael Magnusson
2016-11-12 20:41 ` Bart Schaefer
2016-11-13 14:45 ` Mikael Magnusson
2016-11-13 18:55 ` Bart Schaefer [this message]
2016-11-14 11:15 ` Mikael Magnusson
2016-11-13 19:16 ` [PATCH] Widget fallbacks (Re: Bad effect of error in zle-line-pre-redraw) Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=161113105520.ZM18677@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).