diff --git a/doc/pages/options.asciidoc b/doc/pages/options.asciidoc index 24a08e1b..0f924dc9 100644 --- a/doc/pages/options.asciidoc +++ b/doc/pages/options.asciidoc @@ -77,10 +77,13 @@ are exclusively available to built-in options. *coord*:: a line, column pair (separated by a comma) + Cannot be used with `declare-option` *-list*:: a list, elements are specified as separate arguments to the command. `set -add` appends the new element to the list + Only `int-list` and `str-list` options can be created with + `declare-option`. *range-specs*:: a list of a pair of a buffer range (`., @@ -110,16 +113,19 @@ are exclusively available to built-in options. *enum(value1|value2|...)*:: an enum, taking one of the given values + Cannot be used with `declare-option` *flags(value1|value2|...)*:: a set of flags, taking a combination of the given values joined by a '|' character. `set -add` adds the new flag to the combination + Cannot be used with `declare-option` *-to--map*:: a list of `key=value` pairs. `set -add` adds the new pair to the hashmap or replace an already existing key. + Only `str-to-str-map` options can be created with `declare-option`. == Builtin options diff --git a/src/commands.cc b/src/commands.cc index 59b7711f..990450cc 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1448,7 +1448,8 @@ const CommandDesc declare_option_cmd = { " str-list: list of character strings\n" " completions: list of completion candidates\n" " line-specs: list of line specs\n" - " range-specs: list of range specs\n", + " range-specs: list of range specs\n" + " str-to-str-map: map from strings to strings\n", ParameterDesc{ { { "hidden", { false, "do not display option name when completing" } }, { "docstring", { true, "specify option description" } } }, @@ -1459,7 +1460,7 @@ const CommandDesc declare_option_cmd = { make_completer( [](const Context& context, CompletionFlags flags, const String& prefix, ByteCount cursor_pos) -> Completions { - auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-specs", "range-specs"}; + auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-specs", "range-specs", "str-to-str-map"}; return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) }; }), [](const ParametersParser& parser, Context& context, const ShellContext&) @@ -1492,6 +1493,8 @@ const CommandDesc declare_option_cmd = { opt = ®.declare_option>(parser[1], docstring, {}, flags); else if (parser[0] == "range-specs") opt = ®.declare_option>(parser[1], docstring, {}, flags); + else if (parser[0] == "str-to-str-map") + opt = ®.declare_option>(parser[1], docstring, {}, flags); else throw runtime_error(format("no such option type: '{}'", parser[0]));