From 4f2b1eb3e28341c3eb9bba0488bc4b553d305071 Mon Sep 17 00:00:00 2001 From: Eliza Velasquez <4576666+elizagamedev@users.noreply.github.com> Date: Tue, 21 May 2024 15:59:55 -0700 Subject: Log more unexpected output from REPL When a transmission queue request successfully completes and the REPL prints a return value, it skips over unexpected and potentially meaningful output. Given that geiser:eval captures standard out, this output may contain warning or error messages. This PR captures and logs this extra output instead of discarding it. --- elisp/geiser-connection.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el index b7d312e..5aa05a9 100644 --- a/elisp/geiser-connection.el +++ b/elisp/geiser-connection.el @@ -87,7 +87,7 @@ (unwind-protect (funcall (tq-queue-head-fn tq) (tq-queue-head-closure tq) - (buffer-substring (point-min) (point))) + (buffer-substring (point-min) (match-beginning 0))) (delete-region (point-min) (point-max)) (tq-queue-pop tq))))))) @@ -202,7 +202,20 @@ (debugging (geiser-con--has-entered-debugger con answer))) (condition-case err (let ((start (string-match "((\\(?:result)?\\|error\\) " answer))) - (or (and start (car (read-from-string answer start))) + (or (and start + (progn + (let ((extra-output (substring answer 0 start))) + (unless (string-blank-p extra-output) + (geiser-log--warn "Extra output (before): %s" + (string-trim extra-output)))) + (let* ((ret (read-from-string answer start))) + (let ((extra-output (substring answer (cdr ret)))) + (unless (string-blank-p extra-output) + ;; Usually, the extra output is just the return value + ;; being echoed by the REPL, and not worth noting. + (geiser-log--debug "Extra output (after): %s" + (string-trim extra-output)))) + (car ret)))) `((error (key . retort-syntax)) (output . ,answer) (debug . ,debugging)))) -- cgit v1.2.3