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=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12769 invoked from network); 28 May 2022 10:07:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 May 2022 10:07:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653732475; b=a9cF1jEQLciqELduq0sEap3z6byf95pdLexGSv4nlHhp9DzRJZGznKQstY6+3RQoVckZyKigeA rs9B2+UzB4gBSd0lv84qZ7NAlWqBAfnGsbJ6sBTM7NNu2u37sw++Yz/107kazSWqWc+L0ozDYO aOUdwhT4VUSuaCps2dq2vXmm1IaggKlUUjwbndQnNFS1QLZG6dYPX3MOy44vC7D/4Z4g3/UXXL rmYxYwOU84UlbHX16rcFhaGqskwx8Rk6xUQ8mwguwba8+k5XaDzZqE7jrZKPNB7kbH/e9NtB9t oHLjAXtBSatWLEX+6ZfZ7KpbF41/nqXFew4izYp871EXDg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653732475; bh=//fVImErKxjTdxOuVMrQsy1xdnEyjFlI7gryraUAH0k=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=IUT3sbZPKWAfVLiK+47T0XSbP25zx1vS6O+IkANYRiFNvRFp8+2vTsxU4ZiS05FZV9GKFiVRbL m092u32u1xRJlcyld16sJI+sRfakHUn+05XLtBQzw6eFz4I/FP0CL5XcCKddzRcikkvsvb+SPW PY+DVrR3Y4brkounlrjCtpF2sH8fMPFZEc6Wg8Xg+/HZPxAQy6fuROWy37cE8HQJBKQi7tjV6M evTHX0SoMtlOwUSTAWU6MxM5jrfk4oh/LbZtYPGbvq3KPTgQDmTu4d7+eDAzOhgArxwqB4Aakv T7agdGlxggTNtvcUUYLzjjsujGq6MqsruwW0zYhqIM/81A==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=gnixHcNYb2U+ouCpzbxjEiOmf0eZxrhqVPXJyMrqgl8=; b=Ynt/tzjCUSKjn4Ww6Ug5qItxcd +cFNAUkN9uvB7fPPk4901iceoCyj+aaLpqSuxtVdaAWyuSq8iA+wb5FT5En29fTclbjnv9VK9PT0D Napwpvcn0SxSj0J6ONpUVGTO76AX644tx/kGfBQxe1Man24DJsxIpQ8n0SRF7NYm16KNIJ4xxGR11 OC43gmw/tBDRGKCuw3d8i21YECktjrx5Itt5GPmrcOIVoPja0U/FDs6MQsPz/QsQbV14KTdlvQVBt oQJQv9nOMZkzXmsvrFYndwrRIXyL51PRhhG8FZ+DutBhmfAHRr91u5xQYxjztAe63Uv7qQ6GAnCZS JEkBsHRA==; Received: from authenticated user by zero.zsh.org with local id 1nutMP-000Fk2-Tz; Sat, 28 May 2022 10:07:53 +0000 Authentication-Results: zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out5-smtp.messagingengine.com ([66.111.4.29]:34445) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nutLI-000F2R-3i; Sat, 28 May 2022 10:06:46 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D42B55C00C7; Sat, 28 May 2022 06:06:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 28 May 2022 06:06:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm3; t=1653732401; x=1653818801; bh=gnixHcNYb2U+ouCpzbxjEiOmf 0eZxrhqVPXJyMrqgl8=; b=QmAWdcsV7vaTncOED5+cHIrgA+BsQsK666RFehirF m3+PNuuJINC91V0kpjhoIwEU4oMVTVlEM7lthIxZ2PRvvuaPSWU5tjJQoxrAUseX QwbsK94hmwi1KxSXvyF94xBr2qfftzVyF2qfBy/G3+aSg0BbX/2GfC0EohSfz4/K sLsJe4oPwzJyvnGc1fwTrWLPAHJnM1XZEalqOMr2irsym/xbY/3xNVExQlH0rIFs 6h0pYGBeg1BrWTugj+1gUza4q8005HVgK9pjoWxVyJA5aH89HgzAJO/JoKNYENEq hBYlzU0vPnynpCpvNEUhr7226Gwh5tTaX7noyCkAEqjHA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1653732401; x=1653818801; bh=g nixHcNYb2U+ouCpzbxjEiOmf0eZxrhqVPXJyMrqgl8=; b=YqydwTerJdNi1eNFU ZlfCyfJvDol+F1xCEJ4p/qh9p4fjXVhyh41XtI/BtrzMQkSyUEdEVHumUduzA0+A b5DZ4uPMKk9Nm4zAuH0kwQnQpOAxbWCXCo03AE15oDd2pRoB+9iN0ex4QzDXZvU4 rUExDCJfM9a8ZW8wf+PYhyXbXsfBD9xCrsz4UTK3PG2vDHTAyqQ8/2226aO29yEM EaEmt0zVcnq5uXumBeUcfSi+IY+1Yd3S0CjJPt1I7iuxBQJyXabAszAcIrrFgice 8p0n7gXpoxg5wcj3RLxoUUCnmSQR6hTCRGpAxda3di9pbHPU6A5XvO47AlO3j2yd o1PxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrkedugddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfsehtke dttddtredunecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefgleehtdffuefhge euleefffejgedttdelhedvvdeuiefhvefgvdfghfevvdekteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrg hhrghfrdhnrghmvg X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 28 May 2022 06:06:41 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4L9HQ71hf9z3Jc; Sat, 28 May 2022 10:06:39 +0000 (UTC) Date: Sat, 28 May 2022 10:06:39 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: prevent some lines directly coming from the history from being executed Message-ID: <20220528100639.GB29128@tarpaulin.shahaf.local2> References: <20220525025403.GA97860@zira.vinc17.org> <20220525084920.GB97860@zira.vinc17.org> <20220526143602.GA1236826@zira.vinc17.org> <20220526155329.GF19001@tarpaulin.shahaf.local2> <1936193667.415066.1653581604546@mail2.virginmedia.com> <20220528000720.GB1236826@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220528000720.GB1236826@zira.vinc17.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 27820 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Vincent Lefevre wrote on Sat, May 28, 2022 at 02:07:20 +0200: > On 2022-05-27 12:40:32 +0000, Daniel Shahaf wrote: > > Peter Stephenson wrote on Thu, 26 May 2022 16:13 +00:00: > > >> On 26 May 2022 at 16:53 Daniel Shahaf wrote: > > >> Vincent Lefevre wrote on Thu, May 26, 2022 at 16:36:02 +0200: > > >> > When searching the man pages, I could find only one place where > > >> > such a built-in is used: in the example for recursive-edit. > > >>... > > >> but, yes, it should be mentioned in the zle documentation too, not only > > >> in the compsys documentation. > > >> > > >> Anyone volunteering to write the patch? > > > > > > zle.yo contains the following. We don't have the actual names for > > > all the widgets, which makes them hard to search for, but the actual > > > rule is very simple once you know it. So while this isn't ideal I'm > > > not sure what we'd want to change. > > This is in Section "ZLE WIDGETS". But since this is specific to > the standard widgets, shouldn't this be also at the beginning of > Section "STANDARD WIDGETS"? > The next paragraph recommends that user-defined widgets not be named with leading dots. That wouldn't belong under "Standard widgets". > > > Should we put some examples here of the cases you're most likely > > > to use, in particular .accept-line? > > This would be interesting for users who wish to control the line > before it is accepted. > > > Thanks. > > > > I expected there'd be an instance of «tt(.)var(widget)», and that's what > > I initially grepped for. > > > > Vincent, what did you search the man pages for? > > I had searched for " \.[a-z]". I wasn't expecting quotes (it seems > that most often, quotes are not used for single words). There's no shortage of tt() instances surrounded by `TeX quotes', though. How about the following? I think the new text has a lot of room for improvement, so feedback's very welcome. Cheers, Daniel diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index 2d033a0a1..ce20513b8 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -746,17 +746,42 @@ ifnzman(noderef(Standard Widgets)). Other built-in widgets can be defined by other modules (see ifzman(zmanref(zshmodules))\ ifnzman(noderef(Zsh Modules))\ -). Each built-in widget has two names: its normal canonical name, and the -same name preceded by a `tt(.)'. The `tt(.)' name is special: it can't be -rebound to a different widget. This makes the widget available even when -its usual name has been redefined. +). User-defined widgets are defined using `tt(zle -N)', and implemented as shell functions. When the widget is executed, the corresponding shell function is executed, and can perform editing (or other) actions. -It is recommended that user-defined widgets should not have names + +cindex(widgets, shadowing standard) +User-defined widgets may shadow (replace) standard widgets: for instance, +after `tt(zle -N self-insert myfunc)', any invocation of the standard +tt(self-insert) widget (including every keypress that appends an alphanumeric +or space character to the command line) would invoke the user-defined +function tt(myfunc) rather than the standard implementation of that widget. +However, each standard widget `var(foo)' is also available under the +name `tt(.)var(foo)', and this name can't be rebound to a different widget. +This makes the standard widget available to be called or bound even when +its usual name has been redefined. +Therefore, for forward compatibility with future versions of the shell, +it is recommended that user-defined widgets should not have names starting with `tt(.)'. +Continuing the example, tt(myfunc) would typically invoke the built-in widget +it is replacing using the dot-prefix syntax: + +example(zle -N self-insert myfunc +myfunc+LPAR()+RPAR() { + [[ $KEYS == [aeiou] ]] && zle .self-insert -- "$@" + zle .self-insert -- "$@" +}) + +This example causes vowels to be inserted twice. + +Note the use of the dot-prefix syntax. If the tt(self-insert) widget had been +invoked without the dot DASH()- that is, as `tt(zle self-insert -- "$@")' DASH()- +then tt(myfunc) would have been called again, effecting a bottomless +recursion. + texinode(User-Defined Widgets)(Standard Widgets)(Zle Widgets)(Zsh Line Editor) sect(User-Defined Widgets) cindex(widgets, user-defined)