From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27906 invoked by alias); 6 Sep 2015 09:51:02 -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: 36428 Received: (qmail 9748 invoked from network); 6 Sep 2015 09:50:59 -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 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=k596eAphJ+Ov/N4U /76Z/WR/JaE=; b=kLFRm7OUfE1Z7KjHx7XULN70djxXUQsQzZteAI7uVHYkyYR5 LYmv45LrX2BJk4asi9ceuGulzqJe+1gEHIqXRc7PkD+vSgyUkE+wHK9A7HP5G2QC np5E5vC7huDSGWQS5cjmfVHSyhK8FkLOROuCKAjTCYom5vJFrg8FkSIG6QE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=k596eAphJ+Ov/N4 U/76Z/WR/JaE=; b=S9iJ4QWs3PHV56dRGMXCjmtpT0wvevqKIJFVT2lQusEIUjE sCLYu+iGiB7iHVtFEMjjpeVTi118aSKY0eh56QSIjU8e7cpxAk814UCAvCZxIW8k DLZNWvpqlCWLbN8qR5MTURn9b2DncqwV0rRHiXc8g+X+3YbGmqebR80lHN0Y= X-Sasl-enc: l/32kXOtGiV07jzbgbRZpYBcaXmJ5OnWr5mLvHFjDo9X 1441533057 Date: Sun, 6 Sep 2015 09:50:54 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: PATCH v2 (complete): Implement zle -P Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150901110331.437e4db8@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) 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 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 ", but in "echo foo bar " 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.