Minimize dependence on map!

This is in preparation for general.el integration coming in 2.1.1. It is
very likely that map! will change (and even more, be split into several
macros). Not much, but change none-the-less. Specifically, the state
keywords (e.g. :nvi, :n, :i) will be removed in favor of a :state
property that takes a list, e.g. (normal visual insert).

In any case, both map! and general are also relatively expensive
compared to define-key and evil-define-key* (and the new define-key!
macro), so use that when we can.

This also means changes to either API won't affect Doom's modules in the
long term.
This commit is contained in:
Henrik Lissner 2018-06-03 15:46:00 +02:00
parent 83590d65ba
commit 1e81a35461
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
20 changed files with 276 additions and 239 deletions

View file

@ -55,20 +55,23 @@
(defun +eshell|init-keymap ()
"Setup eshell keybindings. This must be done in a hook because eshell-mode
redefines its keys every time `eshell-mode' is enabled."
(map! :map eshell-mode-map
:n [return] #'+eshell/goto-end-of-prompt
:n "c" #'+eshell/evil-change
:n "C" #'+eshell/evil-change-line
:n "d" #'+eshell/evil-delete
:n "D" #'+eshell/evil-delete-line
:i "C-d" #'+eshell/quit-or-delete-char
:i "C-p" #'eshell-previous-input
:i "C-n" #'eshell-next-input
[remap doom/backward-to-bol-or-indent] #'eshell-bol
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
[remap split-window-below] #'+eshell/split-below
[remap split-window-right] #'+eshell/split-right
[remap evil-window-split] #'+eshell/split-below
[remap evil-window-vsplit] #'+eshell/split-right))
(when (featurep 'evil)
(evil-define-key* 'normal eshell-mode-map
[return] #'+eshell/goto-end-of-prompt
"c" #'+eshell/evil-change
"C" #'+eshell/evil-change-line
"d" #'+eshell/evil-delete
"D" #'+eshell/evil-delete-line)
(evil-define-key* 'insert eshell-mode-map
"\C-d" #'+eshell/quit-or-delete-char
"\C-p" #'eshell-previous-input
"\C-n" #'eshell-next-input))
(define-key! eshell-mode-map
[remap split-window-below] #'+eshell/split-below
[remap split-window-right] #'+eshell/split-right
[remap doom/backward-to-bol-or-indent] #'eshell-bol
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
[remap evil-window-split] #'+eshell/split-below
[remap evil-window-vsplit] #'+eshell/split-right))
(add-hook 'eshell-first-time-mode-hook #'+eshell|init-keymap))