   (or (geiser-repl--only-impl-p)
       (and (eq major-mode 'geiser-repl-mode) geiser-impl--implementation)
       (geiser-repl--read-impl prompt)))
+
++
+;;; Prompt &co.
+
+(defun geiser-repl--last-prompt-end ()
+  (cond ((and (boundp 'comint-last-prompt) (markerp (cdr comint-last-prompt)))
+         (marker-position (cdr comint-last-prompt)))
+        ((and (boundp 'comint-last-prompt-overlay) comint-last-prompt-overlay)
+         (overlay-end comint-last-prompt-overlay))
+        (t (save-excursion (geiser-repl--bol) (point)))))
+
+(defun geiser-repl--last-prompt-start ()
+  (cond ((and (boundp 'comint-last-prompt) (markerp (car comint-last-prompt)))
+         (marker-position (car comint-last-prompt)))
+        ((and (boundp 'comint-last-prompt-overlay) comint-last-prompt-overlay)
+         (overlay-start comint-last-prompt-overlay))
+        (t (save-excursion (geiser-repl--bol) (point)))))
 
  


(defun geiser-repl--beginning-of-defun ()
  (save-restriction
    (when comint-last-prompt-overlay
      (narrow-to-region (overlay-end comint-last-prompt-overlay) (point)))
    (let ((beginning-of-defun-function nil))
      (beginning-of-defun))))


(defun geiser-repl--is-debugging ()
  (let ((dp (geiser-con--connection-debug-prompt geiser-repl--connection)))
    (and dp
         (save-excursion
           (goto-char (geiser-repl--last-prompt-start))
           (re-search-forward dp (geiser-repl--last-prompt-end) t)))))

(defun geiser-repl--connection* ()
  (let ((buffer (geiser-repl--set-up-repl geiser-impl--implementation)))
