emacs-diffs
[Top][All Lists]
Advanced

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

master 3d6c013a27 2/5: Allow checking specific Eshell handles for intera


From: Jim Porter
Subject: master 3d6c013a27 2/5: Allow checking specific Eshell handles for interactive output
Date: Sun, 4 Sep 2022 19:04:13 -0400 (EDT)

branch: master
commit 3d6c013a27e0b72c8fbe2d47f752dd0dfd4ff47a
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    Allow checking specific Eshell handles for interactive output
    
    This changes the default behavior of the function to check only stdout
    for interactivity, but for most cases this should be what we want.
    
    * lisp/eshell/esh-io.el (eshell-interactive-output-p): Pass HANDLES
    and handle INDEX.
    
    * lisp/eshell/em-term.el (eshell-visual-command-p): Check for
    interactivity of both stdout and stderr.
---
 lisp/eshell/em-term.el |  2 +-
 lisp/eshell/esh-io.el  | 20 ++++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el
index a4fa699aa9..6811e70313 100644
--- a/lisp/eshell/em-term.el
+++ b/lisp/eshell/em-term.el
@@ -153,7 +153,7 @@ behavior for short-lived processes, see bug#18108."
 If either COMMAND or a subcommand in ARGS (e.g. git log) is a
 visual command, returns non-nil."
   (let ((command (file-name-nondirectory command)))
-    (and (eshell-interactive-output-p)
+    (and (eshell-interactive-output-p 'all)
          (or (member command eshell-visual-commands)
              (member (car args)
                      (cdr (assoc command eshell-visual-subcommands)))
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index f5dac2c81c..01e8aceeab 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -407,12 +407,20 @@ it defaults to `insert'."
     (error "Invalid redirection target: %s"
           (eshell-stringify target)))))
 
-(defun eshell-interactive-output-p ()
-  "Return non-nil if current handles are bound for interactive display."
-  (and (eq (car (aref eshell-current-handles
-                     eshell-output-handle)) t)
-       (eq (car (aref eshell-current-handles
-                     eshell-error-handle)) t)))
+(defun eshell-interactive-output-p (&optional index handles)
+  "Return non-nil if the specified handle is bound for interactive display.
+HANDLES is the set of handles to check; if nil, use
+`eshell-current-handles'.
+
+INDEX is the handle index to check.  If nil, check
+`eshell-output-handle'.  If `all', check both
+`eshell-output-handle' and `eshell-error-handle'."
+  (let ((handles (or handles eshell-current-handles))
+        (index (or index eshell-output-handle)))
+    (if (eq index 'all)
+        (and (eq (car (aref handles eshell-output-handle)) t)
+             (eq (car (aref handles eshell-error-handle)) t))
+      (eq (car (aref handles index)) t))))
 
 (defvar eshell-print-queue nil)
 (defvar eshell-print-queue-count -1)



reply via email to

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