Fuco1 on Anchored Fontlocking

Matus Goljer (Fuco1) has a really meaty post on one of the dark corners in Emacs. By dark corner I mean little understood and complicated. Fuco1 doesn’t think very much of the font lock logic, depending, as it does, on regular expressions1. Never-the-less, he admits, it does work very well in practice. Fuco1 had a use case that he thought would serve as an example of a problem that the existing font lock logic couldn’t handle. When he looked into it a bit more, he discovered that the mechanism is a little more flexible than is generally believed and that it could, in fact, solve his problem.

I’ll let you read Fuco1’s post for the details. If you’re like me, you’ll probably never have occasion to need the full flexibility of the font lock mechanism but the details of his solution are fascinating anyway. It’s not documented very well so Fuco1 had to tease out the details by reading the code. Even the commentary in font-lock.el, which I read using the wonderful finder-commentary, doesn’t tell the whole story.

My takeaway from all this is that Emacs has some (more or less) hidden capabilities that the average user won’t ever stumble on and that sometimes you have to get your hands dirty and read the code to find out what’s going on. It’s yet another reason to spend a little time learning to read Elisp.

Footnotes:

1

Ironically, one of authors of the font lock package is Jamie Zawinski.

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