emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/forth-mode 21033fc700 031/153: Improve sending commands to


From: ELPA Syncer
Subject: [nongnu] elpa/forth-mode 21033fc700 031/153: Improve sending commands to an interactive Forth session.
Date: Sat, 29 Jan 2022 08:02:14 -0500 (EST)

branch: elpa/forth-mode
commit 21033fc700282702aa4615bb7c039709d0f16dc9
Author: Lars Brinkhoff <lars.brinkhoff@delphi.com>
Commit: Lars Brinkhoff <lars.brinkhoff@delphi.com>

    Improve sending commands to an interactive Forth session.
---
 forth-interaction-mode.el | 22 ++++++++++++++--------
 forth-mode.el             |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/forth-interaction-mode.el b/forth-interaction-mode.el
index 5e07613e28..87fad97fc9 100644
--- a/forth-interaction-mode.el
+++ b/forth-interaction-mode.el
@@ -19,9 +19,7 @@
 
 (defun forth-interaction-preoutput-filter (text)
   (if forth-interaction-callback
-      (prog1 (when forth-interaction-callback
-              (funcall forth-interaction-callback text))
-       (setq forth-interaction-callback nil))
+      (funcall forth-interaction-callback text)
       text))
 
 (defun forth-kill (&optional buffer)
@@ -64,10 +62,18 @@
   (get-buffer-process forth-interaction-buffer))
 
 ;;;###autoload
-(defun forth-interaction-send (string &optional callback)
-  (let ((proc (forth-ensure)))
-    (setq forth-interaction-callback callback)
-    (comint-send-string proc string)
-    (comint-send-string proc "\n")))
+(defun forth-interaction-send (&rest strings)
+  (let* ((proc (forth-ensure))
+        (forth-result nil)
+        (forth-interaction-callback (lambda (x)
+                                      (setq forth-result (concat forth-result 
x))
+                                      ""))
+        (end-time (+ (float-time) .4)))
+    (dolist (s strings)
+      (comint-send-string proc s))
+    (comint-send-string proc "\n")
+    (while (< (float-time) end-time)
+      (accept-process-output proc 0.1))
+    forth-result))
 
 (provide 'forth-interaction-mode)
diff --git a/forth-mode.el b/forth-mode.el
index ba5289ec44..61b6d4c0fe 100644
--- a/forth-mode.el
+++ b/forth-mode.el
@@ -107,7 +107,7 @@
 
 (defun forth-load-file (file)
   (interactive (list (buffer-file-name (current-buffer))))
-  (forth-interaction-send (concat "include " file)))
+  (forth-interaction-send "include " file))
 
 (defun forth-beginning ()
   (goto-char (point-min)))



reply via email to

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