Bending Emacs 6: Overlays

Álvaro Ramírez has another video in his Bending Emacs series out. It’s about something that we see all the time but may not even be aware is happening or how it works. The subject of the video is overlays.

Overlays are a way of decorating, changing, or hiding text. A nice feature of them is that the underlying text is not changed. Rather the changes are simply overlayed on top of it and when the overlay is removed, the underlying text in the buffer is revealed again.

Although it may sound complicated or obscure, it’s actually pretty simple: you simply specify the beginning and end of the text you wish to overlay and make a simple call insert the overlay. Ramírez has a bit of code that shows several different type of overlays and invokes them one by one in the video. It’s a nice demonstration because you get to see many of the things overlays can do.

After those demonstrations, Ramírez shows some “experiments” he’s done with overlays. One of them completely change the look of the text by adding images and looking up and adding additional data on the fly. Another takes a regular expression and “redacts” anything it matches by replacing the text with x’s.

The video is 11 minutes, 57 seconds so plan accordingly but it is, believe me, worth a few minutes of your time to explore what’s possible with overlays.

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