zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Parks <danielrparks@gmail.com>
To: zsh-users@zsh.org
Subject: Re: Strange behavior when calling select-a-shell-word multiple times from the same user-defined widget
Date: Wed, 22 Dec 2021 17:09:06 -0600	[thread overview]
Message-ID: <d391398813b231b61575db04d986e36ea89f6b47.camel@gmail.com> (raw)
In-Reply-To: <6e3644fd-07ad-4251-9310-b6899c41a233@www.fastmail.com>

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

On Wed, 2021-12-22 at 22:08 +0000, Daniel Shahaf wrote:
> Adding «-N» to both select-a-shell-word calls does the trick.

Thanks, that fixed it! I do still think it's pretty strange, though,
because select-a-shell-word does not normally seem to respond to the
numeric argument in a command like `v3aa` (still only selects one
word).

> While here, you can simplify the function a bit.  For one, you could
> use
> a «repeat» loop — its repeat count is a math expression, so you can
> actually do «repeat "NUMERIC - 1"; do …; done»

Nice, thanks for pointing that out.

>  — but I'm not sure why you
> select-a-shell-word more than once.  Why not just this:
> 
> select-n-shell-word() {
>   CURSOR=0
>   repeat "${NUMERIC:-1} - 1" zle vi-forward-word
>   zle visual-mode
>   zle select-a-shell-word -N
> }

I want to select the nth argument on the command line, taking into
account spaces, so using vi-forward-word is not a good choice. For
example, on the command `echo "these are all one" third` I want
3:select-n-shell-word to select

echo "these are all one"[ third]

not

echo[ "these are all one"] third

> «CURSOR=0» is not equivalent to «zle vi-beginning-of-line» when
> there's
> a literal newline in $BUFFER.  Pick what you prefer.

Oops, thank you for that as well.

I appreciate all the help! It's working perfectly now.



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-12-22 23:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 21:20 Daniel Parks
2021-12-22 22:08 ` Daniel Shahaf
2021-12-22 23:09   ` Daniel Parks [this message]
2021-12-23 13:24     ` Oliver Kiddle

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=d391398813b231b61575db04d986e36ea89f6b47.camel@gmail.com \
    --to=danielrparks@gmail.com \
    --cc=zsh-users@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).