Merge remote-tracking branch 'krobelus/document-history-registers'

This commit is contained in:
Maxime Coste 2022-08-03 19:51:22 +10:00
commit fa209a9a97
4 changed files with 17 additions and 10 deletions

View File

@ -15,7 +15,7 @@ released versions.
* User mappings is now bound to `<space>` while keeping/removing main selection * User mappings is now bound to `<space>` while keeping/removing main selection
moved to `,` and `<a-,>` moved to `,` and `<a-,>`
* History registers `%reg{colon}`, `%reg{slash}` and `%reg{pipe}` now * Prompt history registers `%reg{colon}`, `%reg{slash}` and `%reg{pipe}` now
have reverse chronological order have reverse chronological order
== Kakoune 2021.11.07 == Kakoune 2021.11.07

View File

@ -13,7 +13,7 @@ error occurs.
Without the *-save-regs* switch, *execute-keys* saves the following registers, which Without the *-save-regs* switch, *execute-keys* saves the following registers, which
are then restored when the keys have been executed: */*, *"*, *|*, *^*, are then restored when the keys have been executed: */*, *"*, *|*, *^*,
*@*. *evaluate-commands* doesn't save any registers by default. *@*, *:*. *evaluate-commands* doesn't save any registers by default.
(See <<registers#,`:doc registers`>>) (See <<registers#,`:doc registers`>>)
== Switches for both commands == Switches for both commands

View File

@ -34,7 +34,9 @@ All normal-mode commands using a register default to a specific one if not speci
default search / regex register, used by: default search / regex register, used by:
*/*, *<a-/>*, *?*, *<a-?>*, *n*, *<a-n>*, *N*, *<a-N>*, ***, *<a-***>*, */*, *<a-/>*, *?*, *<a-?>*, *n*, *<a-n>*, *N*, *<a-N>*, ***, *<a-***>*,
*s*, *S*, *<a-k>* and *<a-K>* *s*, *S*, *<a-k>* and *<a-K>*
(see <<keys#searching, `:doc keys searching`>>) (see <<keys#searching, `:doc keys searching`>>).
This is a prompt history register, holding the last 100 commands entered
at an interactive regex prompt.
*@* (arobase):: *@* (arobase)::
default macro register, used by: default macro register, used by:
@ -50,7 +52,10 @@ All normal-mode commands using a register default to a specific one if not speci
*|* (pipe):: *|* (pipe)::
default shell command register, used by commands that spawn a subshell: default shell command register, used by commands that spawn a subshell:
*|*, *<a-|>*, *!* and *<a-!>* *|*, *<a-|>*, *!* and *<a-!>*
(see <<keys#changes-through-external-programs, `:doc keys changes-through-external-programs`>>) (see <<keys#changes-through-external-programs, `:doc keys changes-through-external-programs`>>).
This is a prompt history register, holding the last 100 commands entered
at interactive shell command prompts, except for commands starting with
a space.
== Special registers == Special registers
@ -70,7 +75,8 @@ contain some special data
null register, always empty null register, always empty
*:* (colon):: *:* (colon)::
last entered command prompt history register holding the last 100 commands entered at the
interactive prompt, except for commands starting with a space.
== Integer registers == Integer registers

View File

@ -1926,7 +1926,6 @@ ParameterDesc make_context_wrap_params_impl(Array<HashItem<String, SwitchDesc>,
{ "buffer", { true, "run in a disposable context for each given buffer in the comma separated list argument" } }, { "buffer", { true, "run in a disposable context for each given buffer in the comma separated list argument" } },
{ "draft", { false, "run in a disposable context" } }, { "draft", { false, "run in a disposable context" } },
{ "itersel", { false, "run once for each selection with that selection as the only one" } }, { "itersel", { false, "run once for each selection with that selection as the only one" } },
{ "save-regs", { true, "restore all given registers after execution" } },
std::move(additional_params[P])...}, std::move(additional_params[P])...},
ParameterDesc::Flags::SwitchesOnlyAtStart, 1 ParameterDesc::Flags::SwitchesOnlyAtStart, 1
}; };
@ -2089,7 +2088,8 @@ const CommandDesc execute_keys_cmd = {
"execute-keys", "execute-keys",
"exec", "exec",
"execute-keys [<switches>] <keys>: execute given keys as if entered by user", "execute-keys [<switches>] <keys>: execute given keys as if entered by user",
make_context_wrap_params<2>({{ make_context_wrap_params<3>({{
{"save-regs", {true, "restore all given registers after execution (default: '/\"|^@:')"}},
{"with-maps", {false, "use user defined key mapping when executing keys"}}, {"with-maps", {false, "use user defined key mapping when executing keys"}},
{"with-hooks", {false, "trigger hooks while executing keys"}} {"with-hooks", {false, "trigger hooks while executing keys"}}
}}), }}),
@ -2100,7 +2100,7 @@ const CommandDesc execute_keys_cmd = {
{ {
context_wrap(parser, context, "/\"|^@:", [](const ParametersParser& parser, Context& context) { context_wrap(parser, context, "/\"|^@:", [](const ParametersParser& parser, Context& context) {
ScopedSetBool disable_keymaps(context.keymaps_disabled(), not parser.get_switch("with-maps")); ScopedSetBool disable_keymaps(context.keymaps_disabled(), not parser.get_switch("with-maps"));
ScopedSetBool disable_hoooks(context.hooks_disabled(), not parser.get_switch("with-hooks")); ScopedSetBool disable_hooks(context.hooks_disabled(), not parser.get_switch("with-hooks"));
for (auto& key : parser | transform(parse_keys) | flatten()) for (auto& key : parser | transform(parse_keys) | flatten())
context.input_handler().handle_key(key); context.input_handler().handle_key(key);
@ -2112,7 +2112,8 @@ const CommandDesc evaluate_commands_cmd = {
"evaluate-commands", "evaluate-commands",
"eval", "eval",
"evaluate-commands [<switches>] <commands>...: execute commands as if entered by user", "evaluate-commands [<switches>] <commands>...: execute commands as if entered by user",
make_context_wrap_params<2>({{ make_context_wrap_params<3>({{
{"save-regs", {true, "restore all given registers after execution (default: '')"}},
{"no-hooks", { false, "disable hooks while executing commands" }}, {"no-hooks", { false, "disable hooks while executing commands" }},
{"verbatim", { false, "do not reparse argument" }} {"verbatim", { false, "do not reparse argument" }}
}}), }}),
@ -2123,7 +2124,7 @@ const CommandDesc evaluate_commands_cmd = {
{ {
context_wrap(parser, context, {}, [&](const ParametersParser& parser, Context& context) { context_wrap(parser, context, {}, [&](const ParametersParser& parser, Context& context) {
const bool no_hooks = context.hooks_disabled() or parser.get_switch("no-hooks"); const bool no_hooks = context.hooks_disabled() or parser.get_switch("no-hooks");
ScopedSetBool disable_hoooks(context.hooks_disabled(), no_hooks); ScopedSetBool disable_hooks(context.hooks_disabled(), no_hooks);
if (parser.get_switch("verbatim")) if (parser.get_switch("verbatim"))
CommandManager::instance().execute_single_command(parser | gather<Vector>(), context, shell_context); CommandManager::instance().execute_single_command(parser | gather<Vector>(), context, shell_context);