1

Suppose I try to use an undefined variable in MIT Scheme's REPL:

1 ]=> blablabla

;Unbound variable: blablabla
;To continue, call RESTART with an option number:
; (RESTART 3) => Specify a value to use instead of blablabla.
; (RESTART 2) => Define blablabla to a given value.
; (RESTART 1) => Return to read-eval-print level 1.

2 error> 

This automatically brings me into the debugger. To exit the debugger, I have to type (restart 1). Is there an alternative way that does not involve typing 11 characters just to exit the debugger? It's a bit silly that all three options involve typing 11 characters.

Flux
  • 9,805
  • 5
  • 46
  • 92

2 Answers2

1

According to Flux's answer, pressing CTRLC twice will work with mit-scheme, but not when it runs within rlwrap

In order to make rlwrap more "transparent" with regard to CTRLC and CTRLG

  • Use the -W (--polling) option: rlwrap -W will make rlwrap wake up every 40 msecs to check whether the client has changed its terminal settings (in your case, its interrupt character)
  • Add a few lines to your .inputrc:
$if mit-scheme
  "\C-c" rlwrap-direct-keypress
  "\C-g" rlwrap-direct-keypress
$endif

Those lines will tell rlwrap (when wrapping mit-scheme) to pass on CTRLC and CTRLG even when in the middle of a line edit.

With those two tweaks, I can't tell the difference anymore in interrupt behaviour between rlwrapped and unwrapped mit-scheme

-W needs rlwrap >= 0.41, rlwrap-direct-keypress >= 0.43

For a more in-depth explanation why this works (and why the options and .inputrc entries are necessary) see this rlwrap issue on Github.

Hans Lub
  • 5,513
  • 1
  • 23
  • 43
  • Should the `~/.inputrc` entries be enclosed in `$if mit-scheme ... $endif`? – Flux Feb 14 '21 at 13:36
  • Typos: `-w` should be `-W`, and `rlwrap -w` should be `rlwrap -W` instead. – Flux Feb 14 '21 at 13:44
  • (I corrected the typos, thanks!!). Yes, better enclose the lines in `$if..$endif` even though you will probably be allright when you don't (as the terminal will catch the CTRL+C before `rlwrap` can, and CTRL+G is seldom used. – Hans Lub Feb 14 '21 at 14:00
  • I noticed that I don't even need to add those `rlwrap-direct-keypress` lines to `~/.inputrc`. `rlwrap -W mit-scheme` alone seems to solve the Ctrl-c Ctrl-c problem. Is this normal? – Flux Feb 14 '21 at 16:55
  • `-W` is the more important setting. Without the `rlwrap-direct-keypress`, for me sometimes the _first_ CTRL+C seemed to misfire. Apart from that, `-W` on its own will do. – Hans Lub Feb 14 '21 at 17:12
0

According to the MIT Scheme user manual's section about interrupting the REPL:

  • C-c C-c
  • C-g

Abort whatever Scheme evaluation is currently running and return to the top-level REPL. If no evaluation is running, this is equivalent to evaluating (cmdl-interrupt/abort-top-level)

So there are two ways to quickly exit the debugger:

  • CtrlcCtrlc — Unfortunately, this method is unsuitable when using MIT Scheme with rlwrap (i.e. rlwrap mit-scheme). When in the debugger, rlwrap somehow causes the second Ctrlc to be ignored.

  • Ctrlg — This works well with rlwrap, and requires less key presses than the above.

Flux
  • 9,805
  • 5
  • 46
  • 92