zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: 'zle redisplay' bug in 5.3?
Date: Sat, 7 Jan 2017 20:04:55 +0000	[thread overview]
Message-ID: <20170107200455.656cec0c@ntlworld.com> (raw)
In-Reply-To: <20170107185325.061a57cf@ntlworld.com>

On Sat, 7 Jan 2017 18:53:25 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> The other uses showinglist and then calls listmatches().  Furthermore,
> it then calls zrefresh() recursively.  I modified that in 36416, commit
> 32f5d3d8, only to get called if there was no error, but the recursive
> call has always been there.  This might have something to do with
> it, particularly now errflag signals both error and interrupt.  Could
> propagation of ERRFLAG_INT or the lack of it or the fact that it affects
> the code that calls zrefresh() recursively have something to do with
> the interrupt problem that caused the changed to redisplaying?

OK, how about this as an alternative to the previous change to the
refresh code?  If I'm following properly, this was a problem when

TRAPINT () {
	zle reset-prompt
	return 127
}

was in effect during interruption at a completion list.

If we have been interrupted don't try to list matches at all; abort as
if there ws no list.  Obviously, I can't be sure this doesn't have side
effects of its own but as far as I can see it seems to remove the
TRAPINT problem without resorting to tweaking bits I haven't the
faintest clue about, and it also seems OK without the trap.

An additional fix is that at the zle call from the TRAPINT in this case
we don't know where the command line has been, so should take account of
both possibilities.  In general allowing the command line to be modified
here is dangerous but stopping it without forbidding all zle calls is
difficult, so assume the user is only doing basic stuff here (like
redisplay).

Note that if the discussion returns nonetheless to showlinglist etc. I
shall once again be unable to provide useful replies.

pws

1diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 2edaf6e..0350388 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1993,7 +1993,8 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat)
     if (noselect > 0)
 	noselect = 0;
 
-    if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines) {
+    if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines ||
+	errflag) {
 	showinglist = 0;
 	amatches = oamatches;
 	return (noselect = 1);
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 8d173cd..8391739 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -2434,8 +2434,8 @@ redisplay(UNUSED(char **args))
     moveto(0, 0);
     zputc(&zr_cr);		/* extra care */
     tc_upcurs(lprompth - 1);
-    resetneeded = !showinglist;
-    clearflag = showinglist;
+    resetneeded = 1;
+    clearflag = 0;
     return 0;
 }
 
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index c709285..c003148 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -703,7 +703,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 {
     Thingy t;
     struct modifier modsave = zmod;
-    int ret, saveflag = 0, setbindk = 0;
+    int ret, saveflag = 0, setbindk = 0, remetafy;
     char *wname = *args++, *keymap_restore = NULL, *keymap_tmp;
 
     if (!wname)
@@ -714,7 +714,15 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 	return 1;
     }
 
-    UNMETACHECK();
+    /*
+     * zle is callable in traps, so we can't be sure the line is
+     * in its normal state.
+     */
+    if (zlemetaline) {
+	unmetafy_line();
+	remetafy = 1;
+    } else
+	remetafy = 0;
 
     while (*args && **args == '-') {
 	char *num;
@@ -728,6 +736,8 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 		num = args[0][1] ? args[0]+1 : args[1];
 		if (!num) {
 		    zwarnnam(name, "number expected after -%c", **args);
+		    if (remetafy)
+			metafy_line();
 		    return 1;
 		}
 		if (!args[0][1])
@@ -745,19 +755,26 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 		keymap_tmp = args[0][1] ? args[0]+1 : args[1];
 		if (!keymap_tmp) {
 		    zwarnnam(name, "keymap expected after -%c", **args);
+		    if (remetafy)
+			metafy_line();
 		    return 1;
 		}
 		if (!args[0][1])
 		    *++args = "" - 1;
 		keymap_restore = dupstring(curkeymapname);
-		if (selectkeymap(keymap_tmp, 0))
+		if (selectkeymap(keymap_tmp, 0)) {
+		    if (remetafy)
+			metafy_line();
 		    return 1;
+		}
 		break;
 	    case 'w':
 		setbindk = 1;
 		break;
 	    default:
 		zwarnnam(name, "unknown option: %s", *args);
+		if (remetafy)
+		    metafy_line();
 		return 1;
 	    }
 	}
@@ -775,6 +792,8 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 	zmod = modsave;
     if (keymap_restore)
 	selectkeymap(keymap_restore, 0);
+    if (remetafy)
+	metafy_line();
     return ret;
 }
 


  reply	other threads:[~2017-01-07 20:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170105030137.v4tzweda6pxyqnrq@majutsushi.net>
     [not found] ` <CGME20170105091042epcas1p3ebc6c107d3121c8f6b980bbcbc59bc60@epcas1p3.samsung.com>
     [not found]   ` <170105010914.ZM1529@torch.brasslantern.com>
2017-01-05 15:01     ` Peter Stephenson
2017-01-05 17:08       ` Bart Schaefer
2017-01-07 18:05         ` Bart Schaefer
2017-01-07 18:53           ` Peter Stephenson
2017-01-07 20:04             ` Peter Stephenson [this message]
2017-01-08  4:46               ` Bart Schaefer
2017-01-08 17:59                 ` Peter Stephenson

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=20170107200455.656cec0c@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).