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

Keyboard macro support #1127

Closed
tshino opened this issue Dec 5, 2021 · 9 comments
Closed

Keyboard macro support #1127

tshino opened this issue Dec 5, 2021 · 9 comments

Comments

@tshino
Copy link

tshino commented Dec 5, 2021

This is a proposal for collaborative work to add keyboard macro support.

Recently I've published an extension Keyboard Macro Beta which enables to record and playback of keyboard operations on VS Code.
But the Keyboard Macro extension itself supports only the default keybindings of VS Code.
So in order to support a keymap extension such as your Awesome Emacs Keymap, it is required to make additional work.

However, hopefully, the required work will be entirely on my side. Likely your extension (Awesome Emacs Keymap) would not need any modification on itself.
I'm currently working on it. The work is making a keymap wrapper for Awesome Emacs Keymap.

I would like to ask you to comment on my plan. And if you don't mind taking your time, I would like to ask to perform some random manual testing after the keymap wrapper has been made.

And, I would like to ask you that what is the preferred keybindings to start/stop macro recording and trigger playback in terms of emacs emulation?

Thank you in advance.

@whitphx
Copy link
Owner

whitphx commented Dec 8, 2021

Hello, thanks for the comment.
It looks great.

I would like to ask you to comment on my plan. And if you don't mind taking your time, I would like to ask to perform some random manual testing after the keymap wrapper has been made.

OK, I have installed the extension, though actually, I don't use keyboard marco much frequently... Anyway, I will send comments when I found something 👍

I would like to ask you that what is the preferred keybindings to start/stop macro recording and trigger playback in terms of emacs emulation?

This document seems to be helpful.

@tshino
Copy link
Author

tshino commented Dec 8, 2021

Thank you for your reply!
I have just finished the work to make the keymap wrapper.

It is now available on my repository. You can try it with both two extensions enabled.
https://github.com/tshino/vscode-kb-macro/tree/main/keymap-wrapper

As the document you mentioned says, I was trying to assign C-x ( and C-x ) to start/stop recording, but VS Code seems not to allow to use of ( or ) in keybindings.
So as a compromise, I assigned C-x S-9 and C-x S-0 instead. Though they may not be appropriate depending on actual keyboard layouts.
That is my concern for now.

Thanks.

@tshino
Copy link
Author

tshino commented Dec 11, 2021

Let me inform you that I've just updated the keymap wrapper to reduce some unnecessary delays in playback.
Improved commands are for example setMarkCommand, deleteForwardChar, and killWord.
If you have already retrieved the keymap wrapper, could you please update it to get better behavior of playback?

@whitphx
Copy link
Owner

whitphx commented Dec 12, 2021

Hi,

So as a compromise, I assigned C-x S-9 and C-x S-0 instead. Though they may not be appropriate depending on actual keyboard layouts.

I think it's the only available solution with VSCode for now. Awesome Emacs Kaymap also does the same thing, e.g. using M-S-[ instead of M-{, and I think it's not a problem as there have been no argument on that.

could you please update it to get better behavior of playback?

I installed the extension v0.3.0 👌

@tshino
Copy link
Author

tshino commented Dec 12, 2021

I think it's the only available solution with VSCode for now. Awesome Emacs Kaymap also does the same thing, e.g. using M-S-[ instead of M-{, and I think it's not a problem as there have been no argument on that.

It's good to hear. Thanks.

@tshino
Copy link
Author

tshino commented Dec 18, 2021

Hi, in my point of view, it's working basically. So please feel free to close this issue if you have any more actions.
I really appreciate your cooperation on this issue.

If I could say some more, it would be nice to have the prefix-argument capability on the playback command, isn't it?

I thought the emacs-mcx.prefixArgumentExists and emacs-mcx.prefixArgument makes it possible for me to implement the capability, but it's not possible because there is no VS Code API to read the value of 'when' clause context.

But maybe it's possible by having kind of a proxy command in emacs-mcx, that passes the prefix argument to another command.
The scenario is something like:

  1. C-x e with potential prefix argument invokes the proxy with args = { command: 'kb-macro.playback' }
  2. The proxy invokes kb-macro.playback with args = { repeat: n } if prefix argument exists.
  3. kb-macro.playback performs playback n times if the repeat argument exists.
    Though this repeat feature on kb-macro.playback has not been implemented yet.

How about?

@whitphx
Copy link
Owner

whitphx commented Dec 23, 2021

Hi, the idea of the proxy command looks reasonable. Thank you for the suggestion.
I created an issue about it: #1146.

While I proposed a command in #1146 just like the one you suggested,
I think there can be another command that calls the proxied command n-times instead of calling it with the prefix-argument value just once.
Which design do you prefer especially for your purpose?

@tshino
Copy link
Author

tshino commented Dec 24, 2021

Sounds great!
I prefer the one that invokes the target command once with the prefix-argument value.

The reason is as follows.
To the best of my knowledge, the vscode.commands.executeCommand API doesn't guarantee the end of execution of a command even if you apply await for the returned value.
So multiple calls of command may not work expectedly.

On the kb-macro side, the repeat argument has been already implemented and shipped in the kb-macro v0.6.0.
tshino/vscode-kb-macro#19
The accepted key is repeat at this moment, however, I can add an extra key if you like.

@whitphx
Copy link
Owner

whitphx commented Dec 26, 2021

I see, it makes sense. Thanks.

The accepted key is repeat at this moment, however, I can add an extra key if you like.

OK. I think the key will be customizable.

Then, I will close this issue now. The discussion will continue in #1146

@whitphx whitphx closed this as completed Dec 26, 2021
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