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

Cleanup key remapping technique #83

Open
alerque opened this issue Nov 16, 2019 · 1 comment
Open

Cleanup key remapping technique #83

alerque opened this issue Nov 16, 2019 · 1 comment
Labels

Comments

@alerque
Copy link
Member

alerque commented Nov 16, 2019

The merge of #50 accomplished something positive (allowing people with rebound motion keys to keep using their preferred key rather than the hard coded defaults) but it also introduced a regression. In fixing the regression (see #82) I observed there are several more potential problems lurking in this method.

First, Mapkey() should be refactored completely so it queries the map for a single binding rather than iterating though the entire map parsing for bindings itself.

Second, we're completely inconsistent about what keys we account for possibly having been user remapped and which we don't. I think the entire things should be fixed so that all keys respect what users may have mapped them to and Pencil's behavior gets added to their preferred mappings with no hard coded keys at all.

Third, their doesn't seem to be a reliable way to turn off all the Pencil modified bindings at once. Most of them get reverted, but not quite all. And now that we're looking an what user mappings were, we need to revert to those not just revert to hard coded defaults!

I'm opening this as an issue because I won't be able to get to this soon (traveling for a couple weeks) and don't want to loose track of things I noticed needed attention.

Possibly related: #34.

@beelzebielsk
Copy link

beelzebielsk commented Jan 28, 2023

I have a suggestion. Instead of detection, what about using <Plug> bindings? With these, you can make movement commands a user binds their keys to, and pencil manages the meaning of these commands to suit the wrap mode.

On startup you'd make bindings like:

nnoremap <Plug>Pencilkeys_down j
nnoremap <Plug>Pencilkeys_AltDown gj
...

The user would bind to these plug mappings in their rc file.

And when you initialize pencil mode, you'd change what the plug mappings do for the buffer:

nnoremap <buffer> <Plug>Pencilkeys_down gj
nnoremap <buffer> <Plug>Pencilkeys_AltDown j
...

And to shut off pencil mappings you can unbind the buffer local pencil mappings.

This should make unbinding everything clean. It solves the problem of reverting to a user's original bindings because you won't have to anymore.

I was going to suggest this as an enhancement, but this issue covers my problem and why I am doing this on my own, since my 0 and ^ weren't handled right.

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

No branches or pull requests

2 participants