   (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)))))
 
  

    (narrow-to-region comint-last-input-start (point-max))
    (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 ()
  (save-restriction


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

