diff --git a/doc/pages/execeval.asciidoc b/doc/pages/execeval.asciidoc index 5705bdf3..9d784e22 100644 --- a/doc/pages/execeval.asciidoc +++ b/doc/pages/execeval.asciidoc @@ -44,16 +44,22 @@ when the commands have been executed: */*, *"*, *|*, *^*, *@*. execute in the context of each buffers in the comma separated list *names*. `*` as a name can be used to iterate on all buffers -*-no-hooks*:: - disable hook execution while executing the keys/commands - (See <>) - *-save-regs* :: regs is a string of registers to be restored after execution (overwrites the list of registers saved by default, c.f. description) +== evaluate-commands specific switches + +*-no-hooks*:: + disable hook execution while executing the keys/commands + (See <>) + == execute-keys specific switches *-with-maps*:: use user key mapping in instead of built in keys (See <>) + +*-with-hooks*:: + the execution of keys will trigger existing hooks + (See <>) diff --git a/src/commands.cc b/src/commands.cc index df114314..8323aa56 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1565,7 +1565,7 @@ const CommandDesc unmap_key_cmd = { }; template -ParameterDesc make_context_wrap_params_impl(std::array, sizeof...(P)>&& additional_params, +ParameterDesc make_context_wrap_params_impl(Array, sizeof...(P)>&& additional_params, std::index_sequence) { return { { { "client", { true, "run in given client context" } }, @@ -1573,7 +1573,6 @@ ParameterDesc make_context_wrap_params_impl(std::array -ParameterDesc make_context_wrap_params(std::array, N>&& additional_params) +ParameterDesc make_context_wrap_params(Array, N>&& additional_params) { return make_context_wrap_params_impl(std::move(additional_params), std::make_index_sequence()); } @@ -1594,8 +1593,6 @@ void context_wrap(const ParametersParser& parser, Context& context, StringView d (int)(bool)parser.get_switch("try-client") > 1) throw runtime_error{"only one of -buffer, -client or -try-client can be specified"}; - const bool no_hooks = parser.get_switch("no-hooks") or context.hooks_disabled(); - auto& register_manager = RegisterManager::instance(); auto make_register_restorer = [&](char c) { return on_scope_end([&, c, save=register_manager[c].get(context) | gather>()] { @@ -1620,7 +1617,6 @@ void context_wrap(const ParametersParser& parser, Context& context, StringView d Context::Flags::Draft}; Context& c = input_handler.context(); - ScopedSetBool disable_hooks(c.hooks_disabled(), no_hooks); ScopedSetBool disable_history(c.history_disabled()); func(parser, c); @@ -1672,7 +1668,6 @@ void context_wrap(const ParametersParser& parser, Context& context, StringView d Context& c = *effective_context; - ScopedSetBool disable_hooks(c.hooks_disabled(), no_hooks); ScopedSetBool disable_history(c.history_disabled()); ScopedEdition edition{c}; @@ -1729,7 +1724,10 @@ const CommandDesc exec_string_cmd = { "execute-keys", "exec", "execute-keys [] : execute given keys as if entered by user", - make_context_wrap_params<1>({{"with-maps", {false, "use user defined key mapping when executing keys" }}}), + make_context_wrap_params<2>({{ + {"with-maps", {false, "use user defined key mapping when executing keys"}}, + {"with-hooks", {false, "trigger hooks while executing keys"}} + }}), CommandFlags::None, CommandHelper{}, CommandCompleter{}, @@ -1737,6 +1735,8 @@ const CommandDesc exec_string_cmd = { { context_wrap(parser, context, "/\"|^@", [](const ParametersParser& parser, Context& context) { ScopedSetBool disable_keymaps(context.keymaps_disabled(), not parser.get_switch("with-maps")); + ScopedSetBool disable_hoooks(context.hooks_disabled(), not parser.get_switch("with-hooks")); + KeyList keys; for (auto& param : parser) { @@ -1754,13 +1754,16 @@ const CommandDesc eval_string_cmd = { "evaluate-commands", "eval", "evaluate-commands [] ...: execute commands as if entered by user", - make_context_wrap_params<0>({}), + make_context_wrap_params<1>({{{"no-hooks", { false, "disable hooks while executing commands" }}}}), CommandFlags::None, CommandHelper{}, CommandCompleter{}, [](const ParametersParser& parser, Context& context, const ShellContext& shell_context) { context_wrap(parser, context, {}, [&](const ParametersParser& parser, Context& context) { + const bool no_hooks = context.hooks_disabled() or parser.get_switch("no-hooks"); + ScopedSetBool disable_hoooks(context.hooks_disabled(), no_hooks); + CommandManager::instance().execute(join(parser, ' ', false), context, shell_context); }); }