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

Re: [PATCH] add-zle-hook-widget zle-line-pre-redraw issue

On Sun, Jul 24, 2016 at 11:30 PM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Bart Schaefer wrote on Sat, Jul 23, 2016 at 18:14:45 -0700:
>> On Jul 23,  9:23pm, Daniel Shahaf wrote:
>> }
>> } The reason appears to be that, while in azhw:zle-line-init $WIDGET is
>> } "zle-line-init", in azhw:zle-line-pre-redraw $WIDGET is the name of the
>> } widget the user invoked (e.g., "self-insert"), so the 'zstyle -a' does
>> } not find the registered hooks.
>> If zsh-syntax-highlighting doesn't depend on that behavior, it's probably
>> unlikely that anything else does.
> z-sy-h assumes that zle-line-finish sets $WIDGET, but doesn't assume
> anything else about $WIDGET.
>> } Each of the following alternative patches solves the issue:
>> The "second option" obviously isn't finished / leaves a lot of dead
>> code behind.
> Indeed it isn't: the unidiff I'd sent was not the unidiff I would commit
> if that option is chosen.  Its purpose was not to be committed as is,
> only to unambiguously explain what the second alternative was.
> Sorry if that wasn't clear.
>> However, I think the first option is the correct one,
>> unless there's a good reason to leave $WIDGET alone; the context
>> that's being saved/restored by redrawhook() is important, because
>> we're in the middle of an arbitrary other widget
>> This is actually related to what I was saying about it not being
>> appropriate to stick a list of callbacks on any widget.
>> We can easily special-case add-zle-hook-widget to find the name another
>> way for this particular hook.  $funcstack[1] for example.
> Okay, so let's wait for Mikael to weigh in, then we can choose between
> making pre-redraw set $WIDGET or making a-z-h-w handle pre-redraw's not
> doing so.

I don't think I made a conscious decision about this when writing the
code, so if there's any dissimilarity between this and other things
it's probably unintentional. I don't use $WIDGET myself in my callback
either. I think I just copied the part that sets args[0] a bit blindly
from another callback, but in that one I bet it uses initthingy->nam
for the rthingy_nocreate() call too. So to summarize, feel free to
change it.

Mikael Magnusson

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