:version "24.1" ; removed eshell-cmd-initialize
:type 'hook)
-(defcustom eshell-deferrable-commands
- '(eshell-named-command
- eshell-lisp-command
- eshell-process-identity)
- "A list of functions which might return an asynchronous process.
-If they return a process object, execution of the calling Eshell
-command will wait for completion (in the background) before finishing
-the command."
- :type '(repeat function))
-
(defcustom eshell-subcommand-bindings
'((eshell-in-subcommand-p t)
(eshell-in-pipeline-p nil)
(defvar eshell-last-arguments nil)
(defvar eshell-last-command-name nil)
+(defvar eshell-deferrable-commands '(eshell-deferrable)
+ "A list of functions which might return a deferrable process.
+If they return a process object (or list thereof), execution of the
+calling Eshell command will wait for completion (in the background)
+before finishing the command.")
+
(defvar eshell-allow-commands t
"If non-nil, allow evaluating command forms (including Lisp forms).
If you want to forbid command forms, you can let-bind this to a
(error "Empty command before `&'"))
(setq cmd (eshell-parse-pipeline cmd))
(unless eshell-in-pipeline-p
- (setq cmd `(eshell-trap-errors ,cmd)))
+ (setq cmd `(eshell-do-command ,cmd)))
;; Copy I/O handles so each full statement can manipulate
;; them if they like. Steal the handles for the last
;; command (first in our reversed list); we won't use the
;; statement.
(unless (memq (car test) '(eshell-convert eshell-escape-arg))
(setq test
- `(progn ,test
+ `(progn (eshell-deferrable ,test)
(eshell-exit-success-p))))
;; should we reverse the sense of the test? This depends
(defvar eshell-this-command-hook nil)
-(defmacro eshell-trap-errors (object)
+(defmacro eshell-do-command (object)
"Trap any errors that occur, so they are not entirely fatal.
Also, the variable `eshell-this-command-hook' is available for the
duration of OBJECT's evaluation. Note that functions should be added
`(eshell-condition-case err
(let ((eshell-this-command-hook '(ignore)))
(unwind-protect
- ,object
+ (eshell-deferrable ,object)
(mapc #'funcall eshell-this-command-hook)))
(error
(eshell-errorn (error-message-string err))
(eshell-close-handles 1))))
+(define-obsolete-function-alias 'eshell-trap-errors #'eshell-do-command "31.1")
+
+(defalias 'eshell-deferrable 'identity
+ "A wrapper to mark a particular form as potentially deferrable.
+If the wrapped form returns a process (or list thereof), Eshell will
+wait for completion in the background for the process(es) to complete.")
+
(defmacro eshell-with-copied-handles (object &optional steal-p)
"Duplicate current I/O handles, so OBJECT works with its own copy.
If STEAL-P is non-nil, these new handles will be stolen from the
(eshell-protect-handles eshell-current-handles)
,object))
-(defun eshell--unmark-deferrable (command)
- "If COMMAND is (or ends with) a deferrable command, unmark it as such.
-This changes COMMAND in-place by converting function calls listed
-in `eshell-deferrable-commands' to their non-deferrable forms so
-that Eshell doesn't erroneously allow deferring it. For example,
-`eshell-named-command' becomes `eshell-named-command*'."
- (let ((cmd command))
- (when (memq (car cmd) '(let progn))
- (setq cmd (car (last cmd))))
- (when (memq (car cmd) eshell-deferrable-commands)
- (setcar cmd (intern-soft
- (concat (symbol-name (car cmd)) "*"))))
- command))
-
(defmacro eshell-do-pipelines (pipeline &optional notfirst)
"Execute the commands in PIPELINE, connecting each to one another.
Returns a list of the processes in the pipeline.
This macro calls itself recursively, with NOTFIRST non-nil."
(when (setq pipeline (cadr pipeline))
- (eshell--unmark-deferrable (car pipeline))
`(eshell-with-copied-handles
(let ((next-procs
,(when (cdr pipeline)
This is used on systems where async subprocesses are not
supported."
(when (setq pipeline (cadr pipeline))
- ;; FIXME: is deferrable significant here?
- (eshell--unmark-deferrable (car pipeline))
`(prog1
(eshell-with-copied-handles
(progn
,(when (cdr pipeline)
`(eshell-do-pipelines-synchronously (quote ,(cdr pipeline)))))))
-(defalias 'eshell-process-identity 'identity)
+(define-obsolete-function-alias 'eshell-process-identity #'identity "31.1")
(defmacro eshell-execute-pipeline (pipeline)
"Execute the commands in PIPELINE, connecting each to one another."
- `(eshell-process-identity
- ,(if eshell-supports-asynchronous-processes
- `(remove nil (eshell-do-pipelines ,pipeline))
- `(eshell-do-pipelines-synchronously ,pipeline))))
+ (if eshell-supports-asynchronous-processes
+ `(remove nil (eshell-do-pipelines ,pipeline))
+ `(eshell-do-pipelines-synchronously ,pipeline)))
(defmacro eshell-as-subcommand (command)
"Execute COMMAND as a subcommand.
* The command is of the form
(eshell-with-copied-handles
- (eshell-trap-errors (eshell-named-command NAME [ARGS])) _).
+ (eshell-do-command (eshell-named-command NAME [ARGS])) _).
* NAME is a string referring to an alias function and isn't a
complex command (see `eshell-complex-commands').
* Any subcommands in ARGS can also be invoked directly."
(pcase command
(`(eshell-with-copied-handles
- (eshell-trap-errors (eshell-named-command ,name . ,args))
+ (eshell-do-command (eshell-named-command ,name . ,args))
,_)
(and name (stringp name)
(not (member name eshell-complex-commands))
(eshell-plain-command eshell-last-command-name
eshell-last-arguments))))
-(defalias 'eshell-named-command* 'eshell-named-command)
+(define-obsolete-function-alias 'eshell-named-command* #'eshell-named-command
+ "31.1")
(defun eshell-find-alias-function (name)
"Check whether a function called `eshell/NAME' exists."
2)
(list 'quote result)))))
-(defalias 'eshell-lisp-command* #'eshell-lisp-command)
+(define-obsolete-function-alias 'eshell-lisp-command* #'eshell-lisp-command
+ "31.1")
(provide 'esh-cmd)