summaryrefslogtreecommitdiff
path: root/elisp/geiser-connection.el
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2011-01-03 01:45:13 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2011-01-03 01:45:13 +0100
commitdac9e147a1717674aab32ecc47bb9ea6cddb4ef1 (patch)
tree0136c0dc53f2764460721729c92f1b6b7f845735 /elisp/geiser-connection.el
parent78554a9c2bbbe59b007f85c8ee113b9a449db231 (diff)
downloadgeiser-dac9e147a1717674aab32ecc47bb9ea6cddb4ef1.tar.gz
geiser-dac9e147a1717674aab32ecc47bb9ea6cddb4ef1.tar.bz2
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.
Diffstat (limited to 'elisp/geiser-connection.el')
-rw-r--r--elisp/geiser-connection.el22
1 files 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) "")))