1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 20:41:49 +03:00

Add a -verbatim switch to evaluate-commands for perfect forwarding

-verbatim will disable argument parsing in evaluate-commands, making
it possible to forward a single command to a different context without
triggering a reparsing of the arguments.

Fixes -try-client support in grep.kak

Closes #3153
This commit is contained in:
Maxime Coste 2019-10-23 22:23:59 +11:00
parent 362021c1d3
commit a49ae162f4
5 changed files with 22 additions and 8 deletions

View File

@ -12,6 +12,9 @@ released versions.
`InsertBegin`, `InsertEnd`, `NormalBegin` and `NormalEnd`
were removed.
* `-verbatim` switch in `evaluate-commands` for perfect command
forwarding to another context.
== Kakoune 2019.07.01
* Re-organized bundled script files directory hierarchy.

View File

@ -55,6 +55,10 @@ when the commands have been executed: */*, *"*, *|*, *^*, *@*.
disable hook execution while executing the keys/commands
(See <<hooks#disabling-hooks,`:doc hooks`>>)
*-verbatim*::
do not reparse and split positional arguments. Forward them
exactly as given to the `evaluate-commands` command.
== execute-keys specific switches
*-with-maps*::

View File

@ -44,7 +44,7 @@ define-command -hidden grep-jump %{
try %{
execute-keys '<a-x>s^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>'
set-option buffer grep_current_line %val{cursor_line}
evaluate-commands -try-client %opt{jumpclient} %{ edit -existing %reg{1} %reg{2} %reg{3} }
evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing %reg{1} %reg{2} %reg{3}
try %{ focus %opt{jumpclient} }
}
}

View File

@ -100,6 +100,12 @@ public:
void execute(StringView command_line, Context& context,
const ShellContext& shell_context = ShellContext{});
void execute_single_command(CommandParameters params,
Context& context,
const ShellContext& shell_context,
BufferCoord pos = {});
Completions complete(const Context& context, CompletionFlags flags,
StringView command_line, ByteCount cursor_pos);
@ -132,11 +138,6 @@ public:
Completions complete_module_name(StringView query) const;
private:
void execute_single_command(CommandParameters params,
Context& context,
const ShellContext& shell_context,
BufferCoord pos);
struct Command
{
CommandFunc func;

View File

@ -1910,7 +1910,10 @@ const CommandDesc eval_string_cmd = {
"evaluate-commands",
"eval",
"evaluate-commands [<switches>] <commands>...: execute commands as if entered by user",
make_context_wrap_params<1>({{{"no-hooks", { false, "disable hooks while executing commands" }}}}),
make_context_wrap_params<2>({{
{"no-hooks", { false, "disable hooks while executing commands" }},
{"verbatim", { false, "do not reparse argument" }}
}}),
CommandFlags::None,
CommandHelper{},
CommandCompleter{},
@ -1920,7 +1923,10 @@ const CommandDesc eval_string_cmd = {
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);
if (parser.get_switch("verbatim"))
CommandManager::instance().execute_single_command(parser | gather<Vector>(), context, shell_context);
else
CommandManager::instance().execute(join(parser, ' ', false), context, shell_context);
});
}
};