diff options
author | Alex Branham <alex.branham@gmail.com> | 2019-06-26 13:59:06 -0500 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2019-08-15 20:49:15 -0400 |
commit | 1ee0192b792124663a0a40a729dd83c047d21535 (patch) | |
tree | ee51acecf6d02868d81344c7d0249d45b070ab9b /lisp/eshell/em-hist.el | |
parent | b3713265cbb8eb591ac832ae4c35bf8185544467 (diff) | |
download | emacs-1ee0192b792124663a0a40a729dd83c047d21535.tar.gz emacs-1ee0192b792124663a0a40a729dd83c047d21535.tar.bz2 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
Diffstat (limited to 'lisp/eshell/em-hist.el')
-rw-r--r-- | lisp/eshell/em-hist.el | 62 |
1 files changed, 34 insertions, 28 deletions
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, 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,12 @@ 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) @@ -242,30 +274,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 +309,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." |