From f435b2b70ad68400c1ae7f3c800cbfaf679837f4 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 31 Jul 2022 10:44:53 +0200 Subject: [PATCH 1/4] doc execeval: mention that the colon register is saved by default --- doc/pages/execeval.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/pages/execeval.asciidoc b/doc/pages/execeval.asciidoc index 617f5ea0..4606c634 100644 --- a/doc/pages/execeval.asciidoc +++ b/doc/pages/execeval.asciidoc @@ -13,7 +13,7 @@ error occurs. Without the *-save-regs* switch, *execute-keys* saves the following registers, which 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 <>) == Switches for both commands From d999a00b0ccacbaac2739a8102171ff8d004d08b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 29 Jul 2022 22:08:29 +0200 Subject: [PATCH 2/4] Fix typo in eval/exec code Will touch similar code --- src/commands.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index f07c768b..ebede998 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2100,7 +2100,7 @@ const CommandDesc execute_keys_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")); + ScopedSetBool disable_hooks(context.hooks_disabled(), not parser.get_switch("with-hooks")); for (auto& key : parser | transform(parse_keys) | flatten()) context.input_handler().handle_key(key); @@ -2123,7 +2123,7 @@ const CommandDesc evaluate_commands_cmd = { { 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); + ScopedSetBool disable_hooks(context.hooks_disabled(), no_hooks); if (parser.get_switch("verbatim")) CommandManager::instance().execute_single_command(parser | gather(), context, shell_context); From 253b13281e6b960fe750cdbc064b8dafd6c1449f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 31 Jul 2022 11:58:51 +0200 Subject: [PATCH 3/4] Show the default values for -save-regs in autoinfo of exec/eval They are documented in ":doc execeval" but it seems like a good idea to make this info more prominent. --- src/commands.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index ebede998..84e0fdf3 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1926,7 +1926,6 @@ ParameterDesc make_context_wrap_params_impl(Array, { "buffer", { true, "run in a disposable context for each given buffer in the comma separated list argument" } }, { "draft", { false, "run in a disposable context" } }, { "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])...}, ParameterDesc::Flags::SwitchesOnlyAtStart, 1 }; @@ -2089,7 +2088,8 @@ const CommandDesc execute_keys_cmd = { "execute-keys", "exec", "execute-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-hooks", {false, "trigger hooks while executing keys"}} }}), @@ -2112,7 +2112,8 @@ const CommandDesc evaluate_commands_cmd = { "evaluate-commands", "eval", "evaluate-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" }}, {"verbatim", { false, "do not reparse argument" }} }}), From c335712e4e53d1b3fa6b6dd69629ff0d11e07518 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 29 Jul 2022 21:04:23 +0200 Subject: [PATCH 4/4] doc registers: document prompt history registers So far they have only been talked about in source code (HistoryRegister), not in documentation. Let's give them an official name so users can find them better; "prompt history register" seems better than "history register" since the former gives more context. OTOH, in future other registers (like @) could grow into history registers, so I'm not sure. State that the history registers are only changed by _interactive_ prompts; that's not quite true yet for user modes but I'll push a separate fix for that. --- doc/pages/changelog.asciidoc | 2 +- doc/pages/registers.asciidoc | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index 8cd81a80..d475f278 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -15,7 +15,7 @@ released versions. * User mappings is now bound to `` while keeping/removing main selection moved to `,` and `` -* 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 == Kakoune 2021.11.07 diff --git a/doc/pages/registers.asciidoc b/doc/pages/registers.asciidoc index 28aed054..65f6baf4 100644 --- a/doc/pages/registers.asciidoc +++ b/doc/pages/registers.asciidoc @@ -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: */*, **, *?*, **, *n*, **, *N*, **, ***, **, *s*, *S*, ** and ** - (see <>) + (see <>). + This is a prompt history register, holding the last 100 commands entered + at an interactive regex prompt. *@* (arobase):: 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):: default shell command register, used by commands that spawn a subshell: *|*, **, *!* and ** - (see <>) + (see <>). + 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 @@ -70,7 +75,8 @@ contain some special data null register, always empty *:* (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