Which Function Mode

Ruslan Bekenev has an interesting post that discusses which-function-mode. I was vaguely familiar with it before I read Bekenev’s post but never thought much about it. Bekenev, however, makes a good case for it. His use case is that he has long functions and deep Org trees and it’s nice to be able to see at a glance where he is.

Wait. What? Org trees? What do they have to do with functions? Probably nothing but the thing is that when which-function-mode is on, it does an excellent job of telling you were you are regardless of what object it’s dealing with. If you’re in an Org tree, it will tell you what subheading you’re in. If you’re in a code buffer it does a similarly good job. I tried it out in my init.el and besides functions, it identified setq, devar, define-key, use=package, and, doubtless, many other objects.

Bekenev says that it worked on most of the files he tried except for files containing HTML. Still, it seems pretty complete.

If you’re a good doobie and keep your functions short it may not do much for you and in any event, if you’re working in a function you’d better know what function it is. On the other hand, it’s easy to imagine searching for a variable and landing in the middle of a function and having no idea what function it is. It may, ironically, be more useful in Org files. Of course, that’s just my take and you may have a very different opinion.

In any event, which-function-mode is a handy thing to know about. Bekenev’s post is short and well worth a minute or two of your time. Check it out.

Update [2024-02-04 Sun]: Fixed link.

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