Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from hermes.apache.org by f.primenet.com.au (envelope-from <danielsh@apache.org>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(140.211.11.3):SA:0(-1.3/5.0):. 
 Processed in 0.124245 secs); 06 Aug 2016 00:06:53 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,
	RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: danielsh@apache.org
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: none (ns1.primenet.com.au: domain at apache.org does not designate permitted sender hosts)
Date: Sat, 06 Aug 2016 00:06:36 +0000
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: Deliberately abstract question about calling zle widgets
Message-ID: <20160806000636.GA15622@tarsus.local2>
References: <160805161937.ZM11838@torch.brasslantern.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <160805161937.ZM11838@torch.brasslantern.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Seq: zsh-workers 39002

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

