Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Combine key-chord.el with key maps to have many quick bindings in non-modal settings
(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