zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: "Peter Slížik" <peter.slizik@gmail.com>
Cc: zsh <zsh-users@zsh.org>
Subject: Re: A wrong bindkey command breaks the way bck-i-search (Ctrl+R) works
Date: Mon, 26 Jul 2021 17:58:25 +0200	[thread overview]
Message-ID: <CAHYJk3QZ4n_fN1qThre7JcL9ixu6wmcvjwRSop+ZW4xQ5UGR9Q@mail.gmail.com> (raw)
In-Reply-To: <CAC-uhUDYyX34h7thLGjCSFYf4CBD-+2jp9As16mkSdqFeqCNfg@mail.gmail.com>

On 7/26/21, Peter Slížik <peter.slizik@gmail.com> wrote:
> Hello,
>
> I created a few useful helper functions and bound them to specified keys.
> For example, pressing " inserts a pair of quotes and puts the cursor inside
> them, like this: "|".
> Another example, pressing a space fixes some of the typos I'm inclined to
> do repeatedly, e.g. pyhton<Space> is expanded to python<Space>.
>
> The implementation is quite straightforward, the widget examines LBUFFER
> and RBUFFER and modifies LBUFFER accordingly.
>
> _expand_abbreviations ()
> {
>     if [[ LBUFFER =~ 'this' && RBUFFER == 'that' ]]; then
>         LBUFER+='something '    # mind the trailing space
>     fi
> }
>
> zle -N expand-abbreviations _expand_abbreviations
> bindkey ' ' expand-abbreviations
>
> The problem with this solution is that it breaks the way that Ctrl+R
> history search works.
> Before, typing a space inside Ctrl+R just underlined the space in the
> offered string:
>
> % abcd efgh
> zsh: command not found: abcd
> % <Ctrl+R>*abcd *efgh    # the space is underlined here
> bck-i-search: abcd<Space>
>
> After using the " bindkey ' ' expand-abbreviations" command, the space
> finishes the Ctrl+R editor and inserts itself in front of the offered text:
> % _abcd efgh    # a space prepended before abcd
> and I'm not able to continue with the bck-i-search widget any more.
>
> The behavior is identical for other bound keys, e.g. the double quote mark
> in the first example with quote duplication.
>
> I'm pretty sure there's something I'm missing in the bindkey command, but
> frankly, the documentation is quite complex and I'm not sure what to look
> for.
>
> Any suggestions are appreciated.

You can use bindkey -M isearch ' ' self-insert to restore the previous behavior.

-- 
Mikael Magnusson


  reply	other threads:[~2021-07-26 15:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 14:13 Peter Slížik
2021-07-26 15:58 ` Mikael Magnusson [this message]
2021-07-26 21:10   ` Bart Schaefer
2021-07-27 10:31     ` Peter Slížik
2021-07-27 14:51       ` Bart Schaefer
2021-07-27 15:09         ` Peter Slížik
2021-07-27 15:42           ` Bart Schaefer
2021-07-27 15:44             ` Peter Slížik
2021-07-27 22:35         ` Mikael Magnusson
2021-07-27 22:38           ` 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=CAHYJk3QZ4n_fN1qThre7JcL9ixu6wmcvjwRSop+ZW4xQ5UGR9Q@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=peter.slizik@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).