bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#22792: eshell-mode-map declaration


From: Alex Branham
Subject: bug#22792: eshell-mode-map declaration
Date: Fri, 28 Jun 2019 13:14:20 -0500
User-agent: mu4e 1.2.0; emacs 27.0.50

tags 22792 patch
quit

On Thu 27 Jun 2019 at 14:23, Noam Postavsky <npostavs@gmail.com> wrote:

> Alex Branham <alex.branham@gmail.com> writes:
>
>> We could create an em-cmpl minor mode with its own keymap, I
>> suppose. Would that be satisfactory?
>
> Makes sense to me.

OK, here's a patch that does so. The general idea is to make a minor
mode with its own keymap for each of eshell's modules that (previously)
assigned their keybindings into eshell-mode-map.

Alex

>From 00e5ad69971e7f9abacf10d25325bdee6088f648 Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham@gmail.com>
Date: Wed, 26 Jun 2019 13:59:06 -0500
Subject: [PATCH] Fix eshell-mode-map initialization

* lisp/eshell/esh-mode.el (eshell-mode-map):
(eshell-command-map): Set up normal keymaps and prefix commands rather
than re-initializing them in each eshell buffer

* lisp/eshell/em-cmpl.el (eshell-cmpl-mode-map):
(eshell-cmpl-mode):
(eshell-cmpl-initialize):
* lisp/eshell/em-hist.el (eshell-hist-mode-map):
(eshell-hist-mode):
(eshell-hist-initialize):
* lisp/eshell/em-pred.el (eshell-pred-mode-map):
(eshell-pred-mode):
(eshell-pred-initialize):
* lisp/eshell/em-prompt.el (eshell-prompt-mode-map):
(eshell-prompt-mode):
(eshell-prompt-initialize):
* lisp/eshell/em-rebind.el (eshell-rebind-mode-map):
(eshell-rebind-mode):
(eshell-rebind-initialize):
* lisp/eshell/esh-arg.el (eshell-arg-mode-map):
(eshell-arg-mode):
(eshell-arg-initialize):
* lisp/eshell/esh-proc.el (eshell-proc-mode-map):
(eshell-proc-mode):
(eshell-proc-initialize):
* lisp/eshell/esh-var.el (eshell-var-mode-map):
(eshell-var-mode):
(eshell-var-initialize): Create a new minor mode with a keymap and
call it in the module initialization function.

bug#33808
bug#22792
---
 etc/NEWS                 |  5 ++++
 lisp/eshell/em-cmpl.el   | 33 ++++++++++++----------
 lisp/eshell/em-hist.el   | 60 +++++++++++++++++++++-------------------
 lisp/eshell/em-pred.el   | 13 +++++++--
 lisp/eshell/em-prompt.el | 14 ++++++++--
 lisp/eshell/em-rebind.el | 11 +++++++-
 lisp/eshell/esh-arg.el   | 14 +++++++---
 lisp/eshell/esh-mode.el  | 58 +++++++++++++++++---------------------
 lisp/eshell/esh-proc.el  | 26 +++++++++--------
 lisp/eshell/esh-var.el   | 14 ++++++----
 10 files changed, 148 insertions(+), 100 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 864eb8c110..83fac26e3a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1237,6 +1237,11 @@ default, and not just the opening element.
 behave similarly, e.g. Pcomplete's default cycling can be obtained
 with '(setq completion-cycle-threshold 5)'.
 
+*** Eshell no longer re-initializes its keymap every call.
+This allows users to use (define-key eshell-mode-map ...) as usual.
+Some modules have their own minor mode now to account for these
+changes.
+
 ---
 *** Expansion of history event designators is disabled by default.
 To restore the old behavior, use
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index 8f6c6781b9..952091a479 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -244,6 +244,24 @@ to writing a completion function."
   (let ((completion-at-point-functions '(lisp-completion-at-point)))
     (completion-at-point)))
 
+(defvar eshell-cmpl-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(control ?i)] #'completion-at-point)
+    ;; jww (1999-10-19): Will this work on anything but X?
+    (define-key map [backtab] #'pcomplete-reverse)
+    (define-key map [(meta ??)] #'completion-help-at-point)
+    (define-key map [(meta control ?i)] #'eshell-complete-lisp-symbol)
+    ;; C-c prefix:
+    (define-key map (kbd "C-c M-h") #'eshell-completion-help)
+    (define-key map (kbd "C-c TAB") #'pcomplete-expand-and-complete)
+    (define-key map (kbd "C-c C-i") #'pcomplete-expand-and-complete)
+    (define-key map (kbd "C-c SPC") #'pcomplete-expand)
+    map))
+
+(define-minor-mode eshell-cmpl-mode
+  "Minor mode that provides a keymap when `eshell-cmpl' active."
+  :keymap eshell-cmpl-mode-map)
+
 (defun eshell-cmpl-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the completions module."
   (set (make-local-variable 'pcomplete-command-completion-function)
@@ -291,22 +309,9 @@ to writing a completion function."
                    eshell-special-chars-outside-quoting)))
             nil t)
   (add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t)
-  ;;(define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) ; 
Redundant
-  (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol)
-  (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help)
-  (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete)
-  (define-key eshell-command-map [(control ?i)]
-    'pcomplete-expand-and-complete)
-  (define-key eshell-command-map [space] 'pcomplete-expand)
-  (define-key eshell-command-map [? ] 'pcomplete-expand)
-  ;;(define-key eshell-mode-map [tab] 'completion-at-point) ;Redundant!
-  (define-key eshell-mode-map [(control ?i)] 'completion-at-point)
   (add-hook 'completion-at-point-functions
             #'pcomplete-completions-at-point nil t)
-  ;; jww (1999-10-19): Will this work on anything but X?
-  (define-key eshell-mode-map
-    (if (featurep 'xemacs) [iso-left-tab] [backtab]) 'pcomplete-reverse)
-  (define-key eshell-mode-map [(meta ??)] 'completion-help-at-point))
+  (eshell-cmpl-mode))
 
 (defun eshell-completion-command-name ()
   "Return the command name, possibly sans globbing."
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index adb028002b..19782e8d6c 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -202,6 +202,32 @@ element, regardless of any text on the command line.  In 
that case,
     map)
   "Keymap used in isearch in Eshell.")
 
+(defvar eshell-hist-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [up] #'eshell-previous-matching-input-from-input)
+    (define-key map [down] #'eshell-next-matching-input-from-input)
+    (define-key map [(control up)] #'eshell-previous-input)
+    (define-key map [(control down)] #'eshell-next-input)
+    (define-key map [(meta ?r)] #'eshell-previous-matching-input)
+    (define-key map [(meta ?s)] #'eshell-next-matching-input)
+    (define-key map (kbd "C-c M-r") 
#'eshell-previous-matching-input-from-input)
+    (define-key map (kbd "C-c M-s") #'eshell-next-matching-input-from-input)
+    ;; FIXME: Relies on `eshell-hist-match-partial' being set _before_
+    ;; em-hist is loaded and won't respect changes.
+    (if eshell-hist-match-partial
+       (progn
+         (define-key map [(meta ?p)] 
'eshell-previous-matching-input-from-input)
+         (define-key map [(meta ?n)] 'eshell-next-matching-input-from-input)
+         (define-key map (kbd "C-c M-p") #'eshell-previous-input)
+         (define-key map (kbd "C-c M-n") #'eshell-next-input))
+      (define-key map [(meta ?p)] #'eshell-previous-input)
+      (define-key map [(meta ?n)] #'eshell-next-input)
+      (define-key map (kbd "C-c M-p") 
#'eshell-previous-matching-input-from-input)
+      (define-key map (kbd "C-c M-n") #'eshell-next-matching-input-from-input))
+    (define-key map (kbd "C-c C-l") #'eshell-list-history)
+    (define-key map (kbd "C-c C-x") #'eshell-get-next-from-history)
+    map))
+
 (defvar eshell-rebind-keys-alist)
 
 ;;; Functions:
@@ -216,6 +242,10 @@ Returns non-nil if INPUT is blank."
 Returns nil if INPUT is prepended by blank space, otherwise non-nil."
   (not (string-match-p "\\`\\s-+" input)))
 
+(define-minor-mode eshell-hist-mode
+  "Minor mode for the eshell-hist module."
+  :keymap eshell-hist-mode-map)
+
 (defun eshell-hist-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the history management code for one Eshell buffer."
   (when (eshell-using-module 'eshell-cmpl)
@@ -242,30 +272,7 @@ Returns nil if INPUT is prepended by blank space, 
otherwise non-nil."
                   (lambda ()
                     (setq overriding-terminal-local-map nil)))
                   nil t))
-    (define-key eshell-mode-map [up] 
'eshell-previous-matching-input-from-input)
-    (define-key eshell-mode-map [down] 'eshell-next-matching-input-from-input)
-    (define-key eshell-mode-map [(control up)] 'eshell-previous-input)
-    (define-key eshell-mode-map [(control down)] 'eshell-next-input)
-    (define-key eshell-mode-map [(meta ?r)] 'eshell-previous-matching-input)
-    (define-key eshell-mode-map [(meta ?s)] 'eshell-next-matching-input)
-    (define-key eshell-command-map [(meta ?r)]
-      'eshell-previous-matching-input-from-input)
-    (define-key eshell-command-map [(meta ?s)]
-      'eshell-next-matching-input-from-input)
-    (if eshell-hist-match-partial
-       (progn
-         (define-key eshell-mode-map [(meta ?p)]
-           'eshell-previous-matching-input-from-input)
-         (define-key eshell-mode-map [(meta ?n)]
-           'eshell-next-matching-input-from-input)
-         (define-key eshell-command-map [(meta ?p)] 'eshell-previous-input)
-         (define-key eshell-command-map [(meta ?n)] 'eshell-next-input))
-      (define-key eshell-mode-map [(meta ?p)] 'eshell-previous-input)
-      (define-key eshell-mode-map [(meta ?n)] 'eshell-next-input)
-      (define-key eshell-command-map [(meta ?p)]
-       'eshell-previous-matching-input-from-input)
-      (define-key eshell-command-map [(meta ?n)]
-       'eshell-next-matching-input-from-input)))
+    (eshell-hist-mode))
 
   (make-local-variable 'eshell-history-size)
   (or eshell-history-size
@@ -300,10 +307,7 @@ Returns nil if INPUT is prepended by blank space, 
otherwise non-nil."
   (add-hook 'kill-emacs-hook #'eshell-save-some-history)
 
   (make-local-variable 'eshell-input-filter-functions)
-  (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t)
-
-  (define-key eshell-command-map [(control ?l)] 'eshell-list-history)
-  (define-key eshell-command-map [(control ?x)] 'eshell-get-next-from-history))
+  (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t))
 
 (defun eshell-save-some-history ()
   "Save the history for any open Eshell buffers."
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index 9bc856a296..1017e2b7c0 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -229,6 +229,12 @@ FOR LISTS OF ARGUMENTS:
 EXAMPLES:
   *.c(:o)  sorted list of .c files")
 
+(defvar eshell-pred-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c M-q") #'eshell-display-predicate-help)
+    (define-key map (kbd "C-c M-m") #'eshell-display-modifier-help)
+    map))
+
 ;;; Functions:
 
 (defun eshell-display-predicate-help ()
@@ -245,12 +251,15 @@ EXAMPLES:
     (lambda ()
       (insert eshell-modifier-help-string)))))
 
+(define-minor-mode eshell-pred-mode
+  "Minor mode for the eshell-pred module."
+  :keymap eshell-pred-mode-map)
+
 (defun eshell-pred-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the predicate/modifier code."
   (add-hook 'eshell-parse-argument-hook
            #'eshell-parse-arg-modifier t t)
-  (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help)
-  (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help))
+  (eshell-pred-mode))
 
 (defun eshell-apply-modifiers (lst predicates modifiers)
   "Apply to LIST a series of PREDICATES and MODIFIERS."
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index adc68b6c85..9c396ce627 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -97,8 +97,18 @@ arriving, or after."
   :options '(eshell-show-maximum-output)
   :group 'eshell-prompt)
 
+(defvar eshell-prompt-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c C-n") #'eshell-next-prompt)
+    (define-key map (kbd "C-c C-p") #'eshell-previous-prompt)
+    map))
+
 ;;; Functions:
 
+(define-minor-mode eshell-prompt-mode
+  "Minor mode for eshell-prompt module."
+  :keymap eshell-prompt-mode-map)
+
 (defun eshell-prompt-initialize ()  ;Called from `eshell-mode' via intern-soft!
   "Initialize the prompting code."
   (unless eshell-non-interactive-p
@@ -110,9 +120,7 @@ arriving, or after."
 
     (set (make-local-variable 'eshell-skip-prompt-function)
         'eshell-skip-prompt)
-
-    (define-key eshell-command-map [(control ?n)] 'eshell-next-prompt)
-    (define-key eshell-command-map [(control ?p)] 'eshell-previous-prompt)))
+    (eshell-prompt-mode)))
 
 (defun eshell-emit-prompt ()
   "Emit a prompt if eshell is being used interactively."
diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el
index a817edbcc9..318f13d244 100644
--- a/lisp/eshell/em-rebind.el
+++ b/lisp/eshell/em-rebind.el
@@ -137,6 +137,11 @@ This is default behavior of shells like bash."
   :type '(repeat function)
   :group 'eshell-rebind)
 
+(defvar eshell-rebind-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c M-l") #'eshell-lock-local-map)
+    map))
+
 ;; Internal Variables:
 
 (defvar eshell-input-keymap)
@@ -145,6 +150,10 @@ This is default behavior of shells like bash."
 
 ;;; Functions:
 
+(define-minor-mode eshell-rebind-mode
+  "Minor mode for the eshell-rebind module."
+  :keymap eshell-rebind-mode-map)
+
 (defun eshell-rebind-initialize ()  ;Called from `eshell-mode' via intern-soft!
   "Initialize the inputting code."
   (unless eshell-non-interactive-p
@@ -154,7 +163,7 @@ This is default behavior of shells like bash."
     (make-local-variable 'overriding-local-map)
     (add-hook 'post-command-hook 'eshell-rebind-input-map nil t)
     (set (make-local-variable 'eshell-lock-keymap) nil)
-    (define-key eshell-command-map [(meta ?l)] 'eshell-lock-local-map)))
+    (eshell-rebind-mode)))
 
 (defun eshell-lock-local-map (&optional arg)
   "Lock or unlock the current local keymap.
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index 026edc5980..bd31703e0d 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -155,14 +155,20 @@ treated as a literal character."
   :type 'hook
   :group 'eshell-arg)
 
+(defvar eshell-arg-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c M-b") #'eshell-insert-buffer-name)
+    map))
+
 ;;; Functions:
 
+(define-minor-mode eshell-arg-mode
+  "Minor mode for the arg eshell module."
+  :keymap eshell-arg-mode-map)
+
 (defun eshell-arg-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the argument parsing code."
-  ;; This is supposedly run after enabling esh-mode, when eshell-mode-map
-  ;; already exists.
-  (defvar eshell-command-map)
-  (define-key eshell-command-map [(meta ?b)] 'eshell-insert-buffer-name)
+  (eshell-arg-mode)
   (set (make-local-variable 'eshell-inside-quote-regexp) nil)
   (set (make-local-variable 'eshell-outside-quote-regexp) nil))
 
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 80844c3a64..91204877f5 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -213,10 +213,7 @@ This is used by `eshell-watch-for-password-prompt'."
 ;; these are only set to nil initially for the sake of the
 ;; byte-compiler, when compiling other files which `require' this one
 (defvar eshell-mode nil)
-(defvar eshell-mode-map nil)
 (defvar eshell-command-running-string "--")
-(defvar eshell-command-map nil)
-(defvar eshell-command-prefix nil)
 (defvar eshell-last-input-start nil)
 (defvar eshell-last-input-end nil)
 (defvar eshell-last-output-start nil)
@@ -286,6 +283,32 @@ This is used by `eshell-watch-for-password-prompt'."
      (standard-syntax-table))
     st))
 
+(defvar eshell-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(control ?c)] 'eshell-command-map)
+    (define-key map "\r" #'eshell-send-input)
+    (define-key map "\M-\r" #'eshell-queue-input)
+    (define-key map [(meta control ?l)] #'eshell-show-output)
+    (define-key map [(control ?a)] #'eshell-bol)
+    map))
+
+(defvar eshell-command-map
+  (let ((map (define-prefix-command 'eshell-command-map)))
+    (define-key map [(meta ?o)] #'eshell-mark-output)
+    (define-key map [(meta ?d)] #'eshell-toggle-direct-send)
+    (define-key map [(control ?a)] #'eshell-bol)
+    (define-key map [(control ?b)] #'eshell-backward-argument)
+    (define-key map [(control ?e)] #'eshell-show-maximum-output)
+    (define-key map [(control ?f)] #'eshell-forward-argument)
+    (define-key map [(control ?m)] #'eshell-copy-old-input)
+    (define-key map [(control ?o)] #'eshell-kill-output)
+    (define-key map [(control ?r)] #'eshell-show-output)
+    (define-key map [(control ?t)] #'eshell-truncate-buffer)
+    (define-key map [(control ?u)] #'eshell-kill-input)
+    (define-key map [(control ?w)] #'backward-kill-word)
+    (define-key map [(control ?y)] #'eshell-repeat-argument)
+    map))
+
 ;;; User Functions:
 
 (defun eshell-kill-buffer-function ()
@@ -304,10 +327,6 @@ and the hook `eshell-exit-hook'."
   "Emacs shell interactive mode."
   (setq-local eshell-mode t)
 
-  ;; FIXME: What the hell!?
-  (setq-local eshell-mode-map (make-sparse-keymap))
-  (use-local-map eshell-mode-map)
-
   (when eshell-status-in-mode-line
     (make-local-variable 'eshell-command-running-string)
     (let ((fmt (copy-sequence mode-line-format)))
@@ -316,31 +335,6 @@ and the hook `eshell-exit-hook'."
       (if mode-line-elt
          (setcar mode-line-elt 'eshell-command-running-string))))
 
-  (define-key eshell-mode-map "\r" 'eshell-send-input)
-  (define-key eshell-mode-map "\M-\r" 'eshell-queue-input)
-  (define-key eshell-mode-map [(meta control ?l)] 'eshell-show-output)
-  (define-key eshell-mode-map [(control ?a)] 'eshell-bol)
-
-  (setq-local eshell-command-prefix (make-symbol "eshell-command-prefix"))
-  (fset eshell-command-prefix (make-sparse-keymap))
-  (setq-local eshell-command-map (symbol-function eshell-command-prefix))
-  (define-key eshell-mode-map [(control ?c)] eshell-command-prefix)
-
-  (define-key eshell-command-map [(meta ?o)] 'eshell-mark-output)
-  (define-key eshell-command-map [(meta ?d)] 'eshell-toggle-direct-send)
-
-  (define-key eshell-command-map [(control ?a)] 'eshell-bol)
-  (define-key eshell-command-map [(control ?b)] 'eshell-backward-argument)
-  (define-key eshell-command-map [(control ?e)] 'eshell-show-maximum-output)
-  (define-key eshell-command-map [(control ?f)] 'eshell-forward-argument)
-  (define-key eshell-command-map [(control ?m)] 'eshell-copy-old-input)
-  (define-key eshell-command-map [(control ?o)] 'eshell-kill-output)
-  (define-key eshell-command-map [(control ?r)] 'eshell-show-output)
-  (define-key eshell-command-map [(control ?t)] 'eshell-truncate-buffer)
-  (define-key eshell-command-map [(control ?u)] 'eshell-kill-input)
-  (define-key eshell-command-map [(control ?w)] 'backward-kill-word)
-  (define-key eshell-command-map [(control ?y)] 'eshell-repeat-argument)
-
   (setq local-abbrev-table eshell-mode-abbrev-table)
 
   (set (make-local-variable 'list-buffers-directory)
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 32a3eecb52..7825377e66 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -109,6 +109,16 @@ information, for example."
 (defvar eshell-process-list nil
   "A list of the current status of subprocesses.")
 
+(defvar eshell-proc-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c M-i") #'eshell-insert-process)
+    (define-key map (kbd "C-c C-c") #'eshell-interrupt-process)
+    (define-key map (kbd "C-c C-k") #'eshell-kill-process)
+    (define-key map (kbd "C-c C-d") #'eshell-send-eof-to-process)
+    (define-key map (kbd "C-c C-s") #'list-processes)
+    (define-key map (kbd "C-c C-\\") #'eshell-quit-process)
+    map))
+
 ;;; Functions:
 
 (defun eshell-kill-process-function (proc status)
@@ -121,20 +131,14 @@ PROC and STATUS to functions on the latter."
   (eshell-reset-after-proc status)
   (run-hook-with-args 'eshell-kill-hook proc status))
 
+(define-minor-mode eshell-proc-mode
+  "Minor mode for the proc eshell module."
+  :keymap eshell-proc-mode-map)
+
 (defun eshell-proc-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the process handling code."
   (make-local-variable 'eshell-process-list)
-  ;; This is supposedly run after enabling esh-mode, when eshell-command-map
-  ;; already exists.
-  (defvar eshell-command-map)
-  (define-key eshell-command-map [(meta ?i)] 'eshell-insert-process)
-  (define-key eshell-command-map [(control ?c)]  'eshell-interrupt-process)
-  (define-key eshell-command-map [(control ?k)]  'eshell-kill-process)
-  (define-key eshell-command-map [(control ?d)]  'eshell-send-eof-to-process)
-; (define-key eshell-command-map [(control ?q)]  'eshell-continue-process)
-  (define-key eshell-command-map [(control ?s)]  'list-processes)
-; (define-key eshell-command-map [(control ?z)]  'eshell-stop-process)
-  (define-key eshell-command-map [(control ?\\)] 'eshell-quit-process))
+  (eshell-proc-mode))
 
 (defun eshell-reset-after-proc (status)
   "Reset the command input location after a process terminates.
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index b08a5d242f..00bea09384 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -197,8 +197,17 @@ function), and the arguments passed to this function would 
be the list
 
 (put 'eshell-variable-aliases-list 'risky-local-variable t)
 
+(defvar eshell-var-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c M-v") #'eshell-insert-envvar)
+    map))
+
 ;;; Functions:
 
+(define-minor-mode eshell-var-mode
+  "Minor mode for the esh-var module."
+  :keymap eshell-var-mode-map)
+
 (defun eshell-var-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the variable handle code."
   ;; Break the association with our parent's environment.  Otherwise,
@@ -207,11 +216,6 @@ function), and the arguments passed to this function would 
be the list
     (set (make-local-variable 'process-environment)
         (eshell-copy-environment)))
 
-  ;; This is supposedly run after enabling esh-mode, when eshell-command-map
-  ;; already exists.
-  (defvar eshell-command-map)
-  (define-key eshell-command-map [(meta ?v)] 'eshell-insert-envvar)
-
   (set (make-local-variable 'eshell-special-chars-inside-quoting)
        (append eshell-special-chars-inside-quoting '(?$)))
   (set (make-local-variable 'eshell-special-chars-outside-quoting)
-- 
2.22.0


reply via email to

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