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

Re: Bug: Callback to widget set with `zle -Fw <widget>` shouldn't change $LASTWIDGET



The -w in `zle -Fw arg` is not the inverse of the -w in `zle -w arg`.
It has a different purpose:
* In `zle -F callback`, callback is a function and gets called as such.
* In `zle -Fw callback`, callback is a widget and gets called as such.

The latter form is necessary if you want to be able to call other ZLE
widgets from the callback or access other ZLE functionality. You
cannot do that with the first form.

It's not the "inverted meaning" here that is the bug. `zle -F` (with
or without -w) just shouldn't ever change $LASTWIDGET in the first
place. It breaks a lot of existing widget functions and there is no
possible workaround.

On Wed, Nov 16, 2022 at 8:25 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Nov 16, 2022 at 7:08 AM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> >
> > Currently, when the ZLE calls a widget set with `zle -Fw <widget>`,
> > this changes the value of $LASTWIDGET.
>
> Hrm, normally (running "zle WIDGET ..." explicitly) this would be
> skipped (unless "zle WIDGET -w ...").  Too bad -w was overloaded in
> this way.  It's not technically overloading because it's used in
> different contexts, but mnemonically at least it could be confusing
> that "zle -Fw FD WIDGET" and "zle WIDGET -w" would seem to have
> inverted meanings of -w if we were to change the default behavior of
> -F.
>
> Of course it's also "-Fw" as a single "option", not "-F -w", so we
> can't even do something like "zle -F +w" to indicate the desired
> behavior.




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