xahlee / xah-fly-keys

the most efficient keybinding for emacs
http://xahlee.info/emacs/misc/xah-fly-keys.html
484 stars 83 forks source link

Allow for keybinding customization outside of xah-fly-keys.el (define-key xah-fly-command-map #40

Closed rschmidlin closed 6 years ago

xahlee commented 6 years ago

can you describe what this do exactly?

i looked at it, but haven't figured out what's the benefit. It complicated things, now with 3 key maps, and seems other parts are changes... but i wasn't sure what is the benefit. How is it allow customization outside xfk? example?

rschmidlin commented 6 years ago

I'm sorry Xah, I did not have much time lately. I will try to explain it basically: If I want to change "i" in Dvorak to kill-line instead of xah-delete-current-text-block: (define-key xah-fly-key-map (kbd "i") 'kill-line) I suppose it will be overwritten back to xah-delete-current-text-block the next time I switch from insert into command mode.

Now again, if I try to map a keybinding to the command mode that is not reset to nil on insert-mode, this will make the insertion of the letter as text impossible. An example would be the case for any capital letter: (define-key xah-fly-key-map (kbd "I") 'xah-delete-current-text-block) Now also in insert mode, "I" will delete the paragraph instead of inserting the letter "I".

If you use the new system, you can do both by replacing xah-fly-key-map to xah-fly-command-map in the code above.

I know the implementation is somewhat obscure. But it is based on the Emacs emulation-mode-map-alists. By pushing the alist xah-fly-key-map-alist to it, the cdrs of the internal cons enable or disable the corresponding keymaps automatically. Basically, the xah-fly-generic-map is always enabled (if xah-fly-keys is enabled) while xah-fly-command-map is enabled on xah-fly-command-mode-activate-no-hook by setting xah-fly-command-state-q to true and xah-fly-insert-state-q to false and conversely on xah-fly-insert-mode-activate.