[plt-scheme] Chaining Keymaps

From: Ed Cavazos (proteus at theworld.com)
Date: Thu May 15 01:40:58 EDT 2003

I'm trying to understand how to chain keymaps together. I'm comparing
how they work to Emacs keymaps, but maybe they aren't that similar
afterall. In Emacs there's a global-keymap. Using MrEd notation, "c:x"
in global-keymap would chain to ctl-x-map. "5" in ctl-x-map would
chain to ctl-x-5-map. Finally, "2" in ctl-x-5-map would invoke
make-frame. So using that as a model, here's some MrEd code:
(which doesn't quite work)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define global-keymap (make-object keymap%))

(define ctl-x-map (make-object keymap%))

(define ctl-x-5-map (make-object keymap%))

(send ctl-x-5-map map-function "c:x;5;2" "make-frame")

(send ctl-x-5-map add-function "make-frame"
      (lambda (value event) (make-frame)))

(send global-keymap chain-to-keymap ctl-x-map   #f)
(send ctl-x-map     chain-to-keymap ctl-x-5-map #f)

(send *text* set-keymap global-keymap)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I was confused at first because the chain-to-keymap method just
requires a "next keymap" parameter, but no "prefix key" parameter to
indicate how to jump to a child keymap. The docs led me to believe
that you just add child keymaps and populate those with mappings
accordingly. Then the system would just start from the root of the
keymap and "search" the children for an appropriate one.

Sorry about all the MrEd questions of late... I searched through the
mbox archive for "keymap" but didn't find too much.

MrEd



Posted on the users mailing list.