The idea behind a 'hook' is that it is a place where code can be inserted without having to modify the original code. They're pretty common in emacs, for instance, where lots of packages provide hooks for easy extension in your .emacs file.
So, if there's a function bound to that name in the hooks table, it is run with the arguments. You only call 'defhook when you want to bind to that point in the code.
This is a rather interesting implementation to me, because I'm used to the emacs-lisp concept, where a hook is actually a list of functions that all get called on the arguments, so it can be added to multiple times. The corresponding names in elisp are 'run-hooks and 'add-hook. https://www.gnu.org/software/emacs/manual/html_node/elisp/Ho...
OK, I have a stupid question. How do I remove an item from a table?
Apparently it's (rem test table) but everything I've tried fails with "Can't take car of #hash(("foo" . (app-run "foo")))" I also thought I might have to assign nil to it but that returns an error as well. Here is my current code if it helps... it's just minor edits of prompt.arc, assignment and running an app in a hook all work:
(def app-unhook (user app)
(do ((rem !app hooks*)
(editor-page user "Hook removed from " app))))
(def app-hook (user app)
(if (file-exists (app-filepath app))
(do ((= (hooks* app) `(app-run ,app))
(editor-page user "Hook applied to " app)))
(editor-page user "Error: No application " app)))
I feel like I'm probably missing something obvious.