Function: eshell--find-subcommands

eshell--find-subcommands is a byte-compiled function defined in esh-cmd.el.gz.

Signature

(eshell--find-subcommands HAYSTACK)

Documentation

Recursively search for subcommand forms in HAYSTACK.

This yields the SUBCOMMANDs when found in forms like
"(eshell-as-subcommand SUBCOMMAND)".

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
;;;_* Iterative evaluation
;;
;; Eshell runs all of its external commands asynchronously, so that
;; Emacs is not blocked while the operation is being performed.
;; However, this introduces certain synchronization difficulties,
;; since the Lisp code, once it returns, will not "go back" to finish
;; executing the commands which haven't yet been started.
;;
;; What Eshell does to work around this problem (basically, the lack
;; of threads in Lisp), is that it evaluates the command sequence
;; iteratively.  Whenever an asynchronous process is begun, evaluation
;; terminates and control is given back to Emacs.  When that process
;; finishes, it will resume the evaluation using the remainder of the
;; command tree.

(iter-defun eshell--find-subcommands (haystack)
  "Recursively search for subcommand forms in HAYSTACK.
This yields the SUBCOMMANDs when found in forms like
\"(eshell-as-subcommand SUBCOMMAND)\"."
  (dolist (elem haystack)
    (cond
     ((eq (car-safe elem) 'eshell-as-subcommand)
      (iter-yield (cadr elem)))
     ((listp elem)
      (iter-yield-from (eshell--find-subcommands elem))))))