Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Off-by-one with select-*-shell-word text object?



Bart wrote:
> } Or a ZLE_ flag - actually two to cover
>
> I think one flag to force the equivalent of set_bindk = 1 would do?
> (zle_main.c:1358)

That seems like a nice simple solution. Especially if there aren't
any that need set_bindk = 0 as you suggest below.

> It also occurs to me to wonder whether set_bindk = 0 *ever* makes sense
> for builtin widgets.  Can somebody give me an example of a builtin that
> would care about the widget name of its user-defined caller?

I think it matters for the k2 == bindk test in getvirange(). That's
the code that ensures that pressing the same key twice indicates
that the vi command should operate on a line. Builtin widgets that
call getvirange() all have the ZLE_VIOPER flag set so could be
selected for on the basis of that.

zlecallhook sets set_bindk. That doesn't seem entirely useful
($WIDGET is zle-keymap-select etc) but if it did the opposite, that
could matter here because you'd get something like vi-cmd-mode
instead of the calling widget.

run-help, which-command and zap-to-char suffer from the same
issue as the text object widgets: they use bindk to select their
behaviour. 

So any thoughts on this solution?

Oliver

diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 9107154..345534e 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -756,7 +756,10 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
     }
 
     t = rthingy(wname);
-    ret = execzlefunc(t, args, setbindk);
+    /* for internal widgets we don't want bindk set except for when getting
+     * a vi range to detect a repeated key */
+    ret = execzlefunc(t, args, setbindk ||
+	    (t->widget && (t->widget->flags & (WIDGET_INT | ZLE_VIOPER)) == WIDGET_INT));
     unrefthingy(t);
     if (saveflag)
 	zmod = modsave;



Messages sorted by: Reverse Date, Date, Thread, Author