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,11 +118,6 @@ You should use `set-eshell-alias!' to change this.")
|
|||
(append eshell-command-aliases-list
|
||||
+eshell-aliases))))
|
||||
|
||||
(add-hook! 'eshell-first-time-mode-hook
|
||||
(defun +eshell-init-keymap-h ()
|
||||
;; Keys must be bound in a hook because eshell resets its keymap every
|
||||
;; time `eshell-mode' is enabled. Why? It is not for us mere mortals to
|
||||
;; grasp such wisdom.
|
||||
(map! :map eshell-mode-map
|
||||
:n "RET" #'+eshell/goto-end-of-prompt
|
||||
:n [return] #'+eshell/goto-end-of-prompt
|
||||
|
@ -150,7 +145,17 @@ You should use `set-eshell-alias!' to change this.")
|
|||
(:localleader
|
||||
"b" #'eshell-insert-buffer-name
|
||||
"e" #'eshell-insert-envvar
|
||||
"s" #'+eshell/search-history)))))
|
||||
"s" #'+eshell/search-history))
|
||||
|
||||
;; HACK Eshell resets its keymap every time `eshell-mode' is enabled. Why? It
|
||||
;; is not for us mere mortals to question! Fun fact: there's a "FIXME
|
||||
;; What the hell?!" above the offending line in esh-mode.el.
|
||||
;; 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue