Add User hook support
This commit is contained in:
parent
e509a8e9cd
commit
f2cc7bc891
|
@ -5,6 +5,8 @@ released versions.
|
||||||
|
|
||||||
== Development version
|
== Development version
|
||||||
|
|
||||||
|
* Introduce `User` hook support.
|
||||||
|
|
||||||
* The `bold` and `italic` faces are no longer built-in. Highlighters
|
* The `bold` and `italic` faces are no longer built-in. Highlighters
|
||||||
are expected to use face attributes (`+b` and `+i`, respectively) to
|
are expected to use face attributes (`+b` and `+i`, respectively) to
|
||||||
decorate text.
|
decorate text.
|
||||||
|
|
|
@ -210,6 +210,10 @@ of the file onto the filesystem
|
||||||
remove every hooks in *scope* that are part of the given *group*
|
remove every hooks in *scope* that are part of the given *group*
|
||||||
(See <<hooks#,`:doc hooks`>> and <<scopes#,`:doc scopes`>>)
|
(See <<hooks#,`:doc hooks`>> and <<scopes#,`:doc scopes`>>)
|
||||||
|
|
||||||
|
*trigger-user-hook* <param>::
|
||||||
|
trigger the `User` hook with the given *param* as filter string in
|
||||||
|
the current context. (See <<hooks#,`:doc hooks`>>)
|
||||||
|
|
||||||
== Display
|
== Display
|
||||||
|
|
||||||
*echo* [<switches>] <text>::
|
*echo* [<switches>] <text>::
|
||||||
|
|
|
@ -178,6 +178,10 @@ name. Hooks with no description will always use an empty string.
|
||||||
*ModuleLoaded* `module`::
|
*ModuleLoaded* `module`::
|
||||||
Triggered after a module is evaluated by the first `require-module` call
|
Triggered after a module is evaluated by the first `require-module` call
|
||||||
|
|
||||||
|
*User* `param`::
|
||||||
|
Triggered via the `trigger-user-hook` command. Provides a way for plugins
|
||||||
|
to introduce custom hooks by specifying what *param* would be.
|
||||||
|
|
||||||
Note that some hooks will not consider underlying scopes depending on what
|
Note that some hooks will not consider underlying scopes depending on what
|
||||||
context they are bound to be run into, e.g. the `BufWritePost` hook is a buffer
|
context they are bound to be run into, e.g. the `BufWritePost` hook is a buffer
|
||||||
hook, and will not consider the `window` scope.
|
hook, and will not consider the `window` scope.
|
||||||
|
|
|
@ -1093,6 +1093,20 @@ const CommandDesc remove_hook_cmd = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CommandDesc trigger_user_hook_cmd = {
|
||||||
|
"trigger-user-hook",
|
||||||
|
nullptr,
|
||||||
|
"trigger-user-hook <param>: run 'User' hook with <param> as filter string",
|
||||||
|
single_param,
|
||||||
|
CommandFlags::None,
|
||||||
|
CommandHelper{},
|
||||||
|
CommandCompleter{},
|
||||||
|
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
|
{
|
||||||
|
context.hooks().run_hook(Hook::User, parser[0], context);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Vector<String> params_to_shell(const ParametersParser& parser)
|
Vector<String> params_to_shell(const ParametersParser& parser)
|
||||||
{
|
{
|
||||||
Vector<String> vars;
|
Vector<String> vars;
|
||||||
|
@ -2635,6 +2649,7 @@ void register_commands()
|
||||||
register_command(remove_highlighter_cmd);
|
register_command(remove_highlighter_cmd);
|
||||||
register_command(add_hook_cmd);
|
register_command(add_hook_cmd);
|
||||||
register_command(remove_hook_cmd);
|
register_command(remove_hook_cmd);
|
||||||
|
register_command(trigger_user_hook_cmd);
|
||||||
register_command(define_command_cmd);
|
register_command(define_command_cmd);
|
||||||
register_command(alias_cmd);
|
register_command(alias_cmd);
|
||||||
register_command(unalias_cmd);
|
register_command(unalias_cmd);
|
||||||
|
|
|
@ -54,7 +54,8 @@ enum class Hook
|
||||||
WinDisplay,
|
WinDisplay,
|
||||||
WinResize,
|
WinResize,
|
||||||
WinSetOption,
|
WinSetOption,
|
||||||
ModuleLoaded
|
ModuleLoaded,
|
||||||
|
User
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto enum_desc(Meta::Type<Hook>)
|
constexpr auto enum_desc(Meta::Type<Hook>)
|
||||||
|
@ -97,7 +98,8 @@ 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::ModuleLoaded, "ModuleLoaded"}
|
{Hook::ModuleLoaded, "ModuleLoaded"},
|
||||||
|
{Hook::User, "User"}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user