From 759da77c957816820803d525ed8779224a89aec3 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Tue, 14 Dec 2010 22:57:18 +0100 Subject: No more vicious error circle on tq errors I've eliminated the annoying *spurious* popup produced by tq, so that Geiser can recover from error conditions arising from unexpected input to a transaction queue that has no active transaction. We now log the offending input and keep going. Greg, over at racket's list, reported such a happening when leaving the REPL after C-u C-c C-z; but i've been unable to reproduce the problem. Probably, we have a bug lurking somewhere that this patch doesn't fix, but at least it should work as a palliative. --- elisp/geiser-connection.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'elisp/geiser-connection.el') 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) -- cgit v1.2.3