aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorJim Porter2023-01-26 23:18:42 -0800
committerJim Porter2023-03-16 22:16:37 -0700
commit67a2b320f61642d0cbbce31ac34d4e1ce77c9230 (patch)
tree48e54ce8b87993adf78491031ee6ecc8fdda81da /lisp/eshell
parent0330cff65ae837e93ae4d059acf643734d16386d (diff)
downloademacs-67a2b320f61642d0cbbce31ac34d4e1ce77c9230.tar.gz
emacs-67a2b320f61642d0cbbce31ac34d4e1ce77c9230.zip
Simplify iteration in Eshell for loops
The previous code fixed an issue in Eshell's iterative evaluation where deferred commands caused an infinite loop (see bug#12571). However, with the fix to unwinding let forms in 'eshell-do-eval' (see bug#59469), we can just write this code as we normally would (bug#61954). * lisp/eshell/esh-cmd.el (eshell-rewrite-for-command): Simplify.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-cmd.el28
1 files changed, 13 insertions, 15 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index d609711402a..2dd8f5d6042 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -533,25 +533,23 @@ implemented via rewriting, rather than as a function."
533 (equal (nth 2 terms) "in")) 533 (equal (nth 2 terms) "in"))
534 (let ((body (car (last terms)))) 534 (let ((body (car (last terms))))
535 (setcdr (last terms 2) nil) 535 (setcdr (last terms 2) nil)
536 `(let ((for-items 536 `(let ((for-items
537 (copy-tree 537 (append
538 (append 538 ,@(mapcar
539 ,@(mapcar 539 (lambda (elem)
540 (lambda (elem) 540 (if (listp elem)
541 (if (listp elem) 541 elem
542 elem 542 `(list ,elem)))
543 `(list ,elem))) 543 (nthcdr 3 terms))))
544 (cdr (cddr terms)))))) 544 (eshell-command-body '(nil))
545 (eshell-command-body '(nil))
546 (eshell-test-body '(nil))) 545 (eshell-test-body '(nil)))
547 (while (car for-items) 546 (while for-items
548 (let ((,(intern (cadr terms)) (car for-items)) 547 (let ((,(intern (cadr terms)) (car for-items))
549 (eshell--local-vars (cons ',(intern (cadr terms)) 548 (eshell--local-vars (cons ',(intern (cadr terms))
550 eshell--local-vars))) 549 eshell--local-vars)))
551 (eshell-protect 550 (eshell-protect
552 ,(eshell-invokify-arg body t))) 551 ,(eshell-invokify-arg body t)))
553 (setcar for-items (cadr for-items)) 552 (setq for-items (cdr for-items)))
554 (setcdr for-items (cddr for-items)))
555 (eshell-close-handles))))) 553 (eshell-close-handles)))))
556 554
557(defun eshell-structure-basic-command (func names keyword test body 555(defun eshell-structure-basic-command (func names keyword test body