diff options
author | Bart Schaefer <barts@users.sourceforge.net> | 2001-04-14 16:34:14 +0000 |
---|---|---|
committer | Bart Schaefer <barts@users.sourceforge.net> | 2001-04-14 16:34:14 +0000 |
commit | 7286f7bc374b5016238581fd50ce3383a4aab8c8 (patch) | |
tree | 36b6573278ac0e98f9e369718fe86309dc4ee113 | |
parent | d7417bdc0e500fff5f6890c3ee1f70dff54c3f18 (diff) | |
download | zsh-7286f7bc374b5016238581fd50ce3383a4aab8c8.tar.gz zsh-7286f7bc374b5016238581fd50ce3383a4aab8c8.tar.xz zsh-7286f7bc374b5016238581fd50ce3383a4aab8c8.zip |
Delete duplicated text in development guide.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Etc/zsh-development-guide | 76 |
2 files changed, 7 insertions, 74 deletions
diff --git a/ChangeLog b/ChangeLog index 94b730279..2e9d4aa74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-04-14 Bart Schaefer <schaefer@zsh.org> + + * unposted: Etc/zsh-development-guide: The entire section on hook + functions was repeated twice; delete one copy. + 2001-04-13 Oliver Kiddle <opk@zsh.org> * 13982: Completion/Base/Utility/_multi_parts, diff --git a/Etc/zsh-development-guide b/Etc/zsh-development-guide index 8f67eb43b..6917621b2 100644 --- a/Etc/zsh-development-guide +++ b/Etc/zsh-development-guide @@ -630,80 +630,6 @@ that are changed or called very often. These functions, structure defining the hook instead of the name and otherwise behave like their counterparts. -Modules can also define function hooks. Other modules can then add -functions to these hooks to make the first module call these functions -instead of the default. - -Again, an array is used to define hooks: - - static struct hookdef foohooks[] = { - HOOKDEF("foo", foofunc, 0), - }; - -The first argument of the macro is the name of the hook. This name -is used whenever the hook is used. The second argument is the default -function for the hook or NULL if no default function exists. The -last argument is used to define flags for the hook. Currently only one -such flag is defined: `HOOKF_ALL'. If this flag is given and more than -one function was added to the hook, all functions will be called -(including the default function). Otherwise only the last function -added will be called. - -The functions that can be used as default functions or that can be -added to a hook have to be defined like: - - /**/ - static int - foofunc(Hookdef h, void *data) - { - ... - } - -The first argument is a pointer to the struct defining the hook. The -second argument is an arbitrary pointer that is given to the function -used to invoke hooks (see below). - -The functions to register and de-register hooks look like those for -the other things that can be defined by modules: - - /**/ - int - boot_foo(Module m) - { - int ret; - - ret = addhookdefs(m->nam, foohooks, sizeof(foohooks)/sizeof(*foohooks)) - ... - } - ... - /**/ - int - cleanup_foo(Module m) - { - deletehookdefs(m->nam, foohooks, sizeof(foohooks)/sizeof(*foohooks)); - ... - } - -Modules that define hooks can invoke the function(s) registered for -them by calling the function `runhook(name, data)'. The first argument -is the name of the hook and the second one is the pointer given to the -hook functions as their second argument. Hooks that have the `HOOKF_ALL' -flag call all function defined for them until one returns non-zero. -The return value of `runhook()' is the return value of the last hook -function called or zero if none was called. - -To add a function to a hook, the function `addhookfunc(name, func)' is -called with the name of the hook and a hook function as arguments. -Deleting them is done by calling `deletehookfunc(name, func)' with the -same arguments as for the corresponding call to `addhookfunc()'. - -Alternative forms of the last three function are provided for hooks -that are changed or called very often. These functions, -`runhookdef(def, data)', `addhookdeffunc(def, func)', and -`deletehookdeffunc(def, func)' get a pointer to the `hookdef' -structure defining the hook instead of the name and otherwise behave -like their counterparts. - Finally, modules can define wrapper functions. These functions are called whenever a shell function is to be executed. @@ -731,6 +657,7 @@ The first two arguments should only be used to pass them to is the name of the function to be executed. The arguments passed to the function can be accessed vie the global variable `pparams' (a NULL-terminated array of strings). + The return value of the wrapper function should be zero if it calls `runshfunc()' itself and non-zero otherwise. This can be used for wrapper functions that only need to run under certain conditions or @@ -778,6 +705,7 @@ de-registered. But if there is some module-global state that has to be finalized (e.g. some memory that has to be freed) and that is used by the wrapper functions finalizing this data in the cleanup function won't work. + This is why there are two functions each for the initialization and finalization of modules. The `boot'- and `cleanup'-functions are run whenever the user calls `zmodload' or `zmodload -u' and should only |