Created
May 22, 2020 03:25
-
-
Save dangirsh/86c001351c02b42321d20f462a66da6b to your computer and use it in GitHub Desktop.
Combine key-chord.el with key maps to have many quick bindings in non-modal settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun add-to-keymap (keymap bindings) | |
(dolist (binding bindings) | |
(define-key keymap (kbd (car binding)) (cdr binding)))) | |
(defun add-to-dk-keymap (bindings) | |
(add-to-keymap dk-keymap bindings)) | |
;; Example usage with dk and sl | |
(setq dk-keymap (make-sparse-keymap)) | |
(setq sl-keymap (make-sparse-keymap)) | |
(key-chord-define-global "dk" dk-keymap) | |
(key-chord-define-global "sl" sl-keymap) | |
(defun add-to-sl-keymap (bindings) | |
(add-to-keymap sl-keymap bindings)) | |
(add-to-dk-keymap | |
'(("<SPC>" . rgrep) | |
("o" . ibuffer) | |
("s" . save-buffer) | |
("." . pop-global-mark))) | |
(add-to-sl-keymap | |
'(("k" . magit-dispatch-popup) | |
("s" . magit-status) | |
("o" . magit-log) | |
("u" . magit-submodule-update) | |
("l" . magit-show-refs-head))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment