zsh-workers
 help / color / mirror / code / Atom feed
* Deliberately abstract question about calling zle widgets
@ 2016-08-05 23:19 Bart Schaefer
  2016-08-06  0:06 ` Daniel Shahaf
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2016-08-05 23:19 UTC (permalink / raw)
  To: zsh-workers

Ignoring for the moment the pseudo-keymaps that switch on internal thingy
names of builtin widgets ... can anyone tell me whether the following is
a true assertion?

  Given an absence of other user-defined widgets and a function
    wrap_builtin_widget() { zle .$WIDGET "$@" }
  then for any (every) builtin widget bltinwid,
    zle -N bltinwid wrap_builtin_widget
  has no observable side-effects.

When I say "no side effects" I'm referring to things like loss of suffix
autoremoval when bltinwid is a completion widget, changed "undo" handling,
mishandled numeric prefixes, etc.  I'm not looking for obscure ways to
break it such as aliasing or disabling the zle command.

If the assertion is known to be false, please name any builtin widgets you
are aware of for which this assertion does not hold.

Thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Deliberately abstract question about calling zle widgets
  2016-08-05 23:19 Deliberately abstract question about calling zle widgets Bart Schaefer
@ 2016-08-06  0:06 ` Daniel Shahaf
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2016-08-06  0:06 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote on Fri, Aug 05, 2016 at 16:19:37 -0700:
> Ignoring for the moment the pseudo-keymaps that switch on internal thingy
> names of builtin widgets ... can anyone tell me whether the following is
> a true assertion?
> 
>   Given an absence of other user-defined widgets and a function
>     wrap_builtin_widget() { zle .$WIDGET "$@" }
>   then for any (every) builtin widget bltinwid,
>     zle -N bltinwid wrap_builtin_widget
>   has no observable side-effects.
> 

The assertion is false, for two reasons:

1. The function should have been defined with a double-minus guard:
wrap_builtin_widget() { zle .$WIDGET -- "$@" }

2. The wrapper needs to call «zle -f 'yank'» if the wrapped widget has
the ZLE_YANK flag, etc..

> When I say "no side effects" I'm referring to things like loss of suffix
> autoremoval when bltinwid is a completion widget, changed "undo" handling,
> mishandled numeric prefixes, etc.  I'm not looking for obscure ways to
> break it such as aliasing or disabling the zle command.
> 
> If the assertion is known to be false, please name any builtin widgets you
> are aware of for which this assertion does not hold.

Any widget with ZLE_YANK / ZLE_KILL set.  Example:

% bindkey -e
% wrap_builtin_widget() { zle .$WIDGET -- "$@" }
% echo foo bar ^W^W^Y^C
% zle -N backward-kill-word wrap_builtin_widget
% echo foo bar ^W^W^Y^C

> Thanks.
> 

You're welcome. It's being the maintainer of z-sy-h that taught me this
answer.

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-06  0:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-05 23:19 Deliberately abstract question about calling zle widgets Bart Schaefer
2016-08-06  0:06 ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).