[plt-scheme] ( for [

From: Richard Cobbe (cobbe at ccs.neu.edu)
Date: Mon Apr 10 07:45:25 EDT 2006

On Sun, Apr 09, 2006 at 11:42:05PM -0400, Nicholas Chubrich wrote:
> Is there any kosher way to essentially swap the square-bracket key
> with the parentheses, i.e. have Shift-9 output [ and [ output ( ?
> Could this be done without modifying DrScheme?

Probably, yes, although if you do it outside DrScheme it will almost
certainly affect all other applications on the same system (for the same
user).

What operating system are you using?

If you're using a unix, you can definitely do this at the X11 level,
although this will affect all of your other X clients as well, as noted
above.  Take a look at the xmodmap manpage, and put the appropriate
xmodmap incantations in your .xsession or .xinitrc file.  (You can use
xev to find out what keycodes the various keys on your keyboard actually
generate.)

For the X11 server on my Mac, the following would do the trick:

    xmodmap -e "keycode 33 = 9 bracketleft ordfeminine periodcentered"
    xmodmap -e "keycode 37 = 0 bracketright masculine slingelowquotemark"
    xmodmap -e "keycode 41 = parenleft braceleft leftdoublequotemark rightdoublequotemark"
    xmodmap -e "keycode 38 = parenright braceright leftsinglequotemark rightsinglequotemark"

But be aware that the keycodes will vary from system to system (and
possibly keyboard to keyboard), as will the other keysyms attached to
these keys.  (For the Mac, each keycode is bound to 4 keysyms: the key
itself, shift+key, option+key, and option+shift+key.)  You can use
xmodmap -pke to print out the current key map for editing purposes.

I'm fairly certain there are ways to do this sort of thing under Windows
and MacOS X, but I don't happen to know what they are off the top of my
head.  Googling for keymaps is probably a good place to start.

And, of course, I should state clearly that, if you're running DrScheme
on a Mac, doing the xmodmap trick will only work if you're running
DrScheme as an X11 client, which is almost certainly not the case.  I
just did that on a Mac because that's what I'm sitting at right now, so
I could look up the documentation.

Hope this helps,

Richard


Posted on the users mailing list.