From 1fef55a87f0b10945b185d80f5282fc5fd82997e Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Tue, 20 Jul 2010 22:20:16 +0200 Subject: Guile: geiser commands working at the debugging prompt. --- elisp/geiser-connection.el | 24 +++++++++++++++++++++--- elisp/geiser-guile.el | 6 +++++- elisp/geiser-repl.el | 14 ++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) (limited to 'elisp') diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el index 577ca97..dfdb21d 100644 --- a/elisp/geiser-connection.el +++ b/elisp/geiser-connection.el @@ -126,8 +126,15 @@ (make-variable-buffer-local (defvar geiser-con--debugging-prompt-regexp nil)) +(make-variable-buffer-local + (defvar geiser-con--debugging-inhibits-eval t)) + +(make-variable-buffer-local + (defvar geiser-con--debugging-preamble-regexp nil)) + (defun geiser-con--is-debugging () (and geiser-con--debugging-prompt-regexp + geiser-con--debugging-inhibits-eval comint-last-prompt-overlay (string-match-p geiser-con--debugging-prompt-regexp (buffer-substring (overlay-start @@ -135,16 +142,25 @@ (overlay-end comint-last-prompt-overlay))))) +(defsubst geiser-con--has-entered-debugger () + (and geiser-con--debugging-prompt-regexp + (re-search-backward geiser-con--debugging-prompt-regexp nil t) + (or (null geiser-con--debugging-preamble-regexp) + (save-excursion + (re-search-backward geiser-con--debugging-preamble-regexp nil t))))) + (defun geiser-con--cleanup-connection (c) (geiser-con--connection-cancel-timer c)) (defun geiser-con--setup-connection (buffer prompt-regexp - &optional debug-prompt-regexp) + &optional debug-prompt-regexp + debug-preamble-regexp) (with-current-buffer buffer (when geiser-con--connection (geiser-con--cleanup-connection geiser-con--connection)) (setq geiser-con--debugging-prompt-regexp debug-prompt-regexp) + (setq geiser-con--debugging-preamble-regexp debug-preamble-regexp) (setq geiser-con--connection (geiser-con--make-connection buffer)) (geiser-con--setup-comint prompt-regexp debug-prompt-regexp) (geiser-con--connection-start-timer geiser-con--connection) @@ -169,8 +185,7 @@ (defun geiser-con--comint-buffer-form () (with-current-buffer (geiser-con--comint-buffer) (goto-char (point-max)) - (if (and geiser-con--debugging-prompt-regexp - (re-search-backward geiser-con--debugging-prompt-regexp nil t)) + (if (geiser-con--has-entered-debugger) `((error (key . geiser-debugger)) (output . ,(buffer-substring (point-min) (point)))) (condition-case nil @@ -188,6 +203,8 @@ (let* ((buffer (geiser-con--connection-buffer con)) (debug-prompt (with-current-buffer buffer geiser-con--debugging-prompt-regexp)) + (debug-preamble (with-current-buffer buffer + geiser-con--debugging-preamble-regexp)) (req (geiser-con--connection-pop-request con)) (str (and req (geiser-con--request-string req))) (cbuf (geiser-con--comint-buffer))) @@ -197,6 +214,7 @@ (with-current-buffer cbuf (setq comint-redirect-echo-input nil) (setq geiser-con--debugging-prompt-regexp debug-prompt) + (setq geiser-con--debugging-preamble-regexp debug-preamble) (delete-region (point-min) (point-max))) (set-buffer buffer) (if (geiser-con--is-debugging) diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index 7fae364..91a316b 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -65,6 +65,8 @@ This function uses `geiser-guile-init-file' if it exists." (defconst geiser-guile--prompt-regexp "^[^() \n]+@([^)]*?)> ") (defconst geiser-guile--debugger-prompt-regexp "^[^() \n]+@([^)]*?) \\[[0-9]+\\]> ") +(defconst geiser-guile--debugger-preamble-regexp + "^Entering a new prompt\\. ") ;;; Evaluation support: @@ -140,7 +142,7 @@ This function uses `geiser-guile-init-file' if it exists." (defun geiser-guile--display-error (module key msg) (if (eq key 'geiser-debugger) (progn - (comint-send-string nil "0\n") + (comint-send-string nil ",locals\n") (accept-process-output nil 0.01) (when msg (goto-char (point-max)) @@ -198,6 +200,7 @@ This function uses `geiser-guile-init-file' if it exists." ("^ *\\([0-9]+\\): +" nil 1) ("at \\(/[^:\n]+\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\)" 1 2 3))) (setq geiser-guile--load-path (geiser-guile--load-path)) + (setq geiser-con--debugging-inhibits-eval nil) (compilation-setup t) (font-lock-add-keywords nil `((,geiser-guile--path-rx 1 @@ -212,6 +215,7 @@ This function uses `geiser-guile-init-file' if it exists." (startup geiser-guile--startup) (prompt-regexp geiser-guile--prompt-regexp) (debugger-prompt-regexp geiser-guile--debugger-prompt-regexp) + (debugger-preamble-regexp geiser-guile--debugger-preamble-regexp) (marshall-procedure geiser-guile--geiser-procedure) (find-module geiser-guile--get-module) (enter-command geiser-guile--enter-command) diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index f1da27f..694f21b 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -149,6 +149,11 @@ expression for this implementation's scheme prompt.") "A variable (or thunk returning a value) giving the regular expression for this implementation's debugging prompt.") +(geiser-impl--define-caller + geiser-repl--debugger-preamble-regexp debugger-preamble-regexp () + "A variable (or thunk returning a value) used to determine whether +the REPL has entered debugging mode.") + (geiser-impl--define-caller geiser-repl--startup startup () "Function taking no parameters that is called after the REPL has been initialised. All Geiser functionality is available to @@ -161,6 +166,7 @@ you at that point.") (args (geiser-repl--arglist impl)) (prompt-rx (geiser-repl--prompt-regexp impl)) (deb-prompt-rx (geiser-repl--debugger-prompt-regexp impl)) + (deb-preamble-rx (geiser-repl--debugger-preamble-regexp impl)) (cname (geiser-repl--repl-name impl))) (unless (and binary prompt-rx) (error "Sorry, I don't know how to start a REPL for %s" impl)) @@ -169,7 +175,10 @@ you at that point.") `(,cname ,(current-buffer) ,binary nil ,@args)) (geiser-repl--wait-for-prompt 10000) (geiser-repl--history-setup) - (geiser-con--setup-connection (current-buffer) prompt-rx deb-prompt-rx) + (geiser-con--setup-connection (current-buffer) + prompt-rx + deb-prompt-rx + deb-preamble-rx) (add-to-list 'geiser-repl--repls (current-buffer)) (geiser-repl--set-this-buffer-repl (current-buffer)) (geiser-repl--startup impl))) @@ -279,7 +288,8 @@ module command as a string") (comint-redirect-cleanup) (geiser-con--setup-connection (current-buffer) comint-prompt-regexp - geiser-con--debugging-prompt-regexp)) + geiser-con--debugging-prompt-regexp + geiser-con--debugging-preamble-regexp)) ;;; REPL history and clean-up: -- cgit v1.2.3