1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-28 06:08:05 +03:00

Do not save any registers by default in evaluate-commands

This commit is contained in:
Maxime Coste 2018-05-15 07:44:18 +10:00
parent ec16969609
commit 5902c7b790
2 changed files with 6 additions and 5 deletions

View File

@ -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 <<registers#,`:doc registers`>>)
== Optional switches

View File

@ -1577,7 +1577,7 @@ const ParameterDesc context_wrap_params = {
};
template<typename Func>
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<decltype(make_register_restorer(0))> 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);
});
}