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

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

Bart Schaefer wrote on Sat, Sep 17, 2016 at 07:29:18 -0700:
> On Sep 17,  7:42am, Daniel Shahaf wrote:
> }
> } I think it would be cleaner to invent a new bitmask flag and set it on
> } the affected widgets (select-*-word, run-help, etc) than to overload
> } WIDGET_INT for this purpose.
> It's not overloading WIDGET_INT, it's overloading ZLE_VIOPER - because
> those are the only cases of builtins that want the opposite case (point
> to the caller).  Testing WIDGET_INT is only necessary because the sense
> of setbindk is reversed from the sense of ZLE_VIOPER.

The code tests that ZLE_VIOPER is unset and that WIDGET_INT is set;
therefore, any widget implemented in a module will have $WIDGET pointing
to itself, unless that widget has ZLE_VIOPER set.

As Oliver said, aside from the vi operator widgets, only 4 builtin
widgets care about whether $WIDGET points to themselves or not.  There
is no reason, AIUI, to force set_bindk to 1 for the other 390 builtin
widgets, as well as for all future widgets implemented in modules.

That's why I suggested to invent a new bitmask flag that implies
set_bindk on a per-widget basis: the property 'requires $WIDGET to be
self-referential' does not follow from 'is implemented in C'.  I can
also imagine future user-defined widgets that need $WIDGET to always
point to themselves.

> } Whether a widget is implemented in C or in shell has no bearing on
> } whether it assumes that $WIDGET points to itself.
> At the moment that's not true; a widget implemented in shell can never
> safely assume that $WIDGET points to itself.

I am not arguing that widgets implemented in shell should be able to
assume that $WIDGET is self-referential.  I am arguing that widgets
implemented in C should not be able to to assume that.  (unless they
have that new bitmask flag I'm proposing)



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