From: Mikael Magnusson <mikachu@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org, Eric Freese <ericdfreese@gmail.com>
Subject: Re: add-zle-hook-widget and multiple hooks
Date: Sat, 6 Jun 2020 13:58:40 +0200 [thread overview]
Message-ID: <CAHYJk3Rtfj=cfhRpnBhzBUjbF2_9R5W9vG4a68qT84pH9xVRGA@mail.gmail.com> (raw)
In-Reply-To: <20200606084054.GA31628@tarpaulin.shahaf.local2>
On 6/6/20, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> When two or more zle-line-pre-redraw hooks are registered using
> add-zle-hook-widget, the value of $LASTWIDGET when the each hook is
> called is the name of the former hook:
>
> [Eric Freese wrote in
> https://github.com/zsh-users/zsh-autosuggestions/issues/529#issuecomment-632113840]
> $ zsh -df
> % autoload add-zle-hook-widget
> % f() {}
> % g() { zle -M "$(typeset -p LASTWIDGET)" }
> % add-zle-hook-widget line-pre-redraw f
> % add-zle-hook-widget line-pre-redraw g
> % x<CURSOR>
> typeset -r LASTWIDGET=f
>
> The issue here is that g would like to to know what widget was invoked
> immediately before the redraw. In the example, that'd be self-insert.
>
> I've attached two proofs of concept. WDYT?
>
> I'll add docs, etc, once an approach is chosen.
>
> Cheers,
>
> Daniel
>
> P.S. For the latter patch, note that «zle $widget -f» is distinct from
> «zle -f».
I think the warning message when -f is not followed by nolast should
be phrased in the same way it would if there were other valid flags,
since it would have to change when more are added anyway (we will
probably not want to enumerate all possible flags in this warning
message).
Also, I think rather than reusing the concept of the -f option, it
would be better to use another flag (maybe -l for LASTWIDGET) which is
analogous to the existing -w option:
Normally, calling a widget in this way does not set the special
parameter WIDGET and related parameters, so that the environ‐
ment appears as if the top-level widget called by the user were
still active. With the option -w, WIDGET and related parame‐
ters are set to reflect the widget being executed by the zle
call.
--
Mikael Magnusson
next prev parent reply other threads:[~2020-06-06 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-06 8:40 Daniel Shahaf
2020-06-06 11:58 ` Mikael Magnusson [this message]
2020-06-08 6:14 ` Daniel Shahaf
2020-06-08 17:52 ` Mikael Magnusson
2020-06-10 13:34 ` Daniel Shahaf
2020-06-18 11:42 ` Daniel Shahaf
2020-06-27 2:54 ` Daniel Shahaf
2020-06-27 3:02 ` Daniel Shahaf
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='CAHYJk3Rtfj=cfhRpnBhzBUjbF2_9R5W9vG4a68qT84pH9xVRGA@mail.gmail.com' \
--to=mikachu@gmail.com \
--cc=d.s@daniel.shahaf.name \
--cc=ericdfreese@gmail.com \
--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).