zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH v2 (complete): Implement zle -P
Date: Sun, 6 Sep 2015 13:51:57 +0200	[thread overview]
Message-ID: <CAHYJk3QZVuxUuZ4BPAD9qh42Yt0zj1i74G5QTWFaUd+o0ru6sQ@mail.gmail.com> (raw)
In-Reply-To: <20150906095054.GC1895@tarsus.local2>

On Sun, Sep 6, 2015 at 11:50 AM, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Peter Stephenson wrote on Tue, Sep 01, 2015 at 11:03:31 +0100:
>> On Tue, 1 Sep 2015 11:50:27 +0200
>> Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
>> > Mikael Magnusson wrote:
>> > > Indeed, I'm not sure if a user can figure out which widgets are useful
>> > > to override in this way.  Would it be more useful to just do what Wayne
>> > > did originally and let zle -N take some flags that specify which specific
>> > > flags the new widget should have after all? The advantage of this method
>> > > is that if we add more flags, users can wrap those widgets without us
>> > > remembering to add a new zle -N flag as well.
>> >
>> > I think that approach is better than the prototypes.
>>
>> I'd be inclined to think this is both clearer and more powerful, too.
>
> The 'zle -P' form is nice when wrapping arbitrary widgets and wanting to
> preserve their properties.  For example:
>
>     zsh -f
>     bindkey -e
>     bkw-wrapper() { zle .backward-kill-word }
>     zle -N backward-kill-word bkw-wrapper
>     echo foo bar<^W><^W><^Y>
>
> This results in "echo foo <CURSOR>", but in "echo foo bar <CURSOR>"
> without the third line — because 'bkw-wrapper' lacks the ZLE_KILL flag
> which backward-kill-word has.
>
> When I wrap a built-in widget, I would rather just say "Make my widget
> like that other widget" than enumerate all flags my widget requires;
> but when I define a new widget from scratch, being able to enumerate all
> flags my widgets required would be good.
>
> So, in summary, I think both forms are useful: 'zle -P' is useful for
> wrapping widgets and 'zle -f' for defining new ones.
>
> Cheers,
>
> Daniel
>
> P.S. As a concrete example, in zsh-syntax-highlighting, the difference
> in flags between a built-in widget and a user-defined wrapper thereof
> leads to issues such as [1], where wrapping a widget causes it to change
> behaviour: https://github.com/zsh-users/zsh-syntax-highlighting/issues/150
> I believe using 'zle -P' to define the wrapper widget would immediately
> solve that issue.

You can believe it, but it's not the case. The code that handles most
of these flags first checks that the widget is internal, and not a
shell wrapper function. Some more changes would be needed to make this
work. The yank flag is the only one that does something useful at the
moment.

-- 
Mikael Magnusson


  reply	other threads:[~2015-09-06 11:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01  6:07 Mikael Magnusson
2015-09-01  6:53 ` Bart Schaefer
2015-09-01  9:50 ` Oliver Kiddle
2015-09-01 10:03   ` Peter Stephenson
2015-09-06  9:50     ` Daniel Shahaf
2015-09-06 11:51       ` Mikael Magnusson [this message]
2015-09-01 23:32   ` Bart Schaefer
2015-09-03 10:38     ` PATCH: zle -f from inside widget to set flags Mikael Magnusson
2015-09-03 10:40       ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3QZVuxUuZ4BPAD9qh42Yt0zj1i74G5QTWFaUd+o0ru6sQ@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).