Add a 'disabled_hooks' regex option
Hooks whose group matches this regex wont get executed.
This commit is contained in:
parent
50e1e5fadd
commit
8fc230e40d
|
@ -552,6 +552,8 @@ Some options are built in Kakoune, and can be used to control it's behaviour:
|
|||
* +ignored_files+ _regex_: filenames matching this regex wont be considered
|
||||
as candidates on filename completion (except if the text being completed
|
||||
already matches it).
|
||||
* +disabled_hooks+ _regex_: hooks whose group matches this regex wont be
|
||||
executed. For example indentation hooks can be disabled with '.*-indent'.
|
||||
* +filetype+ _str_: arbitrary string defining the type of the file
|
||||
filetype dependant actions should hook on this option changing for
|
||||
activation/deactivation.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "hook_manager.hh"
|
||||
|
||||
#include "context.hh"
|
||||
#include "debug.hh"
|
||||
|
||||
namespace Kakoune
|
||||
|
@ -45,8 +46,13 @@ void HookManager::run_hook(const String& hook_name,
|
|||
if (hook_list_it == m_hook.end())
|
||||
return;
|
||||
|
||||
auto& disabled_hooks = context.options()["disabled_hooks"].get<Regex>();
|
||||
for (auto& hook : hook_list_it->second)
|
||||
{
|
||||
if (not hook.first.empty() and not disabled_hooks.empty() and
|
||||
boost::regex_match(hook.first, disabled_hooks))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
hook.second(param, context);
|
||||
|
|
|
@ -157,6 +157,9 @@ GlobalOptions::GlobalOptions()
|
|||
declare_option("ignored_files",
|
||||
"patterns to ignore when completing filenames",
|
||||
Regex{R"(^(\..*|.*\.(o|so|a))$)"});
|
||||
declare_option("disabled_hooks",
|
||||
"patterns to disable hooks whose group is matched",
|
||||
Regex{});
|
||||
declare_option("filetype", "buffer filetype", ""_str);
|
||||
declare_option("path", "path to consider when trying to find a file",
|
||||
std::vector<String>({ "./", "/usr/include" }));
|
||||
|
|
Loading…
Reference in New Issue
Block a user