artempyanykh / evil-russian

Evil key bindings translated to Russian layout for seamless transition.
11 stars 0 forks source link

Альтернативы / Alternatives #4

Open mentalisttraceur opened 4 weeks ago

mentalisttraceur commented 4 weeks ago

Just sharing this in case it helps anyone. I started doing this at the end of my config:

https://github.com/mentalisttraceur/home/blob/b87838a23700d52cfd45aec8e3870daa4b55084f/.emacs.el#L5127-L5215

In particular, it's possible you'd prefer this approach for ex command aliases, and maybe it suggests a satisfying way to handle #1 .

Basically this defines a mapping from QWERTY to ЙЦУКЕН and then:

It does have some weaknesses:

  1. If the English bindings change or new ones are added, the Russian one needs to be redone too (I think this can be solved by binding Russian keys to English keys instead of Russian keys to the English keys' looked-up bindings. But I didn't like the error behavior that has when the English key is unbound, and it would require extra bindings to preserve self-insert behavior in Evil's Insert and Emacs states).
  2. Buffer-local bindings currently need to be separately duplicated for Russian (this might also get obviated by a solution to # 1).
  3. Un-optimized. (There's some low-hanging fruit in how I'm replacing letters in ex-command names. And if we bind key-to-key instead of key-to-looked-up-binding, it's cheaper.)
  4. I currently only handle {{button}}, Shift+{{button}}, and Ctrl+{{button}}. I'm sure that's not enough for everyone. (Only takes a few lines of code to add support for one more modifier though.)
  5. I haven't yet figured out what to do with symbols that get moved from their QWERTY positions on ЙЦУКЕН, ditto symbols that get lost to such moves. (Like how "$" on 4 gets replaced with the moved ";". )

It works really well for me for now, although I've only just started using it.

mentalisttraceur commented 3 weeks ago

Я тут немного подумал... maybe the best way to do the keymap stuff is:

  1. A sparse keymap where all Russian letters are bound to the corresponding QWERTY letters/symbols. Theb compose this map into global-map (slash whichever other maps turn out to need it). This would cover approximately all situations, only breaking regular text insertion.

  2. A sparse keymap with just all Russian letters bound to self-insert-command - compose this map into Evil's insert state and emacs state maps to fix text insertion.

For "compose this map into", c.f. how make-composed-keymap makes composed keymaps.

I haven't tried this yet, but as soon as I have reason to improve on what I have above, this is probably my next move.