1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 08:51:46 +03:00

Add a 'disabled_hooks' regex option

Hooks whose group matches this regex wont get executed.
This commit is contained in:
Maxime Coste 2014-08-21 13:37:59 +01:00
parent 50e1e5fadd
commit 8fc230e40d
3 changed files with 11 additions and 0 deletions

View File

@ -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 * +ignored_files+ _regex_: filenames matching this regex wont be considered
as candidates on filename completion (except if the text being completed as candidates on filename completion (except if the text being completed
already matches it). 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+ _str_: arbitrary string defining the type of the file
filetype dependant actions should hook on this option changing for filetype dependant actions should hook on this option changing for
activation/deactivation. activation/deactivation.

View File

@ -1,5 +1,6 @@
#include "hook_manager.hh" #include "hook_manager.hh"
#include "context.hh"
#include "debug.hh" #include "debug.hh"
namespace Kakoune namespace Kakoune
@ -45,8 +46,13 @@ void HookManager::run_hook(const String& hook_name,
if (hook_list_it == m_hook.end()) if (hook_list_it == m_hook.end())
return; return;
auto& disabled_hooks = context.options()["disabled_hooks"].get<Regex>();
for (auto& hook : hook_list_it->second) 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 try
{ {
hook.second(param, context); hook.second(param, context);

View File

@ -157,6 +157,9 @@ GlobalOptions::GlobalOptions()
declare_option("ignored_files", declare_option("ignored_files",
"patterns to ignore when completing filenames", "patterns to ignore when completing filenames",
Regex{R"(^(\..*|.*\.(o|so|a))$)"}); 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("filetype", "buffer filetype", ""_str);
declare_option("path", "path to consider when trying to find a file", declare_option("path", "path to consider when trying to find a file",
std::vector<String>({ "./", "/usr/include" })); std::vector<String>({ "./", "/usr/include" }));