From: Daniel Parks <danielrparks@gmail.com>
To: zsh-users@zsh.org
Subject: Strange behavior when calling select-a-shell-word multiple times from the same user-defined widget
Date: Wed, 22 Dec 2021 15:20:11 -0600 [thread overview]
Message-ID: <2495135b4cf73e7add73e3fcd5fd6165a76b3cfa.camel@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]
Hello zsh-users,
I'm trying to write a function that selects the nth argument in the
buffer. I would use it like `3gva` to select the 3rd argument.
Here's the widget I have so far:
function select-n-shell-word {
if [[ -z "$NUMERIC" ]]; then NUMERIC=1; fi
zle vi-beginning-of-line
zle visual-mode
zle select-a-shell-word
for ((i = 1; i < $NUMERIC; i = i + 1)); do
zle deactivate-region
zle vi-forward-char -n 2
zle visual-mode
zle select-a-shell-word
done
}
zle -N select-n-shell-word
bindkey -M vicmd "gva" select-n-shell-word
Given the command line `echo these are arguments`, I would expect the
command `3gva` to select like this:
echo these[ are] arguments
and indeed that's what happens if I run the following commands
(emualating the for loop myself):
- :vi-beginning-of-line
- :visual-mode
- :select-a-shell-word
- :deactivate-region
- 2:vi-forward-char
- :visual-mode
- :select-a-shell-word
- :deactivate-region
- 2:vi-forward-char
- :visual-mode
- :select-a-shell-word
Nevertheless, when I run the command `3gva` it selects like this:
[echo these are] arguments
Does anybody know what's going on here?
Thanks,
Daniel
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next reply other threads:[~2021-12-22 21:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 21:20 Daniel Parks [this message]
2021-12-22 22:08 ` Daniel Shahaf
2021-12-22 23:09 ` Daniel Parks
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=2495135b4cf73e7add73e3fcd5fd6165a76b3cfa.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).