term/eshell: fix eshell resetting eshell-mode-map
This "backports" a Emacs 28 fix which prevents eshell from resetting eshell-mode-map every time eshell-mode is activated. Now users can bind keys to eshell-mode-map like they could for any normal mode.
This commit is contained in:
parent
fe37a590cc
commit
f33b141650
1 changed files with 38 additions and 33 deletions
|
@ -118,39 +118,44 @@ You should use `set-eshell-alias!' to change this.")
|
||||||
(append eshell-command-aliases-list
|
(append eshell-command-aliases-list
|
||||||
+eshell-aliases))))
|
+eshell-aliases))))
|
||||||
|
|
||||||
(add-hook! 'eshell-first-time-mode-hook
|
(map! :map eshell-mode-map
|
||||||
(defun +eshell-init-keymap-h ()
|
:n "RET" #'+eshell/goto-end-of-prompt
|
||||||
;; Keys must be bound in a hook because eshell resets its keymap every
|
:n [return] #'+eshell/goto-end-of-prompt
|
||||||
;; time `eshell-mode' is enabled. Why? It is not for us mere mortals to
|
:ni "C-j" #'eshell-next-matching-input-from-input
|
||||||
;; grasp such wisdom.
|
:ni "C-k" #'eshell-previous-matching-input-from-input
|
||||||
(map! :map eshell-mode-map
|
:ig "C-d" #'+eshell/quit-or-delete-char
|
||||||
:n "RET" #'+eshell/goto-end-of-prompt
|
:i "C-c h" #'evil-window-left
|
||||||
:n [return] #'+eshell/goto-end-of-prompt
|
:i "C-c j" #'evil-window-down
|
||||||
:ni "C-j" #'eshell-next-matching-input-from-input
|
:i "C-c k" #'evil-window-up
|
||||||
:ni "C-k" #'eshell-previous-matching-input-from-input
|
:i "C-c l" #'evil-window-right
|
||||||
:ig "C-d" #'+eshell/quit-or-delete-char
|
"C-s" #'+eshell/search-history
|
||||||
:i "C-c h" #'evil-window-left
|
;; Emacs bindings
|
||||||
:i "C-c j" #'evil-window-down
|
"C-e" #'end-of-line
|
||||||
:i "C-c k" #'evil-window-up
|
;; Tmux-esque prefix keybinds
|
||||||
:i "C-c l" #'evil-window-right
|
"C-c s" #'+eshell/split-below
|
||||||
"C-s" #'+eshell/search-history
|
"C-c v" #'+eshell/split-right
|
||||||
;; Emacs bindings
|
"C-c x" #'+eshell/kill-and-close
|
||||||
"C-e" #'end-of-line
|
[remap split-window-below] #'+eshell/split-below
|
||||||
;; Tmux-esque prefix keybinds
|
[remap split-window-right] #'+eshell/split-right
|
||||||
"C-c s" #'+eshell/split-below
|
[remap doom/backward-to-bol-or-indent] #'eshell-bol
|
||||||
"C-c v" #'+eshell/split-right
|
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
|
||||||
"C-c x" #'+eshell/kill-and-close
|
[remap evil-delete-back-to-indentation] #'eshell-kill-input
|
||||||
[remap split-window-below] #'+eshell/split-below
|
[remap evil-window-split] #'+eshell/split-below
|
||||||
[remap split-window-right] #'+eshell/split-right
|
[remap evil-window-vsplit] #'+eshell/split-right
|
||||||
[remap doom/backward-to-bol-or-indent] #'eshell-bol
|
(:localleader
|
||||||
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
|
"b" #'eshell-insert-buffer-name
|
||||||
[remap evil-delete-back-to-indentation] #'eshell-kill-input
|
"e" #'eshell-insert-envvar
|
||||||
[remap evil-window-split] #'+eshell/split-below
|
"s" #'+eshell/search-history))
|
||||||
[remap evil-window-vsplit] #'+eshell/split-right
|
|
||||||
(:localleader
|
;; HACK Eshell resets its keymap every time `eshell-mode' is enabled. Why? It
|
||||||
"b" #'eshell-insert-buffer-name
|
;; is not for us mere mortals to question! Fun fact: there's a "FIXME
|
||||||
"e" #'eshell-insert-envvar
|
;; What the hell?!" above the offending line in esh-mode.el.
|
||||||
"s" #'+eshell/search-history)))))
|
;; DEPRECATED As of Emacs 28, binding keys in a hook is no longer necessary.
|
||||||
|
(add-hook! 'eshell-mode-hook
|
||||||
|
(defun +eshell-fix-keymap-h ()
|
||||||
|
"Undo buffer-local `eshell-mode-map', so global keybinds work."
|
||||||
|
(kill-local-variable 'eshell-mode-map)
|
||||||
|
(use-local-map eshell-mode-map))))
|
||||||
|
|
||||||
|
|
||||||
(use-package! eshell-up
|
(use-package! eshell-up
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue