From ec3d7c31040afaee65afde15832d9b0ed6b2224d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 9 Sep 2020 19:38:12 +1000 Subject: [PATCH] Add support for removing from options `set -remove ...` will remove from the current option value, substracting from int, removing elements from vectors and maps. --- doc/pages/changelog.asciidoc | 4 +++ doc/pages/options.asciidoc | 40 +++++++++++++++------ src/commands.cc | 12 +++++-- src/main.cc | 3 ++ src/option.hh | 9 +++++ src/option_manager.hh | 7 ++++ src/option_types.hh | 70 +++++++++++++++++++++++++++++++++--- 7 files changed, 128 insertions(+), 17 deletions(-) diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index e9699779..6063963a 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -3,6 +3,10 @@ This changelog contains major and/or breaking changes to Kakoune between released versions. +== Development version + +* `set-option -remove` support for substracting/removing from option values + == Kakoune 2020.09.01 * The `repl` and `send-text` aliases have been renamed respectively into diff --git a/doc/pages/options.asciidoc b/doc/pages/options.asciidoc index 9ee4504e..18668d70 100644 --- a/doc/pages/options.asciidoc +++ b/doc/pages/options.asciidoc @@ -10,7 +10,7 @@ scripts. Options can be modified using the `set-option` command: -------------------------------------------- -set-option [-add] ... +set-option [-add|-remove] ... -------------------------------------------- can be *global*, *buffer*, *window* or *current* (See @@ -20,8 +20,9 @@ which the option is already set. Multiple can be given as separate arguments when the option is a list or map. -If `-add` is specified, the new value is *added* to the current one -instead of replacing it (the exact outcome depends on the type, see below). +If `-add` or `-remove` is specified, the new value is respectively *added* +to or *removed* from the current one instead of replacing it (the exact +outcome depends on the type, see below). [[unset-option]] Options values can be unset in a specific scope with the `unset-option` @@ -63,7 +64,9 @@ are exclusively available to built-in options. *int*:: an integer number. - `set -add` performs a math addition + + `set -add` performs a math addition. + + `set -remove` performs a math substraction. + *bool*:: a boolean value, yes/true or no/false @@ -81,7 +84,10 @@ are exclusively available to built-in options. *-list*:: a list, elements are specified as separate arguments to the command. - `set -add` appends the new element to the list + + `set -add` appends the new element to the list. + + `set -remove` removes each given element from the list. + + Only `int-list` and `str-list` options can be created with `declare-option`. @@ -115,7 +121,8 @@ are exclusively available to built-in options. its ranges get updated according to all the buffer modifications that happened since its timestamp. - `set -add` appends the new pair to the list + `set -add` appends the new pairs to the list. + + `set -remove` removes the given pairs from the list. + See <>) @@ -126,7 +133,9 @@ are exclusively available to built-in options. type, its lines get updated according to all the buffer modifications that happened since its timestamp. See <>) - `set -add` appends the new spec to the list + + `set -add` appends the new specs to the list. + + `set -remove` removes the given specs from the list. + *completions*:: a list of `|