[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eat ccfccf016b 2/2: Fix recursive output processing
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eat ccfccf016b 2/2: Fix recursive output processing |
Date: |
Thu, 14 Sep 2023 09:59:40 -0400 (EDT) |
branch: elpa/eat
commit ccfccf016b91b2ec1a22bda6a12bcedad9043d96
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Fix recursive output processing
* eat.el (eat--pending-input-chunks)
(eat--process-input-queue-timer): New variable.
* eat.el (eat-mode): Make 'eat--pending-input-chunks' and
'eat--process-input-queue-timer' buffer-local.
* eat.el (eat--send-input): Queue input instead of sending
immediately.
* eat.el (eat--process-input-queue): New function.
---
eat.el | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/eat.el b/eat.el
index e40192222b..bdf296d9c7 100644
--- a/eat.el
+++ b/eat.el
@@ -5149,7 +5149,7 @@ BUFFER is the terminal buffer."
(defun eat--set-cmd (cmd)
"Add CMD to `shell-command-history'."
- (when-let* (((and eat-enable-shell-command-history))
+ (when-let* ((eat-enable-shell-command-history)
(command (ignore-errors (decode-coding-string
(base64-decode-string cmd)
locale-coding-system))))
@@ -6168,6 +6168,8 @@ END if it's safe to do so."
eat--prompt-input-ring-index
eat--prompt-stored-incomplete-input
eat--prompt-matching-input-from-input-string
+ eat--pending-input-chunks
+ eat--process-input-queue-timer
eat--pending-output-chunks
eat--output-queue-first-chunk-time
eat--process-output-queue-timer
@@ -6294,6 +6296,14 @@ The output chunks are pushed, so last output appears
first.")
(defvar eat--process-output-queue-timer nil
"Timer to process output queue.")
+(defvar eat--pending-input-chunks nil
+ "The list of pending input chunks.
+
+The input chunks are pushed, so last input appears first.")
+
+(defvar eat--process-input-queue-timer nil
+ "Timer to process input queue.")
+
(defvar eat--shell-prompt-annotation-correction-timer nil
"Timer to correct shell prompt annotations.")
@@ -6323,9 +6333,25 @@ OS's."
(defun eat--send-input (_ input)
"Send INPUT to subprocess."
- (when-let* ((eat--terminal)
- (proc (eat-term-parameter eat--terminal 'eat--process)))
- (eat--send-string proc input)))
+ (push input eat--pending-input-chunks)
+ (unless eat--process-input-queue-timer
+ (setq eat--process-input-queue-timer
+ (run-with-idle-timer 0 nil #'eat--process-input-queue
+ (current-buffer)))))
+
+(defun eat--process-input-queue (buffer)
+ "Process the input queue on BUFFER."
+ (setf (buffer-local-value 'eat--process-input-queue-timer buffer)
+ nil)
+ (when-let* (((buffer-live-p buffer))
+ (terminal (buffer-local-value 'eat--terminal buffer))
+ (proc (eat-term-parameter terminal 'eat--process))
+ ((process-live-p proc)))
+ (with-current-buffer buffer
+ (let ((chunks (nreverse eat--pending-input-chunks)))
+ (setq eat--pending-input-chunks nil)
+ (dolist (str chunks)
+ (eat--send-string proc str))))))
(defun eat--process-output-queue (buffer)
"Process the output queue on BUFFER."