From 7866d88131837f7c514e73c57773185ba33beb7b Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 13 Mar 2019 12:46:53 -0700 Subject: [PATCH] Added ModuleLoad hook that uses the module name as the parameter --- src/command_manager.cc | 2 ++ src/hook_manager.hh | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 91c41bd3..aff9e3fd 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -65,6 +65,8 @@ void CommandManager::load_module(StringView module_name, Context& context) module->value.loaded = true; execute(module->value.commands, context); module->value.commands.clear(); + + context.hooks().run_hook(Hook::ModuleLoad, module_name, context); } struct parse_error : runtime_error diff --git a/src/hook_manager.hh b/src/hook_manager.hh index 1653791c..38d1c611 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -57,12 +57,13 @@ enum class Hook WinCreate, WinDisplay, WinResize, - WinSetOption + WinSetOption, + ModuleLoad }; constexpr auto enum_desc(Meta::Type) { - return make_array, 41>({ + return make_array, 42>({ {Hook::BufCreate, "BufCreate"}, {Hook::BufNewFile, "BufNewFile"}, {Hook::BufOpenFile, "BufOpenFile"}, @@ -104,6 +105,7 @@ constexpr auto enum_desc(Meta::Type) {Hook::WinDisplay, "WinDisplay"}, {Hook::WinResize, "WinResize"}, {Hook::WinSetOption, "WinSetOption"}, + {Hook::ModuleLoad, "ModuleLoad"} }); }