summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-14 22:57:18 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-14 22:57:18 +0100
commit759da77c957816820803d525ed8779224a89aec3 (patch)
treedb3228b4526dafd42d6a7259d1eaaffcdda71ce4 /elisp
parent02c0f7b213c52fb5643fc4578d68af8d43991530 (diff)
downloadgeiser-759da77c957816820803d525ed8779224a89aec3.tar.gz
geiser-759da77c957816820803d525ed8779224a89aec3.tar.bz2
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.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-connection.el17
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)