anchor.diff:                  on_build}).
   
   -type hook() :: {atom(), atom(), non_neg_integer()}
  -    | {atom(), atom(), non_neg_integer(), integer()}.
  +| {atom(), atom(), non_neg_integer(), integer()}.
   -type hookname() :: any().
   -type hooks() :: [{hookname(), [hook()]}].
   
  
positive.code: %% the next function.
  -spec run_fold(HookName::hookname(), Args::list(), Acc::any()) -> Acc2::any().
  run_fold(HookName, Args, Acc) ->
  	case hooks_list:find(HookName) of
  		{ok, Hooks} -> run_fold1(Hooks, Args, HookName, Acc);
  		_ -> Acc
  	end.
  
  
  run_fold1([], _Args, _HookName, Acc) ->
  	Acc;
  run_fold1([{M, F} | Rest], Args0, HookName, Acc) ->
  	Args = Args0 ++ [Acc],
  	Ret = (catch apply(M, F, Args)),
  	case Ret of
          {'EXIT', Reason} ->
          	error_logger:error_msg("~p~n error running hook: ~p~n",
          		[HookName, Reason]),
              run_fold1(Rest, Args0, HookName, Acc);
          stop ->
              Acc;
  
negative.code: 
  
  start_link() ->
      _ = init_tabs(),
      gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
  
  
  init_tabs() ->
      case ets:info(?TAB, name) of
          undefined ->
              ets:new(?TAB, [ordered_set, public, named_table,
                             {read_concurrency, true},
                             {write_concurrency, true}]);
          _ ->
              true
      end.
  
  init([]) ->
      Ready = case application:get_env(hooks, wait_for_proc) of
                  {ok, Proc} when is_atom(Proc) ->
                      spawn_waiter(self(), Proc),
                      false;
                  _ ->
                      true
              end,
  
      self() ! init_internal_hooks,
  
      {ok, #state{ready=Ready}}.
  
  handle_call({reg, HookName, {Priority, MFA}}, _From, State) ->
      case do_reg(HookName, {Priority, MFA}) of
          ok ->
              maybe_build_hooks(State),
              {reply, ok, State};
          Error ->
              {reply, Error, State}
      end;
  
  handle_call({unreg, HookName, {Priority, MFA}}, _From, State) ->
      do_unreg(HookName, {Priority, MFA}),
      maybe_build_hooks(State),
      {reply, ok, State};
  
  handle_call({mreg, Hooks}, _From, State) ->
      case do_mreg(Hooks) of
          ok ->
              maybe_build_hooks(State),
              {reply, ok, State};
          Error ->
              {reply, Error, State}
      end;
  
  handle_call({munreg, Hooks}, _From, State) ->
      do_munreg(Hooks),
      maybe_build_hooks(State),
      {reply, ok, State};
  
  handle_call({enable_plugin, Application, Paths}, _From, State) ->
      case do_enable_plugin(Application, Paths) of
          ok ->
              maybe_build_hooks(State),
              {reply, ok, State};
          Error ->
              {reply, Error, State}
      end;
  handle_call({disable_plugin, Application}, _From, State) ->
      do_disable_plugin(Application),
      maybe_build_hooks(State),
      {reply, ok, State};
  
  handle_call(_Msg, _From, State) ->
      {reply, badarg, State}.
  
  
  handle_cast(_Msg, State) ->
      {noreply, State}.
  
  handle_info(ready, State) ->
      build_hooks(),
  