Function: eshell-split-commands
eshell-split-commands is a byte-compiled function defined in
esh-cmd.el.gz.
Signature
(eshell-split-commands TERMS SEPARATOR &optional REVERSED RETURN-SEPS)
Documentation
Split TERMS using SEPARATOR.
If REVERSED is non-nil, the list of separated term groups will be returned in reverse order.
If RETURN-SEPS is nil, return just the separated terms as a list; otherwise, return both the separated terms and their separators as a pair of lists.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defun eshell-split-commands (terms separator &optional
reversed return-seps)
"Split TERMS using SEPARATOR.
If REVERSED is non-nil, the list of separated term groups will be
returned in reverse order.
If RETURN-SEPS is nil, return just the separated terms as a list;
otherwise, return both the separated terms and their separators
as a pair of lists."
(let (sub-chains sub-terms sep-terms)
(dolist (term terms)
(if (and (eq (car-safe term) 'eshell-operator)
(string-match (concat "^" separator "$")
(nth 1 term)))
(progn
(push (nth 1 term) sep-terms)
(push (nreverse sub-terms) sub-chains)
(setq sub-terms nil))
(push term sub-terms)))
(when terms
(push (nreverse sub-terms) sub-chains))
(unless reversed
(setq sub-chains (nreverse sub-chains)
sep-terms (nreverse sep-terms)))
(if return-seps
(cons sub-chains sep-terms)
sub-chains)))