diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-07-20 22:20:16 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-07-20 22:20:16 +0200 |
commit | 7b4d5fd4a3692817c220b852c40976af7e2e0cf2 (patch) | |
tree | 57ecb5c5c81fb1e651144d43e8440f46a7c95a0f /elisp | |
parent | e181f09fce76b2fe8b870ec52dad1247c8947645 (diff) | |
download | geiser-7b4d5fd4a3692817c220b852c40976af7e2e0cf2.tar.gz geiser-7b4d5fd4a3692817c220b852c40976af7e2e0cf2.tar.bz2 |
Guile: geiser commands working at the debugging prompt.
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-connection.el | 24 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 14 |
2 files changed, 33 insertions, 5 deletions
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-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: |