How to configure the Racket interpreter to support command history?
Asked Answered
K

1

9

I've just set up Racket and have been trying out the interpreter.

However, I can't seem to go up and down the command history using the arrows (or Ctrlp/Ctrln for that matter) or use Ctrlr to search through it.

Is that even supported? Can I build it with that feature in?

Coming from a Python background I'm very used to these features and would like to have them available for Racket too.

Kelleekelleher answered 26/5, 2015 at 10:0 Comment(0)
B
11

DrRacket IDE

In the Racket IDE you can hold CTRL with arrow keys to get to previously written statements in the interactions window.

Racket in terminal

eXtended REPL

Extended REPL gives read-line features like using arrows to go back in history as well as you can search with CTRL+r. It has in addition REPL-commands like ,apropos. By entering ,help you get a list of commands you can use or you can consult the documentation. To use it you can:

  1. enter (require xrepl) to activate it
  2. run racket with racket -il xrepl
  3. install it once and for all from xrepl by evaluating ,install!

Standard readline

You have normal readline which you can activate by:

  1. enter (require readline/rep) to activate it
  2. run racket with racket -il readline
  3. install in once and for all by evaluating (install-readline!).
Beane answered 26/5, 2015 at 10:34 Comment(7)
Hmm, I get ; Warning: no readline support (ffi-lib: couldn't open "libreadline.so.5" (/usr/lib64/libreadline.so.5: undefined symbol: PC)) so I guess it can't be helped in my case, but it looks like all of the above does work. Thanks!Kelleekelleher
@Kelleekelleher Try starting racket with env LD_PRELOAD=/usr/lib64/libcurses.so racket. (It's a hint from this page, but I have no idea if it will work)Beane
@Kelleekelleher If you can't get readline to work, try a pre-release version from download.racket-lang.org. The pre-release version has a fallback version of "readline" (where "" means I can't remember what the fallback is).Matelote
@Beane Cool, that seemed to work, thanks very much!Kelleekelleher
I can't make the ctrl + r work with my racket REPL. Does anyone run into the same thing as me?Coen
@Coen It might be that your terminal or OS is overriding CTRL + r for some other purpose. Eg. I have the same issue in iTerm on MacOS, but I'm not using that combination so much as to have investigated why that is.Beane
@Beane yes you are right. I've tried that and it turns out the ctrl+r works very well on my ubuntu virtual machine, but I just can not make it work on my macOS no matter with iTerm or macOS's default terminal. Does anyone have a successful working experience of it on the macOS?Coen

© 2022 - 2024 — McMap. All rights reserved.