From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15522 invoked from network); 6 Jun 2020 11:59:23 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 6 Jun 2020 11:59:23 -0000 Received: (qmail 6988 invoked by alias); 6 Jun 2020 11:59:15 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 46006 Received: (qmail 14761 invoked by uid 1010); 6 Jun 2020 11:59:15 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25828. spamassassin: 3.4.4. Clear:RC:0(209.85.166.46):SA:0(-2.0/5.0):. Processed in 0.74362 secs); 06 Jun 2020 11:59:15 -0000 X-Envelope-From: mikachu@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.46 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=a5OEJXDIYBaqKOceN0fGPipY7KCWXaTakS9ER6XkQKQ=; b=KTzbTrPLCs9vufF/Po3C6gnZ/Lr91P9f2K67NQEerbPKxUEyGLrtUC7PEmXSrHdbud BRXlcMuPoL4lbmK99Aatb5DhVrZypau1AdaZqyQuEOdrHTOKRv8AlK2XyiImn525NYsa B1tksh1he8nDFe6O5ItiMyY3LRHVgBmL7SjgwJWyyHloPs2YOzM5mtesOgZwLu02izMs UZeOVzk01eq/OsfhOYuvGI7H1cJd7+TraCqEA3m2uAXVDQr0cRI7VVXMBWjNbTHTUzte PS4PGX4ZaA6gfTHc3g6SqluYZ2/YrkJ7fY0AabVY0V8dx7qReRq9jI6jANwtcirZvkNE ye3w== X-Gm-Message-State: AOAM532QDb1dWt7ystVlS7FGFMM/HGkdv/oXPZnZ3iX3YMbVQlVJpBcc r+w1NqHPOHjFx8DRZ0QkWMKiyabaxqc1NP8FIK9laA== X-Google-Smtp-Source: ABdhPJwglD8ege6ncR5RRhxUJgVXFzISXEVmJs0KbEfp44q82iGDQQstuiu9dsGG+M7EMJmfjWWMjOnrnebRkBAbM6g= X-Received: by 2002:a6b:8b51:: with SMTP id n78mr12540471iod.120.1591444721709; Sat, 06 Jun 2020 04:58:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20200606084054.GA31628@tarpaulin.shahaf.local2> References: <20200606084054.GA31628@tarpaulin.shahaf.local2> From: Mikael Magnusson Date: Sat, 6 Jun 2020 13:58:40 +0200 Message-ID: Subject: Re: add-zle-hook-widget and multiple hooks To: Daniel Shahaf Cc: zsh-workers@zsh.org, Eric Freese Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 6/6/20, Daniel Shahaf 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 > typeset -r LASTWIDGET=3Df > > 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 =C2=ABzle $widget -f=C2=BB is disti= nct from > =C2=ABzle -f=C2=BB. 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=E2=80=90 ment appears as if the top-level widget called by the user were still active. With the option -w, WIDGET and related parame=E2=80=90 ters are set to reflect the widget being executed by the zle call. --=20 Mikael Magnusson