For an explanation and examples of hooks see using hooks.
/usr/share/Macaulay2/Core/methods.m2:587:52-596:32: --source code: addHook(MutableHashTable, Thing, Function) := opts -> (store, key, hook) -> ( -- this is the hashtable of Hooks for a specific key, which stores HookAlgorithms and HookPriority if not store#?key then store#key = new MutableHashTable from { HookAlgorithms => new MutableHashTable, -- a mutable hash table "strategy key" => "strategy code" HookPriority => new MutableList}, -- a mutable list of strategy keys, in order store = store#key; ind := #store.HookPriority; -- index to add the hook in the list; TODO: use Priority to insert in the middle? alg := if opts.Strategy =!= null then opts.Strategy else ind; store.HookPriority#ind = alg; store.HookAlgorithms#alg = hook)
The object addHook is a method function with options.