From 000aa2282c3d8bb075cdaa3944c86848b410a05b Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Wed, 13 Feb 2019 14:14:10 -0500 Subject: [PATCH] Add object command --- doc/pages/keys.asciidoc | 4 ++++ src/normal.cc | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/pages/keys.asciidoc b/doc/pages/keys.asciidoc index 35febbdf8..012f142a9 100644 --- a/doc/pages/keys.asciidoc +++ b/doc/pages/keys.asciidoc @@ -681,6 +681,10 @@ in order to specify the wanted object: *c*:: select user defined object, will prompt for open and close text +**:: + run a command in object context. The expansions `%val{count}` and + `%val{register}` are available here. + == Prompt commands When pressing `:` in normal mode, Kakoune will open a prompt to enter diff --git a/src/normal.cc b/src/normal.cc index c7b074a43..66eec914b 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1252,12 +1252,12 @@ void select_object(Context& context, NormalParams params) whole ? "" : (flags & ObjectFlags::ToBegin ? " begin" : " end")); }; - const int count = params.count <= 0 ? 0 : params.count - 1; on_next_key_with_autoinfo(context, KeymapMode::Object, - [count](Key key, Context& context) { + [params](Key key, Context& context) { if (key == Key::Escape) return; + const int count = params.count <= 0 ? 0 : params.count - 1; static constexpr struct ObjectType { Key key; @@ -1311,6 +1311,12 @@ void select_object(Context& context, NormalParams params) return; } + if (key == alt(';')) + { + command(context, params); + return; + } + static constexpr struct SurroundingPair { char opening; @@ -1365,7 +1371,8 @@ void select_object(Context& context, NormalParams params) {{'i'}, "indent"}, {{'u'}, "argument"}, {{'n'}, "number"}, - {{'c'}, "custom object desc"}})); + {{'c'}, "custom object desc"}, + {{alt(';')}, "run command in object context"}})); } enum Direction { Backward = -1, Forward = 1 };