modularize hooks
1.0.2Generic hooks and triggers extension for modularize.
Table of Contents
About Modularize-Hooks
This is a simple extension to Modularize that allows modules to define and trigger hooks, which other modules can... well, hook on to. While such a system is very easy to create for your own projects, it's a good idea to have a standard form of doing it that doesn't interfere in any other way.
How To
In order to define hooks, you need to have a module. See Modularize on how to get that set up. If the modularize-hooks system has already been loaded prior to your module definition, everything should be ready and set up. Otherwise, you may call HOOKIFY
on your module to initialise it. Creating hooks is similar to creating generic functions:
(define-hook documentation-finished (project)
"Hook called whenever documentation for a project is finished.")
This defines a hook with a single argument, the project. In order to latch on to this hook, you may define a trigger. It is not strictly necessary to be within a module context to define triggers, but it is recommended in order to keep things tidy.
(define-trigger other-module:documentation-finished (project)
(format T "~&Finished project documentation for ~a" project))
If you want to have multiple triggers on the same hook within the same package, you need to specify some kind of identifier to distinguish it from others.
(define-trigger (other-module:documentation-finished extra) ()
(format T "~&ゆっくりしていってね!!!"))
Note that in this second example we did not provide any arguments to the trigger. Triggers may either accept no arguments if they have no use for them, or they need to match the arguments list of the hook. A simple test to assert this is done on trigger definition. Actually triggering the hook with its trigger is merely a question of calling TRIGGER
:
(trigger 'other-module:documentation-finished :modularize-hooks)
System Information
Definition Index
-
MODULARIZE-HOOKS
- ORG.SHIRAKUMO.RADIANCE.LIB.MODULARIZE.HOOKS
- HOOKS
No documentation provided.-
EXTERNAL CLASS HOOK
No documentation provided. -
EXTERNAL CLASS STICKY-HOOK
No documentation provided. -
EXTERNAL FUNCTION DEHOOKIFY
- &OPTIONAL
- MODULE
- &REST
Returns the module to one that is not capable of hooks. In essence this merely removes all functions from the hooks package and deletes it.
-
EXTERNAL FUNCTION HOOK
- NAME
- &OPTIONAL
- MODULE
- ERROR
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF HOOK)
- HOOK
- NAME
- &OPTIONAL
- MODULE
- &REST
No documentation provided. -
EXTERNAL FUNCTION HOOKIFY
- &OPTIONAL
- MODULE
- &REST
Turns the module into one capable of hooks. In essence this merely defines a new package with a matching name.
-
EXTERNAL FUNCTION LIST-HOOKS
- &OPTIONAL
- MODULE
- &REST
No documentation provided. -
EXTERNAL FUNCTION REMOVE-HOOK
- NAME
- &OPTIONAL
- MODULE
- &REST
Removes the hook as named.
-
EXTERNAL FUNCTION REMOVE-TRIGGER
- HOOK
- &OPTIONAL
- IDENT
- MODULE
- &REST
Attempts to remove the trigger from the hook.
-
EXTERNAL FUNCTION TRIGGER
- HOOK
- &REST
- ARGS
- &REST
Calls all triggers registered on the hook with the given arguments.
-
EXTERNAL GENERIC-FUNCTION ARGLIST
- OBJECT
- &REST
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF ARGLIST)
- NEW-VALUE
- OBJECT
- &REST
No documentation provided. -
EXTERNAL GENERIC-FUNCTION DOCSTRING
- OBJECT
- &REST
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF DOCSTRING)
- NEW-VALUE
- OBJECT
- &REST
No documentation provided. -
EXTERNAL GENERIC-FUNCTION NAME
- OBJECT
- &REST
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF NAME)
- NEW-VALUE
- OBJECT
- &REST
No documentation provided. -
EXTERNAL MACRO DEFINE-HOOK
- NAME
- ARGS
- &OPTIONAL
- DOCUMENTATION
- &REST
Defines a new hook on which triggers can be defined. The name should be a symbol from the module that the hook should belong to.
-
EXTERNAL MACRO DEFINE-HOOK-SWITCH
- ON
- OFF
- ARGS
- &REST
No documentation provided. -
EXTERNAL MACRO DEFINE-TRIGGER
- HOOK
- ARGS
- &BODY
- BODY
- &REST
Defines a new trigger on the hook. A trigger can either accept no arguments or it has to match the hook in its arguments list. The name of the trigger defaults to the *PACKAGE*. If you want to have multiple triggers for the same hook in the same package, use a list of the following structure as the HOOK argument: (hook trigger-name hook-module)