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

Re: [PATCH] add-zle-hook-widget

On Jun 21,  1:41am, Daniel Shahaf wrote:
} Subject: Re: [PATCH] add-zle-hook-widget
} Bart Schaefer wrote on Sat, Jun 18, 2016 at 16:25:58 -0700:
} >  for hook in $hooktypes
} >  do
} > +  # Check for an existing widget, add it as the first hook
} > +  if [[ ${widgets[$hook]} = user:* ]]; then
} > +      zle -A "$hook" "${widgets[$hook]}"
} > +      zstyle -- "$hook" widgets 0:"${widgets[$hook]}"
} The last parameter expansion should strip the "user:" prefix.

No, it shouldn't, because the "zle -A" command creates a new widget
whose name begins with "user:".

This way if you run "add-zle-hook-widget -L" it will show you that the
widget with index zero was the user's previously defined widget.

Yes, this breaks things if the user's widget compares itself to $WIDGET
but there's no way around that [*] because the newly created hook is
the only widget allowed to use the reserved hook-widget name.

[*] A possible fix for this is to omit the -w when calling the widget
from zle, so that $WIDGET remains the hook-widget.  That would look
something like

      for hook in "${(@)${(@on)hook_widgets[@]}#<->:}"; do
          if [[ "$hook" = user:* ]]; then
              # Do not change $WIDGET, it may be tested in $hook
              zle "$hook" -N "$@" || return
              zle "$hook" -Nw "$@" || return

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