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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22164 invoked from network); 20 Apr 2021 21:58:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Apr 2021 21:58:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1618955891; b=FTGfZj+9OffYsFnIxR+pX4JVkIxmHlXTcURonzR8KlRjjTXGSn5tO/LFck/20KlCm9JKg+JijT 7nFUvkP98MykBs2GK/ZrFq0Y9ucnA27+3lKPt+UyD+d3sNK2xW1JTyaY0g6zuOOLarUSb2Fb8x Wk0shAcD03Quapcn1Yi9cWVzKKaDdwH+FSpgVI3nxNC4EBhgc7mpKojFg0iEaohig2W7vDJTr/ I49fAS6x8U1Hi4WGpTmrjRN20OQDzyby+hGrISzn+4pMIS/25XJ75gwT2Sk70q5/hDbY0zNfp9 3EMs0k1t0wm29OKgprz8zIwVj3hBjf20qj9CpmO/wPce0A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 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-20200801; t=1618955891; bh=ixhTDps9APQ/FoK+CAjAuerLSzxb3OOccLK9vRecf1A=; 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:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=wy4ork0PQegGZUUdt0EANLZ9T7rV+uJwgAKYZSGIZWDrXGompu9vGscjMMcBGcDS+o2kW1/LMy rIkQjHhSmiAOcS84bxTZKqUEyqKySp03XFTXGntJqcIfM45Wg5NfFSNAx7c7bhwQOs0g2SQqrF B34NvZmh+SrCMgoFaOG7ZzSGZPm7pNNo6oTpnNQFTptXZZeDYZh8Yqey4P+1Zj4Ul5KM5caGg9 Rn4w28hsmhyFEce0rflGoBhAbz1xcY9C33CMHuSdYFMByyKKpqYizpQ7WLpHGex28htv8dFk3a 61sK8l7+vUTC5qXcK1GkZyu3RghpcLT8vTP35/JNTuSUOQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; 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:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=Ws8+PL511RyUGrvDm41jKWTSDP8QSW1TdDYUwzDWe2s=; b=fucX5qIYnpEvYiAgtQ4oafeSLN mDPX7MBa8dEDxedg74JgrS7JaXpCKKj9s6w8MTiJBhCuJ4ItvAClke/IXdrS1r+GWq4V1JFUbAzl5 LDP74ZTYWp4M4jsPtYs3s59N7sZqkOfMg4ydwkGaXD0ZGcVv0OemMspDPo5BAMWGIAci7OTQVZIzL rb9WWwyJWQCNd+TJ5sVY0gWH0dHaTY5GsUYOaCQw5VOw46apEaxH+z7q/zjq3jz+TYSsAFLDiI9ct CtsfGr3LCzTV70uaXjbvlelvFPBC1jKiDrdv4Z52/0OVtwt+JxtLGlUNarhoAXmlWpyjIJeSEQGGc No50ttSQ==; Received: from authenticated user by zero.zsh.org with local id 1lYyNi-000M6y-7d; Tue, 20 Apr 2021 21:58:06 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:48473) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lYyNQ-000Lrv-9g; Tue, 20 Apr 2021 21:57:49 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 12EA95C015A; Tue, 20 Apr 2021 17:57:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 20 Apr 2021 17:57:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm3; bh=Ws8+PL511RyUGrvDm41jKWTSDP8QSW1TdDYUwzDW e2s=; b=D8eH/zeSAzdBXyslvT0BOmfONeigH7mIuDw5vSinOGuNKOJg7seOkg75 WR9cnunYs18wUT8HX2a2QDwVLUG9u6Z74hVOdCEXWdOgVo0YK7FIVLxk4npvQa1p 9e9v7QZLUy+Iuf3jy+3i4ZtanfUzzY6FWvcfXJyuOnjqwbR+BZVena8SqUHMVPJY W3eZtfIB0Hn3TATVBm9OIa6a+jvR9jnHTXVOFt1VXLdv36aSMzJziHlYlbJ55nq4 proTg7H8BN5AC2mipNWzixYQ5blRJOsN94VU2hZcYAo+8vH0d2bNhRJWo/2xKdOP mRHhiH2XoUNbT12iz7cohAeezOyrVw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=Ws8+PL511RyUGrvDm41jKWTSDP8QSW1TdDYUwzDWe 2s=; b=ezvuUGSN9htq5bKw0rv7a1Wn73Pz05JJub/Dcsa+n/z4S4AiZJP8330c6 ive45sBUWLrnFJl9Z+UOGt9XHnZq8JwGt0IyPPbU3tfQxpDzEwnc9aCQmljOp2hz ooQd8+S2crZ86YmQigcIp64j+FGOq3K4WYvewSv4eeEaI3/7ABR4OV+98vLecbvN qKJ/sxMu2c1YXVpaWVOGh9mWpA+UBAdI81Wx8xYiqjj8UYHULAcSAkc3uNeaejYw G4eTqypKARWIVJ45++7svF3ZcHHocR0o2TkRepDPfo+Y621M4QgrUjs0qv3T9Zcc XTNxNjep8Yt64XnF7ztPzv0MbLUvA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddtjedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtugfgjggfsehtkedttddtreejnecuhfhrohhmpeffrghn ihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpefgkefgfeejgfdvvdfguddtleelkedvfeetiedtudfhveev veduhfdvveeffedvueenucfkphepuddtledrieeirdeifedrvdeftdenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdr shhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-109-66-63-230.red.bezeqint.net [109.66.63.230]) by mail.messagingengine.com (Postfix) with ESMTPA id 98AC01080067; Tue, 20 Apr 2021 17:57:46 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4FPyGc4KFdz22Y; Tue, 20 Apr 2021 21:57:44 +0000 (UTC) Date: Tue, 20 Apr 2021 21:57:44 +0000 From: Daniel Shahaf To: Marlon Richert Cc: Zsh hackers list Subject: Re: [RFC][PATCH] Add change-directory() widget function Message-ID: <20210420215744.GD1035@tarpaulin.shahaf.local2> References: <95CDA630-4EE5-4003-8D9C-CCCB9A47F109@gmail.com> <4D587C0C-EB5F-4A58-A0AE-D45E43F432CD@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4D587C0C-EB5F-4A58-A0AE-D45E43F432CD@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48633 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > +++ b/Doc/Zsh/contrib.yo > @@ -2423,6 +2423,21 @@ history is restricted, so cursor motions, etc., may not pass outside of > the pasted content. Text assigned to tt(BUFFER) by the active widgets > is copied back into tt(PASTED) before tt(paste-finish). > ) > +tindex(change-directory) > +item(tt(change-directory))( > +This function implements the widgets tt(cd-upward), tt(cd-backward) and > +tt(cd-forward). They can be used, respectively, to change to the current > +directory's parent or the previous/next entry in the directory stack. They > +should be initialized as follows: > + > +example(autoload -Uz change-directory > +zle -N cd-upward change-directory > +zle -N cd-backward change-directory > +zle -N cd-forward change-directory > +bindkey '^[^[OA' cd-upward # Alt-Up > +bindkey '^[^[OD' cd-backward # Alt-Left > +bindkey '^[^[OC' cd-forward # Alt-Right s/Right/Right)/ > +) > tindex(copy-earlier-word) > item(tt(copy-earlier-word))( > This widget works like a combination of tt(insert-last-word) and > diff --git a/Functions/Zle/change-directory b/Functions/Zle/change-directory > new file mode 100644 > index 000000000..376e4414c > --- /dev/null > +++ b/Functions/Zle/change-directory > @@ -0,0 +1,29 @@ > +zle .push-line-or-edit > +case $WIDGET in > + *-upward ) > + if [[ -o autocd ]]; then > + BUFFER='..' > + else > + BUFFER='cd ..' > + fi > + ;; > + *-backward ) > + if [[ -o pushdminus ]]; then > + BUFFER='pushd -1' > + else > + BUFFER='pushd +1' > + fi > + ;; > + *-forward ) > + if [[ -o pushdminus ]]; then > + BUFFER='pushd +0' > + else > + BUFFER='pushd -0' > + fi > + ;; > + * ) > + print -u2 'change-directory: widget name should end in -(up|back|for)ward' Suggest to add a detail: print -u2 $'change-directory: widget name should end in -(up|back|for)ward; review the \'zle -N ... change-directory\' commands in your configuration' And to remove an implementation detail: print -u2 $'change-directory: widget name should be cd-(up|back|for)ward; review the \'zle -N ... change-directory\' commands in your configuration' And to avoid (foo|bar|baz) constructs — not for greppability reasons as requested in 48402#13[48408] and again in 48632, but for user-friendliness reasons (cf. my feedback to Sebastian back in [workers/45149, second bullet]): print -u2 $'change-directory: widget name should be "cd-upward", "cd-backward", or "cd-downward"; review the \'zle -N ... change-directory\' commands in your configuration' > + return 1 > + ;; > +esac > +zle .accept-line > -- > 2.31.1 > > >