diff options
Diffstat (limited to 'lisp/eshell')
-rw-r--r-- | lisp/eshell/em-cmpl.el | 35 | ||||
-rw-r--r-- | lisp/eshell/em-dirs.el | 5 | ||||
-rw-r--r-- | lisp/eshell/em-glob.el | 4 | ||||
-rw-r--r-- | lisp/eshell/em-hist.el | 62 | ||||
-rw-r--r-- | lisp/eshell/em-ls.el | 3 | ||||
-rw-r--r-- | lisp/eshell/em-pred.el | 25 | ||||
-rw-r--r-- | lisp/eshell/em-prompt.el | 16 | ||||
-rw-r--r-- | lisp/eshell/em-rebind.el | 13 | ||||
-rw-r--r-- | lisp/eshell/em-unix.el | 7 | ||||
-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-util.el | 6 | ||||
-rw-r--r-- | lisp/eshell/esh-var.el | 53 | ||||
-rw-r--r-- | lisp/eshell/eshell.el | 22 |
15 files changed, 210 insertions, 143 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 48c99acac33..dcf56af6051 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -244,6 +244,26 @@ 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) @@ -291,22 +311,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-dirs.el b/lisp/eshell/em-dirs.el index 1949e5dc8fc..51df6fa1d52 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -168,6 +168,9 @@ Thus, this does not include the current directory.") (defvar eshell-last-dir-ring nil "The last directory that Eshell was in.") +(defconst eshell-inside-emacs (format "%s,eshell" emacs-version) + "Value for the `INSIDE_EMACS' environment variable.") + ;;; Functions: (defun eshell-dirs-initialize () ;Called from `eshell-mode' via intern-soft! @@ -191,6 +194,8 @@ Thus, this does not include the current directory.") (unless (ring-empty-p eshell-last-dir-ring) (expand-file-name (ring-ref eshell-last-dir-ring 0)))) + t) + ("INSIDE_EMACS" eshell-inside-emacs t)))) (when eshell-cd-on-directory diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el index 43483dcd50e..a32a6abe29c 100644 --- a/lisp/eshell/em-glob.el +++ b/lisp/eshell/em-glob.el @@ -232,8 +232,6 @@ resulting regular expression." (regexp-quote (substring pattern matched-in-pattern)) "\\'"))) -(defvar ange-cache) ; XEmacs? See esh-util - (defun eshell-extended-glob (glob) "Return a list of files generated from GLOB, perhaps looking for DIRS-ONLY. This function almost fully supports zsh style filename generation @@ -252,7 +250,7 @@ the form: (INCLUDE-REGEXP EXCLUDE-REGEXP (PRED-FUNC-LIST) (MOD-FUNC-LIST))" (let ((paths (eshell-split-path glob)) - eshell-glob-matches message-shown ange-cache) + eshell-glob-matches message-shown) (unwind-protect (if (and (cdr paths) (file-name-absolute-p (car paths))) diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index 73742a361da..267936583e1 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." diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el index 70b3ad611a1..c1a022ee521 100644 --- a/lisp/eshell/em-ls.el +++ b/lisp/eshell/em-ls.el @@ -239,7 +239,6 @@ scope during the evaluation of TEST-SEXP." (defvar show-recursive) (defvar show-size) (defvar sort-method) -(defvar ange-cache) (defvar dired-flag) ;;; Functions: @@ -406,7 +405,7 @@ Sort entries alphabetically across.") (setq listing-style 'by-columns)) (unless args (setq args (list "."))) - (let ((eshell-ls-exclude-regexp eshell-ls-exclude-regexp) ange-cache) + (let ((eshell-ls-exclude-regexp eshell-ls-exclude-regexp)) (when ignore-pattern (unless (eshell-using-module 'eshell-glob) (error (concat "-I option requires that `eshell-glob'" diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index ee4b28fb3ae..c26f654e278 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,17 @@ 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) - (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." @@ -440,11 +451,9 @@ resultant list of strings." `(lambda (file) (let ((attrs (file-attributes file))) (if attrs - (,(if (eq qual ?-) - 'time-less-p - (if (eq qual ?+) - '(lambda (a b) (time-less-p b a)) - 'time-equal-p)) + (,(cond ((eq qual ?-) #'time-less-p) + ((eq qual ?+) (lambda (a b) (time-less-p b a))) + (#'time-equal-p)) ,when (nth ,attr-index attrs))))))) (defun eshell-pred-file-type (type) @@ -467,7 +476,7 @@ that `ls -l' will show in the first column of its display." (defsubst eshell-pred-file-mode (mode) "Return a test which tests that MODE pertains to the file." `(lambda (file) - (let ((modes (file-modes file))) + (let ((modes (file-modes file 'nofollow))) (if modes (logand ,mode modes))))) diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index bbf3b94ff44..9ae5ae12816 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -97,8 +97,20 @@ 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 @@ -110,9 +122,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 85593e45160..bf5a4bf1afe 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,12 @@ 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 @@ -154,7 +165,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/em-unix.el b/lisp/eshell/em-unix.el index 51699a7aa46..fbd3cfbb6fc 100644 --- a/lisp/eshell/em-unix.el +++ b/lisp/eshell/em-unix.el @@ -469,8 +469,6 @@ Remove the DIRECTORY(ies), if they are empty.") (eshell-parse-command (format "tar %s %s" tar-args archive) args)))) -(defvar ange-cache) ; XEmacs? See esh-util - ;; this is to avoid duplicating code... (defmacro eshell-mvcpln-template (command action func query-var force-var &optional preserve) @@ -488,8 +486,7 @@ Remove the DIRECTORY(ies), if they are empty.") (or (not no-dereference) (not (file-symlink-p (car args))))))) (eshell-shorthand-tar-command ,command args) - (let ((target (car (last args))) - ange-cache) + (let ((target (car (last args)))) (setcdr (last args 2) nil) (eshell-shuffle-files ,command ,action args target ,func nil @@ -924,7 +921,7 @@ Summarize disk usage of each FILE, recursively for directories.") ;; filesystem support means nothing under Windows (if (eshell-under-windows-p) (setq only-one-filesystem nil)) - (let ((size 0.0) ange-cache) + (let ((size 0.0)) (while args (if only-one-filesystem (setq only-one-filesystem diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index 86ceb41ffd2..e7b07b4208d 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el @@ -155,14 +155,22 @@ 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." - ;; 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 db5fddb2aaf..d0147b345aa 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) @@ -280,6 +277,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 () @@ -298,10 +321,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))) @@ -310,31 +329,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 c3ac3a5b71b..d2c17fe1f77 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,16 @@ 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) - ;; 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-util.el b/lisp/eshell/esh-util.el index 0328c1f12fa..ab030ede05b 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -647,14 +647,8 @@ gid format. Valid values are `string' and `integer', defaulting to (let ((base (file-name-nondirectory file)) (dir (file-name-directory file))) (if (string-equal "" base) (setq base ".")) - (if (boundp 'ange-cache) - (setq entry (cdr (assoc base (cdr (assoc dir ange-cache)))))) (unless entry (setq entry (eshell-parse-ange-ls dir)) - (if (boundp 'ange-cache) - (setq ange-cache - (cons (cons dir entry) - ange-cache))) (if entry (let ((fentry (assoc base (cdr entry)))) (if fentry diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 75ccf5b8353..96838d41327 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -179,26 +179,50 @@ if they are quoted with a backslash." (eshell-apply-indices eshell-command-arguments indices))))) "This list provides aliasing for variable references. -It is very similar in concept to what `eshell-user-aliases-list' does -for commands. Each member of this defines the name of a command, -and the Lisp value to return for that variable if it is accessed -via the syntax `$NAME'. - -If the value is a function, that function will be called with two -arguments: the list of the indices that was used in the reference, and -whether the user is requesting the length of the ultimate element. -For example, a reference of `$NAME[10][20]' would result in the -function for alias `NAME' being called (assuming it were aliased to a -function), and the arguments passed to this function would be the list -'(10 20)', and nil." +Each member defines the name of a variable, and a Lisp value used to +compute the string value that will be returned when the variable is +accessed via the syntax `$NAME'. + +If the value is a function, call that function with two arguments: the +list of the indices that was used in the reference, and whether the +user is requesting the length of the ultimate element. For example, a +reference of `$NAME[10][20]' would result in the function for alias +`NAME' being called (assuming it were aliased to a function), and the +arguments passed to this function would be the list '(10 20)', and +nil. + +If the value is a string, return the value for the variable with that +name in the current environment. If no variable with that name exists +in the environment, but if a symbol with that same name exists and has +a value bound to it, return its value instead. You can prioritize +symbol values over environment values by setting +`eshell-prefer-lisp-variables' to t. + +If the value is a symbol, return the value bound to it. + +If the value has any other type, signal an error. + +Additionally, each member may specify if it should be copied to the +environment of created subprocesses." :type '(repeat (list string sexp (choice (const :tag "Copy to environment" t) (const :tag "Use only in Eshell" nil))))) (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, @@ -207,11 +231,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) diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el index 2a63882ff09..5ffb159b575 100644 --- a/lisp/eshell/eshell.el +++ b/lisp/eshell/eshell.el @@ -265,14 +265,18 @@ information on Eshell, see Info node `(eshell)Top'." (eshell-mode)) buf)) -(defun eshell-return-exits-minibuffer () - ;; This is supposedly run after enabling esh-mode, when eshell-mode-map - ;; already exists. - (defvar eshell-mode-map) - (define-key eshell-mode-map [(control ?g)] 'abort-recursive-edit) - (define-key eshell-mode-map [(control ?m)] 'exit-minibuffer) - (define-key eshell-mode-map [(control ?j)] 'exit-minibuffer) - (define-key eshell-mode-map [(meta control ?m)] 'exit-minibuffer)) +(define-minor-mode eshell-command-mode + "Minor mode for `eshell-command' input. +\\{eshell-command-mode-map}" + :keymap (let ((map (make-sparse-keymap))) + (define-key map [(control ?g)] 'abort-recursive-edit) + (define-key map [(control ?m)] 'exit-minibuffer) + (define-key map [(control ?j)] 'exit-minibuffer) + (define-key map [(meta control ?m)] 'exit-minibuffer) + map)) + +(define-obsolete-function-alias 'eshell-return-exits-minibuffer + #'eshell-command-mode "28.1") (defvar eshell-non-interactive-p nil "A variable which is non-nil when Eshell is not running interactively. @@ -292,7 +296,7 @@ With prefix ARG, insert output into the current buffer at point." ;; Enable `eshell-mode' only in this minibuffer. (minibuffer-with-setup-hook #'(lambda () (eshell-mode) - (eshell-return-exits-minibuffer)) + (eshell-command-mode +1)) (unless command (setq command (read-from-minibuffer "Emacs shell command: ")) (if (eshell-using-module 'eshell-hist) |