From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20507 invoked by alias); 6 Sep 2015 11:52:06 -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: X-Seq: 36430 Received: (qmail 635 invoked from network); 6 Sep 2015 11:52:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=hBMAlZ79EgOtHLmPM57eZBajqlY5oJRIQaG9s3Fg/w0=; b=akCy7rxj+RcrM/84CI8NkmIA+oUpbEiWcPEcB9ZkbUepE3RKDYYi8gjqE17XLCX2kr Wju88qPlgiAEdmZH/4J5SS/H9V6Q7z1tBNu0f0AXMAPB8ofT6ViL+aZNrbYQ3jtO/F1V kIs8GC8f9NQ5D7cDVr6iwzHebZ9VkTYHxpV68I+aa7NjnpWgBEKr12MztGLmyxYV3E2A e+EEm+SJGz4WecyFkJiOIFhljLQaWjuEEKBGbxXlKIgY7we6YbF8k4gShv0t/XIJFlIR Uk766aFw87rgNdIJpvFu8Tszz/hRlmjDJXY3WQhqwj/XLSvY4MRFwclnD3SstNdqjyyn L0KA== MIME-Version: 1.0 X-Received: by 10.55.221.8 with SMTP id n8mr19797528qki.85.1441540317740; Sun, 06 Sep 2015 04:51:57 -0700 (PDT) In-Reply-To: <20150906095054.GC1895@tarsus.local2> References: <1441087664-9081-1-git-send-email-mikachu@gmail.com> <23177.1441101027@thecus.kiddle.eu> <20150901110331.437e4db8@pwslap01u.europe.root.pri> <20150906095054.GC1895@tarsus.local2> Date: Sun, 6 Sep 2015 13:51:57 +0200 Message-ID: Subject: Re: PATCH v2 (complete): Implement zle -P From: Mikael Magnusson To: Daniel Shahaf Cc: zsh workers Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sun, Sep 6, 2015 at 11:50 AM, Daniel Shahaf wro= te: > Peter Stephenson wrote on Tue, Sep 01, 2015 at 11:03:31 +0100: >> On Tue, 1 Sep 2015 11:50:27 +0200 >> Oliver Kiddle wrote: >> > Mikael Magnusson wrote: >> > > Indeed, I'm not sure if a user can figure out which widgets are usef= ul >> > > to override in this way. Would it be more useful to just do what Wa= yne >> > > did originally and let zle -N take some flags that specify which spe= cific >> > > flags the new widget should have after all? The advantage of this me= thod >> > > is that if we add more flags, users can wrap those widgets without u= s >> > > 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 ", but in "echo foo bar " > without the third line =E2=80=94 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/15= 0 > 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. --=20 Mikael Magnusson