Function: eshell-rewrite-for-command
eshell-rewrite-for-command is a byte-compiled function defined in
esh-cmd.el.gz.
Signature
(eshell-rewrite-for-command TERMS)
Documentation
Rewrite a for command into its equivalent Eshell command form.
Because the implementation of for relies upon conditional evaluation
of its argument (i.e., use of a Lisp special form), it must be
implemented via rewriting, rather than as a function.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defun eshell-rewrite-for-command (terms)
"Rewrite a `for' command into its equivalent Eshell command form.
Because the implementation of `for' relies upon conditional evaluation
of its argument (i.e., use of a Lisp special form), it must be
implemented via rewriting, rather than as a function."
(if (and (equal (car terms) "for")
(equal (nth 2 terms) "in"))
(let ((iter-symbol (intern (nth 1 terms)))
(body (car (last terms))))
(setcdr (last terms 2) nil)
`(let ((eshell--local-vars (cons ',iter-symbol eshell--local-vars)))
(iter-do (,iter-symbol (eshell-for-iterate
,@(mapcar #'eshell-term-as-value
(nthcdr 3 terms))))
,body)))))