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
(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.
+
+\\{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)
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."
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:
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)
(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
(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."
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 ()
(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)
- (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."
: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
(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."
: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)
;;; 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
(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.
: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."
- ;; 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))
;; 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)
(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 ()
"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)))
(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)
(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)
(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)
- ;; 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.
(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,
(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)