zsh-users
 help / color / mirror / code / Atom feed
From: Ahmad Ismail <ismail783@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Select Whole, When There are Multiple Lines
Date: Mon, 27 Sep 2021 07:17:03 +0000	[thread overview]
Message-ID: <CAHAhJwL6vJjt0S9tVepnpZQuRzvGr4NMrLN5BxDXPJbow2QMXQ@mail.gmail.com> (raw)
In-Reply-To: <a6941ef8-6131-4887-a634-ad26f6fe776a@www.fastmail.com>

I did not notice it earlier. The following also works.
....
_select-whole() {
    zle beginning-of-buffer-or-history
    ((REGION_ACTIVE)) || zle set-mark-command
    zle end-of-buffer-or-history
}

zle -N _select-whole
bindkey '^A' _select-whole
....
However, it works weirdly when used on single line.

What can I do so that _select-whole works on both single and multi-lines?

Thanks and Best Regards,
Ahmad Ismail

On Sun, Sep 26, 2021 at 7:08 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> Ahmad Ismail wrote on Sat, 25 Sep 2021 11:29 +00:00:
> > I mean when there are multiple lines on the prompt, the keybinding
> > only works for the line where the cursor is. How can I select all
> > lines using ctrl-A
>
> This works:
>
> f() { MARK=0; CURSOR=$#BUFFER; REGION_ACTIVE=1; }
> zle -N f
> bindkey '^T' f
> echo foo^V^Jecho bar^T    # In this line, ^X means to press Ctrl+X
>
> It doesn't work in some other cases.  It works when $BUFFER is
> multiline and $PREBUFFER is empty, but it doesn't work when $BUFFER is
> single-line and the previous content is in $PREBUFFER.  You might be
> able to simulate that with 'P' ranges in region_highlight and
> overriding widgets that operate on the region, but it might be easier
> to just use edit-command-line.


  reply	other threads:[~2021-09-27  7:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-25 11:29 Ahmad Ismail
2021-09-26  7:08 ` Daniel Shahaf
2021-09-27  7:17   ` Ahmad Ismail [this message]
2021-09-27  8:40     ` Ahmad Ismail

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=CAHAhJwL6vJjt0S9tVepnpZQuRzvGr4NMrLN5BxDXPJbow2QMXQ@mail.gmail.com \
    --to=ismail783@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --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).