In the DrRacket REPL (interaction window), I can use ctrl-up (up = arrow up) to recall one of the previous inputs. However, recently I've become used to use ctrl-p in Bash to recall previous inputs, because that's easier to type if you touch type. (It's not necessary to reach for the arrow key block.)
The problem is that if I habitually press ctrl-p in the DrRacket interaction window, I get a print dialog, which is somewhat annoying. Since I practically never need printing in DrRacket, I'd like to change the ctrl-p keybinding to be equivalent to ctrl-up. Is this possible, and if yes, how?
I found the "Keybindings" option in the "Edit" dropdown menu and the documentation on DrRacket 3.3 Keyboard Shortcuts , but I don't understand how to apply the information there to my problem.
Quickly: It appears the keymap function name is put-previous-sexp.
To call this method, you need to find the interaction's keymap, then use the keymap API to call by name. I may be able to dig a little more tomorrow.
Quickly again, here's a quickscript that does the job:
;; Scratchpad to try scripts.
;; Returns a replacement string for the selected string `selection`
;; ("" if no text is selected), or `#f` to leave the selection as is.
(λ (selection #:interactions ints)
(define km (send ints get-keymap))
(send km call-function "put-previous-sexp" ints (new event%) #t)
I guess you probably want just a keybinding. Unfortunately I was not able to overload the predefined Ctrl-p. (More and more I believe the whole keymap business needs to be rethought, but that's quite some work.)
The rebind definition above is the same as the one given on the documentation page.
It does take a bit of trial and error to work out what's going on when customising keys in this way... I suspect the documentation and / or DrRacket could be improved to make it easier to achieve quick customisations like this.