diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-06-16 20:42:12 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-06-16 20:42:12 +0100 |
| commit | b8a205b858dbed727a1722e60219340bec9263ef (patch) | |
| tree | 03f1843d3443fb1996f152bfd12b289d67dc6e42 | |
| parent | fc6a16a571f6f5f67350c859785e4a0269168cb6 (diff) | |
Use -group rather than -id in hooks to mirror highlighters closer
| -rw-r--r-- | rc/clang.kak | 2 | ||||
| -rw-r--r-- | rc/cpp.kak | 8 | ||||
| -rw-r--r-- | rc/ctags.kak | 8 | ||||
| -rw-r--r-- | rc/grep.kak | 2 | ||||
| -rw-r--r-- | rc/make.kak | 2 | ||||
| -rw-r--r-- | rc/man.kak | 2 | ||||
| -rw-r--r-- | src/commands.cc | 10 | ||||
| -rw-r--r-- | src/hook_manager.cc | 10 | ||||
| -rw-r--r-- | src/hook_manager.hh | 4 |
9 files changed, 25 insertions, 23 deletions
diff --git a/rc/clang.kak b/rc/clang.kak index 824bcef8..23369d96 100644 --- a/rc/clang.kak +++ b/rc/clang.kak @@ -46,7 +46,7 @@ def clang-complete %{ def clang-enable-autocomplete %{ set window completers %sh{ echo "'option=clang_completions:${kak_opt_completers}'" } - hook window -id clang-autocomplete InsertIdle .* %{ try %{ + hook window -group clang-autocomplete InsertIdle .* %{ try %{ exec -draft <a-h><a-k>(\.|->|::).$<ret> echo 'completing...' clang-complete @@ -57,11 +57,11 @@ hook global WinSetOption filetype=cpp %[ addhl ref cpp # cleanup trailing whitespaces when exiting insert mode - hook window InsertEnd .* -id cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } } + hook window InsertEnd .* -group cpp-hooks %{ try %{ exec -draft <a-x>s\h+$<ret>d } } - hook window InsertChar \n -id cpp-indent _cpp_indent_on_new_line - hook window InsertChar \{ -id cpp-indent _cpp_indent_on_opening_curly_brace - hook window InsertChar \} -id cpp-indent _cpp_indent_on_closing_curly_brace + hook window InsertChar \n -group cpp-indent _cpp_indent_on_new_line + hook window InsertChar \{ -group cpp-indent _cpp_indent_on_opening_curly_brace + hook window InsertChar \} -group cpp-indent _cpp_indent_on_closing_curly_brace ] hook global WinSetOption filetype=(?!cpp).* %{ diff --git a/rc/ctags.kak b/rc/ctags.kak index 5d340f29..8d9d96cd 100644 --- a/rc/ctags.kak +++ b/rc/ctags.kak @@ -40,10 +40,10 @@ def funcinfo %{ } def ctags-enable-autoinfo %{ - hook window -id ctags-autoinfo NormalIdle .* funcinfo - hook window -id ctags-autoinfo NormalEnd .* info - hook window -id ctags-autoinfo NormalKey .* info - hook window -id ctags-autoinfo InsertIdle .* funcinfo + hook window -group ctags-autoinfo NormalIdle .* funcinfo + hook window -group ctags-autoinfo NormalEnd .* info + hook window -group ctags-autoinfo NormalKey .* info + hook window -group ctags-autoinfo InsertIdle .* funcinfo } def ctags-disable-autoinfo %{ rmhooks window ctags-autoinfo } diff --git a/rc/grep.kak b/rc/grep.kak index 18247bb2..c7467864 100644 --- a/rc/grep.kak +++ b/rc/grep.kak @@ -21,7 +21,7 @@ def -shell-params -file-completion \ hook global WinSetOption filetype=grep %{ addhl group grep addhl -group grep regex "^([^:]+):(\d+):(\d+)?" 1:cyan 2:green 3:green - hook buffer -id grep-hooks NormalKey <c-m> jump + hook buffer -group grep-hooks NormalKey <c-m> jump } hook global WinSetOption filetype=(?!grep).* %{ rmhl grep; rmhooks buffer grep-hooks } diff --git a/rc/make.kak b/rc/make.kak index 98fb4aff..241054cc 100644 --- a/rc/make.kak +++ b/rc/make.kak @@ -18,7 +18,7 @@ addhl -group /make regex "^([^:\n]+):(\d+):(\d+):\h+(?:((?:fatal )?error)|(warni hook global WinSetOption filetype=make %{ addhl ref make - hook buffer -id make-hooks NormalKey <c-m> errjump + hook buffer -group make-hooks NormalKey <c-m> errjump } hook global WinSetOption filetype=(?!make).* %{ rmhl make; rmhooks buffer make-hooks } @@ -5,7 +5,7 @@ hook global WinSetOption filetype=man %{ addhl -group man-highlight regex ^\S.*?$ 0:blue addhl -group man-highlight regex ^\h+-+[-a-zA-Z_]+ 0:yellow addhl -group man-highlight regex [-a-zA-Z_.]+\(\d\) 0:green - hook window -id man-hooks NormalKey <c-m> man + hook window -group man-hooks NormalKey <c-m> man set buffer tabstop 8 } diff --git a/src/commands.cc b/src/commands.cc index 77b3fed6..327c9986 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -496,7 +496,7 @@ const CommandDesc add_hook_cmd = { " (and any window for that buffer)\n" " * window: hook is executed only for the current window\n", ParameterDesc{ - SwitchMap{ { "id", { true, "set hook id, see rmhooks" } } }, + SwitchMap{ { "group", { true, "set hook group, see rmhooks" } } }, ParameterDesc::Flags::None, 4, 4 }, CommandFlags::None, @@ -523,15 +523,17 @@ const CommandDesc add_hook_cmd = { CommandManager::instance().execute(command, context, {}, { { "hook_param", param } }); }; - String id = parser.has_option("id") ? parser.option_value("id") : ""; - get_hook_manager(parser[0], context).add_hook(parser[1], id, hook_func); + StringView group; + if (parser.has_option("group")) + group = parser.option_value("group"); + get_hook_manager(parser[0], context).add_hook(parser[1], group, hook_func); } }; const CommandDesc rm_hook_cmd = { "rmhooks", nullptr, - "rmhooks <id>: remove all hooks whose id is <id>", + "rmhooks <group>: remove all hooks whose group is <group>", ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::None, 2, 2 }, CommandFlags::None, CommandCompleter{}, diff --git a/src/hook_manager.cc b/src/hook_manager.cc index 47b52e00..9287e9ab 100644 --- a/src/hook_manager.cc +++ b/src/hook_manager.cc @@ -5,18 +5,18 @@ namespace Kakoune { -void HookManager::add_hook(const String& hook_name, String id, HookFunc hook) +void HookManager::add_hook(const String& hook_name, String group, HookFunc hook) { auto& hooks = m_hook[hook_name]; - hooks.append({std::move(id), std::move(hook)}); + hooks.append({std::move(group), std::move(hook)}); } -void HookManager::remove_hooks(const String& id) +void HookManager::remove_hooks(StringView group) { - if (id.empty()) + if (group.empty()) throw runtime_error("invalid id"); for (auto& hooks : m_hook) - hooks.second.remove_all(id); + hooks.second.remove_all(group); } void HookManager::run_hook(const String& hook_name, diff --git a/src/hook_manager.hh b/src/hook_manager.hh index 794f8077..d0def2de 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -17,8 +17,8 @@ class HookManager public: HookManager(HookManager& parent) : m_parent(&parent) {} - void add_hook(const String& hook_name, String id, HookFunc hook); - void remove_hooks(const String& id); + void add_hook(const String& hook_name, String group, HookFunc hook); + void remove_hooks(StringView group); void run_hook(const String& hook_name, const String& param, Context& context) const; |
