Temporary Syntax Tables

Xah Lee has a nice post on how to temporarily modify a syntax table. It’s not something you want to do everyday, of course, but the example Lee gives is a real-world case.

It turns out that it’s pretty easy. Just use the with-syntax-table macro and you can change the syntax table in a way useful for the rest of the code in the macro’s body. When control exits the macro expansion, the old syntax table is restored. You can also use the macro to temporarily switch to a different syntax table. If the foregoing seems opaque, the example in Lee’s post will clear things up.

I didn’t know about the with-syntax-table macro so this post is my way of writing it down so I won’t forget. I’m sure I won’t need it often but when I do, it’s just the thing.

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