Exit user-mode with lock

Hello,

I would like to use -lock for all of my user-mode command exept for one that need to exit the user-mode to do some editing.

I try to run:

map global my-user-mode x "<esc>" 

But this doesn’t seems to exit the usermode.
Is there a way to exit the “locking”?

I could remove the “-lock” and add :enter-user-mode my-user-mode<ret> at the end of all my usermode mapping but would be nice to have a less verbose solution.

The way user-modes work is:

  • Kakoune displays the list of mappings
  • The user presses one of the mapped keys
  • Kakoune exits the user-mode and returns to normal mode
  • Kakoune executes the mapping
  • If -lock was used when the user-mode was first entered, Kakoune re-enters the user-mode

So if you have a user-mode mapping that maps to <esc>, that won’t exit the user-mode, because Kakoune isn’t in the user-mode when the mapping is executed.

I don’t know of a way around this, other than adding an extra enter-user-mode to the end of every mapping, which causes issues if anybody does try to use -lock mode.

2 Likes

Maybe a hook when re-entering user-mode could work?

it’s not pretty but

map global user-mode x ': fail<ret>'

works

3 Likes

Punk rock editor I guess :wink: