B.5 Hooks for integrating libraries

Some libraries realise an entirely new programming paradigm on top of Prolog. An example is XPCE which adds an object-system to Prolog as well as an extensive set of graphical primitives. SWI-Prolog provides several hooks to improve the integration of such libraries. See also section 4.4 for editing hooks and section 4.9.3 for hooking into the message system.

Hook, normally not defined. This hook is called by the 'L' command of the tracer in the module user to list the currently called predicate. This hook may be defined to list only relevant clauses of the indicated Goal and/or show the actual source-code in an editor. See also portray/1 and multifile/1.
Hook for the debugger-control predicates that allows the creator of more high-level programming languages to use the common front-end predicates to control de debugger. For example, XPCE uses these hooks to allow for spying methods rather then predicates. Action is one of:
Hook in spy/1. If the hook succeeds spy/1 takes no further action.
Hook in nospy/1. If the hook succeeds spy/1 takes no further action. If spy/1 is hooked, it is advised to place a complementary hook for nospy/1.
Hook in nospyall/0. Should remove all spy-points. This hook is called in a failure-driven loop.
Hook in debugging/0. It can be used in two ways. It can report the status of the additional debug-points controlled by the above hooks and fail to let the system report the others or it succeed, overruling the entire behaviour of debugging/0.
Hook into help/0 and help/1. If the hook succeeds, the built-in actions are not executed. For example, ?- help(picture). is caught by the XPCE help-hook to give help on the class picture. Defined actions are:
User entered plain help/0 to give default help. The default performs help(help/1), giving help on help.
Hook in help/1 on the topic What.
Hook in apropos/1 on the topic What.