Thank you very much for all the answers. If I may have one more question - hopefully the last one on this topic. ;-)

As I mentioned before, I used a similar function to take care of " and ' characters.
- Pressing a " inserts two of them and places the cursor inside the pair. Pressing an ' works in a similar fashion.
- Pressing a backspace inside the pair ("|" or '|', where | is the cursor) deletes both quotes - the left and the right at the same time.

Now, binding the backspace breaks it for isearch.

zle -N insert-single-quotes _insert_single_quotes
zle -N insert-double-quotes _insert_double_quotes
zle -N remove-quotes _remove_quotes
bindkey "'" insert-single-quotes    # " ' "
bindkey '"' insert-double-quotes    # ' " '
bindkey "^?" remove-quotes    # backspace remove the whole pair
bindkey -M isearch '^?' self-insert    # This does NOT restore the original functionality.

Instead of restoring the original functionality (deleting the last char), ^? is just inserted into the searched text.

Best regards,
Peter


уто, 27. јул 2021. у 16:51 Bart Schaefer <schaefer@brasslantern.com> је написао/ла:
On Tue, Jul 27, 2021 at 3:31 AM Peter Slížik <peter.slizik@gmail.com> wrote:
>
> bindkey -M emacs ' ' expand_abbreviations
>
> But alas, this changes the behavior of isearch, too. The documentation is really sometimes too wordy and, in cases like this, too terse.

I think that's because emacs == main and isearch is initialized from
main ... so if you did that bindkey but only after isearch was
initialized, it might work.  I don't know how you assure that order of
events, though.