Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION]: hook gives different results when the same keystrokes are splitted to two execute-keys. Why? #5140

Closed
VKondakoff opened this issue Apr 10, 2024 · 2 comments

Comments

@VKondakoff
Copy link

Question

Hi!

While experimenting with Kakoune I created a one-line hook to modify the text in *scratch* buffer which appears automatically when you start kak without parameters.
Here is the text:

*** this is a *scratch* buffer which won't be automatically saved ***
*** use it for notes or open a file buffer with the :edit command ***

For testing purposes I'm replacing the *** with yyy.
Here is the hook:

hook global BufCreate '^\*scratch\*$' %{
  execute-keys -buffer *scratch* '%s\*\*\*<ret>cyyy<esc>'
}

Everything works as expected. Here is the output:
Снимок экрана 2024-04-11 в 00 47 23

But if I split execute-keys into two lines, the output is different and wrong:

hook global BufCreate '^\*scratch\*$' %{
  execute-keys -buffer *scratch* '%s\*\*\*<ret>'
  execute-keys -buffer *scratch* 'cyyy<esc>'
}

Output:
Снимок экрана 2024-04-11 в 00 49 55

Why this happens?

@krobelus
Copy link
Contributor

the -buffer switch makes it run in a draft context so selections etc. won't escape. See also clippy's comments on :execute-keys

@VKondakoff
Copy link
Author

Got it. Thank you, closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants