branch: elpa/forth-mode
commit 21033fc700282702aa4615bb7c039709d0f16dc9
Author: Lars Brinkhoff <[email protected]>
Commit: Lars Brinkhoff <[email protected]>
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)))