diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-10-31 19:47:40 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-10-31 19:47:40 +0100 |
commit | df85a7034789007da33e2b3a5efc12a32e53a651 (patch) | |
tree | ff4fcdf34ec3bb8da98b95dc14e26b7351622657 | |
parent | 9325189d4b3cfa2207c015b4f60cf397089edc9f (diff) | |
download | geiser-chez-df85a7034789007da33e2b3a5efc12a32e53a651.tar.gz geiser-chez-df85a7034789007da33e2b3a5efc12a32e53a651.tar.bz2 |
REPL: RET on an error jumps to it
-rw-r--r-- | elisp/geiser-repl.el | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 900ba16..c5d6543 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -463,13 +463,20 @@ With a prefix argument, force exit by killing the scheme process." (insert "\n") (lisp-indent-line))) +(defun geiser-repl--last-prompt-end () + (if comint-last-prompt-overlay + (overlay-end comint-last-prompt-overlay) + (save-excursion (geiser-repl--bol) (point)))) + +(defun geiser-repl--last-prompt-start () + (if comint-last-prompt-overlay + (overlay-start comint-last-prompt-overlay) + (save-excursion (geiser-repl--bol) (point)))) + (defun geiser-repl--nesting-level () - (let ((begin (if comint-last-prompt-overlay - (overlay-end comint-last-prompt-overlay) - (save-excursion (geiser-repl--bol) (point))))) - (save-restriction - (narrow-to-region begin (point-max)) - (geiser-syntax--nesting-level)))) + (save-restriction + (narrow-to-region (geiser-repl--last-prompt-end) (point-max)) + (geiser-syntax--nesting-level))) (defun geiser-repl--send-input () (let* ((proc (get-buffer-process (current-buffer))) @@ -487,13 +494,14 @@ With a prefix argument, force exit by killing the scheme process." (defun geiser-repl--maybe-send () (interactive) (let ((p (point))) - (end-of-line) - (if (<= (geiser-repl--nesting-level) 0) - (geiser-repl--send-input) - (goto-char p) - (if geiser-repl-auto-indent-p - (geiser-repl--newline-and-indent) - (insert "\n"))))) + (cond ((< p (geiser-repl--last-prompt-start)) + (ignore-errors (compile-goto-error))) + ((progn (end-of-line) (<= (geiser-repl--nesting-level) 0)) + (geiser-repl--send-input)) + (t (goto-char p) + (if geiser-repl-auto-indent-p + (geiser-repl--newline-and-indent) + (insert "\n")))))) (define-derived-mode geiser-repl-mode comint-mode "REPL" "Major mode for interacting with an inferior scheme repl process. |