Using Hook Functions

Arialdo Martini has a nice post on how to configure and use Emacs hook functions. Most Emacs users have a general idea about hook functions but Martini goes into more detail, especially as concerns their use in major modes. The TL;DR is that when a major mode starts, it calls a series of functions called “hook functions”.

That may seem a bit esoteric and something that only very advanced users would want to do but Martini gives some everyday uses that make sense for any Emacs user. His post is a reasonably detailed explanation of how to use hook functions and is well worth reading. He includes information how to handle conflicts where more than one one mode in a major mode hierarchy add the same function.

One thing that Martini covers that I didn’t know about is how to walk the major mode hierarchy to find out what modes the current mode is derived from. You probably won’t ever need to do this but it is interesting and points to how to investigate problems with conflicting hook functions.

The post is apparently Martini’s interpretation of some lessons he took from Protesilaos Stavrou and the usual Prot excellence shines through. As I say, it’s well worth taking a look at the post to get a better idea of what’s going on with hook functions.

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