Make register expansions expand to the full register content
Now that we have a nice standard way to express lists of strings, registers can be fully exposed. An new $kak_main_reg_... env var was added to provide the previous behaviour which is relied on by doc.kak.
This commit is contained in:
parent
d6c6ed9bbf
commit
27163106c7
|
@ -38,8 +38,8 @@ parameter:
|
||||||
section)
|
section)
|
||||||
|
|
||||||
*reg*::
|
*reg*::
|
||||||
register expansion, will expand to the content of the register named
|
register expansion, will expand to the strings stored in the register
|
||||||
by *<content>*. See <<registers#,`:doc registers`>>
|
named by *<content>*. See <<registers#,`:doc registers`>>
|
||||||
|
|
||||||
*opt*::
|
*opt*::
|
||||||
option expansion, will expand to the value of the option named by
|
option expansion, will expand to the value of the option named by
|
||||||
|
@ -114,7 +114,10 @@ informations about Kakoune's state:
|
||||||
value of option *name*
|
value of option *name*
|
||||||
|
|
||||||
*kak_reg_<r>*::
|
*kak_reg_<r>*::
|
||||||
value of register *r*
|
quoted list of value of register *r*
|
||||||
|
|
||||||
|
*kak_main_reg_<r>*::
|
||||||
|
content of register *r* associated with the main selection.
|
||||||
|
|
||||||
*kak_session*::
|
*kak_session*::
|
||||||
name of the current session
|
name of the current session
|
||||||
|
|
|
@ -31,7 +31,7 @@ define-command -hidden autowrap-cursor %{ evaluate-commands -save-regs '/"|^@m'
|
||||||
execute-keys '<a-]>p<a-x><a-j>|${format_cmd}<ret>'
|
execute-keys '<a-]>p<a-x><a-j>|${format_cmd}<ret>'
|
||||||
try %{ execute-keys s\h+$<ret> d }
|
try %{ execute-keys s\h+$<ret> d }
|
||||||
}
|
}
|
||||||
select '${kak_reg_m}'
|
select '${kak_main_reg_m}'
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ define-command -hidden doc-parse-anchors %{
|
||||||
# Find sections as add them as imlicit anchors
|
# Find sections as add them as imlicit anchors
|
||||||
execute-keys \%s ^={2,}\h+([^\n]+)$ <ret>
|
execute-keys \%s ^={2,}\h+([^\n]+)$ <ret>
|
||||||
evaluate-commands -itersel %{
|
evaluate-commands -itersel %{
|
||||||
set-option -add buffer doc_anchors "%val{selection_desc}|%sh{printf '%s' ""$kak_reg_1"" | tr '[A-Z ]' '[a-z-]'}"
|
set-option -add buffer doc_anchors "%val{selection_desc}|%sh{printf '%s' ""$kak_main_reg_1"" | tr '[A-Z ]' '[a-z-]'}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse explicit anchors and remove their text
|
# Parse explicit anchors and remove their text
|
||||||
|
|
|
@ -263,6 +263,16 @@ auto expand_option(Option& opt, std::false_type)
|
||||||
return opt.get_as_strings();
|
return opt.get_as_strings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto expand_register(StringView reg, const Context& context, std::true_type)
|
||||||
|
{
|
||||||
|
return join(RegisterManager::instance()[reg].get(context) | transform(quote), ' ', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto expand_register(StringView reg, const Context& context, std::false_type)
|
||||||
|
{
|
||||||
|
return RegisterManager::instance()[reg].get(context) | gather<Vector<String>>();
|
||||||
|
}
|
||||||
|
|
||||||
String expand_arobase(ConstArrayView<String> params, std::true_type)
|
String expand_arobase(ConstArrayView<String> params, std::true_type)
|
||||||
{
|
{
|
||||||
return join(params, ' ', false);
|
return join(params, ' ', false);
|
||||||
|
@ -298,7 +308,7 @@ expand_token(const Token& token, const Context& context, const ShellContext& she
|
||||||
return {str};
|
return {str};
|
||||||
}
|
}
|
||||||
case Token::Type::RegisterExpand:
|
case Token::Type::RegisterExpand:
|
||||||
return {context.main_sel_register_value(content).str()};
|
return expand_register(content, context, IsSingle{});
|
||||||
case Token::Type::OptionExpand:
|
case Token::Type::OptionExpand:
|
||||||
return expand_option(context.options()[content], IsSingle{});
|
return expand_option(context.options()[content], IsSingle{});
|
||||||
case Token::Type::ValExpand:
|
case Token::Type::ValExpand:
|
||||||
|
|
|
@ -132,10 +132,14 @@ static const EnvVarDesc builtin_env_vars[] = { {
|
||||||
"opt_", true,
|
"opt_", true,
|
||||||
[](StringView name, const Context& context)
|
[](StringView name, const Context& context)
|
||||||
{ return context.options()[name.substr(4_byte)].get_as_string(); }
|
{ return context.options()[name.substr(4_byte)].get_as_string(); }
|
||||||
|
}, {
|
||||||
|
"main_reg_", true,
|
||||||
|
[](StringView name, const Context& context)
|
||||||
|
{ return context.main_sel_register_value(name.substr(9_byte)).str(); }
|
||||||
}, {
|
}, {
|
||||||
"reg_", true,
|
"reg_", true,
|
||||||
[](StringView name, const Context& context)
|
[](StringView name, const Context& context)
|
||||||
{ return context.main_sel_register_value(name.substr(4_byte)).str(); }
|
{ return join(RegisterManager::instance()[name.substr(4_byte)].get(context) | transform(quote), ' ', false); }
|
||||||
}, {
|
}, {
|
||||||
"client_env_", true,
|
"client_env_", true,
|
||||||
[](StringView name, const Context& context)
|
[](StringView name, const Context& context)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user