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

  ("Previous input" "\C-c\M-p" comint-previous-input)
  ("Next input" "\C-c\M-n" comint-next-input)
  --
  (mode "Autodoc mode" ("\C-c\C-a" "\C-ca") geiser-autodoc-mode)
  ("Module documentation" ("\C-c\C-d" "\C-cd") geiser-repl--doc-module
   "Documentation for module at point" :enable (symbol-at-point))
  --
  ("Kill Scheme interpreter" "\C-c\C-q" comint-kill-subjob

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