Dear Mikael & Bart,

yes, both solutions work.

Taking into account that there are more keymaps, I think that the best solution would be to remap the keys *only* for the emacs keymap, leaving the other keymaps untouched.

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.

Peter

пон, 26. јул 2021. у 23:10 Bart Schaefer <schaefer@brasslantern.com> је написао/ла:
On Mon, Jul 26, 2021 at 8:58 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On 7/26/21, Peter Slížik <peter.slizik@gmail.com> wrote:
> >
> > 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.
>
> You can use bindkey -M isearch ' ' self-insert to restore the previous behavior.

I  believe you could also do

zle -N magic-space _expand_abbreviations
bindkey ' ' magic-space

because the isearch keymap already understands what (not) to do with
magic-space.