[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b9b8c5e 2/2: Make dedicated keymap and mode for eshell-command (B

From: Noam Postavsky
Subject: master b9b8c5e 2/2: Make dedicated keymap and mode for eshell-command (Bug#41370)
Date: Sun, 24 May 2020 20:25:28 -0400 (EDT)

branch: master
commit b9b8c5e3fa71aea719934ce422fb22734590a8b3
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Make dedicated keymap and mode for eshell-command (Bug#41370)
    Otherwise, we end up permanently modifying eshell-mode-map when
    running eshell-command.
    * lisp/eshell/eshell.el (eshell-command-mode): New mode, with map to
    contain the bindings previously set by eshell-return-exits-minibuffer.
    (eshell-return-exits-minibuffer): Make into obsolete alias for
    (eshell-command): Use eshell-command-mode instead of
 lisp/eshell/eshell.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index 2a63882..5ffb159 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -265,14 +265,18 @@ information on Eshell, see Info node `(eshell)Top'."
-(defun eshell-return-exits-minibuffer ()
-  ;; This is supposedly run after enabling esh-mode, when eshell-mode-map
-  ;; already exists.
-  (defvar eshell-mode-map)
-  (define-key eshell-mode-map [(control ?g)] 'abort-recursive-edit)
-  (define-key eshell-mode-map [(control ?m)] 'exit-minibuffer)
-  (define-key eshell-mode-map [(control ?j)] 'exit-minibuffer)
-  (define-key eshell-mode-map [(meta control ?m)] 'exit-minibuffer))
+(define-minor-mode eshell-command-mode
+  "Minor mode for `eshell-command' input.
+  :keymap (let ((map (make-sparse-keymap)))
+            (define-key map [(control ?g)] 'abort-recursive-edit)
+            (define-key map [(control ?m)] 'exit-minibuffer)
+            (define-key map [(control ?j)] 'exit-minibuffer)
+            (define-key map [(meta control ?m)] 'exit-minibuffer)
+            map))
+(define-obsolete-function-alias 'eshell-return-exits-minibuffer
+  #'eshell-command-mode "28.1")
 (defvar eshell-non-interactive-p nil
   "A variable which is non-nil when Eshell is not running interactively.
@@ -292,7 +296,7 @@ With prefix ARG, insert output into the current buffer at 
     ;; Enable `eshell-mode' only in this minibuffer.
     (minibuffer-with-setup-hook #'(lambda ()
-                                    (eshell-return-exits-minibuffer))
+                                    (eshell-command-mode +1))
       (unless command
         (setq command (read-from-minibuffer "Emacs shell command: "))
        (if (eshell-using-module 'eshell-hist)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]