/usr/share/jed/lib/hooks.sl is in jed-common 1:0.99.19-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | % This interface is obsolete. New code should use the add_to_hook function
private variable Hooks = NULL;
private define add_hook_function (name, main_hook)
{
variable h;
h = struct
{
hook_name,
next,
main_hook_function,
list_of_hooks
};
h.hook_name = name;
h.main_hook_function = main_hook;
h.next = Hooks;
Hooks = h;
}
private define find_hook (name)
{
variable h;
#iftrue
foreach (Hooks)
{
h = ();
if (name == h.hook_name)
return h;
}
return NULL;
#endif
}
define hook_add_hook (hook_name, hook_function)
{
variable h;
variable list;
switch (hook_name)
{
case "save_buffer_hook":
add_to_hook ("_jed_write_buffer_before_hooks", hook_function);
return;
}
{
case "init_display_hook":
add_to_hook ("_jed_init_display_hooks", hook_function);
return;
}
{
case "reset_display_hook":
add_to_hook ("_jed_reset_display_hooks", hook_function);
return;
}
h = find_hook (hook_name);
if (h == NULL)
verror ("hook %s unknown to this interface", hook_name);
list = struct
{
hook_function,
next
};
list.hook_function = hook_function;
list.next = h.list_of_hooks;
h.list_of_hooks = list;
}
% This function just runs the hooks with arguments assuming that the
% hook returns nothing
private define do_simple_hook (name)
{
variable args, h;
args = __pop_args (_NARGS - 1);
h = find_hook (name);
if (h == NULL)
return;
foreach (h.list_of_hooks)
{
h = ();
@h.hook_function (__push_args(args));
}
}
define save_buffer_hook (file, mode)
{
do_simple_hook (file, mode, _function_name ());
}
add_hook_function ("save_buffer_hook", &save_buffer_hook);
define init_display_hook ()
{
do_simple_hook (_function_name ());
}
add_hook_function ("init_display_hook", &init_display_hook);
define reset_display_hook ()
{
do_simple_hook (_function_name ());
}
add_hook_function ("reset_display_hook", &reset_display_hook);
|