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

Hydrogen keybindings #304

Closed
n-riesco opened this issue Jun 21, 2016 · 7 comments · Fixed by #488
Closed

Hydrogen keybindings #304

n-riesco opened this issue Jun 21, 2016 · 7 comments · Fixed by #488

Comments

@n-riesco
Copy link
Collaborator

Moving the discussion from here and here.


Shall we add a setting to enable the keybindings that we would like to introduce in Hydrogen v1.0.0?

? hydrogen:inspect

C-enter hydrogen:run
S-enter hydrogen:run-and-move-down

A-C-enter hydrogen:run-cell
A-S-enter hydrogen:run-cell-and-move-down

? hydrogen:add-break-point
S-backspace hydrogen:remove-latest-break-point
S-A-backspace hydrogen:remove-all-break-points

? hydrogen:clear-results

A-S-C-enter hydrogen:run-all


Currently, we're shadowing

S-C-enter hydrogen:run-and-move-down editor:newline-above
C-backspace hydrogen:clear-results editor:delete-to-beginning-of-word

@lgeiger
Copy link
Member

lgeiger commented Jun 21, 2016

hydrogen:clear-results on the mac is mapped to cmd-alt-backspace, is ctrl-alt-backspace available on linux and windows?

For me I have hydrogen:inspect mapped to cmd-ctr-i to avoid complications with atom-script (which uses cmd-i and shift-cmd-i) but that wouldn't work on windows. What do you think about alt-i?

For hydrogen:add-break-point on mac, cmd-ctrl-b would work, but I couldn't come up with a great shortcut for windows. A second option would be C-S-m and rename "break-point" to something with "marker" in it.

@n-riesco Shall we add a setting to enable the keybindings that we would like to introduce in Hydrogen v1.0.0?

I like this idea, but is there an easy way of changing between two sets of keybindings in atom?

@n-riesco
Copy link
Collaborator Author

On 21/06/16 23:11, Lukas Geiger wrote:

|hydrogen:clear-results| on the mac is mapped to cmd-alt-backspace, is ctrl-alt-backspace available on linux and windows?

It's assigned to bracket-matcher:remove-matching-brackets.

For me I have |hydrogen:inspect| mapped to cmd-ctr-i to avoid complications with |atom-script| (which uses cmd-i and shift-cmd-i) but that wouldn't work on windows. What do you think about alt-i?

alt-i is free in linux

For |hydrogen:add-break-point| on mac, cmd-ctrl-b would work, but I couldn't come up with a great shortcut for windows. A second option would be C-S-m and rename "break-point" to something with "marker" in it.

shit-ctrl-b would work in linux

@n-riesco <https://github.com/n-riesco> Shall we add a setting to enable the keybindings that we would like to introduce in Hydrogen v1.0.0?

I like this idea, but is there an easy way of changing between two sets of keybindings in atom?

I don't know if there is an API to do this dynamically, but if there isn't, we can hack our way like this:

  • define hydrogen-exp:* commands that are equivalent to the corresponding hydrogen:*. This experimental commands would run only if the experimental setting is enabled. If it isn't enabled, they would call evt.abortKeyBinding().
  • register the exp and no-exp keybindings in keymap/hydrogen.cson

@n-riesco
Copy link
Collaborator Author

@lgeiger
Copy link
Member

lgeiger commented Jun 22, 2016

We can rename the keymaps folder (so no keymaps are loaded by default) and use atom.keymaps.loadKeymap to load the desired keymaps file.
But in order to make this work, we have to remove the activationCommands from package.json because there would be no way of activating Hydrogen with a keymap. Instead Hydrogen would be activated on startup of atom.

@n-riesco
Copy link
Collaborator Author

What would be the drawbacks of activating Hydrogen on startup?

I guess we could do something like this:

  • on startup invoke:
    • Config.onDidChange with a callback to handle changes in the Hydrogen setting to toggle the experimental features;
    • and atom.workspace.observeActivePaneItem with another callback to:
      • dispose previous subscriptions (commands, observers, keymaps)
      • if there isn't a running kernel for this pane, only register commands and the keymap to start a kernel
      • if there is a running kernel, then register all the commands and the full keymap

Relevant links:

@n-riesco
Copy link
Collaborator Author

@lgeiger The main problem I see with the KernelManager.loadKeymap is that it doesn't return the the corresponding CompositeDisposible, that would allow us to unload the keymap when the experimental setting changes.

At the moment I think that the hacky way I proposed above is easier.

@lgeiger
Copy link
Member

lgeiger commented Jun 27, 2016

You're right. With kernelManager.loadKeymap changing the keymap would require a restart of Atom.

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

Successfully merging a pull request may close this issue.

2 participants