Emacs-style key bindings

A post by Shriram Krishnamurthi on the racket-users mailing list uncovers a hidden gem in the DrRacket programming environment:

I turn off menu key bindings:

Edit | Preferences... | Editing | General | Enable keybindings in menus

(turn it off). Now you have Alt at your disposal, and with it a good chunk of Emacs keybindings.

Indeed, turning off menu key bindings does a lot more than what its description might suggest. It rebinds a whole slew of key bindings to make the environment feel more Emacs-like.

Rebinding auto-completion

Emacs-style key bindings are nice and all, but they don't resolve the problem non-US users face when trying to use auto-completion (hint: it's to do with the way that typing [Ctrl]-[/] can be pretty awkward depending on the keyboard layout).

Fortunately, DrRacket's key bindings are customizable, if only by putting a couple of suboptimally documented incantations into a file and adding that file to DrRacket by selecting the “Add User-defined Keybindings...” menu item from the DrRacket “Edit” menu. Try using the following magical formulae:

#lang s-exp framework/keybinding-lang

;; Painfully cribbed from the stuff that racket-5.1.1/collects/drracket/private/unit.rkt
;; does.

(keybinding "m:ß"
            (λ (editor evt)
              (if (is-a? editor text:autocomplete<%>)
                  (send editor auto-complete)
                  #f)))

The above binds auto-completion to [Meta]-[ß], which is most probably pretty much useless to you. Customizing the actual key to be bound is left as an exercise for the reader.