summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-08-30 20:10:00 +1000
committerMaxime Coste <mawww@kakoune.org>2018-08-30 20:10:00 +1000
commitdf655422d185980c859ea676f8ece15d2a56d493 (patch)
tree39a55329bfa67efb073b808f734928540f5c0448
parentee39649d3a2a35812e3deaa231cffd0aed9258d7 (diff)
parentede9155fc778de8153806815c5bc413c7e1bf142 (diff)
Merge remote-tracking branch 'Screwtapello/support-user-map-options'
-rw-r--r--doc/pages/options.asciidoc6
-rw-r--r--src/commands.cc7
2 files changed, 11 insertions, 2 deletions
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`
*<type>-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 (`<begin line>.<begin column>,
@@ -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`
*<type>-to-<type>-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 = &reg.declare_option<TimestampedList<LineAndSpec>>(parser[1], docstring, {}, flags);
else if (parser[0] == "range-specs")
opt = &reg.declare_option<TimestampedList<RangeAndString>>(parser[1], docstring, {}, flags);
+ else if (parser[0] == "str-to-str-map")
+ opt = &reg.declare_option<HashMap<String, String, MemoryDomain::Options>>(parser[1], docstring, {}, flags);
else
throw runtime_error(format("no such option type: '{}'", parser[0]));