emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6419f318e43 1/5: ; Move common Eshell pipeline code to a separate


From: Jim Porter
Subject: master 6419f318e43 1/5: ; Move common Eshell pipeline code to a separate function
Date: Sun, 10 Sep 2023 13:42:08 -0400 (EDT)

branch: master
commit 6419f318e432c00d29d14f1da352bee249864922
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    ; Move common Eshell pipeline code to a separate function
    
    * lisp/eshell/esh-cmd.el (eshell-do-pipelines)
    (eshell-do-pipelines-synchronously): Move code for manipulating
    deferrable command forms to...
    (eshell--unmark-deferrable): ... here.
---
 lisp/eshell/esh-cmd.el | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index ed2d6c71fc8..f6846345d7d 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -790,10 +790,25 @@ current ones (see `eshell-duplicate-handles')."
      (eshell-protect-handles eshell-current-handles)
      ,object))
 
+(defun eshell--unmark-deferrable (command)
+  "If COMMAND is (or ends with) a deferrable command, unmark it as such.
+This changes COMMAND in-place by converting function calls listed
+in `eshell-deferrable-commands' to their non-deferrable forms so
+that Eshell doesn't erroneously allow deferring it.  For example,
+`eshell-named-command' becomes `eshell-named-command*', "
+  (let ((cmd command))
+    (when (memq (car cmd) '(let progn))
+      (setq cmd (car (last cmd))))
+    (when (memq (car cmd) eshell-deferrable-commands)
+      (setcar cmd (intern-soft
+                  (concat (symbol-name (car cmd)) "*"))))
+    command))
+
 (defmacro eshell-do-pipelines (pipeline &optional notfirst)
   "Execute the commands in PIPELINE, connecting each to one another.
 This macro calls itself recursively, with NOTFIRST non-nil."
   (when (setq pipeline (cadr pipeline))
+    (eshell--unmark-deferrable (car pipeline))
     `(eshell-with-copied-handles
       (progn
        ,(when (cdr pipeline)
@@ -801,14 +816,6 @@ This macro calls itself recursively, with NOTFIRST 
non-nil."
                   (eshell-do-pipelines (quote ,(cdr pipeline)) t)))
               (eshell-set-output-handle ,eshell-output-handle
                                         'append nextproc)))
-       ,(let ((head (car pipeline)))
-          (if (memq (car head) '(let progn))
-              (setq head (car (last head))))
-          (when (memq (car head) eshell-deferrable-commands)
-            (ignore
-             (setcar head
-                     (intern-soft
-                      (concat (symbol-name (car head)) "*"))))))
        ;; First and last elements in a pipeline may need special treatment.
        ;; (Currently only eshell-ls-files uses 'last.)
        ;; Affects process-connection-type in eshell-gather-process-output.
@@ -828,20 +835,13 @@ This macro calls itself recursively, with NOTFIRST 
non-nil."
 Output of each command is passed as input to the next one in the pipeline.
 This is used on systems where async subprocesses are not supported."
   (when (setq pipeline (cadr pipeline))
+    ;; FIXME: is deferrable significant here?
+    (eshell--unmark-deferrable (car pipeline))
     `(progn
        ,(when (cdr pipeline)
           `(let ((output-marker ,(point-marker)))
              (eshell-set-output-handle ,eshell-output-handle
                                        'append output-marker)))
-       ,(let ((head (car pipeline)))
-          (if (memq (car head) '(let progn))
-              (setq head (car (last head))))
-          ;; FIXME: is deferrable significant here?
-          (when (memq (car head) eshell-deferrable-commands)
-            (ignore
-             (setcar head
-                     (intern-soft
-                      (concat (symbol-name (car head)) "*"))))))
        ;; The last process in the pipe should get its handles
        ;; redirected as we found them before running the pipe.
        ,(if (null (cdr pipeline))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]