Commit 5101a9dc authored by Glenn Morris's avatar Glenn Morris
Browse files

(eshell-in-pipeline-p): Add doc-string.

(eshell-do-pipelines): Add optional argument to distinguish recursive
calls.  Use to set eshell-in-pipeline-p to 'first for the first command
in a pipeline.
parent 395f0100
...@@ -274,7 +274,10 @@ command line.") ...@@ -274,7 +274,10 @@ command line.")
(defvar eshell-current-command nil) (defvar eshell-current-command nil)
(defvar eshell-command-name nil) (defvar eshell-command-name nil)
(defvar eshell-command-arguments nil) (defvar eshell-command-arguments nil)
(defvar eshell-in-pipeline-p nil) (defvar eshell-in-pipeline-p nil
"Internal Eshell variable, non-nil inside a pipeline.
Has the value 'first, 'last for the first/last commands in the pipeline,
otherwise t.")
(defvar eshell-in-subcommand-p nil) (defvar eshell-in-subcommand-p nil)
(defvar eshell-last-arguments nil) (defvar eshell-last-arguments nil)
(defvar eshell-last-command-name nil) (defvar eshell-last-command-name nil)
...@@ -816,8 +819,9 @@ this grossness will be made to disappear by using `call/cc'..." ...@@ -816,8 +819,9 @@ this grossness will be made to disappear by using `call/cc'..."
(eshell-protect-handles eshell-current-handles) (eshell-protect-handles eshell-current-handles)
,object)) ,object))
(defmacro eshell-do-pipelines (pipeline) (defmacro eshell-do-pipelines (pipeline &optional notfirst)
"Execute the commands in PIPELINE, connecting each to one another." "Execute the commands in PIPELINE, connecting each to one another.
This macro calls itself recursively, with NOTFIRST non-nil."
(when (setq pipeline (cadr pipeline)) (when (setq pipeline (cadr pipeline))
`(eshell-copy-handles `(eshell-copy-handles
(progn (progn
...@@ -825,7 +829,7 @@ this grossness will be made to disappear by using `call/cc'..." ...@@ -825,7 +829,7 @@ this grossness will be made to disappear by using `call/cc'..."
`(let (nextproc) `(let (nextproc)
(progn (progn
(set 'nextproc (set 'nextproc
(eshell-do-pipelines (quote ,(cdr pipeline)))) (eshell-do-pipelines (quote ,(cdr pipeline)) t))
(eshell-set-output-handle ,eshell-output-handle (eshell-set-output-handle ,eshell-output-handle
'append nextproc) 'append nextproc)
(eshell-set-output-handle ,eshell-error-handle (eshell-set-output-handle ,eshell-error-handle
...@@ -839,10 +843,13 @@ this grossness will be made to disappear by using `call/cc'..." ...@@ -839,10 +843,13 @@ this grossness will be made to disappear by using `call/cc'..."
(setcar head (setcar head
(intern-soft (intern-soft
(concat (symbol-name (car head)) "*")))))) (concat (symbol-name (car head)) "*"))))))
;; Indicate to the command if it is the last in the pipeline. ;; First and last elements in a pipeline may need special treatment.
;; Currently only used by eshell-ls-files. ;; (Currently only eshell-ls-files uses 'last.)
;; Perhaps nil, rather than 'last, would be OK? ;; Affects process-connection-type in eshell-gather-process-output.
(let ((eshell-in-pipeline-p ,(if (cdr pipeline) t (quote 'last)))) (let ((eshell-in-pipeline-p
,(cond ((not notfirst) (quote 'first))
((cdr pipeline) t)
(t (quote 'last)))))
,(car pipeline)))))) ,(car pipeline))))))
(defmacro eshell-do-pipelines-synchronously (pipeline) (defmacro eshell-do-pipelines-synchronously (pipeline)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment