From 7342870bfce4071673936597559ae60ffcba03b2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 3 Jan 2011 01:45:13 +0100 Subject: Really avoiding *spurious* buffers My previous attempt was bogus! Also, i'm taking advantage of our sending queries serially to simplify transaction queue processing, and to clean after ourserlves on error. --- elisp/geiser-connection.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el index 3638e12..cade18a 100644 --- a/elisp/geiser-connection.el +++ b/elisp/geiser-connection.el @@ -73,13 +73,21 @@ 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))) + (when (buffer-live-p (tq-buffer tq)) + (with-current-buffer (tq-buffer tq) + (if (tq-queue-empty tq) + (progn (geiser-log--error "Unexpected queue input:\n %s" in) + (delete-region (point-min) (point-max))) + (goto-char (point-max)) + (insert in) + (goto-char (point-min)) + (when (re-search-forward (tq-queue-head-regexp tq) nil t) + (unwind-protect + (funcall (tq-queue-head-fn tq) + (tq-queue-head-closure tq) + (buffer-substring (point-min) (point))) + (delete-region (point-min) (point-max)) + (tq-queue-pop tq))))))) (defun geiser-con--combined-prompt (prompt debug) (format "\\(%s%s\\)" prompt (if debug (format "\\|%s" debug) ""))) -- cgit v1.2.3