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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18674 invoked from network); 22 Apr 2021 23:28:09 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Apr 2021 23:28:09 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1619134089; b=d0SxVTEHhD4gwhtiFr5aL6lWXJBPZrL4CU8c36KwbycwwrNjr0ptsav1mBRqF0ok/oWC9fOfEF k8gNngQmJm5pCobiSLlrwkbqqIABozjglYEUkL8oOzKJRUvT1c5j4453QiuAxyw4GBF0SUciM3 KvXrZjdWliEqlZZx73+sQlUxFcbIzMtpWtChW3anPKQYk1tWr1pPy+cW8DSHn2LkxYd1fwD4e5 SOEaJHW2g6Yb9cbwNeoBjFHhFCZkKy0XlPBMzYqqds3KgV8g+4r5glpVuBsKvUCD2YvZ/tLWwO LGb8IGjsVq/Px9rkK+0RYQPrI+4Fmlwjf+yFpFr7ryGp/Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f48.google.com) smtp.remote-ip=209.85.210.48; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1619134089; bh=byJHiFOZPRU/JeWLqe2/60EDLJHhbBQbE0QPKtGHgxg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=JjgtUpD9Fa95fpE2w5o4xCDTcDyuYToauLwbX6vh1SBiw2r34UgiRtIhR5s0+ClGmBuQKO3HIe GWpjSaltvgsUMRMoGGDfv7ByuY/RY3piFjR6owhqCHT6ncs2PzdVM3PgbUmfgVwqjenZkVhL3Z 8H+bLYsu+pkxWyGEDlwxKW5sILSki0JIVqCjrbvRXsSSQTTccBvVgnahWdmxl8fU1TMgY5twV0 EMe9aXcBX6ZjdAAS7d/viO4/6fMiM6OYcBmiWDEDvc3d5hhWwCnrO5r6U79ErlwPao0jCTGd3h eKZxwk7x7Tm61pORUPHyTKS4dQO2L8Mgxau5xCEKsYMNQg==; 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:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=uGa8oJPv5ll1eafzXxiue425TwnU5UyXr1xVJpgtezQ=; b=C0ufT+6AOrsCc2WYvpz7jxes7K c9GdyEGpEvIk6ni1Fs1rcQZ/Gndm/RmzBp5Cp+jbdLNZwOKwCD8b2jfNzhfMt57ea4VbuCARf9NR2 GHKQG3MOZ4+WR9ZPLuKpAddlJcXCiy407OwuXlG4Ox/6N9kpBk1nJ+PnDbdH82YEGA2jiPDYoNED1 3FEoeH4n7CWVNcufX6WpnyK++lFVZJYeWjIqfy3640kCUePi1Ln+Fv+2rNzTd5MSWKIhXshLB+0Y4 8LjpFGujBvdIq6XOKsZ5HgYTDkahiM+VdnQmZFe0po7HLPdt88govZ0gd//I3ylMwlytfESef1IJs lYtY8D6Q==; Received: from authenticated user by zero.zsh.org with local id 1lZiju-000NLl-Hb; Thu, 22 Apr 2021 23:28:06 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f48.google.com) smtp.remote-ip=209.85.210.48; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ot1-f48.google.com ([209.85.210.48]:40542) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lZijP-000N56-3s; Thu, 22 Apr 2021 23:27:35 +0000 Received: by mail-ot1-f48.google.com with SMTP id g4-20020a9d6b040000b029029debbbb3ecso10814161otp.7 for ; Thu, 22 Apr 2021 16:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=uGa8oJPv5ll1eafzXxiue425TwnU5UyXr1xVJpgtezQ=; b=E7xO2Vm/8HpWgEsIIfm5WqM+6VCMiC/6UM3CvnIOZHgdiKloe3w1JhdTTierq+oIBC 1/PN8Fa0/uqpEVJLUeFB+uTWaDZHa+DyATvOhyWvvJ37Nqnsm584lpbnzVeZiwG7dnl1 DupQ0t2jriF64cu2dMNNKEKrTksGqEDEVClvPBmOhTdqdgYO6SALII4FT/a756exAchp Dw3+LZFQVDY9KillT5eYDwkQaPIRqDpxrSUqRhZWEwj7Ljm3UafYfA6UgfAzWiKVttma 3wMB24IoFqbNx6Mx4aGam9ibVYXb6la5ASyU5jHAhUeqC914fxN2eoSLH9VYu1ycqhNP BJrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=uGa8oJPv5ll1eafzXxiue425TwnU5UyXr1xVJpgtezQ=; b=NcelYKjOZWSmmQiZzkJLCjR3w0Bkb7Gc3i6pHDltQ7hwFC6PsLeCM9C/P7EwLO8qDN 6TijkJehqXb/YdKEUAgwV2NuMLm9R/bFqRUk31Q4cwQ+dWDBVUvFbRFL+aT0SHhZvXKG WpERHZy5fs0eS8j34cB/RoaL0+wSoKyaEeXIfMhsdUh4y8AQFtddHVBIGRUQeHZZh2aN eDMoKteAzTXrGEpg+rOevOQ/pXyARmHWaLkr0rQaBLgX1TQuxKnF4n6W0tqeuCLL67dz JZnjY/vZoxCUvMTCgUpdVjxj+jXDkWce+G5U+FiSy0eqrQNofoS6OOr7tb+YjCRNpR1l tzJQ== X-Gm-Message-State: AOAM5336LqoNBTyK2qZhKTvfAaIFBVCG1Ww/iValZ2cVLcUH1xBO9re9 9HQZyAcxXJlKMuF+S8YoFbFiFJNw2A41lu7NIyj07dbVkwVGSA== X-Google-Smtp-Source: ABdhPJzB/CF7FkbfWjq2WofiGQj/FQXdIRSghSQFuph6ITV2EpdKgrNpbvHDhtUb7jaFRpKxp7ETUdYEw0pD567m/SY= X-Received: by 2002:a9d:4d9a:: with SMTP id u26mr782722otk.161.1619134053621; Thu, 22 Apr 2021 16:27:33 -0700 (PDT) MIME-Version: 1.0 References: <95CDA630-4EE5-4003-8D9C-CCCB9A47F109@gmail.com> <4D587C0C-EB5F-4A58-A0AE-D45E43F432CD@gmail.com> <20210421212717.GE21343@tarpaulin.shahaf.local2> <214AC3E9-FFA5-4F39-A918-562682FE3A3B@gmail.com> In-Reply-To: <214AC3E9-FFA5-4F39-A918-562682FE3A3B@gmail.com> From: Bart Schaefer Date: Thu, 22 Apr 2021 16:27:22 -0700 Message-ID: Subject: Re: [PATCH] Add execute-command() widget function (was Re: [RFC][PATCH] Add change-directory() widget function) To: Marlon Richert Cc: Daniel Shahaf , Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 48664 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: On Thu, Apr 22, 2021 at 3:55 AM Marlon Richert w= rote: > > If I would use push-input instead of push-line-or-edit, the buffer would = not get restored immediately after using the widget. You=E2=80=99d end up w= ith a blank command line instead. I want it to work the same from PS2 as it= does from PS1. I see. (Also, I forgot that push-input is implemented via push-line-or-edit, not the other way around.) Then how about: execute-command() { local finish=3D"zle .reset-prompt" case $CONTEXT in (cont) finish=3D"zle .push-line-or-edit" ;& (start) print -S "${${(q-)@}}" eval "${(q-)@}" ;; (*) return 75 ;; esac eval "$finish" } > Setting PUSHD_MINUS in the example guarantees that it will work out of th= e box for novice users. (More advanced users, I=E2=80=99m sure, will be abl= e to figure out how to modify it to suit their needs.) As I mentioned, by turning this into a generic "execute-command" you've made it the responsibility of the caller to pass the right thing. The question then is how to write the examples. Instead of setopt autopushd pushdminus pushdsilent cd-backward() { execute-command -- 'pushd -1' } It should be similar to cd-backward() { setopt localoptions autopushd pushdminus pushdsilent execute-command -- pushd -1 } (I removed the quotes around =C2=ABpushd -1=C2=BB to correspond to my use o= f ${(q-)@} above.)