From 5902c7b7905ae600481a2920265b7668cbc8a476 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 15 May 2018 07:44:18 +1000 Subject: [PATCH] Do not save any registers by default in evaluate-commands --- doc/pages/execeval.asciidoc | 3 ++- src/commands.cc | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/pages/execeval.asciidoc b/doc/pages/execeval.asciidoc index ad217588b..1c7ed00a9 100644 --- a/doc/pages/execeval.asciidoc +++ b/doc/pages/execeval.asciidoc @@ -15,8 +15,9 @@ evaluates its given parameters as if they were entered in the command prompt. By default, their execution happens within the context of the current client, and stops when the last key/command is reached, or an error is raised. -These two commands also save the following registers, who are then restored +*execute-keys* also save the following registers, who are then restored when the commands have been executed: */*, *"*, *|*, *^*, *@*. +*evaluate-commands* does not save any registers by default. (See <>) == Optional switches diff --git a/src/commands.cc b/src/commands.cc index 1cf8acddd..a169fee49 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1577,7 +1577,7 @@ const ParameterDesc context_wrap_params = { }; template -void context_wrap(const ParametersParser& parser, Context& context, Func func) +void context_wrap(const ParametersParser& parser, Context& context, StringView default_saved_regs, Func func) { if ((int)(bool)parser.get_switch("buffer") + (int)(bool)parser.get_switch("client") + @@ -1601,7 +1601,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) }); }; Vector saved_registers; - for (auto c : parser.get_switch("save-regs").value_or("/\"|^@")) + for (auto c : parser.get_switch("save-regs").value_or(default_saved_regs)) saved_registers.push_back(make_register_restorer(c)); if (auto bufnames = parser.get_switch("buffer")) @@ -1728,7 +1728,7 @@ const CommandDesc exec_string_cmd = { CommandCompleter{}, [](const ParametersParser& parser, Context& context, const ShellContext&) { - context_wrap(parser, context, [](const ParametersParser& parser, Context& context) { + context_wrap(parser, context, "/\"|^@", [](const ParametersParser& parser, Context& context) { KeyList keys; for (auto& param : parser) { @@ -1752,7 +1752,7 @@ const CommandDesc eval_string_cmd = { CommandCompleter{}, [](const ParametersParser& parser, Context& context, const ShellContext& shell_context) { - context_wrap(parser, context, [&](const ParametersParser& parser, Context& context) { + context_wrap(parser, context, {}, [&](const ParametersParser& parser, Context& context) { CommandManager::instance().execute(join(parser, ' ', false), context, shell_context); }); }