1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-30 23:37:17 +03:00

Added ModuleLoad hook that uses the module name as the parameter

This commit is contained in:
Justin Frank 2019-03-13 12:46:53 -07:00
parent c3f694a28f
commit 7866d88131
2 changed files with 6 additions and 2 deletions

View File

@ -65,6 +65,8 @@ void CommandManager::load_module(StringView module_name, Context& context)
module->value.loaded = true; module->value.loaded = true;
execute(module->value.commands, context); execute(module->value.commands, context);
module->value.commands.clear(); module->value.commands.clear();
context.hooks().run_hook(Hook::ModuleLoad, module_name, context);
} }
struct parse_error : runtime_error struct parse_error : runtime_error

View File

@ -57,12 +57,13 @@ enum class Hook
WinCreate, WinCreate,
WinDisplay, WinDisplay,
WinResize, WinResize,
WinSetOption WinSetOption,
ModuleLoad
}; };
constexpr auto enum_desc(Meta::Type<Hook>) constexpr auto enum_desc(Meta::Type<Hook>)
{ {
return make_array<EnumDesc<Hook>, 41>({ return make_array<EnumDesc<Hook>, 42>({
{Hook::BufCreate, "BufCreate"}, {Hook::BufCreate, "BufCreate"},
{Hook::BufNewFile, "BufNewFile"}, {Hook::BufNewFile, "BufNewFile"},
{Hook::BufOpenFile, "BufOpenFile"}, {Hook::BufOpenFile, "BufOpenFile"},
@ -104,6 +105,7 @@ constexpr auto enum_desc(Meta::Type<Hook>)
{Hook::WinDisplay, "WinDisplay"}, {Hook::WinDisplay, "WinDisplay"},
{Hook::WinResize, "WinResize"}, {Hook::WinResize, "WinResize"},
{Hook::WinSetOption, "WinSetOption"}, {Hook::WinSetOption, "WinSetOption"},
{Hook::ModuleLoad, "ModuleLoad"}
}); });
} }