diff options
-rw-r--r-- | elisp/geiser-connection.el | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el index 509bdf0..49f0b0b 100644 --- a/elisp/geiser-connection.el +++ b/elisp/geiser-connection.el @@ -66,6 +66,21 @@ ;;; Connection datatype: +(defun geiser-con--tq-create (process) + (let ((tq (tq-create process))) + (set-process-filter process + `(lambda (p s) (geiser-con--tq-filter ',tq s))) + tq)) + +(defun geiser-con--tq-filter (tq in) + (if (tq-queue-empty tq) + (let ((buffer (tq-buffer tq))) + (geiser-log--error "Unexpected queue input:\n %s" in) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (delete-region (point-min) (point-max))))) + (tq-filter tq in))) + (defun geiser-con--combined-prompt (prompt debug) (format "\\(%s%s\\)" prompt (if debug (format "\\|%s" debug) ""))) @@ -76,7 +91,7 @@ (defun geiser-con--make-connection (proc prompt debug-prompt) (list t (cons :filter (process-filter proc)) - (cons :tq (tq-create proc)) + (cons :tq (geiser-con--tq-create proc)) (cons :tq-filter (process-filter proc)) (cons :eot (geiser-con--connection-eot-re prompt debug-prompt)) (cons :prompt prompt) |