Skip to content

Instantly share code, notes, and snippets.

@wasamasa
Created February 18, 2016 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasamasa/db0d1ef97814caffb4e0 to your computer and use it in GitHub Desktop.
Save wasamasa/db0d1ef97814caffb4e0 to your computer and use it in GitHub Desktop.
my-define-keys
(defun my-partition (n list)
(let (result)
(while list
(let ((i 0)
chunk)
(while (< i n)
(push (pop list) chunk)
(setq i (1+ i)))
(push (nreverse chunk) result)))
(nreverse result)))
(my-partition 3 '(1 2 3 4 5 6 7 8 9 10)) ;=> '((1 2 3) (4 5 6) (7 8 9) (10 nil nil))
(defmacro my-define-keys (feature keymap &rest bindings)
`(with-eval-after-load ',feature
,@(mapcar
(lambda (binding)
`(define-key ,keymap (kbd ,(car binding)) ',(cadr binding)))
(my-partition 2 bindings))))
(my-define-keys evil-maps evil-normal-state-map
"z r" my-revert-buffer
"z s" describe-char
"z e" toggle-debug-on-error
"z q" toggle-debug-on-quit
"z t" my-solarized-toggle
"z m" my-toggle-mode-line-minor-modes
"z n" my-narrow-to-region-with-mode
"z TAB" evil-toggle-fold
"z <backtab>" my-evil-toggle-folds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment