parent
ac73f7c27f
commit
6b79c1e000
|
@ -189,7 +189,9 @@ vars are available:
|
||||||
|
|
||||||
* `kak_hook_param`: filtering text passed to the currently executing hook
|
* `kak_hook_param`: filtering text passed to the currently executing hook
|
||||||
|
|
||||||
* `kak_hook_param_capture_N`: text captured by the hook filter regex capture N
|
* `kak_hook_param_capture_N`: text captured by the hook filter regex capturing
|
||||||
|
group N, N can either be the capturing group number, or its name
|
||||||
|
(See <<regex#groups,`:doc regex groups`>>).
|
||||||
|
|
||||||
== Disabling Hooks
|
== Disabling Hooks
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,9 @@ void HookManager::run_hook(Hook hook, StringView param, Context& context)
|
||||||
for (size_t i = 0; i < to_run.captures.size(); ++i)
|
for (size_t i = 0; i < to_run.captures.size(); ++i)
|
||||||
env_vars.insert({format("hook_param_capture_{}", i),
|
env_vars.insert({format("hook_param_capture_{}", i),
|
||||||
{to_run.captures[i].first, to_run.captures[i].second}});
|
{to_run.captures[i].first, to_run.captures[i].second}});
|
||||||
|
for (auto& c : to_run.hook->filter.impl()->named_captures)
|
||||||
|
env_vars.insert({format("hook_param_capture_{}", c.name),
|
||||||
|
{to_run.captures[c.index].first, to_run.captures[c.index].second}});
|
||||||
|
|
||||||
CommandManager::instance().execute(to_run.hook->commands, context,
|
CommandManager::instance().execute(to_run.hook->commands, context,
|
||||||
{ {}, std::move(env_vars) });
|
{ {}, std::move(env_vars) });
|
||||||
|
|
1
test/compose/hook-named-captures/cmd
Normal file
1
test/compose/hook-named-captures/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
i<ret><esc>
|
1
test/compose/hook-named-captures/in
Normal file
1
test/compose/hook-named-captures/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
1
test/compose/hook-named-captures/out
Normal file
1
test/compose/hook-named-captures/out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ret
|
1
test/compose/hook-named-captures/rc
Normal file
1
test/compose/hook-named-captures/rc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
hook global InsertKey '<(?<name>\w+)>' %{ exec "<backspace>%val(hook_param_capture_name)" }
|
Loading…
Reference in New Issue
Block a user