summaryrefslogtreecommitdiff
path: root/modes/eshell
diff options
context:
space:
mode:
authorcondy <condy0919@gmail.com>2021-11-20 12:08:33 +0800
committercondy <condy0919@gmail.com>2021-11-20 12:08:33 +0800
commita81b6c8f5537b3646e6a66a6e60ec634848d1926 (patch)
tree8a49e808664214141174bd689e0698d3828d858f /modes/eshell
parent652d74acfb5789eacef36660c4ffc68905c8d741 (diff)
eshell: escape doesn't move cursor back
Diffstat (limited to 'modes/eshell')
-rw-r--r--modes/eshell/evil-collection-eshell.el18
1 files changed, 14 insertions, 4 deletions
diff --git a/modes/eshell/evil-collection-eshell.el b/modes/eshell/evil-collection-eshell.el
index c025878..2877632 100644
--- a/modes/eshell/evil-collection-eshell.el
+++ b/modes/eshell/evil-collection-eshell.el
@@ -1,6 +1,6 @@
;;; evil-collection-eshell.el --- Evil bindings for Eshell -*- lexical-binding: t -*-
-;; Copyright (C) 2017 Pierre Neidhardt
+;; Copyright (C) 2017, 2021 Pierre Neidhardt
;; Author: Pierre Neidhardt <mail@ambrevar.xyz>
;; Maintainer: James Nguyen <james@jojojames.com>
@@ -51,6 +51,12 @@
(eshell-interrupt-process)
(evil-insert 1))
+(defun evil-collection-eshell-escape-stay ()
+ "Go back to normal state but don't move cursor backwards.
+Moving cursor backwards is the default Vim behavior but it is not
+appropriate in some cases like terminals."
+ (setq-local evil-move-cursor-back nil))
+
;; Taken from Doom Emacs
(evil-define-operator evil-collection-eshell-evil-change (beg end type register yank-handler delete-func)
"Like `evil-change' but will not delete/copy the prompt."
@@ -79,7 +85,10 @@
type register yank-handler)))
;; Taken from Doom Emacs
-;; Although the BEG argument doesn't get used in any meaningful way, `evil-define-operator' must access it nonetheless, so putting an underscore in front will make the CI fail.
+;;
+;; Although the BEG argument doesn't get used in any meaningful way,
+;; `evil-define-operator' must access it nonetheless, so putting an underscore
+;; in front will make the CI fail.
(evil-define-operator evil-collection-eshell-evil-delete-line (beg end type register yank-handler)
"Change to end of line."
:motion nil
@@ -87,8 +96,8 @@
(interactive "<R><x>")
(evil-collection-eshell-evil-delete (point) end type register yank-handler))
-;;; `eshell-mode-map' is reset when Eshell is initialized in `eshell-mode'. We
-;;; need to add bindings to `eshell-first-time-mode-hook'.
+;; `eshell-mode-map' is reset when Eshell is initialized in `eshell-mode'. We
+;; need to add bindings to `eshell-first-time-mode-hook'.
(defun evil-collection-eshell-setup-keys ()
"Set up `evil' bindings for `eshell'."
(evil-collection-define-key 'normal 'eshell-mode-map
@@ -137,6 +146,7 @@
;;;###autoload
(defun evil-collection-eshell-setup ()
"Set up `evil' bindings for `eshell'."
+ (add-hook 'eshell-mode-hook 'evil-collection-eshell-escape-stay)
(add-hook 'eshell-mode-hook 'evil-collection-eshell-next-prompt-on-insert)
(add-hook 'eshell-first-time-mode-hook 'evil-collection-eshell-setup-keys))