mrkkrp / modalka

Modal editing your way
280 stars 18 forks source link

Add support for multiple states #31

Closed matsievskiysv closed 4 years ago

matsievskiysv commented 4 years ago

This PR extends modalka functionality to support multiple states (or modes). This is done by creating multiple keymaps based on the optional state argument. These keymaps are assigned to modalka-mode in minor-mode-map-alist when modalka-switch-state is called.

For example:

(modalka-define-kbd "a" "C-a")
(modalka-define-kbd "A" "C-a" 'motion)
(modalka-define-binding-kbd "b" #'forward-char)
(modalka-define-binding-kbd "B" #'forward-char 'motion)

This code defines two states: default and motion. They have different key bindings. To switch between them one must call an interactive function modalka-switch-state. Current state name will appear in lighter in square braces.

Introduced changes are compatible with current configuration syntax.

Minimal Emacs version had to be set to 25.1. Keyword was switched due to the package-lint complains.

matsievskiysv commented 4 years ago

Added modalka-supress-global option for suppression of global-mode keymap when in modalka mode. This is used to make sure that no characters will be self-inserted when they are not binded.

mrkkrp commented 4 years ago

I'll be frank, I'm not inclined to merge this. The motivation for having more than one mode is not clear to me, and I'd like to keep the package as simple as it is right now. You still can fork or make your own.