zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Marlon Richert <marlon.richert@gmail.com>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Add execute-command() widget function (was Re: [RFC][PATCH] Add change-directory() widget function)
Date: Thu, 22 Apr 2021 16:27:22 -0700	[thread overview]
Message-ID: <CAH+w=7ZSWhyogP=rn_O40Lc96jTnM4rAKkHaXLn5iOsS7F76Vg@mail.gmail.com> (raw)
In-Reply-To: <214AC3E9-FFA5-4F39-A918-562682FE3A3B@gmail.com>

On Thu, Apr 22, 2021 at 3:55 AM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> If I would use push-input instead of push-line-or-edit, the buffer would not get restored immediately after using the widget. You’d end up with 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="zle .reset-prompt"
  case $CONTEXT in
  (cont) finish="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 the box for novice users. (More advanced users, I’m sure, will be able 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 «pushd -1» to correspond to my use of
${(q-)@} above.)


  parent reply	other threads:[~2021-04-22 23:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 13:36 [RFC][PATCH] Add change-directory() widget function Marlon Richert
2021-04-20 19:43 ` Bart Schaefer
2021-04-20 20:13   ` Marlon Richert
2021-04-20 21:32     ` Bart Schaefer
2021-04-21  3:46       ` Bart Schaefer
2021-04-21 11:37         ` [PATCH] Add execute-command() widget function (was Re: [RFC][PATCH] Add change-directory() widget function) Marlon Richert
2021-04-21 20:40           ` Bart Schaefer
2021-04-21 21:27           ` Daniel Shahaf
2021-04-21 21:58             ` Bart Schaefer
2021-04-22 10:55               ` Marlon Richert
2021-04-22 20:25                 ` Daniel Shahaf
2021-04-22 23:27                 ` Bart Schaefer [this message]
2021-04-24 20:06                   ` Marlon Richert
2021-04-24 21:49                     ` Bart Schaefer
2021-04-24 21:58                       ` Bart Schaefer
2021-04-26 18:08                         ` Marlon Richert
2021-04-26 21:39                           ` Bart Schaefer
2021-04-27 10:46                             ` Marlon Richert
2021-04-27 19:27                               ` Bart Schaefer
2021-04-30 19:16                                 ` Marlon Richert
2021-04-30 20:25                                   ` Bart Schaefer
2021-05-01 13:30                                     ` Marlon Richert
2021-05-31 17:55                                       ` Marlon Richert
2021-04-25 17:02                     ` Hard-wrapping emails (Was: [PATCH] Add execute-command() widget function (was Re: [RFC][PATCH] Add change-directory() widget function)) Lawrence Velázquez
2021-04-20 21:57     ` [RFC][PATCH] Add change-directory() widget function Daniel Shahaf
2021-04-20 22:14     ` Daniel Shahaf
2021-04-21  0:09       ` Bart Schaefer
2021-04-21  3:18       ` Bart Schaefer
2021-04-21 20:11         ` Daniel Shahaf
2021-04-21 20:29           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ZSWhyogP=rn_O40Lc96jTnM4rAKkHaXLn5iOsS7F76Vg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=marlon.richert@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).