Eshell: Try to untangle the dependencies; move 'provide's to the end
* lisp/eshell/esh-arg.el: Move defsubst and vars before first use. Don't require `esh-mode but esh-util instead. * lisp/eshell/esh-cmd.el: Require esh-module and esh-io. * lisp/eshell/esh-ext.el: Don't require esh-proc nor esh-cmd. (eshell-external-command): Require esh-proc for eshell-gather-process-output. * lisp/eshell/esh-mode.el: Don't require esh-io nor esh-var, but require esh-arg. (eshell-directory-name): Move from eshell.el. * lisp/eshell/esh-module.el: Don't require eshell. * lisp/eshell/esh-opt.el: Don't require esh-ext at top-level. (eshell--do-opts, eshell-show-usage): Require it here instead. * lisp/eshell/esh-proc.el: Don't require esh-cmd, but require esh-io. (eshell-reset-after-proc, eshell-record-process-object) (eshell-gather-process-output, eshell-send-eof-to-process): Require esh-mode and esh-var here. * lisp/eshell/esh-var.el: Require esh-module, esh-arg, and esh-io. * lisp/eshell/eshell.el: Require esh-module, esh-proc, esh-io, and esh-cmd. But don't require esh-mode. (eshell-directory-name): Move to esh-mode. (eshell-return-exits-minibuffer): Don't bind 'return' and 'M-return' since we already bind RET and M-RET.
This commit is contained in:
parent
a20845c160
commit
0d5e83611e
12 changed files with 154 additions and 134 deletions
|
|
@ -59,6 +59,7 @@
|
|||
|
||||
(require 'ring)
|
||||
(require 'esh-opt)
|
||||
(require 'esh-mode)
|
||||
(require 'em-pred)
|
||||
(require 'eshell)
|
||||
|
||||
|
|
@ -192,7 +193,6 @@ element, regardless of any text on the command line. In that case,
|
|||
(defvar eshell-isearch-map
|
||||
(let ((map (copy-keymap isearch-mode-map)))
|
||||
(define-key map [(control ?m)] 'eshell-isearch-return)
|
||||
(define-key map [return] 'eshell-isearch-return)
|
||||
(define-key map [(control ?r)] 'eshell-isearch-repeat-backward)
|
||||
(define-key map [(control ?s)] 'eshell-isearch-repeat-forward)
|
||||
(define-key map [(control ?g)] 'eshell-isearch-abort)
|
||||
|
|
@ -220,7 +220,7 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
|
|||
"Initialize the history management code for one Eshell buffer."
|
||||
(when (eshell-using-module 'eshell-cmpl)
|
||||
(add-hook 'pcomplete-try-first-hook
|
||||
'eshell-complete-history-reference nil t))
|
||||
#'eshell-complete-history-reference nil t))
|
||||
|
||||
(if (and (eshell-using-module 'eshell-rebind)
|
||||
(not eshell-non-interactive-p))
|
||||
|
|
@ -235,11 +235,13 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
|
|||
(lambda ()
|
||||
(if (>= (point) eshell-last-output-end)
|
||||
(setq overriding-terminal-local-map
|
||||
eshell-isearch-map)))) nil t)
|
||||
eshell-isearch-map))))
|
||||
nil t)
|
||||
(add-hook 'isearch-mode-end-hook
|
||||
(function
|
||||
(lambda ()
|
||||
(setq overriding-terminal-local-map nil))) nil t))
|
||||
(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)
|
||||
|
|
@ -288,17 +290,17 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil."
|
|||
(if eshell-history-file-name
|
||||
(eshell-read-history nil t))
|
||||
|
||||
(add-hook 'eshell-exit-hook 'eshell-write-history nil t))
|
||||
(add-hook 'eshell-exit-hook #'eshell-write-history nil t))
|
||||
|
||||
(unless eshell-history-ring
|
||||
(setq eshell-history-ring (make-ring eshell-history-size)))
|
||||
|
||||
(add-hook 'eshell-exit-hook 'eshell-write-history nil t)
|
||||
(add-hook 'eshell-exit-hook #'eshell-write-history nil t)
|
||||
|
||||
(add-hook 'kill-emacs-hook 'eshell-save-some-history)
|
||||
(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))
|
||||
|
|
@ -754,7 +756,7 @@ matched."
|
|||
(setq nth (eshell-hist-word-reference nth)))
|
||||
(unless (numberp mth)
|
||||
(setq mth (eshell-hist-word-reference mth)))
|
||||
(cons (mapconcat 'identity (eshell-sublist textargs nth mth) " ")
|
||||
(cons (mapconcat #'identity (eshell-sublist textargs nth mth) " ")
|
||||
end))))
|
||||
|
||||
(defun eshell-hist-parse-modifier (hist reference)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ allowed."
|
|||
(term-exec term-buf program program nil args)
|
||||
(let ((proc (get-buffer-process term-buf)))
|
||||
(if (and proc (eq 'run (process-status proc)))
|
||||
(set-process-sentinel proc 'eshell-term-sentinel)
|
||||
(set-process-sentinel proc #'eshell-term-sentinel)
|
||||
(error "Failed to invoke visual command")))
|
||||
(term-char-mode)
|
||||
(if eshell-escape-control-x
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
;; hook `eshell-parse-argument-hook'. For a good example of this, see
|
||||
;; `eshell-parse-drive-letter', defined in eshell-dirs.el.
|
||||
|
||||
(provide 'esh-arg)
|
||||
;;; Code:
|
||||
|
||||
(require 'esh-mode)
|
||||
(require 'esh-util)
|
||||
|
||||
(defgroup eshell-arg nil
|
||||
"Argument parsing involves transforming the arguments passed on the
|
||||
|
|
@ -36,6 +36,48 @@ yield the values intended."
|
|||
:tag "Argument parsing"
|
||||
:group 'eshell)
|
||||
|
||||
;;; Internal Variables:
|
||||
|
||||
(defvar eshell-current-argument nil)
|
||||
(defvar eshell-current-modifiers nil)
|
||||
(defvar eshell-arg-listified nil)
|
||||
(defvar eshell-nested-argument nil)
|
||||
(defvar eshell-current-quoted nil)
|
||||
(defvar eshell-inside-quote-regexp nil)
|
||||
(defvar eshell-outside-quote-regexp nil)
|
||||
|
||||
;;; User Variables:
|
||||
|
||||
(defcustom eshell-arg-load-hook nil
|
||||
"A hook that gets run when `eshell-arg' is loaded."
|
||||
:version "24.1" ; removed eshell-arg-initialize
|
||||
:type 'hook
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defcustom eshell-delimiter-argument-list '(?\; ?& ?\| ?\> ?\s ?\t ?\n)
|
||||
"List of characters to recognize as argument separators."
|
||||
:type '(repeat character)
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defcustom eshell-special-chars-inside-quoting '(?\\ ?\")
|
||||
"Characters which are still special inside double quotes."
|
||||
:type '(repeat character)
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defcustom eshell-special-chars-outside-quoting
|
||||
(append eshell-delimiter-argument-list '(?# ?! ?\\ ?\" ?\'))
|
||||
"Characters that require escaping outside of double quotes.
|
||||
Without escaping them, they will introduce a change in the argument."
|
||||
:type '(repeat character)
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defsubst eshell-arg-delimiter (&optional pos)
|
||||
"Return non-nil if POS is an argument delimiter.
|
||||
If POS is nil, the location of point is checked."
|
||||
(let ((pos (or pos (point))))
|
||||
(or (= pos (point-max))
|
||||
(memq (char-after pos) eshell-delimiter-argument-list))))
|
||||
|
||||
(defcustom eshell-parse-argument-hook
|
||||
(list
|
||||
;; a term such as #<buffer NAME>, or #<process NAME> is a buffer
|
||||
|
|
@ -113,47 +155,13 @@ treated as a literal character."
|
|||
:type 'hook
|
||||
:group 'eshell-arg)
|
||||
|
||||
;;; Code:
|
||||
|
||||
;;; User Variables:
|
||||
|
||||
(defcustom eshell-arg-load-hook nil
|
||||
"A hook that gets run when `eshell-arg' is loaded."
|
||||
:version "24.1" ; removed eshell-arg-initialize
|
||||
:type 'hook
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defcustom eshell-delimiter-argument-list '(?\; ?& ?\| ?\> ?\s ?\t ?\n)
|
||||
"List of characters to recognize as argument separators."
|
||||
:type '(repeat character)
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defcustom eshell-special-chars-inside-quoting '(?\\ ?\")
|
||||
"Characters which are still special inside double quotes."
|
||||
:type '(repeat character)
|
||||
:group 'eshell-arg)
|
||||
|
||||
(defcustom eshell-special-chars-outside-quoting
|
||||
(append eshell-delimiter-argument-list '(?# ?! ?\\ ?\" ?\'))
|
||||
"Characters that require escaping outside of double quotes.
|
||||
Without escaping them, they will introduce a change in the argument."
|
||||
:type '(repeat character)
|
||||
:group 'eshell-arg)
|
||||
|
||||
;;; Internal Variables:
|
||||
|
||||
(defvar eshell-current-argument nil)
|
||||
(defvar eshell-current-modifiers nil)
|
||||
(defvar eshell-arg-listified nil)
|
||||
(defvar eshell-nested-argument nil)
|
||||
(defvar eshell-current-quoted nil)
|
||||
(defvar eshell-inside-quote-regexp nil)
|
||||
(defvar eshell-outside-quote-regexp nil)
|
||||
|
||||
;;; Functions:
|
||||
|
||||
(defun eshell-arg-initialize ()
|
||||
"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)
|
||||
(set (make-local-variable 'eshell-inside-quote-regexp) nil)
|
||||
(set (make-local-variable 'eshell-outside-quote-regexp) nil))
|
||||
|
|
@ -195,13 +203,6 @@ Without escaping them, they will introduce a change in the argument."
|
|||
(setq eshell-current-argument argument))
|
||||
(throw 'eshell-arg-done t))
|
||||
|
||||
(defsubst eshell-arg-delimiter (&optional pos)
|
||||
"Return non-nil if POS is an argument delimiter.
|
||||
If POS is nil, the location of point is checked."
|
||||
(let ((pos (or pos (point))))
|
||||
(or (= pos (point-max))
|
||||
(memq (char-after pos) eshell-delimiter-argument-list))))
|
||||
|
||||
(defun eshell-quote-argument (string)
|
||||
"Return STRING with magic characters quoted.
|
||||
Magic characters are those in `eshell-special-chars-outside-quoting'."
|
||||
|
|
@ -405,4 +406,5 @@ If the form has no `type', the syntax is parsed as if `type' were
|
|||
(char-to-string (char-after)))))
|
||||
(goto-char end)))))))
|
||||
|
||||
(provide 'esh-arg)
|
||||
;;; esh-arg.el ends here
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@
|
|||
(require 'eldoc))
|
||||
(require 'esh-arg)
|
||||
(require 'esh-proc)
|
||||
(require 'esh-module)
|
||||
(require 'esh-io)
|
||||
(require 'esh-ext)
|
||||
|
||||
(eval-when-compile
|
||||
|
|
@ -1337,7 +1339,7 @@ messages, and errors."
|
|||
(eshell-print "\n"))
|
||||
(eshell-close-handles 0 (list 'quote result)))))
|
||||
|
||||
(defalias 'eshell-lisp-command* 'eshell-lisp-command)
|
||||
(defalias 'eshell-lisp-command* #'eshell-lisp-command)
|
||||
|
||||
(provide 'esh-cmd)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,17 +31,12 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-ext)
|
||||
|
||||
(require 'esh-util)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl-lib)
|
||||
(require 'esh-cmd))
|
||||
(eval-when-compile (require 'cl-lib))
|
||||
(require 'esh-io)
|
||||
(require 'esh-arg)
|
||||
(require 'esh-opt)
|
||||
(require 'esh-proc)
|
||||
|
||||
(defgroup eshell-ext nil
|
||||
"External commands are invoked when operating system executables are
|
||||
|
|
@ -179,7 +174,7 @@ external version."
|
|||
|
||||
(defun eshell-ext-initialize ()
|
||||
"Initialize the external command handling code."
|
||||
(add-hook 'eshell-named-command-hook 'eshell-explicit-command nil t))
|
||||
(add-hook 'eshell-named-command-hook #'eshell-explicit-command nil t))
|
||||
|
||||
(defun eshell-explicit-command (command args)
|
||||
"If a command name begins with `*', call it externally always.
|
||||
|
|
@ -193,8 +188,6 @@ This bypasses all Lisp functions and aliases."
|
|||
(error "%s: external command not found"
|
||||
(substring command 1))))))
|
||||
|
||||
(autoload 'eshell-close-handles "esh-io")
|
||||
|
||||
(defun eshell-remote-command (command args)
|
||||
"Insert output from a remote COMMAND, using ARGS.
|
||||
A remote command is something that executes on a different machine.
|
||||
|
|
@ -211,7 +204,7 @@ causing the user to wonder if anything's really going on..."
|
|||
(progn
|
||||
(setq exitcode
|
||||
(shell-command
|
||||
(mapconcat 'shell-quote-argument
|
||||
(mapconcat #'shell-quote-argument
|
||||
(append (list command) args) " ")
|
||||
outbuf errbuf))
|
||||
(eshell-print (with-current-buffer outbuf (buffer-string)))
|
||||
|
|
@ -235,6 +228,8 @@ causing the user to wonder if anything's really going on..."
|
|||
(cl-assert interp)
|
||||
(if (functionp (car interp))
|
||||
(apply (car interp) (append (cdr interp) args))
|
||||
(require 'esh-proc)
|
||||
(declare-function eshell-gather-process-output "esh-proc" (command args))
|
||||
(eshell-gather-process-output
|
||||
(car interp) (append (cdr interp) args)))))
|
||||
|
||||
|
|
@ -249,7 +244,7 @@ Adds the given PATH to $PATH.")
|
|||
(if args
|
||||
(progn
|
||||
(setq eshell-path-env (getenv "PATH")
|
||||
args (mapconcat 'identity args path-separator)
|
||||
args (mapconcat #'identity args path-separator)
|
||||
eshell-path-env
|
||||
(if prepend
|
||||
(concat args path-separator eshell-path-env)
|
||||
|
|
@ -336,4 +331,5 @@ line of the form #!<interp>."
|
|||
(cdr interp)))))
|
||||
(or interp (list fullname)))))))
|
||||
|
||||
(provide 'esh-ext)
|
||||
;;; esh-ext.el ends here
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-io)
|
||||
|
||||
(require 'esh-arg)
|
||||
(require 'esh-util)
|
||||
|
||||
|
|
@ -511,4 +509,5 @@ Returns what was actually sent, or nil if nothing was sent."
|
|||
(eshell-output-object-to-target object (car target))
|
||||
(setq target (cdr target))))))
|
||||
|
||||
(provide 'esh-io)
|
||||
;;; esh-io.el ends here
|
||||
|
|
|
|||
|
|
@ -58,13 +58,10 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-mode)
|
||||
|
||||
(require 'esh-util)
|
||||
(require 'esh-module)
|
||||
(require 'esh-cmd)
|
||||
(require 'esh-io)
|
||||
(require 'esh-var)
|
||||
(require 'esh-arg) ;For eshell-parse-arguments
|
||||
|
||||
(defgroup eshell-mode nil
|
||||
"This module contains code for handling input from the user."
|
||||
|
|
@ -202,6 +199,12 @@ This is used by `eshell-watch-for-password-prompt'."
|
|||
:type 'boolean
|
||||
:group 'eshell-mode)
|
||||
|
||||
(defcustom eshell-directory-name
|
||||
(locate-user-emacs-file "eshell/" ".eshell/")
|
||||
"The directory where Eshell control files should be kept."
|
||||
:type 'directory
|
||||
:group 'eshell)
|
||||
|
||||
(defvar eshell-first-time-p t
|
||||
"A variable which is non-nil the first time Eshell is loaded.")
|
||||
|
||||
|
|
@ -292,7 +295,7 @@ and the hook `eshell-exit-hook'."
|
|||
;; It's fine to run this unconditionally since it can be customized
|
||||
;; via the `eshell-kill-processes-on-exit' variable.
|
||||
(and (fboundp 'eshell-query-kill-processes)
|
||||
(not (memq 'eshell-query-kill-processes eshell-exit-hook))
|
||||
(not (memq #'eshell-query-kill-processes eshell-exit-hook))
|
||||
(eshell-query-kill-processes))
|
||||
(run-hooks 'eshell-exit-hook))
|
||||
|
||||
|
|
@ -334,7 +337,6 @@ and the hook `eshell-exit-hook'."
|
|||
(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 [return] 'eshell-copy-old-input)
|
||||
(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)
|
||||
|
|
@ -414,19 +416,19 @@ and the hook `eshell-exit-hook'."
|
|||
(and initfunc (fboundp initfunc) (funcall initfunc))))
|
||||
|
||||
(if eshell-send-direct-to-subprocesses
|
||||
(add-hook 'pre-command-hook 'eshell-intercept-commands t t))
|
||||
(add-hook 'pre-command-hook #'eshell-intercept-commands t t))
|
||||
|
||||
(if eshell-scroll-to-bottom-on-input
|
||||
(add-hook 'pre-command-hook 'eshell-preinput-scroll-to-bottom t t))
|
||||
(add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t))
|
||||
|
||||
(when eshell-scroll-show-maximum-output
|
||||
(set (make-local-variable 'scroll-conservatively) 1000))
|
||||
|
||||
(when eshell-status-in-mode-line
|
||||
(add-hook 'eshell-pre-command-hook 'eshell-command-started nil t)
|
||||
(add-hook 'eshell-post-command-hook 'eshell-command-finished nil t))
|
||||
(add-hook 'eshell-pre-command-hook #'eshell-command-started nil t)
|
||||
(add-hook 'eshell-post-command-hook #'eshell-command-finished nil t))
|
||||
|
||||
(add-hook 'kill-buffer-hook 'eshell-kill-buffer-function t t)
|
||||
(add-hook 'kill-buffer-hook #'eshell-kill-buffer-function t t)
|
||||
|
||||
(if eshell-first-time-p
|
||||
(run-hooks 'eshell-first-time-mode-hook))
|
||||
|
|
@ -451,10 +453,10 @@ and the hook `eshell-exit-hook'."
|
|||
(if eshell-send-direct-to-subprocesses
|
||||
(progn
|
||||
(setq eshell-send-direct-to-subprocesses nil)
|
||||
(remove-hook 'pre-command-hook 'eshell-intercept-commands t)
|
||||
(remove-hook 'pre-command-hook #'eshell-intercept-commands t)
|
||||
(message "Sending subprocess input on RET"))
|
||||
(setq eshell-send-direct-to-subprocesses t)
|
||||
(add-hook 'pre-command-hook 'eshell-intercept-commands t t)
|
||||
(add-hook 'pre-command-hook #'eshell-intercept-commands t t)
|
||||
(message "Sending subprocess input directly")))
|
||||
|
||||
(defun eshell-self-insert-command ()
|
||||
|
|
@ -543,7 +545,7 @@ and the hook `eshell-exit-hook'."
|
|||
"Push a mark at the end of the last input text."
|
||||
(push-mark (1- eshell-last-input-end) t))
|
||||
|
||||
(custom-add-option 'eshell-pre-command-hook 'eshell-push-command-mark)
|
||||
(custom-add-option 'eshell-pre-command-hook #'eshell-push-command-mark)
|
||||
|
||||
(defsubst eshell-goto-input-start ()
|
||||
"Goto the start of the last command input.
|
||||
|
|
@ -551,7 +553,7 @@ Putting this function on `eshell-pre-command-hook' will mimic Plan 9's
|
|||
9term behavior."
|
||||
(goto-char eshell-last-input-start))
|
||||
|
||||
(custom-add-option 'eshell-pre-command-hook 'eshell-goto-input-start)
|
||||
(custom-add-option 'eshell-pre-command-hook #'eshell-goto-input-start)
|
||||
|
||||
(defsubst eshell-interactive-print (string)
|
||||
"Print STRING to the eshell display buffer."
|
||||
|
|
@ -1021,4 +1023,5 @@ This function could be in the list `eshell-output-filter-functions'."
|
|||
(custom-add-option 'eshell-output-filter-functions
|
||||
'eshell-handle-ansi-color)
|
||||
|
||||
(provide 'esh-mode)
|
||||
;;; esh-mode.el ends here
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-module)
|
||||
|
||||
(require 'eshell)
|
||||
(require 'esh-util)
|
||||
|
||||
(defgroup eshell-module nil
|
||||
|
|
@ -101,4 +98,5 @@ customization group. Example: `eshell-cmpl' for that module."
|
|||
(unload-feature module)
|
||||
(message "Unloading %s...done" (symbol-name module))))))
|
||||
|
||||
(provide 'esh-module)
|
||||
;;; esh-module.el ends here
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-opt)
|
||||
|
||||
(require 'esh-ext)
|
||||
|
||||
;; Unused.
|
||||
;; (defgroup eshell-opt nil
|
||||
|
|
@ -127,6 +124,8 @@ let-bound variable `args'."
|
|||
(defun eshell--do-opts (name options args)
|
||||
"Helper function for `eshell-eval-using-options'.
|
||||
This code doesn't really need to be macro expanded everywhere."
|
||||
(require 'esh-ext)
|
||||
(declare-function eshell-external-command "esh-ext" (command args))
|
||||
(let ((ext-command
|
||||
(catch 'eshell-ext-command
|
||||
(let ((usage-msg
|
||||
|
|
@ -145,6 +144,8 @@ This code doesn't really need to be macro expanded everywhere."
|
|||
|
||||
(defun eshell-show-usage (name options)
|
||||
"Display the usage message for NAME, using OPTIONS."
|
||||
(require 'esh-ext)
|
||||
(declare-function eshell-search-path "esh-ext" (name))
|
||||
(let ((usage (format "usage: %s %s\n\n" name
|
||||
(cadr (memq ':usage options))))
|
||||
(extcmd (memq ':external options))
|
||||
|
|
@ -273,4 +274,5 @@ switch is unrecognized."
|
|||
(setq index (1+ index))))))))
|
||||
(nconc (mapcar #'cdr opt-vals) eshell--args)))
|
||||
|
||||
(provide 'esh-opt)
|
||||
;;; esh-opt.el ends here
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-proc)
|
||||
|
||||
(require 'esh-cmd)
|
||||
(require 'esh-io)
|
||||
|
||||
(defgroup eshell-proc nil
|
||||
"When Eshell invokes external commands, it always does so
|
||||
|
|
@ -118,14 +116,17 @@ information, for example."
|
|||
Runs `eshell-reset-after-proc' and `eshell-kill-hook', passing arguments
|
||||
PROC and STATUS to functions on the latter."
|
||||
;; Was there till 24.1, but it is not optional.
|
||||
(if (memq 'eshell-reset-after-proc eshell-kill-hook)
|
||||
(setq eshell-kill-hook (delq 'eshell-reset-after-proc eshell-kill-hook)))
|
||||
(if (memq #'eshell-reset-after-proc eshell-kill-hook)
|
||||
(setq eshell-kill-hook (delq #'eshell-reset-after-proc eshell-kill-hook)))
|
||||
(eshell-reset-after-proc status)
|
||||
(run-hook-with-args 'eshell-kill-hook proc status))
|
||||
|
||||
(defun eshell-proc-initialize ()
|
||||
"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)
|
||||
|
|
@ -139,9 +140,11 @@ PROC and STATUS to functions on the latter."
|
|||
"Reset the command input location after a process terminates.
|
||||
The signals which will cause this to happen are matched by
|
||||
`eshell-reset-signals'."
|
||||
(if (and (stringp status)
|
||||
(string-match eshell-reset-signals status))
|
||||
(eshell-reset)))
|
||||
(when (and (stringp status)
|
||||
(string-match eshell-reset-signals status))
|
||||
(require 'esh-mode)
|
||||
(declare-function eshell-reset "esh-mode" (&optional no-hooks))
|
||||
(eshell-reset)))
|
||||
|
||||
(defun eshell-wait-for-process (&rest procs)
|
||||
"Wait until PROC has successfully completed."
|
||||
|
|
@ -209,7 +212,8 @@ The prompt will be set to PROMPT."
|
|||
(function
|
||||
(lambda (proc)
|
||||
(cons (process-name proc) t)))
|
||||
(process-list)) nil t))
|
||||
(process-list))
|
||||
nil t))
|
||||
|
||||
(defun eshell-insert-process (process)
|
||||
"Insert the name of PROCESS into the current buffer at point."
|
||||
|
|
@ -220,10 +224,12 @@ The prompt will be set to PROMPT."
|
|||
|
||||
(defsubst eshell-record-process-object (object)
|
||||
"Record OBJECT as now running."
|
||||
(if (and (eshell-processp object)
|
||||
eshell-current-subjob-p)
|
||||
(eshell-interactive-print
|
||||
(format "[%s] %d\n" (process-name object) (process-id object))))
|
||||
(when (and (eshell-processp object)
|
||||
eshell-current-subjob-p)
|
||||
(require 'esh-mode)
|
||||
(declare-function eshell-interactive-print "esh-mode" (string))
|
||||
(eshell-interactive-print
|
||||
(format "[%s] %d\n" (process-name object) (process-id object))))
|
||||
(setq eshell-process-list
|
||||
(cons (list object eshell-current-handles
|
||||
eshell-current-subjob-p nil nil)
|
||||
|
|
@ -254,7 +260,7 @@ the full name of a command, otherwise just the nondirectory part must match.")
|
|||
(defun eshell-needs-pipe-p (command)
|
||||
"Return non-nil if COMMAND needs `process-connection-type' to be nil.
|
||||
See `eshell-needs-pipe'."
|
||||
(and eshell-in-pipeline-p
|
||||
(and (bound-and-true-p eshell-in-pipeline-p)
|
||||
(not (eq eshell-in-pipeline-p 'first))
|
||||
;; FIXME should this return non-nil for anything that is
|
||||
;; neither 'first nor 'last? See bug#1388 discussion.
|
||||
|
|
@ -267,6 +273,8 @@ See `eshell-needs-pipe'."
|
|||
|
||||
(defun eshell-gather-process-output (command args)
|
||||
"Gather the output from COMMAND + ARGS."
|
||||
(require 'esh-var)
|
||||
(declare-function eshell-environment-variables "esh-var" ())
|
||||
(unless (and (file-executable-p command)
|
||||
(file-regular-p (file-truename command)))
|
||||
(error "%s: not an executable file" command))
|
||||
|
|
@ -283,14 +291,14 @@ See `eshell-needs-pipe'."
|
|||
(unless (eshell-needs-pipe-p command)
|
||||
process-connection-type))
|
||||
(command (file-local-name (expand-file-name command))))
|
||||
(apply 'start-file-process
|
||||
(apply #'start-file-process
|
||||
(file-name-nondirectory command) nil command args)))
|
||||
(eshell-record-process-object proc)
|
||||
(set-process-buffer proc (current-buffer))
|
||||
(if (eshell-interactive-output-p)
|
||||
(set-process-filter proc 'eshell-output-filter)
|
||||
(set-process-filter proc 'eshell-insertion-filter))
|
||||
(set-process-sentinel proc 'eshell-sentinel)
|
||||
(set-process-filter proc (if (eshell-interactive-output-p)
|
||||
#'eshell-output-filter
|
||||
#'eshell-insertion-filter))
|
||||
(set-process-sentinel proc #'eshell-sentinel)
|
||||
(run-hook-with-args 'eshell-exec-hook proc)
|
||||
(when (fboundp 'process-coding-system)
|
||||
(let ((coding-systems (process-coding-system proc)))
|
||||
|
|
@ -325,14 +333,14 @@ See `eshell-needs-pipe'."
|
|||
(set-buffer oldbuf)
|
||||
(run-hook-with-args 'eshell-exec-hook command)
|
||||
(setq exit-status
|
||||
(apply 'call-process-region
|
||||
(apply #'call-process-region
|
||||
(append (list eshell-last-sync-output-start (point)
|
||||
command t
|
||||
eshell-scratch-buffer nil)
|
||||
args)))
|
||||
;; When in a pipeline, record the place where the output of
|
||||
;; this process will begin.
|
||||
(and eshell-in-pipeline-p
|
||||
(and (bound-and-true-p eshell-in-pipeline-p)
|
||||
(set-marker eshell-last-sync-output-start (point)))
|
||||
;; Simulate the effect of the process filter.
|
||||
(when (numberp exit-status)
|
||||
|
|
@ -349,11 +357,14 @@ See `eshell-needs-pipe'."
|
|||
(setq lbeg lend)
|
||||
(set-buffer proc-buf))
|
||||
(set-buffer oldbuf))
|
||||
(require 'esh-mode)
|
||||
(declare-function eshell-update-markers "esh-mode" (pmark))
|
||||
(defvar eshell-last-output-end) ;Defined in esh-mode.el.
|
||||
(eshell-update-markers eshell-last-output-end)
|
||||
;; Simulate the effect of eshell-sentinel.
|
||||
(eshell-close-handles (if (numberp exit-status) exit-status -1))
|
||||
(eshell-kill-process-function command exit-status)
|
||||
(or eshell-in-pipeline-p
|
||||
(or (bound-and-true-p eshell-in-pipeline-p)
|
||||
(setq eshell-last-sync-output-start nil))
|
||||
(if (not (numberp exit-status))
|
||||
(error "%s: external command failed: %s" command exit-status))
|
||||
|
|
@ -540,7 +551,11 @@ See the variable `eshell-kill-processes-on-exit'."
|
|||
(defun eshell-send-eof-to-process ()
|
||||
"Send EOF to process."
|
||||
(interactive)
|
||||
(require 'esh-mode)
|
||||
(declare-function eshell-send-input "esh-mode"
|
||||
(&optional use-region queue-p no-newline))
|
||||
(eshell-send-input nil nil t)
|
||||
(eshell-process-interact 'process-send-eof))
|
||||
|
||||
(provide 'esh-proc)
|
||||
;;; esh-proc.el ends here
|
||||
|
|
|
|||
|
|
@ -105,11 +105,12 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(provide 'esh-var)
|
||||
|
||||
(require 'esh-util)
|
||||
(require 'esh-cmd)
|
||||
(require 'esh-opt)
|
||||
(require 'esh-module)
|
||||
(require 'esh-arg)
|
||||
(require 'esh-io)
|
||||
|
||||
(require 'pcomplete)
|
||||
(require 'env)
|
||||
|
|
@ -206,6 +207,9 @@ 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)
|
||||
|
|
@ -213,16 +217,16 @@ function), and the arguments passed to this function would be the list
|
|||
(set (make-local-variable 'eshell-special-chars-outside-quoting)
|
||||
(append eshell-special-chars-outside-quoting '(?$)))
|
||||
|
||||
(add-hook 'eshell-parse-argument-hook 'eshell-interpolate-variable t t)
|
||||
(add-hook 'eshell-parse-argument-hook #'eshell-interpolate-variable t t)
|
||||
|
||||
(add-hook 'eshell-prepare-command-hook
|
||||
'eshell-handle-local-variables nil t)
|
||||
#'eshell-handle-local-variables nil t)
|
||||
|
||||
(when (eshell-using-module 'eshell-cmpl)
|
||||
(add-hook 'pcomplete-try-first-hook
|
||||
'eshell-complete-variable-reference nil t)
|
||||
#'eshell-complete-variable-reference nil t)
|
||||
(add-hook 'pcomplete-try-first-hook
|
||||
'eshell-complete-variable-assignment nil t)))
|
||||
#'eshell-complete-variable-assignment nil t)))
|
||||
|
||||
(defun eshell-handle-local-variables ()
|
||||
"Allow for the syntax `VAR=val <command> <args>'."
|
||||
|
|
@ -532,7 +536,7 @@ For example, to retrieve the second element of a user's record in
|
|||
(setq separator (caar indices)
|
||||
refs (cdr refs)))
|
||||
(setq value
|
||||
(mapcar 'eshell-convert
|
||||
(mapcar #'eshell-convert
|
||||
(split-string value separator)))))
|
||||
(cond
|
||||
((< (length refs) 0)
|
||||
|
|
@ -618,4 +622,5 @@ For example, to retrieve the second element of a user's record in
|
|||
(setq pcomplete-stub (substring arg pos))
|
||||
(throw 'pcomplete-completions (pcomplete-entries)))))
|
||||
|
||||
(provide 'esh-var)
|
||||
;;; esh-var.el ends here
|
||||
|
|
|
|||
|
|
@ -175,10 +175,10 @@
|
|||
(eval-when-compile
|
||||
(require 'cl-lib))
|
||||
(require 'esh-util)
|
||||
;; Provide eshell before requiring esh-mode, to avoid a recursive load.
|
||||
;; (Bug #34954)
|
||||
(provide 'eshell)
|
||||
(require 'esh-mode)
|
||||
(require 'esh-module) ;For eshell-using-module
|
||||
(require 'esh-proc) ;For eshell-wait-for-process
|
||||
(require 'esh-io) ;For eshell-last-command-status
|
||||
(require 'esh-cmd)
|
||||
|
||||
(defgroup eshell nil
|
||||
"Command shell implemented entirely in Emacs Lisp.
|
||||
|
|
@ -220,12 +220,6 @@ shells such as bash, zsh, rc, 4dos."
|
|||
:type 'string
|
||||
:group 'eshell)
|
||||
|
||||
(defcustom eshell-directory-name
|
||||
(locate-user-emacs-file "eshell/" ".eshell/")
|
||||
"The directory where Eshell control files should be kept."
|
||||
:type 'directory
|
||||
:group 'eshell)
|
||||
|
||||
;;;_* Running Eshell
|
||||
;;
|
||||
;; There are only three commands used to invoke Eshell. The first two
|
||||
|
|
@ -259,11 +253,12 @@ buffer selected (or created)."
|
|||
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 [return] 'exit-minibuffer)
|
||||
(define-key eshell-mode-map [(control ?m)] 'exit-minibuffer)
|
||||
(define-key eshell-mode-map [(control ?j)] 'exit-minibuffer)
|
||||
(define-key eshell-mode-map [(meta return)] 'exit-minibuffer)
|
||||
(define-key eshell-mode-map [(meta control ?m)] 'exit-minibuffer))
|
||||
|
||||
(defvar eshell-non-interactive-p nil
|
||||
|
|
@ -278,7 +273,6 @@ non-interactive sessions, such as when using `eshell-command'.")
|
|||
"Execute the Eshell command string COMMAND.
|
||||
With prefix ARG, insert output into the current buffer at point."
|
||||
(interactive)
|
||||
(require 'esh-cmd)
|
||||
(unless arg
|
||||
(setq arg current-prefix-arg))
|
||||
(let ((eshell-non-interactive-p t))
|
||||
|
|
@ -366,7 +360,8 @@ corresponding to a successful execution."
|
|||
(let ((result (eshell-do-eval
|
||||
(list 'eshell-commands
|
||||
(list 'eshell-command-to-value
|
||||
(eshell-parse-command command))) t)))
|
||||
(eshell-parse-command command)))
|
||||
t)))
|
||||
(cl-assert (eq (car result) 'quote))
|
||||
(if (and status-var (symbolp status-var))
|
||||
(set status-var eshell-last-command-status))
|
||||
|
|
@ -406,4 +401,5 @@ Emacs."
|
|||
|
||||
(run-hooks 'eshell-load-hook)
|
||||
|
||||
(provide 'eshell)
|
||||
;;; eshell.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue