diff options
| author | Alex Branham | 2019-06-26 13:59:06 -0500 |
|---|---|---|
| committer | Noam Postavsky | 2019-08-15 20:49:15 -0400 |
| commit | 1ee0192b792124663a0a40a729dd83c047d21535 (patch) | |
| tree | ee51acecf6d02868d81344c7d0249d45b070ab9b | |
| parent | b3713265cbb8eb591ac832ae4c35bf8185544467 (diff) | |
| download | emacs-1ee0192b792124663a0a40a729dd83c047d21535.tar.gz emacs-1ee0192b792124663a0a40a729dd83c047d21535.zip | |
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
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/eshell/em-cmpl.el | 35 | ||||
| -rw-r--r-- | lisp/eshell/em-hist.el | 62 | ||||
| -rw-r--r-- | lisp/eshell/em-pred.el | 15 | ||||
| -rw-r--r-- | lisp/eshell/em-prompt.el | 16 | ||||
| -rw-r--r-- | lisp/eshell/em-rebind.el | 13 | ||||
| -rw-r--r-- | lisp/eshell/esh-arg.el | 16 | ||||
| -rw-r--r-- | lisp/eshell/esh-mode.el | 58 | ||||
| -rw-r--r-- | lisp/eshell/esh-proc.el | 28 | ||||
| -rw-r--r-- | lisp/eshell/esh-var.el | 16 |
10 files changed, 165 insertions, 100 deletions
| @@ -1355,6 +1355,12 @@ default, and not just the opening element. | |||
| 1355 | behave similarly, e.g. Pcomplete's default cycling can be obtained | 1355 | behave similarly, e.g. Pcomplete's default cycling can be obtained |
| 1356 | with '(setq completion-cycle-threshold 5)'. | 1356 | with '(setq completion-cycle-threshold 5)'. |
| 1357 | 1357 | ||
| 1358 | --- | ||
| 1359 | *** Eshell no longer re-initializes its keymap every call. | ||
| 1360 | This allows users to use (define-key eshell-mode-map ...) as usual. | ||
| 1361 | Some modules have their own minor mode now to account for these | ||
| 1362 | changes. | ||
| 1363 | |||
| 1358 | +++ | 1364 | +++ |
| 1359 | *** Expansion of history event designators is disabled by default. | 1365 | *** Expansion of history event designators is disabled by default. |
| 1360 | To restore the old behavior, use | 1366 | To restore the old behavior, use |
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 8f6c6781b9c..df4e24c88b1 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el | |||
| @@ -244,6 +244,26 @@ to writing a completion function." | |||
| 244 | (let ((completion-at-point-functions '(lisp-completion-at-point))) | 244 | (let ((completion-at-point-functions '(lisp-completion-at-point))) |
| 245 | (completion-at-point))) | 245 | (completion-at-point))) |
| 246 | 246 | ||
| 247 | (defvar eshell-cmpl-mode-map | ||
| 248 | (let ((map (make-sparse-keymap))) | ||
| 249 | (define-key map [(control ?i)] #'completion-at-point) | ||
| 250 | ;; jww (1999-10-19): Will this work on anything but X? | ||
| 251 | (define-key map [backtab] #'pcomplete-reverse) | ||
| 252 | (define-key map [(meta ??)] #'completion-help-at-point) | ||
| 253 | (define-key map [(meta control ?i)] #'eshell-complete-lisp-symbol) | ||
| 254 | ;; C-c prefix: | ||
| 255 | (define-key map (kbd "C-c M-h") #'eshell-completion-help) | ||
| 256 | (define-key map (kbd "C-c TAB") #'pcomplete-expand-and-complete) | ||
| 257 | (define-key map (kbd "C-c C-i") #'pcomplete-expand-and-complete) | ||
| 258 | (define-key map (kbd "C-c SPC") #'pcomplete-expand) | ||
| 259 | map)) | ||
| 260 | |||
| 261 | (define-minor-mode eshell-cmpl-mode | ||
| 262 | "Minor mode that provides a keymap when `eshell-cmpl' active. | ||
| 263 | |||
| 264 | \\{eshell-cmpl-mode-map}" | ||
| 265 | :keymap eshell-cmpl-mode-map) | ||
| 266 | |||
| 247 | (defun eshell-cmpl-initialize () ;Called from `eshell-mode' via intern-soft! | 267 | (defun eshell-cmpl-initialize () ;Called from `eshell-mode' via intern-soft! |
| 248 | "Initialize the completions module." | 268 | "Initialize the completions module." |
| 249 | (set (make-local-variable 'pcomplete-command-completion-function) | 269 | (set (make-local-variable 'pcomplete-command-completion-function) |
| @@ -291,22 +311,9 @@ to writing a completion function." | |||
| 291 | eshell-special-chars-outside-quoting))) | 311 | eshell-special-chars-outside-quoting))) |
| 292 | nil t) | 312 | nil t) |
| 293 | (add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t) | 313 | (add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t) |
| 294 | ;;(define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) ; Redundant | ||
| 295 | (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol) | ||
| 296 | (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help) | ||
| 297 | (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete) | ||
| 298 | (define-key eshell-command-map [(control ?i)] | ||
| 299 | 'pcomplete-expand-and-complete) | ||
| 300 | (define-key eshell-command-map [space] 'pcomplete-expand) | ||
| 301 | (define-key eshell-command-map [? ] 'pcomplete-expand) | ||
| 302 | ;;(define-key eshell-mode-map [tab] 'completion-at-point) ;Redundant! | ||
| 303 | (define-key eshell-mode-map [(control ?i)] 'completion-at-point) | ||
| 304 | (add-hook 'completion-at-point-functions | 314 | (add-hook 'completion-at-point-functions |
| 305 | #'pcomplete-completions-at-point nil t) | 315 | #'pcomplete-completions-at-point nil t) |
| 306 | ;; jww (1999-10-19): Will this work on anything but X? | 316 | (eshell-cmpl-mode)) |
| 307 | (define-key eshell-mode-map | ||
| 308 | (if (featurep 'xemacs) [iso-left-tab] [backtab]) 'pcomplete-reverse) | ||
| 309 | (define-key eshell-mode-map [(meta ??)] 'completion-help-at-point)) | ||
| 310 | 317 | ||
| 311 | (defun eshell-completion-command-name () | 318 | (defun eshell-completion-command-name () |
| 312 | "Return the command name, possibly sans globbing." | 319 | "Return the command name, possibly sans globbing." |
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index adb028002be..9a9e6f0f39b 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, | |||
| 202 | map) | 202 | map) |
| 203 | "Keymap used in isearch in Eshell.") | 203 | "Keymap used in isearch in Eshell.") |
| 204 | 204 | ||
| 205 | (defvar eshell-hist-mode-map | ||
| 206 | (let ((map (make-sparse-keymap))) | ||
| 207 | (define-key map [up] #'eshell-previous-matching-input-from-input) | ||
| 208 | (define-key map [down] #'eshell-next-matching-input-from-input) | ||
| 209 | (define-key map [(control up)] #'eshell-previous-input) | ||
| 210 | (define-key map [(control down)] #'eshell-next-input) | ||
| 211 | (define-key map [(meta ?r)] #'eshell-previous-matching-input) | ||
| 212 | (define-key map [(meta ?s)] #'eshell-next-matching-input) | ||
| 213 | (define-key map (kbd "C-c M-r") #'eshell-previous-matching-input-from-input) | ||
| 214 | (define-key map (kbd "C-c M-s") #'eshell-next-matching-input-from-input) | ||
| 215 | ;; FIXME: Relies on `eshell-hist-match-partial' being set _before_ | ||
| 216 | ;; em-hist is loaded and won't respect changes. | ||
| 217 | (if eshell-hist-match-partial | ||
| 218 | (progn | ||
| 219 | (define-key map [(meta ?p)] 'eshell-previous-matching-input-from-input) | ||
| 220 | (define-key map [(meta ?n)] 'eshell-next-matching-input-from-input) | ||
| 221 | (define-key map (kbd "C-c M-p") #'eshell-previous-input) | ||
| 222 | (define-key map (kbd "C-c M-n") #'eshell-next-input)) | ||
| 223 | (define-key map [(meta ?p)] #'eshell-previous-input) | ||
| 224 | (define-key map [(meta ?n)] #'eshell-next-input) | ||
| 225 | (define-key map (kbd "C-c M-p") #'eshell-previous-matching-input-from-input) | ||
| 226 | (define-key map (kbd "C-c M-n") #'eshell-next-matching-input-from-input)) | ||
| 227 | (define-key map (kbd "C-c C-l") #'eshell-list-history) | ||
| 228 | (define-key map (kbd "C-c C-x") #'eshell-get-next-from-history) | ||
| 229 | map)) | ||
| 230 | |||
| 205 | (defvar eshell-rebind-keys-alist) | 231 | (defvar eshell-rebind-keys-alist) |
| 206 | 232 | ||
| 207 | ;;; Functions: | 233 | ;;; Functions: |
| @@ -216,6 +242,12 @@ Returns non-nil if INPUT is blank." | |||
| 216 | Returns nil if INPUT is prepended by blank space, otherwise non-nil." | 242 | Returns nil if INPUT is prepended by blank space, otherwise non-nil." |
| 217 | (not (string-match-p "\\`\\s-+" input))) | 243 | (not (string-match-p "\\`\\s-+" input))) |
| 218 | 244 | ||
| 245 | (define-minor-mode eshell-hist-mode | ||
| 246 | "Minor mode for the eshell-hist module. | ||
| 247 | |||
| 248 | \\{eshell-hist-mode-map}" | ||
| 249 | :keymap eshell-hist-mode-map) | ||
| 250 | |||
| 219 | (defun eshell-hist-initialize () ;Called from `eshell-mode' via intern-soft! | 251 | (defun eshell-hist-initialize () ;Called from `eshell-mode' via intern-soft! |
| 220 | "Initialize the history management code for one Eshell buffer." | 252 | "Initialize the history management code for one Eshell buffer." |
| 221 | (when (eshell-using-module 'eshell-cmpl) | 253 | (when (eshell-using-module 'eshell-cmpl) |
| @@ -242,30 +274,7 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil." | |||
| 242 | (lambda () | 274 | (lambda () |
| 243 | (setq overriding-terminal-local-map nil))) | 275 | (setq overriding-terminal-local-map nil))) |
| 244 | nil t)) | 276 | nil t)) |
| 245 | (define-key eshell-mode-map [up] 'eshell-previous-matching-input-from-input) | 277 | (eshell-hist-mode)) |
| 246 | (define-key eshell-mode-map [down] 'eshell-next-matching-input-from-input) | ||
| 247 | (define-key eshell-mode-map [(control up)] 'eshell-previous-input) | ||
| 248 | (define-key eshell-mode-map [(control down)] 'eshell-next-input) | ||
| 249 | (define-key eshell-mode-map [(meta ?r)] 'eshell-previous-matching-input) | ||
| 250 | (define-key eshell-mode-map [(meta ?s)] 'eshell-next-matching-input) | ||
| 251 | (define-key eshell-command-map [(meta ?r)] | ||
| 252 | 'eshell-previous-matching-input-from-input) | ||
| 253 | (define-key eshell-command-map [(meta ?s)] | ||
| 254 | 'eshell-next-matching-input-from-input) | ||
| 255 | (if eshell-hist-match-partial | ||
| 256 | (progn | ||
| 257 | (define-key eshell-mode-map [(meta ?p)] | ||
| 258 | 'eshell-previous-matching-input-from-input) | ||
| 259 | (define-key eshell-mode-map [(meta ?n)] | ||
| 260 | 'eshell-next-matching-input-from-input) | ||
| 261 | (define-key eshell-command-map [(meta ?p)] 'eshell-previous-input) | ||
| 262 | (define-key eshell-command-map [(meta ?n)] 'eshell-next-input)) | ||
| 263 | (define-key eshell-mode-map [(meta ?p)] 'eshell-previous-input) | ||
| 264 | (define-key eshell-mode-map [(meta ?n)] 'eshell-next-input) | ||
| 265 | (define-key eshell-command-map [(meta ?p)] | ||
| 266 | 'eshell-previous-matching-input-from-input) | ||
| 267 | (define-key eshell-command-map [(meta ?n)] | ||
| 268 | 'eshell-next-matching-input-from-input))) | ||
| 269 | 278 | ||
| 270 | (make-local-variable 'eshell-history-size) | 279 | (make-local-variable 'eshell-history-size) |
| 271 | (or eshell-history-size | 280 | (or eshell-history-size |
| @@ -300,10 +309,7 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil." | |||
| 300 | (add-hook 'kill-emacs-hook #'eshell-save-some-history) | 309 | (add-hook 'kill-emacs-hook #'eshell-save-some-history) |
| 301 | 310 | ||
| 302 | (make-local-variable 'eshell-input-filter-functions) | 311 | (make-local-variable 'eshell-input-filter-functions) |
| 303 | (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t) | 312 | (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t)) |
| 304 | |||
| 305 | (define-key eshell-command-map [(control ?l)] 'eshell-list-history) | ||
| 306 | (define-key eshell-command-map [(control ?x)] 'eshell-get-next-from-history)) | ||
| 307 | 313 | ||
| 308 | (defun eshell-save-some-history () | 314 | (defun eshell-save-some-history () |
| 309 | "Save the history for any open Eshell buffers." | 315 | "Save the history for any open Eshell buffers." |
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index 9bc856a2966..cfef59f962e 100644 --- a/lisp/eshell/em-pred.el +++ b/lisp/eshell/em-pred.el | |||
| @@ -229,6 +229,12 @@ FOR LISTS OF ARGUMENTS: | |||
| 229 | EXAMPLES: | 229 | EXAMPLES: |
| 230 | *.c(:o) sorted list of .c files") | 230 | *.c(:o) sorted list of .c files") |
| 231 | 231 | ||
| 232 | (defvar eshell-pred-mode-map | ||
| 233 | (let ((map (make-sparse-keymap))) | ||
| 234 | (define-key map (kbd "C-c M-q") #'eshell-display-predicate-help) | ||
| 235 | (define-key map (kbd "C-c M-m") #'eshell-display-modifier-help) | ||
| 236 | map)) | ||
| 237 | |||
| 232 | ;;; Functions: | 238 | ;;; Functions: |
| 233 | 239 | ||
| 234 | (defun eshell-display-predicate-help () | 240 | (defun eshell-display-predicate-help () |
| @@ -245,12 +251,17 @@ EXAMPLES: | |||
| 245 | (lambda () | 251 | (lambda () |
| 246 | (insert eshell-modifier-help-string))))) | 252 | (insert eshell-modifier-help-string))))) |
| 247 | 253 | ||
| 254 | (define-minor-mode eshell-pred-mode | ||
| 255 | "Minor mode for the eshell-pred module. | ||
| 256 | |||
| 257 | \\{eshell-pred-mode-map}" | ||
| 258 | :keymap eshell-pred-mode-map) | ||
| 259 | |||
| 248 | (defun eshell-pred-initialize () ;Called from `eshell-mode' via intern-soft! | 260 | (defun eshell-pred-initialize () ;Called from `eshell-mode' via intern-soft! |
| 249 | "Initialize the predicate/modifier code." | 261 | "Initialize the predicate/modifier code." |
| 250 | (add-hook 'eshell-parse-argument-hook | 262 | (add-hook 'eshell-parse-argument-hook |
| 251 | #'eshell-parse-arg-modifier t t) | 263 | #'eshell-parse-arg-modifier t t) |
| 252 | (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help) | 264 | (eshell-pred-mode)) |
| 253 | (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help)) | ||
| 254 | 265 | ||
| 255 | (defun eshell-apply-modifiers (lst predicates modifiers) | 266 | (defun eshell-apply-modifiers (lst predicates modifiers) |
| 256 | "Apply to LIST a series of PREDICATES and MODIFIERS." | 267 | "Apply to LIST a series of PREDICATES and MODIFIERS." |
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index adc68b6c856..993a740b825 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el | |||
| @@ -97,8 +97,20 @@ arriving, or after." | |||
| 97 | :options '(eshell-show-maximum-output) | 97 | :options '(eshell-show-maximum-output) |
| 98 | :group 'eshell-prompt) | 98 | :group 'eshell-prompt) |
| 99 | 99 | ||
| 100 | (defvar eshell-prompt-mode-map | ||
| 101 | (let ((map (make-sparse-keymap))) | ||
| 102 | (define-key map (kbd "C-c C-n") #'eshell-next-prompt) | ||
| 103 | (define-key map (kbd "C-c C-p") #'eshell-previous-prompt) | ||
| 104 | map)) | ||
| 105 | |||
| 100 | ;;; Functions: | 106 | ;;; Functions: |
| 101 | 107 | ||
| 108 | (define-minor-mode eshell-prompt-mode | ||
| 109 | "Minor mode for eshell-prompt module. | ||
| 110 | |||
| 111 | \\{eshell-prompt-mode-map}" | ||
| 112 | :keymap eshell-prompt-mode-map) | ||
| 113 | |||
| 102 | (defun eshell-prompt-initialize () ;Called from `eshell-mode' via intern-soft! | 114 | (defun eshell-prompt-initialize () ;Called from `eshell-mode' via intern-soft! |
| 103 | "Initialize the prompting code." | 115 | "Initialize the prompting code." |
| 104 | (unless eshell-non-interactive-p | 116 | (unless eshell-non-interactive-p |
| @@ -110,9 +122,7 @@ arriving, or after." | |||
| 110 | 122 | ||
| 111 | (set (make-local-variable 'eshell-skip-prompt-function) | 123 | (set (make-local-variable 'eshell-skip-prompt-function) |
| 112 | 'eshell-skip-prompt) | 124 | 'eshell-skip-prompt) |
| 113 | 125 | (eshell-prompt-mode))) | |
| 114 | (define-key eshell-command-map [(control ?n)] 'eshell-next-prompt) | ||
| 115 | (define-key eshell-command-map [(control ?p)] 'eshell-previous-prompt))) | ||
| 116 | 126 | ||
| 117 | (defun eshell-emit-prompt () | 127 | (defun eshell-emit-prompt () |
| 118 | "Emit a prompt if eshell is being used interactively." | 128 | "Emit a prompt if eshell is being used interactively." |
diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el index a817edbcc99..5fb6677e181 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." | |||
| 137 | :type '(repeat function) | 137 | :type '(repeat function) |
| 138 | :group 'eshell-rebind) | 138 | :group 'eshell-rebind) |
| 139 | 139 | ||
| 140 | (defvar eshell-rebind-mode-map | ||
| 141 | (let ((map (make-sparse-keymap))) | ||
| 142 | (define-key map (kbd "C-c M-l") #'eshell-lock-local-map) | ||
| 143 | map)) | ||
| 144 | |||
| 140 | ;; Internal Variables: | 145 | ;; Internal Variables: |
| 141 | 146 | ||
| 142 | (defvar eshell-input-keymap) | 147 | (defvar eshell-input-keymap) |
| @@ -145,6 +150,12 @@ This is default behavior of shells like bash." | |||
| 145 | 150 | ||
| 146 | ;;; Functions: | 151 | ;;; Functions: |
| 147 | 152 | ||
| 153 | (define-minor-mode eshell-rebind-mode | ||
| 154 | "Minor mode for the eshell-rebind module. | ||
| 155 | |||
| 156 | \\{eshell-rebind-mode-map}" | ||
| 157 | :keymap eshell-rebind-mode-map) | ||
| 158 | |||
| 148 | (defun eshell-rebind-initialize () ;Called from `eshell-mode' via intern-soft! | 159 | (defun eshell-rebind-initialize () ;Called from `eshell-mode' via intern-soft! |
| 149 | "Initialize the inputting code." | 160 | "Initialize the inputting code." |
| 150 | (unless eshell-non-interactive-p | 161 | (unless eshell-non-interactive-p |
| @@ -154,7 +165,7 @@ This is default behavior of shells like bash." | |||
| 154 | (make-local-variable 'overriding-local-map) | 165 | (make-local-variable 'overriding-local-map) |
| 155 | (add-hook 'post-command-hook 'eshell-rebind-input-map nil t) | 166 | (add-hook 'post-command-hook 'eshell-rebind-input-map nil t) |
| 156 | (set (make-local-variable 'eshell-lock-keymap) nil) | 167 | (set (make-local-variable 'eshell-lock-keymap) nil) |
| 157 | (define-key eshell-command-map [(meta ?l)] 'eshell-lock-local-map))) | 168 | (eshell-rebind-mode))) |
| 158 | 169 | ||
| 159 | (defun eshell-lock-local-map (&optional arg) | 170 | (defun eshell-lock-local-map (&optional arg) |
| 160 | "Lock or unlock the current local keymap. | 171 | "Lock or unlock the current local keymap. |
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index 026edc59808..46850958267 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el | |||
| @@ -155,14 +155,22 @@ treated as a literal character." | |||
| 155 | :type 'hook | 155 | :type 'hook |
| 156 | :group 'eshell-arg) | 156 | :group 'eshell-arg) |
| 157 | 157 | ||
| 158 | (defvar eshell-arg-mode-map | ||
| 159 | (let ((map (make-sparse-keymap))) | ||
| 160 | (define-key map (kbd "C-c M-b") #'eshell-insert-buffer-name) | ||
| 161 | map)) | ||
| 162 | |||
| 158 | ;;; Functions: | 163 | ;;; Functions: |
| 159 | 164 | ||
| 165 | (define-minor-mode eshell-arg-mode | ||
| 166 | "Minor mode for the arg eshell module. | ||
| 167 | |||
| 168 | \\{eshell-arg-mode-map}" | ||
| 169 | :keymap eshell-arg-mode-map) | ||
| 170 | |||
| 160 | (defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft! | 171 | (defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft! |
| 161 | "Initialize the argument parsing code." | 172 | "Initialize the argument parsing code." |
| 162 | ;; This is supposedly run after enabling esh-mode, when eshell-mode-map | 173 | (eshell-arg-mode) |
| 163 | ;; already exists. | ||
| 164 | (defvar eshell-command-map) | ||
| 165 | (define-key eshell-command-map [(meta ?b)] 'eshell-insert-buffer-name) | ||
| 166 | (set (make-local-variable 'eshell-inside-quote-regexp) nil) | 174 | (set (make-local-variable 'eshell-inside-quote-regexp) nil) |
| 167 | (set (make-local-variable 'eshell-outside-quote-regexp) nil)) | 175 | (set (make-local-variable 'eshell-outside-quote-regexp) nil)) |
| 168 | 176 | ||
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 80844c3a646..91204877f5d 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'." | |||
| 213 | ;; these are only set to nil initially for the sake of the | 213 | ;; these are only set to nil initially for the sake of the |
| 214 | ;; byte-compiler, when compiling other files which `require' this one | 214 | ;; byte-compiler, when compiling other files which `require' this one |
| 215 | (defvar eshell-mode nil) | 215 | (defvar eshell-mode nil) |
| 216 | (defvar eshell-mode-map nil) | ||
| 217 | (defvar eshell-command-running-string "--") | 216 | (defvar eshell-command-running-string "--") |
| 218 | (defvar eshell-command-map nil) | ||
| 219 | (defvar eshell-command-prefix nil) | ||
| 220 | (defvar eshell-last-input-start nil) | 217 | (defvar eshell-last-input-start nil) |
| 221 | (defvar eshell-last-input-end nil) | 218 | (defvar eshell-last-input-end nil) |
| 222 | (defvar eshell-last-output-start nil) | 219 | (defvar eshell-last-output-start nil) |
| @@ -286,6 +283,32 @@ This is used by `eshell-watch-for-password-prompt'." | |||
| 286 | (standard-syntax-table)) | 283 | (standard-syntax-table)) |
| 287 | st)) | 284 | st)) |
| 288 | 285 | ||
| 286 | (defvar eshell-mode-map | ||
| 287 | (let ((map (make-sparse-keymap))) | ||
| 288 | (define-key map [(control ?c)] 'eshell-command-map) | ||
| 289 | (define-key map "\r" #'eshell-send-input) | ||
| 290 | (define-key map "\M-\r" #'eshell-queue-input) | ||
| 291 | (define-key map [(meta control ?l)] #'eshell-show-output) | ||
| 292 | (define-key map [(control ?a)] #'eshell-bol) | ||
| 293 | map)) | ||
| 294 | |||
| 295 | (defvar eshell-command-map | ||
| 296 | (let ((map (define-prefix-command 'eshell-command-map))) | ||
| 297 | (define-key map [(meta ?o)] #'eshell-mark-output) | ||
| 298 | (define-key map [(meta ?d)] #'eshell-toggle-direct-send) | ||
| 299 | (define-key map [(control ?a)] #'eshell-bol) | ||
| 300 | (define-key map [(control ?b)] #'eshell-backward-argument) | ||
| 301 | (define-key map [(control ?e)] #'eshell-show-maximum-output) | ||
| 302 | (define-key map [(control ?f)] #'eshell-forward-argument) | ||
| 303 | (define-key map [(control ?m)] #'eshell-copy-old-input) | ||
| 304 | (define-key map [(control ?o)] #'eshell-kill-output) | ||
| 305 | (define-key map [(control ?r)] #'eshell-show-output) | ||
| 306 | (define-key map [(control ?t)] #'eshell-truncate-buffer) | ||
| 307 | (define-key map [(control ?u)] #'eshell-kill-input) | ||
| 308 | (define-key map [(control ?w)] #'backward-kill-word) | ||
| 309 | (define-key map [(control ?y)] #'eshell-repeat-argument) | ||
| 310 | map)) | ||
| 311 | |||
| 289 | ;;; User Functions: | 312 | ;;; User Functions: |
| 290 | 313 | ||
| 291 | (defun eshell-kill-buffer-function () | 314 | (defun eshell-kill-buffer-function () |
| @@ -304,10 +327,6 @@ and the hook `eshell-exit-hook'." | |||
| 304 | "Emacs shell interactive mode." | 327 | "Emacs shell interactive mode." |
| 305 | (setq-local eshell-mode t) | 328 | (setq-local eshell-mode t) |
| 306 | 329 | ||
| 307 | ;; FIXME: What the hell!? | ||
| 308 | (setq-local eshell-mode-map (make-sparse-keymap)) | ||
| 309 | (use-local-map eshell-mode-map) | ||
| 310 | |||
| 311 | (when eshell-status-in-mode-line | 330 | (when eshell-status-in-mode-line |
| 312 | (make-local-variable 'eshell-command-running-string) | 331 | (make-local-variable 'eshell-command-running-string) |
| 313 | (let ((fmt (copy-sequence mode-line-format))) | 332 | (let ((fmt (copy-sequence mode-line-format))) |
| @@ -316,31 +335,6 @@ and the hook `eshell-exit-hook'." | |||
| 316 | (if mode-line-elt | 335 | (if mode-line-elt |
| 317 | (setcar mode-line-elt 'eshell-command-running-string)))) | 336 | (setcar mode-line-elt 'eshell-command-running-string)))) |
| 318 | 337 | ||
| 319 | (define-key eshell-mode-map "\r" 'eshell-send-input) | ||
| 320 | (define-key eshell-mode-map "\M-\r" 'eshell-queue-input) | ||
| 321 | (define-key eshell-mode-map [(meta control ?l)] 'eshell-show-output) | ||
| 322 | (define-key eshell-mode-map [(control ?a)] 'eshell-bol) | ||
| 323 | |||
| 324 | (setq-local eshell-command-prefix (make-symbol "eshell-command-prefix")) | ||
| 325 | (fset eshell-command-prefix (make-sparse-keymap)) | ||
| 326 | (setq-local eshell-command-map (symbol-function eshell-command-prefix)) | ||
| 327 | (define-key eshell-mode-map [(control ?c)] eshell-command-prefix) | ||
| 328 | |||
| 329 | (define-key eshell-command-map [(meta ?o)] 'eshell-mark-output) | ||
| 330 | (define-key eshell-command-map [(meta ?d)] 'eshell-toggle-direct-send) | ||
| 331 | |||
| 332 | (define-key eshell-command-map [(control ?a)] 'eshell-bol) | ||
| 333 | (define-key eshell-command-map [(control ?b)] 'eshell-backward-argument) | ||
| 334 | (define-key eshell-command-map [(control ?e)] 'eshell-show-maximum-output) | ||
| 335 | (define-key eshell-command-map [(control ?f)] 'eshell-forward-argument) | ||
| 336 | (define-key eshell-command-map [(control ?m)] 'eshell-copy-old-input) | ||
| 337 | (define-key eshell-command-map [(control ?o)] 'eshell-kill-output) | ||
| 338 | (define-key eshell-command-map [(control ?r)] 'eshell-show-output) | ||
| 339 | (define-key eshell-command-map [(control ?t)] 'eshell-truncate-buffer) | ||
| 340 | (define-key eshell-command-map [(control ?u)] 'eshell-kill-input) | ||
| 341 | (define-key eshell-command-map [(control ?w)] 'backward-kill-word) | ||
| 342 | (define-key eshell-command-map [(control ?y)] 'eshell-repeat-argument) | ||
| 343 | |||
| 344 | (setq local-abbrev-table eshell-mode-abbrev-table) | 338 | (setq local-abbrev-table eshell-mode-abbrev-table) |
| 345 | 339 | ||
| 346 | (set (make-local-variable 'list-buffers-directory) | 340 | (set (make-local-variable 'list-buffers-directory) |
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 32a3eecb523..a6d6aae678d 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el | |||
| @@ -109,6 +109,16 @@ information, for example." | |||
| 109 | (defvar eshell-process-list nil | 109 | (defvar eshell-process-list nil |
| 110 | "A list of the current status of subprocesses.") | 110 | "A list of the current status of subprocesses.") |
| 111 | 111 | ||
| 112 | (defvar eshell-proc-mode-map | ||
| 113 | (let ((map (make-sparse-keymap))) | ||
| 114 | (define-key map (kbd "C-c M-i") #'eshell-insert-process) | ||
| 115 | (define-key map (kbd "C-c C-c") #'eshell-interrupt-process) | ||
| 116 | (define-key map (kbd "C-c C-k") #'eshell-kill-process) | ||
| 117 | (define-key map (kbd "C-c C-d") #'eshell-send-eof-to-process) | ||
| 118 | (define-key map (kbd "C-c C-s") #'list-processes) | ||
| 119 | (define-key map (kbd "C-c C-\\") #'eshell-quit-process) | ||
| 120 | map)) | ||
| 121 | |||
| 112 | ;;; Functions: | 122 | ;;; Functions: |
| 113 | 123 | ||
| 114 | (defun eshell-kill-process-function (proc status) | 124 | (defun eshell-kill-process-function (proc status) |
| @@ -121,20 +131,16 @@ PROC and STATUS to functions on the latter." | |||
| 121 | (eshell-reset-after-proc status) | 131 | (eshell-reset-after-proc status) |
| 122 | (run-hook-with-args 'eshell-kill-hook proc status)) | 132 | (run-hook-with-args 'eshell-kill-hook proc status)) |
| 123 | 133 | ||
| 134 | (define-minor-mode eshell-proc-mode | ||
| 135 | "Minor mode for the proc eshell module. | ||
| 136 | |||
| 137 | \\{eshell-proc-mode-map}" | ||
| 138 | :keymap eshell-proc-mode-map) | ||
| 139 | |||
| 124 | (defun eshell-proc-initialize () ;Called from `eshell-mode' via intern-soft! | 140 | (defun eshell-proc-initialize () ;Called from `eshell-mode' via intern-soft! |
| 125 | "Initialize the process handling code." | 141 | "Initialize the process handling code." |
| 126 | (make-local-variable 'eshell-process-list) | 142 | (make-local-variable 'eshell-process-list) |
| 127 | ;; This is supposedly run after enabling esh-mode, when eshell-command-map | 143 | (eshell-proc-mode)) |
| 128 | ;; already exists. | ||
| 129 | (defvar eshell-command-map) | ||
| 130 | (define-key eshell-command-map [(meta ?i)] 'eshell-insert-process) | ||
| 131 | (define-key eshell-command-map [(control ?c)] 'eshell-interrupt-process) | ||
| 132 | (define-key eshell-command-map [(control ?k)] 'eshell-kill-process) | ||
| 133 | (define-key eshell-command-map [(control ?d)] 'eshell-send-eof-to-process) | ||
| 134 | ; (define-key eshell-command-map [(control ?q)] 'eshell-continue-process) | ||
| 135 | (define-key eshell-command-map [(control ?s)] 'list-processes) | ||
| 136 | ; (define-key eshell-command-map [(control ?z)] 'eshell-stop-process) | ||
| 137 | (define-key eshell-command-map [(control ?\\)] 'eshell-quit-process)) | ||
| 138 | 144 | ||
| 139 | (defun eshell-reset-after-proc (status) | 145 | (defun eshell-reset-after-proc (status) |
| 140 | "Reset the command input location after a process terminates. | 146 | "Reset the command input location after a process terminates. |
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index b08a5d242fe..6ec58464c54 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el | |||
| @@ -197,8 +197,19 @@ function), and the arguments passed to this function would be the list | |||
| 197 | 197 | ||
| 198 | (put 'eshell-variable-aliases-list 'risky-local-variable t) | 198 | (put 'eshell-variable-aliases-list 'risky-local-variable t) |
| 199 | 199 | ||
| 200 | (defvar eshell-var-mode-map | ||
| 201 | (let ((map (make-sparse-keymap))) | ||
| 202 | (define-key map (kbd "C-c M-v") #'eshell-insert-envvar) | ||
| 203 | map)) | ||
| 204 | |||
| 200 | ;;; Functions: | 205 | ;;; Functions: |
| 201 | 206 | ||
| 207 | (define-minor-mode eshell-var-mode | ||
| 208 | "Minor mode for the esh-var module. | ||
| 209 | |||
| 210 | \\{eshell-var-mode-map}" | ||
| 211 | :keymap eshell-var-mode-map) | ||
| 212 | |||
| 202 | (defun eshell-var-initialize () ;Called from `eshell-mode' via intern-soft! | 213 | (defun eshell-var-initialize () ;Called from `eshell-mode' via intern-soft! |
| 203 | "Initialize the variable handle code." | 214 | "Initialize the variable handle code." |
| 204 | ;; Break the association with our parent's environment. Otherwise, | 215 | ;; Break the association with our parent's environment. Otherwise, |
| @@ -207,11 +218,6 @@ function), and the arguments passed to this function would be the list | |||
| 207 | (set (make-local-variable 'process-environment) | 218 | (set (make-local-variable 'process-environment) |
| 208 | (eshell-copy-environment))) | 219 | (eshell-copy-environment))) |
| 209 | 220 | ||
| 210 | ;; This is supposedly run after enabling esh-mode, when eshell-command-map | ||
| 211 | ;; already exists. | ||
| 212 | (defvar eshell-command-map) | ||
| 213 | (define-key eshell-command-map [(meta ?v)] 'eshell-insert-envvar) | ||
| 214 | |||
| 215 | (set (make-local-variable 'eshell-special-chars-inside-quoting) | 221 | (set (make-local-variable 'eshell-special-chars-inside-quoting) |
| 216 | (append eshell-special-chars-inside-quoting '(?$))) | 222 | (append eshell-special-chars-inside-quoting '(?$))) |
| 217 | (set (make-local-variable 'eshell-special-chars-outside-quoting) | 223 | (set (make-local-variable 'eshell-special-chars-outside-quoting) |