[racket] Need Help With Keybindings

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Sep 10 17:22:04 EDT 2011

At Sat, 10 Sep 2011 12:56:29 -0700, "David G. Kay" wrote:
> Hi, everyone;
> I'd like to rebind some of the DrRacket
> editor keys.  (I'm trying to reproduce the
> idiosyncratic editor layout I'm used to;
> it has an emacs flavor but with different
> keys.)
> To start, I just want to map ^t to move
> up a line, ^v to move down, ^f to move
> left, and ^g to move right.
> I created this file ("keys.rkt"):
> #lang s-exp framework/keybinding-lang
> (keybinding "c:t" (lambda (editor evt) (send editor previous-line)))
> (keybinding "c:v" (lambda (editor evt) (send editor next-line)))
> (keybinding "c:f" (lambda (editor evt) (send editor backward-character)))
> (keybinding "c:g" (lambda (editor evt) (send editor forward-character)))
> I add the file using "Add User-defined
> Keybindings" in DrRacket.  But I get
> this message as soon as I type one of
> my rebound keys:
> Error running keybinding .../Scheme/keys.rkt:18:18
> send: no such method: previous-line for class: ...engine/test-tool.scm:36:6
> It's complaining about the previous-line
> method, but that's listed in section 7
> (Editor Functions) of the Racket Graphical
> Interface Toolkit manual:
> http://docs.racket-lang.org/gui/Editor_Functions.html?q=Editor_Functions&q=edit
> or%25&q=forward-select-word&q=key%20bindings

I can see how it's confusing, but that isn't a list of methods. It's a
list of strings that are mapped to functions in a keymap%, where the
string is eventually converted to a function through the
`call-function' method of keymap%. The extra level of indirection is an
ugly artifact of the days when parts of the GUI toolkit were
implemented in C++.

For text-editor methods, look here:


I think you want to use the `move' method.

Posted on the users mailing list.