[plt-scheme] ( for [ on the Mac

From: Nicholas Chubrich (chubrich at cs.brandeis.edu)
Date: Mon Apr 10 22:26:09 EDT 2006

For anyone that might be interested:
	It turns out to be very easy to swap brackets and parentheses on
the Mac---and I would highly recommend it to anyone who has had even the
slightest pain from typing.  (I believe my RSI problems originated during
a night of frenzied Scheme programming: repeated hitting of the shift
key with my pinky and the 9 or 0 with my index finger.  A very awkward 
motion.  I'm criticizing the keyboard layout, not Scheme.)  There is a 
free program called Ukelele, at

	http://scripts.sil.org/ukelele

This makes it pretty trivial to re-map any key to any other.  I haven't
had any problems from doing so.  Once you have made your new keymap, you
put it in the /Library/Keyboard Layouts/ folder (or in your own library if
you share your computer); then you have to log out and log back in again.  
The layout will then appear under the Internationalization pane of the
System Preferences window, and you can follow Ukelele's instructions from
there.  It's easy to switch back to your old keyboard layout from the menu
bar in case the new layout is problematic for other applications.

> 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.