[plt-scheme] Overriding the keymap in drscheme

From: Guillaume Marceau (gmarceau at cs.brown.edu)
Date: Tue Aug 8 11:21:24 EDT 2006

On Thu, 27 Jul 2006 21:25:38 -0500
Robby Findler <robby at cs.uchicago.edu> wrote:


> DrScheme overrides that method many times; none of them break file| 
> open. Perhaps you can explain what you mean by that?

What I mean is, when you override the INSERT method you also change the
behavior of file/open, because file/open is implemented as a loop that
calls INSERT for each 1k chunk (or so).

For DivaScheme, I was trying to disable all inserts generated from
keystrokes, but I couldn't find a way to do that without also disabling
file/open.

No matter.  We ended up doing something completely different.  If you
remember, I was trying to entirely override DrScheme's key bindings.
The solution was to postpone installing the key map until the very end
of the boot process, and play dummy-head tricks with the key map
sequence.  Like this:

      (define (to-command-mode)
        (preferences:set 'divascheme:on? #t)
        (send (get-keymap) chain-to-keymap command-keymap #t))

      (let ([dummy-head-keymap (new keymap:aug-keymap%)]
            [original-keymap (get-keymap)])
        (send dummy-head-keymap chain-to-keymap original-keymap #t)
        (send dummy-head-keymap chain-to-keymap f4-keymap #t)
        (set-keymap dummy-head-keymap))
        (to-command-mode)))

      (queue-callback
       (lambda ()
         (when (preferences:get 'divascheme:on?)

It is a huge hack, but it will do for now.


Posted on the users mailing list.