[racket] How to check if a key is pressed within interaction block, and not declaration one.

From: Oleg Gunkin (oleg.gunkin at gmail.com)
Date: Wed Jul 11 16:02:16 EDT 2012

Basically, I want to change up/down key behaviour within interaction
window to "put-next-sexp"/ "put-previous-sexp" instead moving the
cursor, but only for interaction block.

This is what I came up with:

(require drracket/tool-lib)

(define (rebind key function original-function)
   (lambda (editor event)
      (send editor get-keymap)
      (if (is-a? editor drracket:rep:text<%>)
      editor event #t))))

(rebind "down" "put-next-sexp" "next-line")
(rebind "up" "put-previous-sexp" "previous-line")

However, (is-a? editor drracket:rep:text<%>) together with (require
drracket/tool-lib) crashes Dr. Racket. Is there an alternative way to
do this?

Posted on the users mailing list.