Run :execute-keys -save-regs '' /
Search for foo
Press /
I can see foo in search history.
As -save-regs is provided empty, foo should not show up in search history.
I would like to create a simple command for just jumping around the buffer with search, but I do not want to pollute search history
execute-keys saves and restores the / register by default. If you execute-keys -save-regs '' then it saves and restores no registers, so it makes sense that changes to the search register would persist after execute-keys is over.
One the other hand, execute-keys / should save and restore the / register, but the thing you search for is still in the search history after the execute-keys completes. That seems like a bug.
@Screwtapello Isn鈥檛 the normal behavior as it is completed by the user?
Now that I think about this a little more, I think this is akin to #3753.
When you do :exec / and let the user type foo<ret>, what happens is:
exec saves the slash register (among others)exec executes the / key, queuing up a search operationexec restores the slash register (among others)As another example, consider the following command:
execute-keys / ; echo search completed
You might expect this to:
Instead, what happens is:
There are good, solid dosign reasons why Kakoune does the second thing rather than the first thing, and I expect it would be a huge rewrite of Kakoune to make it work the way people expect, but maybe there's some way to add stronger dependencies between events without completely abandoning the async model.
Thank You, @Screwtapello for clarifying this for me. I have thought that -save-regs will make kakoune save those register changes, instead of discarding them. So it should work the other way around.
And I totally expected the behavior You implied and run into this entry-key loophole explained in #3753 too :-( My workaround is using NormalIdle hook -once to pop up the user mode each time. Asyinc is tricky :-)
What you can do is add a ModeChange hook to restore the register when leaving the prompt.
Most helpful comment
Now that I think about this a little more, I think this is akin to #3753.
When you do
:exec /and let the user typefoo<ret>, what happens is:execsaves the slash register (among others)execexecutes the/key, queuing up a search operationexecrestores the slash register (among others)As another example, consider the following command:
You might expect this to:
Instead, what happens is:
There are good, solid dosign reasons why Kakoune does the second thing rather than the first thing, and I expect it would be a huge rewrite of Kakoune to make it work the way people expect, but maybe there's some way to add stronger dependencies between events without completely abandoning the async model.