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:
#lang racket/base
(require quickscript
racket/class
racket/gui/event)
;; 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.
(define-script find-keymap
#:label "keymap"
#:menu-path ("Scratch")
(λ (selection #:interactions ints)
(define km (send ints get-keymap))
(send km call-function "put-previous-sexp" ints (new event%) #t)
#f))
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.)
I've never worked with quickscripts before. It seems I was able to activate it, as I get an entry Scratch/keymap in DrRacket's Script menu. Selecting keymap actually recalls the history, but ...
yes, that's the idea. If I have to select a menu item to go through the history, I might as well use ctrl-up as before.
Ok, that it (probably) doesn't work is also useful information (in a way).
You should be able to use a custom keybindings file to rebind Ctrl-P via the method described on the shortcuts page. Here's an example file which worked for me:
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.