Xah Lee On Inserting Brackets In Emacs

Xah Lee has an interesting post on inserting bracket pairs in Emacs. This is exactly the same thing that I did using Key Chord Mode as I described in this post. The difference is that Lee uses Elisp code directly and has a function for every imaginable pair of brackets. If you use a lot of brackets in your HTML, as he does, it’s worth while grabbing his code.

For guys like me who use mainly parentheses, square brackets, and the occasional pair of braces, the Key Chord Mode solution works well and is easier to implement. The only pairs I have implemented are the angle brackets for HTML tags and double quotes. I’d definitely do parentheses too except that the Paredit minor mode takes care of that for me.

Lee has 22 little functions to insert these pairs so you might wonder where he finds enough key sequences to bind to them. The answer is the hyper key. None of the standard Emacs functions use the hyper key (or at least don’t use it exclusively) so it’s an ideal modifier to use with private functions. The question for most people is: what key is the hyper key?

That depends on what type of system you’re using. Windows, OS X, and Linux can all be configured with a hyper key but the key and the configuration steps differ. Fortunately, Lee’s post has a section that shows you how to configure it for all three system types. To my mind, that section is probably the most valuable part of his post. If you’d like an extra modifier key, be sure to check it out. He also has a separate page on how to set up the hyper and super keys.

This entry was posted in General and tagged . Bookmark the permalink.