summaryrefslogtreecommitdiff
path: root/elisp/geiser-debug.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-12-18 01:41:35 +0000
committerjao <jao@gnu.org>2021-12-18 21:06:45 +0000
commita789a6c3132d096ac41094a81c3a2638b7a1b6fd (patch)
tree83dcf9f5fc6aa84d72777d195bc4002e62b99ebd /elisp/geiser-debug.el
parentd857699d8cf2a4cdddf1dde58cb3f433d285d97e (diff)
downloadgeiser-a789a6c3132d096ac41094a81c3a2638b7a1b6fd.tar.gz
geiser-a789a6c3132d096ac41094a81c3a2638b7a1b6fd.tar.bz2
Allowing debuggers to use Dbg buffer for output
Diffstat (limited to 'elisp/geiser-debug.el')
-rw-r--r--elisp/geiser-debug.el17
1 files changed, 12 insertions, 5 deletions
diff --git a/elisp/geiser-debug.el b/elisp/geiser-debug.el
index 3956c43..e3f2bb5 100644
--- a/elisp/geiser-debug.el
+++ b/elisp/geiser-debug.el
@@ -159,6 +159,11 @@ buffer.")
(declare-function switch-to-geiser "geiser-repl")
+(defun geiser-debug--remove-prompt (impl str)
+ (replace-regexp-in-string (or (geiser-repl--debugger-prompt-regexp impl) "^$")
+ ""
+ str))
+
(defun geiser-debug--display-retort (what ret &optional res auto-p)
(let* ((err (geiser-eval--retort-error ret))
(key (geiser-eval--error-key err))
@@ -170,6 +175,7 @@ buffer.")
(dir default-directory)
(buffer (current-buffer))
(debug (eq key 'geiser-debugger))
+ (output (if debug (geiser-debug--remove-prompt impl output) output))
(debug-entered (when debug
(switch-to-geiser nil nil buffer)
(geiser-debug--enter-debugger impl)))
@@ -179,7 +185,8 @@ buffer.")
(erase-buffer)
(when dir (setq default-directory dir))
(unless after (insert what "\n\n"))
- (setq img (when (and res (not err)) (geiser-debug--insert-res res)))
+ (setq img (when (and res (not err) (not debug))
+ (geiser-debug--insert-res res)))
(when (or err key output)
(or (geiser-debug--display-error impl module key output)
(insert "\n" (if key (format "%s\n" key) "") output "\n")))
@@ -192,10 +199,10 @@ buffer.")
(remove (ansi-color-filter-region (point-min) (point-max))))
(goto-char (point-min)))
(when (or img err output)
- (when (or geiser-debug-jump-to-debug-p geiser-debug-show-debug-p)
- (if geiser-debug-jump-to-debug-p
- (geiser-debug--pop-to-buffer)
- (display-buffer (geiser-debug--buffer))))
+ (cond (geiser-debug-jump-to-debug-p
+ (geiser-debug--pop-to-buffer))
+ (geiser-debug-show-debug-p
+ (display-buffer (geiser-debug--buffer))))
(when (and err geiser-debug-auto-next-error-p)
(ignore-errors (next-error))
(message "=> %s" output))))))