summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2020-05-24 20:12:30 -0400
committerNoam Postavsky <npostavs@gmail.com>2020-05-24 20:12:30 -0400
commit478638e4706716b74de5b1aa3e85c8fd943f17ba (patch)
treecf5f40cdaec0af986199d3147a480ddca631a3a7 /lisp/eshell
parente7a3ed8a6dddb6e16c83d27a04dfa6ec8160e580 (diff)
downloademacs-478638e4706716b74de5b1aa3e85c8fd943f17ba.tar.gz
emacs-478638e4706716b74de5b1aa3e85c8fd943f17ba.tar.bz2
emacs-478638e4706716b74de5b1aa3e85c8fd943f17ba.zip
Revert "Fix eshell-mode-map initialization"
It makes eshell-return-exits-minibuffer permanently affect the eshell-mode-map (Bug#41370). Do not merge to master, we will fix it properly there.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/em-cmpl.el35
-rw-r--r--lisp/eshell/em-hist.el62
-rw-r--r--lisp/eshell/em-pred.el15
-rw-r--r--lisp/eshell/em-prompt.el16
-rw-r--r--lisp/eshell/em-rebind.el13
-rw-r--r--lisp/eshell/esh-arg.el16
-rw-r--r--lisp/eshell/esh-mode.el58
-rw-r--r--lisp/eshell/esh-proc.el28
-rw-r--r--lisp/eshell/esh-var.el16
9 files changed, 100 insertions, 159 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index dcf56af6051..48c99acac33 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -244,26 +244,6 @@ to writing a completion function."
(let ((completion-at-point-functions '(elisp-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.
-
-\\{eshell-cmpl-mode-map}"
- :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)
@@ -311,9 +291,22 @@ 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)
- (eshell-cmpl-mode))
+ ;; 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))
(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 267936583e1..73742a361da 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -202,32 +202,6 @@ 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:
@@ -242,12 +216,6 @@ 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.
-
-\\{eshell-hist-mode-map}"
- :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)
@@ -274,7 +242,30 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
(lambda ()
(setq overriding-terminal-local-map nil)))
nil t))
- (eshell-hist-mode))
+ (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)))
(make-local-variable 'eshell-history-size)
(or eshell-history-size
@@ -309,7 +300,10 @@ 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))
+ (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))
(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 04bf3ff8998..ee4b28fb3ae 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -229,12 +229,6 @@ 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 ()
@@ -251,17 +245,12 @@ EXAMPLES:
(lambda ()
(insert eshell-modifier-help-string)))))
-(define-minor-mode eshell-pred-mode
- "Minor mode for the eshell-pred module.
-
-\\{eshell-pred-mode-map}"
- :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)
- (eshell-pred-mode))
+ (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help)
+ (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help))
(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 9ae5ae12816..bbf3b94ff44 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -97,20 +97,8 @@ 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.
-
-\\{eshell-prompt-mode-map}"
- :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
@@ -122,7 +110,9 @@ arriving, or after."
(set (make-local-variable 'eshell-skip-prompt-function)
'eshell-skip-prompt)
- (eshell-prompt-mode)))
+
+ (define-key eshell-command-map [(control ?n)] 'eshell-next-prompt)
+ (define-key eshell-command-map [(control ?p)] 'eshell-previous-prompt)))
(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 bf5a4bf1afe..85593e45160 100644
--- a/lisp/eshell/em-rebind.el
+++ b/lisp/eshell/em-rebind.el
@@ -137,11 +137,6 @@ 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)
@@ -150,12 +145,6 @@ This is default behavior of shells like bash."
;;; Functions:
-(define-minor-mode eshell-rebind-mode
- "Minor mode for the eshell-rebind module.
-
-\\{eshell-rebind-mode-map}"
- :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
@@ -165,7 +154,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)
- (eshell-rebind-mode)))
+ (define-key eshell-command-map [(meta ?l)] 'eshell-lock-local-map)))
(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 e7b07b4208d..86ceb41ffd2 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -155,22 +155,14 @@ 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.
-
-\\{eshell-arg-mode-map}"
- :keymap eshell-arg-mode-map)
-
(defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft!
"Initialize the argument parsing code."
- (eshell-arg-mode)
+ ;; 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)
(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 d0147b345aa..db5fddb2aaf 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -213,7 +213,10 @@ 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)
@@ -277,32 +280,6 @@ 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 ()
@@ -321,6 +298,10 @@ 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)))
@@ -329,6 +310,31 @@ 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 d2c17fe1f77..c3ac3a5b71b 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -109,16 +109,6 @@ 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)
@@ -131,16 +121,20 @@ 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.
-
-\\{eshell-proc-mode-map}"
- :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)
- (eshell-proc-mode))
+ ;; 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))
(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 327a1def469..75ccf5b8353 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -197,19 +197,8 @@ 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.
-
-\\{eshell-var-mode-map}"
- :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,
@@ -218,6 +207,11 @@ 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)