 ;;; core-keybinds.el
 
-;; A centralized keybinds system. Uses `which-key' to preview available keys.
+;; A centralized keybinds system, integrated with `which-key' to preview
+;; available keys, and `evil', if it's enabled. All built into one powerful
+;; macro: `map!'.
 
 (defvar doom-leader-key ","
   "The leader prefix key, for global commands.")

  (which-key-mode +1))


(defun doom-keybind-register (key desc &optional modes)
  "TODO"
  (if modes
      (dolist (mode modes)
        (which-key-add-major-mode-key-based-replacements mode key desc))
    (which-key-add-key-based-replacements key desc)))


(defun doom-keyword-to-states (keyword &optional ignore)
  "TODO"
  (let ((states '(("n" . normal)
                  ("v" . visual)
                  ("i" . insert)
                  ("e" . emacs)
                  ("o" . operator)
                  ("m" . motion)
                  ("r" . replace))))
    (delq nil
          (mapcar (lambda (l)
                    (let ((state (cdr (assoc l states))))
                      (unless state
                        (unless (or (eq ignore t) (member l ignore))
                          (error "not a valid state: %s" l)))
                      state))
                  (split-string (substring (symbol-name keyword) 1) "" t)))))

;; Register keywords for proper indentation (see `map!')
(put ':prefix       'lisp-indent-function 'defun)

(defvar doom-localleader-key "\\"
  "The leader prefix key, for global commands.")

(defvar doom-evil-state-alist
  '(("n" . normal)
    ("v" . visual)
    ("i" . insert)
    ("e" . emacs)
    ("o" . operator)
    ("m" . motion)
    ("r" . replace))
  "A list of cons cells that map a letter to a evil state symbol.")


;;
(def-package! which-key
  :demand t
  :config
