         (remove (current-buffer) geiser-repl--closed-repls)))
 
 (defun geiser-repl--input-filter (str)
-  (and (not (string-match "^\\s *$" str))
-       (not (string-match "^,quit *$" str))))
+  (not (or (geiser-con--is-debugging)
+           (string-match "^\\s *$" str)
+           (string-match "^,quit *$" str))))
+
+(defun geiser-repl--old-input ()
+  (save-excursion
+    (let ((end (point)))
+      (backward-sexp)
+      (buffer-substring (point) end))))
 
 (defun geiser-repl--history-setup ()
   (set (make-local-variable 'comint-input-ring-file-name)
        (geiser-repl--history-file))
   (set (make-local-variable 'comint-input-ring-size) geiser-repl-history-size)
   (set (make-local-variable 'comint-input-filter) 'geiser-repl--input-filter)
+  (set (make-local-variable 'comint-get-old-input) 'geiser-repl--old-input)
   (add-hook 'kill-buffer-hook 'geiser-repl--on-kill nil t)
   (comint-read-input-ring t)
   (set-process-sentinel (get-buffer-process (current-buffer))

  ("Edit symbol" "\M-." geiser-edit--symbol-at-point
   :enable (symbol-at-point))
  --
  ("Switch to module..." ("\C-c\C-m" "\C-cm") switch-to-geiser-module)
  ("Import module" ("\C-c\C-i" "\C-ci") geiser-repl-import-module)
  --
  ("Previous matching input" "\M-p" comint-previous-matching-input-from-input
   "Previous input matching current")

  --
  (custom "REPL options" geiser-repl))

(define-key geiser-repl-mode-map [menu-bar completion] 'undefined)


;;; Unload:
