Coloring Camel Case

Marcin Borkowski (mbork) has a cute post that addresses the abomination known as camel case. I use the term camel case to cover actual camel case as well as any of its illegitimate siblings such as studly caps. As I’ve said before, it makes text hard to type and hard to read with no discernible benefit.

Someone on the Emacs mailing list suggested coloring camel case identifiers so that all the odd subwords are in one color and all the even subwords in another. Borkowski took the idea and ran with it producing a proof-of-concept mode based on glasses mode. It turned out to be easy, at least for the simple cases. One thing I learned from his post is that of version 29.1, the overlay implementation was rewritten making it faster.

For me, the takeaway from Borkowski’s post is not a way of making the horror of camel case marginally more legible. It’s about how easy Emacs makes it to implement even a seemingly difficult feature. Or for that matter, to implement it at all. As I said, I have no interest in tinkering with camel case but I love how Emacs makes it relatively simple to tinker with even the seemingly low level display features. Zamanky’s ongoing project to replace certain words with an emoji is another example of this. The emojis are displayed instead of the keywords but the underlying text is unchanged.

Overlays are a powerful technique built into Emacs that can be used in all sorts of projects as Borkowski and Zamanky demonstrate.

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