[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 19:35:37 EDT 2012

I use the following language declaration:
#lang s-exp framework/keybinding-lang

And when I start Dr. Racket, I get:

Error when installing the keybindings C:\Users\oleg\Documents\racket-keys.rkt:

link: reference (phase 0) to a variable in module "C:\Program
Files\Racket\collects\drracket\tool-lib.rkt" that is uninitialized
(phase level 0); reference appears in module:
"C:\Users\oleg\Documents\racket-keys.rkt" in: drracket:rep:text<%>


On Wed, Jul 11, 2012 at 4:17 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> When you say "crashes Dr. Racket", what do you mean? (What is the
> precise error message?)
>
> Are you using this as a keybinding file?
>
> On Wed, Jul 11, 2012 at 3:02 PM, Oleg Gunkin <oleg.gunkin at gmail.com> wrote:
>> 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)
>>   (keybinding
>>    key
>>    (lambda (editor event)
>>      (send
>>       (send editor get-keymap)
>>       call-function
>>       (if (is-a? editor drracket:rep:text<%>)
>>           function
>>           original-function)
>>       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?
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users

Posted on the users mailing list.