Skip to content

Conversation

@CosmicToast
Copy link

This changes the keybinding menu (alt-g) to reflect real keybindings.
Potentially contentious things:

  • internal/display/util.go instead of maybe somewhere in config
  • exact details of the "friendly" function
  • exact API

This also patches the $(bind:) special of the status line.
Why does it need patching?

In go, when you iterate a map, the order is non-deterministic.
With the current handling of $(bind:), if you have >1 binding for the action, which one you get is essentially random.
The way you solve this is to ensure a deterministic order by sorting the set of keys.

This needs to happen every invocation, in case the user changes a binding.
An alternative method would be to keep a cache that is updated whenever bindings are written to.

Lack of this specific feature is a commonly cited reason (to me, personally) of micro not being adopted (thus why it doesn't show up in the issues - it's non-users as of right now), so I figured I would at least offer a way to fix it.
There's already a TODO for it (I didn't remove it in this patch, see next paragraph), so it seems like something that's desirable.

I don't really have the time or energy to modify this patch to suit the exact needs/requirements for merging.
However, it can/should be reasonably trivial to move it anywhere / change some of these minor specifics.
Another thing that could be brushed up (perhaps later?) is the exact way keydisplayGen performs the generation.
Either way - please consider this code to be CC0/Unlicense/BSD0/Blue-Oak-Model 1.0.
I'd rather see it (as in the feature/behaviour on the overall) get merged, ideally with as little involvement from my end from this point on :)

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 this pull request may close these issues.

1 participant